Skip to content

Instantly share code, notes, and snippets.

View jakl's full-sized avatar
💭
🦊

James Koval jakl

💭
🦊
View GitHub Profile
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@Alrecenk
Alrecenk / fastexp.java
Last active August 12, 2022 23:05
Very fast accurate approximation to Math.exp in java using floating point bit hacks.
/* fast floating point exp function
* must initialize table with buildexptable before using
Based on
A Fast, Compact Approximation of the Exponential Function
Nicol N. Schraudolph 1999
Adapted to single precision to improve speed and added adjustment table to improve accuracy.
Alrecenk 2014
@vicapow
vicapow / README.md
Last active December 17, 2019 11:15
An example of creating a PNG from an SVG in D3.

This is an example of creating a PNG from an SVG. (You should notice that you're able to right click on the last image and save it as a PNG image.) It has been Tested in Firefox and Chrome but doesn't work in Safari as of 2014-07-20.

Normally, you'll create your SVG in D3 but to make the example a bit more readable, the SVG is already placed in the document. There are a few important points. Namely:

  1. All the styles of the SVG need to be self contained in side of the <defs> tags. (These styles should be escaped using the <![[CDATA[ ... ]] tag.)
  2. The SVG needs to have the proper namespaces and document types.
  3. The SVG needs to be saved to an image, then read from an canvas element, then saved to an image again.

Note: Portions of this demo where taken from The New York Times' excellent Crowbar SVG extractor.

@camertron
camertron / immutable_strings.rb
Last active December 21, 2015 19:49
Making Ruby Strings Immutable by Default
module BeforeMethodHook
def before(*names)
names.each do |name|
m = instance_method(name)
define_method(name) do |*args, &block|
yield self
m.bind(self).call(*args, &block)
end
end
end
@jakl
jakl / README.md
Last active December 15, 2015 01:29
Cleanup your Twitter timeline by viewing noisiest users - unfollow loud mouths and hear those who are soft spoken. #Twiduster.

USAGE

npm install

Add some twitter creds from apps.twitter.com

then

@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@nicerobot
nicerobot / README.md
Last active November 13, 2024 20:27
Mac OS X uninstall script for packaged install of node.js from https://stackoverflow.com/a/9287292/23056

To run this, you can try:

curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh
@michaelkirk
michaelkirk / show-remote-branch-info.sh
Created May 4, 2012 16:51
sort remote branches by age
#!/bin/sh
#
# Too many crusty old git branches? Run this to find likely candidates for deletion
# It lists all the remote branches and sorts them by age.
#
# Folks at pivotal shared this with me
#
#$ . show-remote-branch-info.sh
# 2012-05-04 09:42:29 -0700 4 minutes ago Ted & Bill \torigin/hey_Bill