Skip to content

Instantly share code, notes, and snippets.

@afternoon
afternoon / xmltest.erl
Created February 22, 2013 15:41
Examples of generating XML with Erlang's xmerl library.
-module(xmltest).
-compile(export_all).
-include_lib("xmerl/include/xmerl.hrl").
%% @doc Helper function to generate XML from a data structure and print it
serialize(Data) ->
Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)),
io:format("~s~n", [Xml]).
@amitsaha
amitsaha / ioctl_demo.c
Created January 18, 2013 07:56
Get sector size, etc using ioctl()
/* Relevant:
http://lists.gnu.org/archive/html/bug-parted/2012-10/msg00018.html
http://stackoverflow.com/questions/8416241/block-device-information-without-mounting-in-linux
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@madrobby
madrobby / gist:3202087
Created July 29, 2012 22:01
Fallback to PNG if SVG is not supported
<!-- example for the http://retinafy.me ebook -->
<style>
div.rss {
background: url(rss.svg);
width: 32px;
height: 32px;
}
body.no-svg div.rss {
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
http:request(get, {"http://hostname/resource", [{"Authorization", "Basic " ++ base64:encode_to_string("username:password")}]}, [], []).