Skip to content

Instantly share code, notes, and snippets.

same = 0
for x in media.get_width(p1):
for y in media.get_height(p1):
p1_pix = media.get_pixel(p1, x, y)
p2_pix = media.get_pixel(p2, x, y)
@jamesnvc
jamesnvc / gist:667229
Created November 8, 2010 00:29
Code lab
# Given dictionaries, d1 and d2, create a new dictionary with the following
# property: for each entry (a, b) in d1, if there is an entry (b, c) in d2, then
# the entry (a, c) should be added to the new dictionary. For example, if d1 is
# {2:3, 8:19, 6:4, 5:12} and d2 is {2:5, 4:3, 3:9}, then the new dictionary
# should be {2:9, 6:3} Associate the new dictionary with the variable d3
d3 = {}
for (k, v) in d1.iteritems():
if v in d2:
d3[k] = d2[v]
(defn agent-die [state]
(println (str (:id state) ": Alas! I am slain!"))
(remove-watch *agent* :stepper)
(swap! remaining-agents dec)
(assoc state :alive false))
(defn agent-fn [state]
(let [new-x (mod ((rand-dir) (:x state)) len-x)
new-y (mod ((rand-dir) (:y state)) len-y)
next-cell (at-loc new-x new-y)]
#!/usr/bin/env bash
while read pathname; do
echo http://dl.dropbox.com/u/3423/${pathname#*Dropbox/Public/}
done
@jamesnvc
jamesnvc / gist:1045414
Created June 24, 2011 18:52
vote GET request
Request URL:http://vote.skule.ca/vote?isstudent=True&isregistered=False&isundergrad=True&primaryorg=APSE&yofstudy=0&campus=STG&postcd=no_POStCD&attendance=ZZ&assocorg=&pid=c9bcc9f1ae24ff7617bdb4a0aa2c6488&hash=a6adb58c4d34d62eb6330c061ae38005
Request Method:GET
Status Code:302 Moved Temporarily
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:voter_credentials=0505957c75d21c79053828d1deb076f4fcc8f3a73b942a070d49b4c91179e4a3fca6a0a11e07d8b9cf4dd39c6775a661b8524fe7c2af520aefc4ac8f807efe61%3A%3A3645; _SkuleVote_session=BAh7CjoPc2Vzc2lvbl9pZCIlNjJmZGQzYzA1ODdlNjE0OTg2YTNjNTdmOWVmZDkyYTYiGXZvdGVyX2NyZWRlbnRpYWxzX2lkaQI9DiIWdm90ZXJfY3JlZGVudGlhbHMiAYAwNTA1OTU3Yzc1ZDIxYzc5MDUzODI4ZDFkZWIwNzZmNGZjYzhmM2E3M2I5NDJhMDcwZDQ5YjRjOTExNzllNGEzZmNhNmEwYTExZTA3ZDhiOWNmNGRkMzljNjc3NWE2NjFiODUyNGZlN2MyYWY1MjBhZWZjNGFjOGY4MDdlZmU2MToQX2NzcmZfd
" Using arrow keys to indent right/left in insert mode
inoremap <Left> <Esc>:exe "normal mz<<`z".(&shiftwidth-1)."h"<CR>i
inoremap <Right> <Esc>:exe "normal mz>>`z".(&shiftwidth+1)."l"<CR>i
javascript:var%20s=document.createElement('script');s.src='https://gist.github.com/raw/09258421225c74d031a3/2d2191207d5c0827ec1c2d048082a54aa03c599e/tumblr_tags.js';document.body.appendChild(s);
#!/bin/bash
run_benchmark() {
echo "Running $2 benchmark with $1 prefetcher"
./sim-cache -redir:sim benchmark-output/$1-$2 \
-redir:prog /dev/null \
-config cache-config/cache-lru$3.cfg /cad2/ece552f/benchmarks/$2.eio
}
mkdir -p benchmark-output
<!-- At the bottom of your <body> -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Change these ids as appropriate
var c1 = $('#leftsidbar').height();
// Not sure what the id of your center column is
var c2 = $('#content').height();
var c3 = $('#rightsidebar').height();
var h = Math.max(c1, c2, c3);
Iron Sports U of T provides a welcoming, inspiring, and educational environment for its members to better themselves physically and mentally through the medium of strength training.