Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Kleindl inkdeep

View GitHub Profile
View js-transduce_experiment.js
/*
arrays
*/
const _set = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const _set2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
/*
predicates
*/
const isEven = x => x % 2 === 0;
const addOne = x => x + 1;
@inkdeep
inkdeep / web_worker_experiment.js
Created Apr 12, 2018
Experimenting with ways to take JavaScript on the client and make web workers with it.
View web_worker_experiment.js
function workerMessageHandler({ data, origin, lastEventId, source, ports }) {
console.warn(`worker got message
data: ${JSON.stringify(data)}
origin: ${origin}
lastEventId: ${lastEventId}
source: ${source}
ports: ${ports}
`);
self.addEventListener("message", function(e) {
@inkdeep
inkdeep / kill_iframe_bookmarklet.js
Created Dec 4, 2014
Bookmarklet to KILL IFRAME
View kill_iframe_bookmarklet.js
javascript:(function(){function R(w){try{var d=w.document,j,i,t,T,N,b,r=1,C;for(j=0;t=['object','embed','applet','iframe'][j];++j){T=d.getElementsByTagName(t);for(i=T.length-1;(i+1)&&(N=T[i]);--i)if(j!=3||!R((C=N.contentWindow)?C:N.contentDocument.defaultView)){b=d.createElement('div');b.style.width=N.width; b.style.height=N.height;b.innerHTML='<del>'+(j==3?'third-party '+t:t)+'</del>';N.parentNode.replaceChild(b,N);}}}catch(E){r=0}return r}R(self);var i,x;for(i=0;x=frames[i];++i)R(x)})()
@inkdeep
inkdeep / Ghostscript Devices
Created Apr 29, 2014
Results of $: gs -h
View Ghostscript Devices
GPL Ghostscript 9.14 (2014-03-26)
Copyright (C) 2014 Artifex Software, Inc. All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
-dNOPAUSE no pause after page | -q `quiet', fewer messages
-g<width>x<height> page size in pixels | -r<res> pixels/inch resolution
-sDEVICE=<devname> select device | -dBATCH exit after last file
-sOutputFile=<file> select output file: - for stdout, |command for pipe,
embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
View one-liners.md

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123
bar
@inkdeep
inkdeep / gist:9882904
Last active Aug 29, 2015 — forked from Mithrandir0x/gist:3639232
angular service/factory/provider styles
View gist:9882904
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@inkdeep
inkdeep / colors_array.js
Created Dec 18, 2013
Array of colors with name and hex value
View colors_array.js
[
["Alice blue", "#F0F8FF"],
["Antique white", "#FAEBD7"],
["Aqua", "#00FFFF"],
["Aquamarine", "#7FFFD4"],
["Azure", "#F0FFFF"],
["Beige", "#F5F5DC"],
["Bisque", "#FFE4C4"],
["Black", "#000000"],
["Blanche dalmond", "#FFEBCD"],
@inkdeep
inkdeep / js-array_uniq.js
Created Mar 6, 2013
javascript uniq - Native and Dojo style
View js-array_uniq.js
// Native JS (fast)
uniq = function( /* Array */ arr) {
var test = {};
var result = [];
for (var i = 0, len = arr.length; i < len; i++) {
if (!test[arr[i]]) { // value not seen yet?
test[arr[i]] = true;
result.push(arr[i]);
}
}
View Failed v8 install.log
☼ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew upgrade v8
==> Upgrading v8
rm /usr/local/bin/v8
rm /usr/local/include/v8stdint.h
rm /usr/local/include/v8.h
rm /usr/local/include/v8-testing.h
rm /usr/local/include/v8-profiler.h
rm /usr/local/include/v8-preparser.h
rm /usr/local/include/v8-debug.h
rm /usr/local/lib/libv8.dylib
@inkdeep
inkdeep / cap_set_branch.rb
Created Aug 20, 2012
Capistrano select branch/tag to deploy
View cap_set_branch.rb
set :branch do
tags = `git tag`.split("\n")
list = tags.collect {|x| %(#{tags.index(x)}: #{x}) }
puts %(------------------------------------------
Available Tags for Deployment
Use m for master
------------------------------------------)
puts list << "------------------------------------------\n"
i = Capistrano::CLI.ui.ask('Tag to deploy:')
i == 'm' ? 'master' : tags[i.to_i]