Skip to content

Instantly share code, notes, and snippets.

View jrolfs's full-sized avatar

Jamie Rolfs jrolfs

View GitHub Profile
@axefrog
axefrog / router.js
Last active May 6, 2024 05:17
Simple router driver for Cycle.js utilising Router5 for routing functionality and adapting some of the code from VisionMedia's Page.js for automatic link click intercepting
'use strict';
import {Router5, RouteNode} from 'router5';
import logger from '../logger';
// The set of valid sink functions includes synchronous state-affecting router functions that do not require a callback
// and which do not have a significant return value other than the router object itself.
const validSinkFuncs = ['add','addNode','canActivate','deregisterComponent','navigate','registerComponent','setOption','start','stop'];
function validateAndRemapSinkArgument(arg) {
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@jonlabelle
jonlabelle / string-utils.js
Last active May 5, 2024 19:44
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@addyosmani
addyosmani / headless.md
Last active May 7, 2024 12:36
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

@addyosmani
addyosmani / notes.md
Created August 29, 2012 17:44
Better Model Property Validation On Set/Save

(rough-cut for Backbone Fundamentals)

Better Model Property Validation On Set/Save

As we learned earlier in the book, the validate method on a Model is called before set and save, and is passed the model attributes updated with the values from these methods.

By default, where we define a custom validate method, Backbone passes all of a Model's attributes through this validation each time, regardless of which model attributes are being set.

This means that it can be a challenge to determine which specific fields are being set or validated without being concerned about the others that aren't being set at the same time.

@moklett
moklett / openconnect.md
Created July 24, 2012 15:21
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@andsens
andsens / bootstrap_homeshick.sh
Last active December 27, 2023 12:47
Script that can set up an entire user account with homeshick automatically
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the raw (<>) button.
### Set some command variables depending on whether we are root or not ###
# This assumes you use a debian derivate, replace with yum, pacman etc.
aptget='sudo apt-get'
chsh='sudo chsh'
@Capncavedan
Capncavedan / Ruby script
Created April 9, 2012 15:45
Ruby script to show OS X battery info at command line
#!/usr/bin/ruby
ioreg_data = IO.popen("ioreg -w0 -l").readlines().join
ioreg_data.sub!(/.*(\+\-o AppleSmartBattery.*?\+\-o).*/m, '\\1')
ioreg_data.gsub!(/\s+\|/, "")
ioreg_data.gsub!(/\s\s+/, "\n")
battery = Hash.new
ioreg_data.split(/\n+/).each do |line|
key, value = line.split(' = ')[0..1]
next if key.nil? || value.nil?

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: