Skip to content

Instantly share code, notes, and snippets.

@jboesch
jboesch / pg_import_csv_to_heroku.sh
Last active April 5, 2022 22:11
Importing a CSV dump of Postgres data into Heroku
# You have your csv data and it looks like so... It's in a file named "my_data.csv" and we want to import it into a table named "my_things".
"1", "Something", "0.50", "2013-05-05 10:00:00"
"2", "Another thing", "1.50", "2013-06-05 10:30:00"
# Now you want to import it, go to the command line and type:
$ PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy my_things FROM 'my_data.csv' WITH CSV;"
# Voila! It's impoted. Now if you want to wipe it out and import a fresh one, you would do this:
@jboesch
jboesch / gist:614548
Created October 7, 2010 04:22
django workaround for jquery tmpl tags
<script id="person-tmpl-django" class="fix" type="text/x-jquery-tmpl">
<div id="person-${user.id}" class="person">
<strong>${user.name}</strong>
[[each(i, c) user.children]]
<div class="child">${c.child_name}</div>
[[/each]]
<span>${user.age}</span>
</div>
@jboesch
jboesch / gist:1299783
Created October 19, 2011 21:44
Drag/drop for fullCalendar on iPad
/********************************
* UPDATE: I have crated a plugin to do this: https://github.com/jboesch/jQuery-fullCalendar-iPad-drag-drop/
*********************************/
/*These are the brief steps that it takes to get fullCalendar (http://arshaw.com/fullcalendar/) up and running with drag/drop support on the iPad. This assumes you already have fullCalendar setup.*/
//1. Include a copy of jQuery touch punch in your project, you can find it here: https://github.com/furf/jquery-ui-touch-punch
//2. Go into jquery-touch-punch.js and right after this line (around line 57 - mouseProto._mouseDown = function (event) {) add this: this._mouseDownEvent = event;
//3. Add this function somewhere in your global.js file or wherever you want:
// Examples can be found here: http://boedesign.com/misc/outer_setters.html
// Discussed here: http://forum.jquery.com/topic/outerheight-int-sets-the-height-taking-into-account-padding-and-border
(function($){
function _outerSetter(direction, args){
var $el = $(this),
$sec_el = $(args[0]),
dir = (direction == 'Height') ? ['Top', 'Bottom'] : ['Left', 'Right'],
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
uglify: {
build: {
files: {
'jquery.timeAutocomplete.min.js': ['src/*.js']
}
}
@jboesch
jboesch / fullcalendar_getdate_by_td_cell.js
Created May 20, 2011 17:09
Get the date by clicking a month td cell in $.fullCalendar (http://arshaw.com/fullcalendar/)
/**
* Get the date we just clicked on (td cell)
*
* @param {Object} $td The jQuery td element
*/
var getDateFromTdCell = function($td)
{
var self = this;
@jboesch
jboesch / websocket-ruby.rb
Created June 4, 2012 17:46
WebSocket server in Ruby
# You need to first download em-websocket at https://github.com/igrigorik/em-websocket
# Then install the gem then name this file to "server.rb" and run it: "ruby server.rb"
# This is a combination of code from the example at http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/
# and at http://jessedearing.com/nodes/4-pubsubbin-with-redis-eventmachine-and-websockets to publish to all connected sockets.
require 'em-websocket'
SOCKETS = []
EventMachine::WebSocket.start(:host => "127.0.0.1", :port => 8080) do |ws|
@jboesch
jboesch / gist:2289031
Created April 3, 2012 03:16
Detect Sencha Touch supported phone
/**
* Are we running a sencha touch supported phone? Needed
* primarily for login page
* Sencha supports: iPhone, iPod touch, Android, Blackberry 6+
*/
var isSenchaTouchSupportedPhone = function()
{
var ua = navigator.userAgent;
var supported = (
@jboesch
jboesch / gist:2255972
Created March 30, 2012 22:05
Get favorite tracked in an array from 8tracks
// 1. Goto 8tracks.com and login.
// 2. Under your profile click "Favorited tracks".
// 3. Open up the console (CMD+OPTION+I) in Chrome or Safari and input this:
var music=[];$('.track_info').each(function(){ music.push($.trim($(this).find('.a').text()) + ' - ' + $.trim($(this).find('.t').text())) });music.join("\n");
// 4. Then hit enter.
// You will get a list of your music that you can copy/paste somewhere else.
@jboesch
jboesch / compass.sh
Created March 20, 2012 04:55
Allow multiple compass projects to be "watched"
#!/bin/bash
# This will run compass watchers as background tasks. When you hit CTRL+C, you don't actually
# exit out of them, they're still running. To kill all the watchers, type ./compass kill
# See usage below.
# Usage:
# Put this shell file (compass) in your compass project directory (same directory as config.rb), then navigate to it
# on the command line and type either of the commands below.
# To run, just type ./compass