Skip to content

Instantly share code, notes, and snippets.

View NickTomlin's full-sized avatar
📚
Reading a book

Nick Tomlin NickTomlin

📚
Reading a book
View GitHub Profile
@NickTomlin
NickTomlin / gist:4002891
Created November 2, 2012 17:20
Faster key rate for mac os x
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0
[from](https://github.com/mathiasbynens/dotfiles/blob/master/.osx)
@NickTomlin
NickTomlin / gist:4164193
Created November 28, 2012 20:36
Bash Parameter exercises
#!/bin/bash
# see http://www.ibm.com/developerworks/library/l-bash-parameters/index.html
testfunc ()
{
echo "$# parameters";
echo "{$1:}";
# if [ $1 = "@*" ]
# then
# echo "it's an @"
# exit
var http = require('http');
var url = require('url');
function start(route,handle) {
function onRequest(request,response){
var postData = "";
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received");
@NickTomlin
NickTomlin / python3.sublime-build
Created April 8, 2013 21:43
Build python files via Python3 in Sublime Text 2
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

This will enable Sass+Compass with LiveReload through Guard. (Guard screen cast)

You will also need a browser component to communicate with LiveReload. (browser extension, livereload.js)

If you prefer going through a GUI, that option is available. The following instructions is specific to Mac OS X and it works through the command line.

Note that this is not specific to Rails projects. This can work for any standalone front-end project.

Instructions

@NickTomlin
NickTomlin / st2-setup.md
Last active December 16, 2015 21:08
Quick notes on my ST2 Setup.

I use sublime text 2 (with vintage mode) to do front-end centric Drupal development, and some Python and Node.js on the side. This works in conjunction with my Dotfiles to make me a better, happier dev.

I love ST2 and use it everyday, but there are still tons of great plugins that I don't know about. Feel free to comment with any suggestions.

Happy Hacking!

-Nick

Using sublime from the command line

@NickTomlin
NickTomlin / override_theme_breadcrumb.php
Last active December 17, 2015 20:09
Taxonomy breadcrumbs. All credit to Dave Ross (@csixty4).
// to be added in your theme's template.php file
/**
* Override theme_breadcrumb().
*
* Base breadcrumbs on paths e.g., about/our-organization/bob-jones
* turns into About Us > Our Organization > Bob Jones
*/
function sndev_breadcrumb($breadcrumb) {
$links = array();
$path = '';
@NickTomlin
NickTomlin / curent-page.js
Created June 7, 2013 14:11
Current page.js
var page = window.location.pathname; // '/our-product'
var link = document.querySelector('.nav-main a[href="'+ page +'"]');
if (link) link.className += " active"; // maybe there is a better way to test if (link actually exists), it seems to fail silenetly regardless, so probably okay
@NickTomlin
NickTomlin / index.js
Created June 25, 2013 15:14
Simple Scraper using node-crawler
var Crawler = require('crawler').Crawler;
var fs = require("fs");
var pageCache = {};
write = fs.createWriteStream('crawled.txt');
write.on('error', function(err){
console.log(err);
});
@NickTomlin
NickTomlin / ga.js
Created October 16, 2013 20:37
Beautified version of ga.js
(function () {
var aa = encodeURIComponent,
ba = Infinity,
ca = setTimeout,
da = isNaN,
m = Math,
ea = decodeURIComponent;
function ha(a, b) {
return a.name = b