Skip to content

Instantly share code, notes, and snippets.

$("ol.statuses [id ^= direct_message]").each(function (index, item) {
$.post("http://twitter.com/direct_messages/destroy/" + $(item).attr("id").split("_")[2]);
$(item).hide()
});
@jeregrine
jeregrine / gist:1910697
Created February 25, 2012 21:00
Polling with backbone model
@model.bind "change", @render
setInterval ()=>
@model.fetch()
, 20000
@jeregrine
jeregrine / Migration.rb
Created September 11, 2012 17:33
Postgres Sequel: GIS and Full Text
Sequel.migration do
up do
run("create extension if not exists postgis;")
alter_table :events do
add_column :geo_location, :geography
add_full_text_index [:description, :name], :language=>'english'
add_index :geo_location, :type=>:gist
end
end
@jeregrine
jeregrine / fixer.rb
Created October 18, 2012 15:55
Encoding::UndefinedConversionError - "\xC2" from ASCII-8BIT to UTF-8 Fix
lines = IO.readlines("app/views/terms.haml").map do |line|
line.encode('ASCII-8BIT', :invalid => :replace, :undef => :replace)
end
File.open("app/views/terms2.haml", "w") do |file|
file.puts(lines)
end
@jeregrine
jeregrine / code.js
Last active December 17, 2015 22:09
ESTIMATOR
function estimate(arr) {
return arr.reduce(function(prev, curr, index, array){
return prev + convertToValue(curr.toString());
}, 0);
}
function estimateRisk(arr){
return arr.reduce(function(prev, curr, index, array){
return prev + convertToRisk(curr.toString());
}, 0);
(ns modern_js.core)
{:zoom 14, :disableDefaultUI true :draggable false, :scrollwheel false }
@jeregrine
jeregrine / route.js
Last active December 23, 2015 11:49
When the HomeCategoryIndex is called params are null.
App.Router.map(function(){
this.resource("home", {path: "/"}, function(){
this.resource("category", {path: "/:name"}, function(){
this.route("featured", {path:"/featured"})
this.route("popular", {path:"/popular"})
});
})
})
@jeregrine
jeregrine / rc.vim
Last active December 24, 2015 02:49
nmap <leader>f :call RunAg()<CR>
function! RunAg()
let string = input('term: ')
execute ':Ag ' . string . ' ./'
endfunction
defmodule PostgrexBugTest do
use ExUnit.Case, async: false
setup_all do
{ :ok, pid } = Postgrex.Connection.start_link([hostname: "localhost", username: "postgres", password: "postgres", database: "postgrex"])
Postgrex.Connection.query!(pid, "CREATE TABLE items(id serial primary key, value text, created timestamp default CURRENT_TIMESTAMP)")
{:ok, [pid: pid]}
end
teardown_all context do
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb -O /tmp/erlang-solutions_1.0_all.deb
Stdout from the command:
Stderr from the command:
--2014-01-15 23:04:22-- https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
Resolving packages.erlang-solutions.com (packages.erlang-solutions.com)... 31.172.186.53