Skip to content

Instantly share code, notes, and snippets.

View mceachen's full-sized avatar

Matthew McEachen mceachen

View GitHub Profile
@ryangreenberg
ryangreenberg / gist:1199301
Created September 6, 2011 23:35
self.destruct!
#!/usr/bin/env ruby -wKU
class Object
def destruct!
print "This message will self-destruct in..."
5.downto(0) {|i| print "#{i}..."; $stdout.flush; sleep(1)}
File.open(__FILE__, 'w') { }
end
end
@ryangreenberg
ryangreenberg / gist:2722492
Last active October 5, 2015 00:18
pid roulette
ps axc -o pid | grep -v PID | ruby -e 'puts STDIN.read.split("\n").shuffle.join("\n")' | head -1 | xargs kill
@azymnis
azymnis / KMeansJob.scala
Created October 23, 2014 23:07
K-Means in scalding
import com.twitter.algebird.{Aggregator, Semigroup}
import com.twitter.scalding._
import scala.util.Random
/**
* This job is a tutorial of sorts for scalding's Execution[T] abstraction.
* It is a simple implementation of Lloyd's algorithm for k-means on 2D data.
*
* http://en.wikipedia.org/wiki/K-means_clustering

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

Output photos that don't have datetimeoriginal to a CSV

Note this can take a long time if you have a lot of jpgs

@Gedrovits
Gedrovits / how-to-fix-on-mac.sh
Last active May 3, 2018 21:50
How to fix 'dyld: lazy symbol binding failed: Symbol not found: _yajl_set_static_value'
# Copy the gem location to clipboard
bundle show yajl-ruby | pbcopy
# Example: /Users/gedrovits/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/yajl-ruby-0.8.2
cd <cmd + v>
cd ext/yajl
# Now we need to replace 'inline void' to 'static void'. This will also create backup of old files.
sed -i '.bak' 's/inline void/static void/g' yajl_ext.h yajl_ext.c
# Now we must rebuild changed extension
make clean all
# After this you should not have any problems with yajl-ruby
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@milsosa
milsosa / test.js
Last active July 21, 2021 21:20
Run Mocha Tests
'use strict';
// 1. Create the file: {projectRoot}/test.js
// 2. Install dependencies: npm i glob why-is-node-running
// 3. Run the tests: node --expose-internals test.js
const whyIsNodeRunning = require('why-is-node-running');
const glob = require('glob');
const Mocha = require('mocha');
/**
* Caches the return value of get accessors and methods.
*
* Notes:
* - Doesn't really make sense to put this on a method with parameters.
* - Creates an obscure non-enumerable property on the instance to store the memoized value.
* - Could use a WeakMap, but this way has support in old environments.
*/
export function Memoize(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) {
if (descriptor.value != null) {
@dshaw
dshaw / nodebook.md
Last active November 17, 2022 14:50
Running Node on a Samsung 303C Chromebook

Running Node on a Samsung 303C Chromebook

Motivation

After @mikeal and @lyle purchased Chromebooks for kids activities at NodeConf 2014, I was very impressed with the device and decided to explore this as a laptop and hacking device for my kids (7 & 8). I'd love to retain the simplicity of the web-focused ChromeOS experience while letting my kids hack on NodeBots and learn how to program.

It seems like the platforms that ChromeOS runs on are quite diverse. The Samsung 303C hit the right balance of being an aesthetically pleasing looking device, having respectable build quality and the amazing $250 price point. The 303C has an ARM processor. Not all Chromebooks do. I'm writing the below step-by-step very specifically for this system.

Resources

@benbuckman
benbuckman / intercept-stdout.js
Created May 20, 2012 15:42 — forked from pguillory/gist:729616
Hooking into Node.js stdout, pipe stdout to telnet
var _ = require('underscore'),
util = require('util');
// intercept stdout, passes thru callback
// also pass console.error thru stdout so it goes to callback too
// (stdout.write and stderr.write are both refs to the same stream.write function)
// returns an unhook() function, call when done intercepting
module.exports = function interceptStdout(callback) {
var old_stdout_write = process.stdout.write,
old_console_error = console.error;