Skip to content

Instantly share code, notes, and snippets.

View siscia's full-sized avatar

Simone Mosciatti siscia

View GitHub Profile
@voondo
voondo / scaleway-inventory.rb
Created February 19, 2016 11:11
Scaleway ansible dynamic inventory
#!/bin/ruby
require 'json'
require 'optparse'
require 'net/http'
require 'pry'
require 'yaml'
auth_token = ENV['SCALEWAY_AUTH_TOKEN']
uri = URI('https://api.scaleway.com/servers')
@ctford
ctford / lenses.clj
Created July 12, 2014 20:40
A Clojure lens implementation based on focus and fmap.
(ns shades.lenses)
; We only need three fns that know the structure of a lens.
(defn lens [focus fmap] {:focus focus :fmap fmap})
(defn view [x {:keys [focus]}] (focus x))
(defn update [x {:keys [fmap]} f] (fmap f x))
; The identity lens.
(defn fapply [f x] (f x))
(def id (lens identity fapply))
@andyburke
andyburke / facebook-photo-post-javascript.js
Created December 19, 2011 20:37
How to post a photo to Facebook from client-side Javascript
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this
// you cannot send image data as part of a multipart/form-data encoded request from
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to
// find yet another way to implement this. (This is left as an exercise for the reader,
// but if you do it, please let me know and I'll integrate it.)
// from: http://stackoverflow.com/a/5303242/945521
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) {