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 / reflatten.js
Created December 24, 2014 18:15
Recursively flatten an array (e.g. _.flatten but less performant probs)
var assert = require('assert');
function reflatten (source, accum) {
accum = accum || [];
if (Array.isArray(source)) {
source.forEach(function (child) {
if (Array.isArray(child)) {
reflatten(child, accum);
} else {
@NickTomlin
NickTomlin / app.html
Last active August 29, 2015 14:06
Angular directive controller
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Directive controllers and wrapper error states
</title>
<style>
.input-group-error {
@NickTomlin
NickTomlin / double-to-single.md
Created August 25, 2014 15:40
double to single bash

Replace double quotes with single quotes

# thanks to http://stackoverflow.com/questions/16154007/replace-all-double-quotes-with-single-quotes and http://stackoverflow.com/questions/22768645/how-to-use-find-exec-and-tr-to-process-a-large-number-of-files
find src -name "*.js" -exec sed -i "s/\"/'/g" {} \;
describe("jasmine.objectContaining", function() {
var filters = {
available: [
{name: "foo"},
{name: "majors"}
]
};
it("matches objects with the expect key/value pairs", function() {
expect(filters.available).not.toEqual(jasmine.objectContaining({
@NickTomlin
NickTomlin / SassMeister-input.scss
Created December 18, 2013 15:59
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
// --- atoms
// tiny, reusable elements of a style that modules
// can extend. They should function like variables.
// @issue
// changes here effect all of the modules that have
@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
@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 / 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 / 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 / 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