Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cantino's full-sized avatar
💭
1AU

Andrew Cantino cantino

💭
1AU
View GitHub Profile
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 / 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" />
@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
// 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);
}
});
# 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