Skip to content

Instantly share code, notes, and snippets.

@krusynth
krusynth / indexSpec.js
Created January 21, 2015 15:24
Example using Squire for Dependency injection.
define(['squire'], function (Squire) {
"use strict";
describe("DashboardIndexController", function () {
var context = {};
var ready = false;
beforeEach(function () {
runs(function () {
context.injector = new Squire();
@krusynth
krusynth / dataTables_patch.js
Created January 13, 2015 04:00
dataTables.js requires you to have "good" tables. If your table has an uneven number of columns per row, and you're getting the dreaded " Cannot read property 'mData' of undefined " this will fix it.
// dataTables.js is great! But it requires you to have "good" tables in
// the first place. If your table has an uneven number of columns per
// row, and you're getting the dreaded "Cannot read property
// 'mData' of undefined" this'll fix it. If you're missing a thead or
// tbody you'll get that error too - this won't fix that!
$(document).ready(function() {
// We need to make sure every row in our table has the same number of columns.
// Otherwise dataTable doesn't work.
$('table').each(function(i, elm) {
@krusynth
krusynth / DocumentController.js
Created December 8, 2014 21:56
Sails.js Controller using etherpad-lite-client
var etherpad_client = require('etherpad-lite-client');
module.exports = {
/**
* list() - list all docs
*/
list: function(req, res) {
etherpad_api = etherpad_client.connect({
apikey: sails.config.connections.etherpad.apikey,
host: sails.config.connections.etherpad.host,
@krusynth
krusynth / .bash_profile
Created December 8, 2014 00:49
Bash script to delete all documents from a Solr core.
# Put this at the end of your .bash_profile.
#
# Usage: clearsolr corename
clearsolr() {
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<commit />'
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<optimize />'
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<commit />'
}
@krusynth
krusynth / rename.sh
Created December 6, 2014 17:54
file rename bash
# Find a *lot* of files with the wrong extension and fix the extension.
for myfile in $(find /var/www/releases/sanfranciscocode/*/production/current/htdocs/downloads/current/code-text -name "*..txt" -type f); do
filetrim=${myfile%????};
mv $myfile $filetrim"txt";
done;
@krusynth
krusynth / vegan_potato_salad
Created November 19, 2014 01:47
Vegan Potato Salad
To celebrate the fourth, here's Bill's Vegan Potato Salad! (Gluten free as well!) Super creamy and delicious, almost makes you think you're eating the dairy-thing. Makes about 8-10 servings, depending on your appetite.
Red Potatoes 5 lbs
Dill, finely chopped 1/4 Cup
Olive oil 1/2 Cup
Rice Vinegar 1/2 Cup
Sea Salt 1 teaspoon
Black Pepper, fresh ground (a dash)
Wash and prep the potatoes, leaving the skins on, and cut into 1/2 inch cubes. Throw them into a large pot with salted water, and boils for 30 minutes.
While the potatoes are cooking, remove the stalks from your dill and chop a fistful or so, to yield 1/4 cup.
After the potatoes are done cooking, drain with a large colander. At this point, you can either put them in the refrigerator to cool, or speed up the process by dipping them into an ice bath. After they've cooled, dab off any extra water with a paper towel.
@krusynth
krusynth / google-fonts.md
Created November 18, 2014 16:39
Actually Pretty Good Google Fonts
@krusynth
krusynth / books.md
Last active June 15, 2021 16:56
A list of useful books to improve your skills

Recommended Books

A list of useful books to improve your skills

Recommendations from others are noted in (parentheses). The rest are my personal recommendations.

Programming

Building your core

  • The Pragmatic Programmer - Hunt & Thomas
@krusynth
krusynth / annotator-ie.js
Created September 10, 2014 20:38
IE patches & shims for Annotator.
/*
* Patch to make console.log, console.warn, etc work in IE8 & 9
*/
// Default list of functions for console.
var logFns = ["log", "info", "warn", "error", "assert", "dir", "clear", "profile", "profileEnd"];
// Define console.
if (typeof console == 'undefined') {
console = {};
@krusynth
krusynth / compareDocumentPosition.js
Created September 10, 2014 20:24
Polyfill for compareDocumentPosition if you need that for old IE or something. But you could probably just use .contains() too.
function compareDocumentPosition(thisNode, other) {
function recursivelyWalk(nodes, cb) {
for (var i = 0, len = nodes.length; i < len; i++) {
var node = nodes[i];
var ret = cb(node);
if (ret) {
return ret;
}
if (node.childNodes && node.childNodes.length) {
var ret = recursivelyWalk(node.childNodes, cb);