Skip to content

Instantly share code, notes, and snippets.

View ivanistheone's full-sized avatar

Ivan Savov ivanistheone

View GitHub Profile
JSCLASS_PATH = 'build/min';
require('./' + JSCLASS_PATH + '/loader');
JS.require('JS.Deferrable');
Promise = new JS.Class({
include: JS.Deferrable,
initialize: function(value) {
if (value !== undefined) this.succeed(value);
@carld
carld / build.sh
Created July 15, 2017 00:22
The build script from my compiler blog article
chez --script c.scm > c.s
nasm -f macho c.s
ld c.o
./a.out
echo $?
@aymanfarhat
aymanfarhat / urlobject.js
Last active July 27, 2017 00:04
JS utility function that: - Breaks down url to an object with accessible properties: protocol, parameters object, host, hash, etc... - Converts url parameters to key/value pairs - Convert parameter numeric values to their base types instead of strings - Store multiple values of a parameter in an array - Unescape parameter values
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
option_key,
i,
urlObj,
get_param,
key,
@tkf
tkf / gdmp.py
Created April 2, 2011 08:02
Command line tool for google-diff-match-patch
#!/usr/bin/env python
"""
Command line tool for google-diff-match-patch
"""
from diff_match_patch import diff_match_patch
HTMLTEMP = '''\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
command count num_people_using
cd 347893.0 803.0
ls 326227.0 783.0
rm 80394.0 744.0
git 426701.0 696.0
sudo 109042.0 690.0
mkdir 22987.0 655.0
cat 54491.0 642.0
mv 39297.0 640.0
ssh 83035.0 623.0
@ozkatz
ozkatz / ec2_ssh_config.py
Created June 21, 2013 00:50
generate an ~/.ssh/config file from your EC2 instances, so that you'd never have to lookup those fugly ec2-xx-xx-xx-xxx.compute-1.amazonaws.com hostnames again. Use your instance name instead!
#!/usr/bin/env python
import os
import sys
import argparse
try:
from boto.ec2.connection import EC2Connection
except ImportError:
sys.stderr.write('Please install boto ( http://docs.pythonboto.org/en/latest/getting_started.html )\n')
sys.exit(1)
@rjz
rjz / cs-jq-plugin-template.coffee
Created September 3, 2012 17:01
Coffeescript jQuery Plugin Class Template
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
@carld
carld / c.scm
Created July 15, 2017 00:21
The compiler from my blog article
(define emit printf)
(define (compile exp)
(cond
[(fixnum? exp) (emit "push ~a~%" exp)]
[(eq? '+ (car exp)) (begin
(compile (cadr exp))
(compile (caddr exp))
(emit "pop eax~%")
(emit "pop ebx~%")
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Lingua::EN::Fathom;
use TeX::Hyphen;
use List::Util qw(min);
@rikusalminen
rikusalminen / pyrocket.py
Created July 31, 2014 09:28
Solving the rocket equation in Python
def numerical():
from scipy.integrate import odeint
from numpy import array
# [position, mass, velocity, mass flow]
def acceleration(y, t, v_exhaust=1.0):
return array([y[2], y[3], v_exhaust * y[3]/y[1], 0.0])
initial_state = array([0.0, 2.0, 0.0, -1.0])