Skip to content

Instantly share code, notes, and snippets.

View feyeleanor's full-sized avatar

Eleanor McHugh feyeleanor

View GitHub Profile
@ged
ged / parasite.rb
Created November 13, 2010 23:33
More cool/stupid Method#to_proc tricks
#!/usr/bin/env ruby -wKU
### A parasitic class
class Parasite
### Make all future instances of the Parasite actually call
### methods of the +victim+ instead.
def self.infest( victim )
victim.methods.each do |m|
meth = victim.method( m )
if (!this.RubyScript)
RubyScript = {};
RubyScript.Base = function() {
function alloc(klass) {
var obj = new klass;
obj.ivars = {};
obj.meta = null;
return obj;
};
@mattetti
mattetti / foo.rb
Last active December 16, 2015 10:59
o_O
module Views
class Rat < SimpleDelegator
begin
include Decorator
rescue NameError => e
end
def initialize(data)
super OpenStruct.new(attributes[data])
end
@bpesquet
bpesquet / rpg_oloo.js
Created September 20, 2015 17:22
Minimalist RPG exemple written in the OLOO style
var Character = {};
Character.initCharacter = function (name, health, strength) {
this.name = name;
this.health = health;
this.strength = strength;
};
Character.attack = function (target) {
if (this.health > 0) {
var damage = this.strength;
console.log(this.name + " attacks " + target.name + " and deals " + damage + " damage");
@adnaan
adnaan / script.sh
Last active September 25, 2019 13:02
Parse and execute a simple bash script.
ls -la
echo "hello"
tree
adb devices
adb wait-for-device #example of a long running task
@jimeh
jimeh / jquery.myplugin.coffee
Created April 7, 2011 23:44
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@peterc
peterc / dnsd.rb
Created December 2, 2011 23:47
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@kavu
kavu / example.go
Created September 28, 2013 10:01
Minimal Golang + Cocoa application using CGO. Build with `CC=clang go build`
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];
@tonious
tonious / hash.c
Last active February 17, 2023 02:25
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@jordanorelli
jordanorelli / input.lisp
Created October 14, 2012 03:15
a lisp lexer in Go
(+ 1 (+ 1 1) (dave (sam 1)))
; alright I have comments now!!!!
; woooohooo!!!!
; nice nice nice
(+ 1
22.3
a
;here comes a comment