Skip to content

Instantly share code, notes, and snippets.

FROM debian:9
# Nothing works if you don't do this first
RUN apt-get update && apt-get upgrade -y
# Set locale to US EN UTF8
RUN apt-get install locales -y && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen && \
locale-gen en_US.UTF-8
@deserat
deserat / gist:8245275
Last active January 2, 2016 03:39
Node JS Benchmarks Amazon AWS vs Joyent

The script:

var http = require('http')
var fs = require('fs')


http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'})
  res.end("hello world")
}).listen(3000);
@deserat
deserat / gist:6602053
Created September 17, 2013 23:20
api example of posting a file. The content file object is part of django but it's easily separated if you use python. Just copy that class out https://github.com/django/django/blob/master/django/core/files/base.py#L132
from django.core.files.base import ContentFile
f = ContentFile(o.read(), name='pic.png')
response = signed_post(self.api_client, self.c, '/api/v1/user/register/', {
'social_id': 'twitter:123452',
'gender': 'f',
'email': 'blah@blah.com',
'name': 'whatevs',
'location': 'New York',
@deserat
deserat / gist:6502045
Created September 9, 2013 21:53
A working javascript implementation CLRAuth for API
GameClient.prototype.buildToken = function (body) {
var dt = Math.round(new Date().getTime() * .001)
var line = this.identity + "." + dt
var data = line
if (body) {
data = line + "." + body.trim()
}
@deserat
deserat / scala trait implementation
Last active December 20, 2015 05:08
Traits can be implemented and extended on the fly with initialized values. This includes JAVA Interfaces.....
trait Similarity {
def isSimilar(x: Any): Boolean
def isNotSimilar(x: Any): Boolean = !isSimilar(x)
}
val b = 25
val foo = new Similarity() {
var x: Int = b
def isSimilar(x: Any): Boolean = {
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
resolvers += "scala-redis" at "https://github.com/debasishg/scala-redis.git",
resolvers += "scala-riak-client" at "https://github.com/agemooij/riak-scala-client.git"
)
@deserat
deserat / gist:726102
Created December 2, 2010 21:26
agegate code
$("div#submit").click( function(e) {
var today = new Date();
var now = today.getTime();
var age_limit = now - 410240038000;
var y = ( !isNaN(parseInt( $('#year_field').val() )) ) ? parseInt( $('#year_field').val() ) : 2010;
var m = ( !isNaN(parseInt( $('#month_field').val() )) ) ? parseInt( $('#month_field').val() ) -1 : 0 ;
var d = ( !isNaN(parseInt( $('#day_field').val() )) ) ? parseInt( $('#day_field').val() ) : 0;