Skip to content

Instantly share code, notes, and snippets.

@jclosure
jclosure / jquery-tmpl.js
Created October 24, 2010 07:01
Modification to jquery-tmpl works with IE when you have an attribute value with spaces in it.
/*
* jQuery Templating Plugin
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
*/
(function (jQuery, undefined) {
var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
function newTmplItem(options, parentItem, fn, data) {
@jclosure
jclosure / nexus1 with jellybean
Last active December 11, 2015 05:28
Install recipe for getting Jelly Bean working on the Nexus1 phone.
1. Get the latest nightly rom build from Evervolv at: http://dl.evervolv.com/nightly
2. Get the latest Google Apps (Universal Package) from: http://wiki.rootzwiki.com/Google_Apps (see: Jelly Bean Android 4.1.x-4.2.x section of page for download link)
3. Restart phone
4. Go into Fastboot and then Recovery
5. Wipe all partitions (/boot, /cache, /data, /sd-card, etc)
6. Connect to computer with roms
7. Mount storage and copy them to root
8. Choose install from .zip
9. Select the evervolv rom
10. Boot system up.
@jclosure
jclosure / Ruby Script Directory Context
Created January 18, 2013 03:32
How to set the directory context to the same dir or nearby dir of currently executing Ruby script
#place at top of file
$:.unshift(File.dirname(__FILE__))
#this will include the dir context to the same folder as the currently executing script
-
|-examples
|-example1.rb
|-lib
|-library1.rb
@jclosure
jclosure / cli github repo
Last active September 13, 2016 07:31
create github repo from cli
CLI commands for github API v3 (replace all CAPS keywords):
git init
git add .
git commit -am "initial commit"
curl -u 'USER:PASS' https://api.github.com/user/repos -d '{"name":"REPO"}'
git remote add origin git@github.com:USER/REPO.git
git push origin master
@jclosure
jclosure / Pow console logging
Created January 22, 2013 05:31
Log to console in Pow. Debugging by printing to console and tailing the pow project log file.
Example:
class FooController < ApplicationController
before_filter :detect_mode
def detect_mode
@mode = params['mode'] || 'normal'
Rails.logger.debug("debug::" + "mode is " + @mode) #note the use of the log filtration token.
end
@jclosure
jclosure / .rvmrc usage in projects
Last active December 11, 2015 17:48
Use a project level .rvmrc for specifying ruby version and gemset for the project. (Shown in this case with jruby)
#replace solverforge and ruby ver as needed
cd solverforge
rvm use jruby
rvm gemset create solverforge
rvm --create --rvmrc jruby-1.7.2@solverforge
#this generates a local .rvmrc specific to the project.
@jclosure
jclosure / Revert src in git
Created January 29, 2013 08:21
Revert source in git repo
Setting your branch to exactly match the remote branch can be done in two steps:
git fetch origin
git reset --hard origin/master
If you want to save your current branch's state before doing this (just in case), you can do:
git commit -a -m "Saving my work, just in case"
git branch my-saved-work
@jclosure
jclosure / phantom dom elem targeting
Last active December 12, 2015 10:39 — forked from n1k0/gist:1501173
Phantom JS copying a specific dom element
var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
@jclosure
jclosure / YAML config & if+else returns
Created March 9, 2013 07:56
Everything is a method in ruby, including if and else. Set from YAML
#USE IF/ELSE TO SET @config
@config ||= if ENV['fb_client_id'] && ENV['fb_client_secret'] && ENV['fb_scope'] && ENV['fb_canvas_url']
{
:client_id => ENV['fb_client_id'],
:client_secret => ENV['fb_client_secret'],
:scope => ENV['fb_scope'],
:canvas_url => ENV['fb_canvas_url']
}
else
YAML.load_file("#{Rails.root}/config/facebook.yml")[Rails.env].symbolize_keys
@jclosure
jclosure / gist:6332497
Created August 25, 2013 07:35
upgrade debian completely
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y