Skip to content

Instantly share code, notes, and snippets.

View pmarreck's full-sized avatar

Peter Marreck pmarreck

  • formerly desk.com, thredup.com and lifebooker.com. currently Director of Engineering @addigence
  • Long Island, NY
  • 17:22 (UTC -04:00)
View GitHub Profile
@ogredude
ogredude / mandelbrot.rb
Created August 4, 2011 20:46
Mandelbrot generator in 111 characters!
80.times{|a|p (0..300).map{|b|x=y=i=0;(x,y,i=x*x-y*y+b/150.0-1.5,2*x*y+a/40.0-1,i+1)until(x*x+y*y>4||i>98);i>98?0:1}*''}
@SchizoDuckie
SchizoDuckie / apf_release.prepend.js
Created March 20, 2012 20:19
Cloud9 IDE Touch Enabler Monkeypatch
/**
* A proof of concept monkeypatch to make Cloud9 IDE work on a tablet.
* Since i'm an extremely lazy bastard I prepended this snippet directly in package/client/js/apf_release.js
*
* What does it do?
* - It fires a doubleclick for a 2-finger tap
* - It fires a mousewheel up / down event for a 2-finger swipe up / down.
*
* How does it work?
* Prepend the functions below to <cloud9>/package/client/js/apf_release.js, save, load in tablet.
@havenwood
havenwood / clippy.rb
Last active December 14, 2015 15:08
Send puts output to OS X clipboard inside a block
def clipboard
yield
pbcopy = IO.popen 'pbcopy', 'w'
$stdout = pbcopy
yield
ensure
pbcopy.close
$stdout = STDOUT
end
@mbbx6spp
mbbx6spp / gist:5622645
Last active December 17, 2015 14:09
Add this to your .bash_profile to handle history properly across multiple terminals, and output exit code of last command plus suitable fortune in appropriate color.
declare -r red=$'\e[31;40m'
declare -r blue=$'\e[0;34m'
declare -r d=$'\e[37;40m' # set this to what makes sense for your terminal color scheme
shopt -s histappend
pre_prompt() {
local exit_code=$?;
history -a;
history -n;
$ whois microsoft.com
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
MICROSOFT.COM.ZZZZZZZZZZZZZZZZZZZZZZ.IS.A.GREAT.COMPANY.ITREBAL.COM
MICROSOFT.COM.ZZZZZZZZZZZZZZZZZZZ.GET.ONE.MILLION.DOLLARS.AT.WWW.UNIMUNDI.COM
MICROSOFT.COM.ZZZZZZZZZZZZZZZZZZ.IM.ELITE.WANNABE.TOO.WWW.PLUS613.NET
anonymous
anonymous / gist:5bf92b9d14b8c529919c6027502fbd09
Created May 24, 2016 14:38
A hands-on workaround to avoid your laptop getting stolen in a security scanning. See http://www.echeng.com/journal/2016/5/23/tsa-gave-my-macbook-pro-to-another-passenger-at-lax-and-now-its-gone
GNU nano 2.0.6 File: tsa Modified
#!/bin/bash
# Run this script just before you put the laptop in the bin for security scanning.
# You can add the seconds the laptop will be waiting before speaking. The default
# is waiting for 180 seconds (3 minutes).
# Switch to the login screen, effectively locking the screen.
function lockscreen() {
/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
@pmarreck
pmarreck / new_auto_link_regex_constant.rb
Created June 19, 2012 20:37
A URI detector/parser regex that is a better, but slower, auto_link regex for Rails (and a line that patches it in)
@mbbx6spp
mbbx6spp / GITHUB-COMPARE-LINKS.md
Created June 21, 2012 03:37
This Gist is worth a million beers. So buy me one (or send me a really cool t-shirt, make sure it is REALLY cool though)! :)
@timruffles
timruffles / dyanmic_or_di_elixir.md
Last active June 11, 2020 04:23
Approaches to dependency-injection/dynamic dispatch in elixir

In many production systems you'll want to have one module capable of talking to many potential implementations of a collaborator module (e.g a in memory cache, a redis-based cache etc). While testing it's useful to control which module the module under test is talking to.

Here are the approaches I can see. The two points that seem to divide the approaches are their tool-ability (dialyzer) and their ability to handle stateful implementations (which need a pid).

Passing modules

Modules are first class, so you can pass them in. Used in EEx, where passed module must implement a behaviour.

@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell