Skip to content

Instantly share code, notes, and snippets.

function main() {
const headers = {Authorization: "Basic " + btoa("user:pass")};
/**
* Convert an Array Buffer into a base64 String.
*
* @param {ArrayBuffer} buffer - The Array buffer to convert.
* @returns {String} - The base64 representation of the given Array
* Buffer.
@almet
almet / -.diff
Last active January 18, 2016 13:57
diff --git a/calendar.js b/calendar.js
index ce462d6..faca709 100644
--- a/calendar.js
+++ b/calendar.js
@@ -10,17 +10,29 @@ $(document).ready(function() {
// Local store in IndexedDB.
var store;
-
var headers;
@almet
almet / test.js
Created January 7, 2016 10:39
Kinto.js get an element.
var db = new Kinto({remote: "https://kinto.dev.mozaws.net/v1/", bucket:"central-repository", headers: {Authorization: "Basic " + btoa("user:pass")}});
var collection = db.collection("server_locations");
collection.get("user_id").then(function(resp) {
// Do something with your "resp" here.
});
@almet
almet / argument_numbers.py
Created January 13, 2014 12:09
that remembers me how python can tell you it was "expecting 2 args, but got 2".
>>> def function(foo, bar, baz="test"):
... pass
>>> function("foo", baz="test")
TypeError: function() takes at least 2 arguments (2 given)
def timeit(what):
def wrapper(fn):
def wrapped(*args, **kwargs):
start = datetime.datetime.now()
rv = fn(*args, **kwargs)
end = datetime.datetime.now()
with open('/tmp/timeit', 'a') as f:
f.write('%s start: %s' % (what, start.isoformat()))
f.write('%s end: %s' % (what, end.isoformat()))
f.write('\n\n')
@almet
almet / gist:7930748
Last active December 31, 2015 03:58
How to get instantbird nightly working on a 64bits ubuntu 13.10 machine
# You need to install some 32bits libs:
sudo apt-get install libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386\
libidn11:i386 libglu1-mesa:i386 liblibxt-dev:i386 libasound-dev:i386
# And you should be all good.
@almet
almet / Makefile
Last active December 21, 2015 06:09
Makefile for pelican with multiple outputs and one single settings file.
generate_site:
SITENAME="site" PATH=sitesrc SITEURL="http://siteurl" pelican -s settings.py output_site
generate_blog:
SITENAME="blog" PATH=blogsrc SITEURL="http://blogurl" pelican -s settings.py output_blog
html: generate_blog generate_site
@echo "done!"
@almet
almet / Makefile
Created August 18, 2013 15:43
Makefile for multiple sites
site:
pelican -s site.settings.py output_site
blog:
pelican -s blog.settings.py output_site
html: blog site
echo "done!"
@almet
almet / map.geojson
Created August 13, 2013 21:04
via:geojson.io
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.