Skip to content

Instantly share code, notes, and snippets.

View cantino's full-sized avatar
💭
1AU

Andrew Cantino cantino

💭
1AU
View GitHub Profile
# Ruby's TSort requires that you implement
# tsort_each_node and tsort_each_child. I
# extend Array so that it knows how to
# TSort instances of Project, which has a
# child_project_id pointing to another
# Project.
require 'tsort'
class Array
// query: select * from html where url="http://some.url.com" and xpath='//title'
var yql_url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22" + encodeURIComponent(url) + "%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2Ftitle'&format=json&callback=?";
$.getJSON(yql_url, function(json) {
if (json && json.query && json.query.results && json.query.results.title) {
$('#page_title').html(json.query.results.title);
}
});
@cantino
cantino / coffee_interactive.sh
Created March 7, 2010 23:16
Adding readline support to coffeescript
#!/bin/sh
if [ ! `which rlwrap` ]; then
echo "Please sudo port install rlwrap"
exit
fi
rlwrap coffee -i
@cantino
cantino / CoffeeScript.xml
Created March 8, 2010 02:09
Partial CoffeeScript highlighting support for RubyMine
<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="CoffeeScript" name="CoffeeScript">
<highlighting>
<options>
<option name="LINE_COMMENT" value="#" />
<option name="COMMENT_START" value="`" />
<option name="COMMENT_END" value="`" />
<option name="HEX_PREFIX" value="" />
<option name="NUM_POSTFIXES" value="" />
<option name="HAS_BRACKETS" value="true" />
class Utilities
@findPos: (obj) ->
obj = obj.get(0) if obj.html?
curLeft = curTop = 0
if obj.offsetParent
loop
curLeft += obj.offsetLeft
curTop += obj.offsetTop
break unless obj = obj.offsetParent
{ x: curLeft, y: curTop }
@cantino
cantino / gradient.go
Last active December 18, 2015 09:39
Some practice Go programs.
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dx)
for i := range(pic) {
pic[i] = make([]uint8, dy)
for j := range(pic[i]) {
pic[i][j] = uint8((i + j)/2)
@cantino
cantino / runthis
Last active December 23, 2015 00:59
Run this in a JavaScript console.
[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]]+([][[]]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[+!+[]]]]+([][[]]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[
@cantino
cantino / example_output.txt
Last active June 16, 2018 18:28
Use google-api-ruby-client with the Google Contacts API
2.1.2 :004 > pp Google::Contacts.new(client).contacts
[{:emails=>{:other=>{:address=>"[email protected]", :primary=>true}},
:phone_numbers=>
{:main=>"(555) 123-1234", :home=>"123-123-1234", :mobile=>"555-555-5555"},
:handles=>
{:home=>{:address=>"something", :protocol=>"AIM"},
:other=>{:address=>"something-else", :protocol=>"AIM"}},
:nickname=>nil,
:websites=>[],
@cantino
cantino / output.md
Last active August 29, 2015 14:16
A breadth-first Tower of Hanoi solver in Go

Example Output

Lower numbers in the towers represent larger disks, so higher integers must always be to the right of smaller ones.

World:
0 [1]
1 [2]
2 [3 4 5 6]
---------------
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 2 in line 2.
San Francisco 4821
London 1409
Seattle, WA 1083
New York, NY 2056
Portland, OR 949
Chicago, IL 930
Tokyo, Japan 1518
London, UK 894
japan 880
Germany 856