Skip to content

Instantly share code, notes, and snippets.

View nathankleyn's full-sized avatar
👨‍💻
Creating!

Nathan Kleyn nathankleyn

👨‍💻
Creating!
View GitHub Profile
@nathankleyn
nathankleyn / gist_9_functional_ruby_part_iii.rb
Created December 30, 2012 12:12
Gist #9 For "Functional Programming Techniques With Ruby: Part III"
(1..100).select { |x| x % 3 == 0 }.select { |x| x % 4 == 0 }
@nathankleyn
nathankleyn / gist_10_functional_ruby_part_iii.rb
Created December 30, 2012 12:12
Gist #10 For "Functional Programming Techniques With Ruby: Part III"
(1..100).lazy.select { |x| x % 3 == 0 }.select { |x| x % 4 == 0 }.to_a
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@nathankleyn
nathankleyn / ruby-events testing
Created April 30, 2013 09:38 — forked from mqu/ruby-events testing
Updating event fire method to fire event on the @piece. This Gist is for https://github.com/nathankleyn/ruby_events/issues/3.
#!/usr/bin/ruby
# coding: utf-8
# author : Marc Quinton, march 2013, licence : http://fr.wikipedia.org/wiki/WTFPL
libdir = 'lib'
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
require 'pp'
@nathankleyn
nathankleyn / jsonview-solarized-light.css
Last active September 25, 2017 18:08 — forked from iansym/jsonview-solarized.css
A Solarized light version of the JSON View stylesheet by @iansym.
body {
background-color: #fdf6e3;
color: #657b83;
font-size: 16px;
white-space: pre;
font-family: "Source Code Pro", monospace;
}
.property {
font-weight: bold;
@nathankleyn
nathankleyn / keybase.md
Created April 7, 2014 10:03
My Keybase Proof For GitHub

Keybase proof

I hereby claim:

  • I am nathankleyn on github.
  • I am nathankleyn (https://keybase.io/nathankleyn) on keybase.
  • I have a public key whose fingerprint is EB7C A542 5921 6E8A B45A 281D CB15 F387 A456 9943

To claim this, I am signing this object:

@nathankleyn
nathankleyn / generators.js
Last active August 29, 2015 14:13
An example of JavaScript generators.
function *asyncThing1() {
someAsyncFn(function(val) {
yield val;
});
}
function *asyncThing2(arg) {
someOtherAsyncFn(arg, function(val) {
yield val;
});
@nathankleyn
nathankleyn / gradle_plugin.rb
Created June 3, 2015 06:41
Gradle Shanty Plugin
require 'english'
require 'shanty/plugin'
module Shanty
# Public: Gradle plugin for building and testing Gradle projects.
module GradleMultiProjectPlugin
extend Plugin
INCLUDE_REGEX = /include\s+((?:(?:,[\s\n\\]+)?['"][^'"]+["'])+)/
@nathankleyn
nathankleyn / Unportify-v1.4.3.js
Created September 28, 2017 22:59 — forked from avillp/Unportify-v1.4.3.js
Unportify helps you export your Google Play Music playlists.
/*
Unportify is a script that exports your Google Play music to text.
Copyright (C) 2016 Arnau Villoslada
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@nathankleyn
nathankleyn / relative_time_logs
Last active April 19, 2018 11:41
Relative times within log files
#!/usr/bin/env ruby
# Takes a log where lines have [HH:MM:SS] in front of the lines, and turns them
# into +HH:MM:SS since start of the script (ie. relative times).
#
# Any line that has no time at the start will be printed as is.
#
# Usage: relative_time_logs < some.log
time_regex = /^\[(?<hours>\d\d):(?<minutes>\d\d):(?<seconds>\d\d)\]/