Skip to content

Instantly share code, notes, and snippets.

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
uglify: {
build: {
files: {
'jquery.timeAutocomplete.min.js': ['src/*.js']
}
}
@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 / 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
@jboesch
jboesch / gravatar_import.php
Created March 17, 2012 06:42
Import gravatar images to store on your local server
<?php
set_time_limit(120);
$domains = ClassRegistry::init('Domain')->find('all', array(
'conditions' => array(
'url' => $_GET['domain']
//'paid_recurring' => 1
),
'recursive' => -1
));
@jboesch
jboesch / gist:1821407
Created February 13, 2012 23:24
cakephp 2.0 plugin re-routing problems
<?
// routes.php
Router::connect('/animals/:action/*', array(
'plugin' => 'big',
'controller' => 'BigAnimalsController'
));
/*
* Now I navigate to /animals and I look at my action attribute on my <form> tag
* How come my $form->create(array('controller' => 'animals')); call still outputs:
@jboesch
jboesch / gist:1586341
Created January 10, 2012 01:57
Auth problems with CakePHP 2.0 - migrating from 1.3 - 2.0
/****************************************************************
* AppController.php
*****************************************************************/
<?
/**
* Most application-wide logic should be handled here
*
*/
class AppController extends Controller
{
@jboesch
jboesch / gist:1585571
Created January 9, 2012 23:18
cakephp 2.0 auth problems
<?
// i login successfully with if($this->Auth->login()) but as soon as I call $this->redirect($this->Auth->redirect());
// it boots me back to the login screen.
public function beforeFilter()
{
//Deny access to everything by default, let isAuthorized decide to let them in
$this->Auth->deny("*");
// Set up auth error messages here, where they can actually be translated