This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open Ast | |
| exception TypeError | |
| exception UnificationError | |
| (* ---------- EQUALITY ---------- *) | |
| (* [typ_eq t1 t2] returns [true] iff [t1] and [t2] are equal *) | |
| let rec typ_eq (t1:typ) (t2:typ) : bool = | |
| match t1,t2 with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pthing(title,ext,n): | |
| overlay = ''' | |
| <GroundOverlay> | |
| <name>res</name> | |
| <TimeSpan> | |
| <begin>%s</begin> | |
| <end>%s</end> | |
| </TimeSpan> | |
| <Icon> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function swinger(x0,y0,m1,m2,l1,l2) | |
| % SWINGER Classic double pendulum. | |
| % SWINGER(x,y) starts the pendulum at the given initial position. | |
| % The initial position can reset with the mouse. | |
| % | |
| % SWINGER with no arguments starts at (x,y) = (0.862,-0.994). | |
| % What is interesting about the resulting orbit? | |
| % | |
| % SWINGER(0,2) starts in an unstable vertical position. | |
| % How long does it stay there and what causes it to move? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <windows.h> | |
| #include <stdio.h> | |
| //68 BE BA FE CA | |
| const unsigned char OP_PUSH = 0x68; | |
| const unsigned char OP_JMP = 0xE9; | |
| static DWORD rets[10000]; | |
| static PDWORD r = NULL; | |
| struct patchwork{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open Ast | |
| (* lexp_of_aexp: convert an aexp into an lexp *) | |
| let rec lexp_of_aexp (a:aexp) : lexp = | |
| match a with | |
| | Int n -> | |
| LInt n | |
| | Var x -> | |
| LPVar x | |
| | Plus(a1,a2) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Scrolling Cards</title> | |
| <script src="http://code.jquery.com/jquery-1.8.1.min.js"></script> | |
| <script type="text/javascript"> | |
| jQuery.fn.center = function () { | |
| this.css("position","absolute"); | |
| this.css("bottom", "1px");// Math.max(0, (($(window).height() - this.outerHeight()) / 2) + | |
| // $(window).scrollTop()) + "px"); | |
| this.css("left", Math.max(0, (($(window).width() - this.outerWidth()) / 2) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json, urllib2 | |
| def perma(o): | |
| return "http://www.reddit.com/r/%s/comments/%s/lol/%s?context=3"%(o['subreddit'],o['link_id'].replace('t3_',''),o['id']) | |
| def q(): | |
| req = urllib.Request("http://reddit.com/r/askreddit/comments/.json", headers={"User-Agent":"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"}) | |
| return json.loads(urllib2.urlopen(req).read()) | |
| def find(listing, func): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* This contains the meat of the algorithm *) | |
| (* Returns a list of all encodings stored in hm *) | |
| let get_codes (hm : huffmantree) : encoding list = | |
| let rec fold_tree tree enc acc = | |
| match tree with | |
| | _, Leaf(c) -> (c, List.rev(enc)) :: acc | |
| | _, Node(l, r) -> | |
| let a = (fold_tree r (1::enc) acc) in | |
| (fold_tree l (0::enc) a) in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- figure out the number of arguments of a lua function | |
| function num_args(f) | |
| local ok, t = pcall(string.dump,f) | |
| if not ok then return nil end | |
| local o = t:byte(13)+t:byte(14)*0x100+t:byte(15)*0x10000+t:byte(16)*0x1000000 | |
| return t:sub(26+o):byte() | |
| end | |
| local __Gmt = getmetatable(_G) or {} | |
| local __o_index = __Gmt.__index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // from lopcodes.h | |
| /* | |
| ** R(x) - register | |
| ** Kst(x) - constant (in constant table) | |
| ** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x) | |
| */ | |
| // Here, x can be three things | |
| // x can be a variable denoting a register (its 8th bit is 0), in which case R(x) returns the value of the x-th register |