Skip to content

Instantly share code, notes, and snippets.

View locks's full-sized avatar
🌟
Ember Polaris

Ricardo Mendes locks

🌟
Ember Polaris
View GitHub Profile
@vangberg
vangberg / app.rb
Created February 8, 2009 14:34
file upload w/ sinatra
require 'rubygems'
require 'sinatra'
get '/' do
@files = Dir['public/*'].map {|f| File.basename(f) }
erb :index
end
post '/upload' do
filename = params[:file][:filename]
#! /usr/bin/python
# flixel (the script) is based on Adam Atomic's 'flx.py' script for
# creating various flixel-related objects in a fresh Flex Builder project.
# flixel (the script) changes the python path to be appropriate for Mac OS,
# generates any needed directories on its own behalf,
# relies on an environment variable (FLIXEL_HOME/lib) to locate flixel's org/...
# directory, and generates a Makefile for use with mxmlc. this behavior can be
# turned off by flipping flexBuilder back to true. it assumes mxmlc is in PATH.
# flixel (the script) also supports a three-argument version like so:
By elasped time
+---------------------------+-----------+-----+------+-------+--------+-----------+-----------+
| Name | Start Mem | 100 | 1000 | 10000 | 100000 | Final Mem | Time |
+---------------------------+-----------+-----+------+-------+--------+-----------+-----------+
| ricardo_mendes_refactored | 10292 | 20 | 20 | 696 | 4420 | 14712 | 0.228459 |
| ali_rizvi | 10784 | 56 | 404 | 2568 | 31824 | 42608 | 0.323051 |
| ali_rizvi_fixed_inc | 9380 | 44 | 236 | 2096 | 32744 | 42124 | 0.370307 |
| ali_rizvi_fixed | 10048 | 56 | 428 | 2092 | 32100 | 42148 | 0.371651 |
| alberto_fernandez_capel | 10764 | 36 | 364 | 888 | 6288 | 17052 | 0.618822 |
| tj_singleton_refactored | 8232 | 20 | 300 | 828 | 16676 | 24908 | 0.733384 |
/*
* bewbs.c: In goes the bewbs, out goes the C!
* By: Jean-Nicolas Jolivet,(c)2010
* (.)(.) ++ptr
* (.){.} --ptr
* (.)[.] ++*ptr
* [.](.) -- *ptr
* [.][.] putchar(*ptr)
* {.}{.} *ptr=getchar()
* {.}[.] while(*ptr) {
@jimweirich
jimweirich / exceptions.rb
Created March 7, 2011 02:55
How to organize exceptions in your library
# Suppose you were designing a library named "Zippo".
# How would you organize the exceptions thrown by the library.
# Option 1
# All library errors inheriting from a common base
module Zippo
class ZippoError < StandardError; end
class ZippoArgumentError < ZippoError; end
class ZippoTypeError < ZippoError; end
@mikekelly
mikekelly / 0_README.txt
Created March 29, 2011 23:19
a sketch of application/halo+json & application/halo+xml
I've added a control element with these properties/attributes:
method ; method to use for generated request e.g. POST/PUT/DELETE
content-type ; (optional) content-type of the request body generated by the template (defaults to application/hal+xml)
schema ; contains schema for data submitted to template
template ; (optional) A string or object representing the template or form for the request.
template-href ; (optional) Contains a URI which links to a resource where the template or form can be fetched.
template-type ; (optional) URI used to identify the template format in use (defaults to mustache).
@nu7hatch
nu7hatch / app.rb
Created April 21, 2011 03:05
OmniAuth login in popup
require 'rubygems'
require 'sinatra'
require 'omniauth/oauth'
set :sessions, true
set :layout, true
use OmniAuth::Builder do
provider :twitter, 'key', 'secret'
end
@zzak
zzak / index.html
Created April 26, 2011 21:43
commonjs mustache
<html>
<head><title>{{title}}</title></head>
<body>
{{title}} spends {{calc}}
</body>
</html>
@jeremytregunna
jeremytregunna / dmr.c
Created October 13, 2011 01:58
Salute to Dennis Ritchie
#include <stdio.h>
#include <stdlib.h>
int main(argc, argv)
int argc;
char** argv;
{
char foo[3] = { 'b', 'y', 'e' };
printf("%s\n", foo);
return 0;
@zobar
zobar / gist:1499822
Created December 20, 2011 01:39
Running a Cinch IRC bot on Heroku
  1. Add Heroku to your Gemfile and bundle install.
  2. Create your Heroku app. This will only work with their (currently-beta) 'cedar' stack, so you have to heroku create --stack=cedar.
  3. Create a Procfile for your bot. This tells Heroku how to run your worker. In our case, the bot is bot.rb, so the only line in the Procfile is cinch: bundle exec ./bot.rb
  4. Commit and push to Heroku.
  5. You do not want a Web worker running, so heroku scale web=0 cinch=1. This also sets up your deployments to restart the bot.