Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Johnstone Widdershin

View GitHub Profile
@Widdershin
Widdershin / router-tdd.ts
Created Feb 11, 2017
TDD Router in Cycle.js
View router-tdd.ts
import {mockTimeSource} from '@cycle/time';
import {mockDOMSource} from '@cycle/dom';
describe.only('steve example', () => {
function Router (sources, change$, definitions) {
let instances = {};
function map (attr) {
return change$.map(path => {
if (path in instances) {
View google
#!/usr/bin/env ruby
term = ARGV.join('+')
puts "\033browse https://google.co.nz/#q=#{term}\033"
@Widdershin
Widdershin / whitespace.txt
Last active Oct 7, 2016
A poem about whitespace
View whitespace.txt
Never put a new line at the top of a scope
So that you can see the structure of the tree
Always put new lines between things on the same level with different responsibilities
But if you have some things that are alike
Like
This
And that
@Widdershin
Widdershin / producers.js
Last active Sep 18, 2016
xstream producers
View producers.js
import fs from 'fs';
import assert from 'assert';
import xs from 'xstream';
function xray (url, classToScrape) {
return function scrape (callback) {
// goes and parses internetty stuff
callback(stuff);
}
View chained_lookup.rb
class Message
def initialize(method_name, *args, &block)
@method_name = method_name
@args = args
@block = block
end
def call(value)
value.send(@method_name, *@args, &@block)
View sonic-pi-fun.rb
live_loop :drums do
sample :drum_tom_lo_hard
sleep 0.4
end
i = 0
live_loop :woo do
sync :drums
if i % 4 == 0 && i % 40 < 20
sample :bass_thick_c
@Widdershin
Widdershin / smart-switch.rb
Created Apr 27, 2016
Switch/open tmux sessions with ease using fzf
View smart-switch.rb
#!/usr/bin/env ruby
require 'set'
PROJECTS_DIR = '/Users/nickj/Projects/'
def tmux_is_running?
ENV.include? 'TMUX'
end
@Widdershin
Widdershin / contributors.md
Last active May 2, 2016
Cycle.js contributors wanted!
View contributors.md

I'm looking for some awesome people to join me in working on some of the Cycle.js projects I've released. Have a look at the list. If you're unsure about anything (such as wanting to help but being unsure if you're able/welcome) please contact me!

Collaborators wanted:

tricycle (difficulty: beginner-advanced)

Tricycle lets you try out Cycle.js in your browser. Try it out here.

Tricycle has lots of opportunities to help out and improvements would make a big difference to the community as for a lot of beginners Tricycle is their first introduction to writing Cycle code.

View slack-topic-extract.js
$('.search_result_with_extract').toArray().map(function (result) {
var message = $(result).find('.extract_content').text()
var date = $(result).parents(".search_message_result").find('.date_links').text().split('•')[1].trim()
return date + ': ' + message.trim()
}).filter(function (text) {
return text.match(/group's topic/)
}).join('\n')