Skip to content

Instantly share code, notes, and snippets.

View DracoBlue's full-sized avatar

DracoBlue

View GitHub Profile
@DracoBlue
DracoBlue / Twitter To Twtxt.md
Last active March 10, 2023 07:05
Poor mans twitter to twtxt converter
@DracoBlue
DracoBlue / 1_kid.json
Last active August 29, 2015 14:19
Selecting a teacher for kids HAL example
{
"_links" : {
"self" : {"href" : "/kids/123"},
"teacher" : {"href" : "/teachers/999"},
"possible-teacher": {"href" : "/kids/123/possible-teachers"}
},
"name" : "Johnny",
"mom_phone" : "5554443333"
}

Collection+JSON application/vnd.collection+json

{ "collection" :
  {
    "version" : "1.0",
    "href" : "http://example.org/friends/",
    
    "links" : [
 {"rel" : "feed", "href" : "http://example.org/friends/rss"}
{
"title": "Apples",
"tags": ["fruits"],
"id": "4ec92e34-34fb-47c1-a2b9-139866eb431a",
"_links": {
"self": {"href": "https://hateoas-notes.herokuapp.com/api/hal/notes/4ec92e34-34fb-47c1-a2b9-139866eb431a"},
"up": {"href": "https://hateoas-notes.herokuapp.com/api/hal/notes"},
"https://hateoas-notes.herokuapp.com/rels/owner": {
"href": "https://hateoas-notes.herokuapp.com/api/hal/users/61a4552c-d73e-4176-a912-adf404f5b6d1",
}
@DracoBlue
DracoBlue / bash_exec.pp
Last active July 11, 2017 18:47
Small snippet to define a bash-exec type for puppet, which launches the exec with `--login` to provide a login shell (full PATH and sourced bash files).
define bash_exec (
$command = $name,
$user,
$creates = undef,
$cwd = undef,
$environment = undef,
$group = undef,
$logoutput = undef,
$onlyif = undef,
$path = undef,
@DracoBlue
DracoBlue / MailQueueService.class.php
Last active August 29, 2015 13:57
Very simple but fast (file based) mail queue
<?php
class MailQueueService()
{
public function getMailsFolder()
{
return '/tmp/mails/';
}
public function popSpooledMail()
@DracoBlue
DracoBlue / _respond-to.scss
Last active December 20, 2021 14:12
respond-to with multiple breakpoints and nice way to define them (in scss)
@mixin respond-to($medias...) {
$breakpoints-length: length($respond-to-breakpoints);
@each $media in $medias {
$had-a-hit: false;
@for $i from 1 through $breakpoints-length {
$breakpoint: nth($respond-to-breakpoints, $i);
@if $media == nth($breakpoint, 1) {
$definition: nth($breakpoint, 2);
@DracoBlue
DracoBlue / Vagrantfile
Last active December 23, 2015 17:19
A way to require specific versions for puppet modules in Vagrantfile.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
@DracoBlue
DracoBlue / my-first-goto.php
Last active December 16, 2015 01:49 — forked from hoffigk/my-first-goto.php
goto without goto ;)
<?php
function createFoo()
{
$pdo = new PDO(/*...*/);
$maxTryCount = 3;
$tryCount = $maxTryCount;
while ($tryCount > 0)
{
@DracoBlue
DracoBlue / API.md
Created October 1, 2012 15:25 — forked from graste/API.md
Documenting your REST API

Hint: This is heavily based on https://gist.github.com/3428555.

Api Name

Title: METHOD URL

Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple). The request type and the URL Structure (path only, no root url). METHOD may be GET | POST | DELETE | PUT.