Skip to content

Instantly share code, notes, and snippets.

View andrew's full-sized avatar

Andrew Nesbitt andrew

View GitHub Profile
@mislav
mislav / fat-logfiles.sh
Last active December 22, 2018 19:56
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@elliottkember
elliottkember / heroku-CVE-2013-0156.rb
Last active December 10, 2015 20:38
CVE-2013-0156 is a nasty vulnerability in many versions of Rails. This script checks all your Heroku apps for this vulnerability in one quick (slow) move. More info: https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
## The quick-and-nasty CVE-2013-0156 Heroku inspector!
## Originally brought to you by @elliottkember with changes by @markpundsack @ Heroku
## Download and run using:
## ruby heroku-CVE-2013-0156.rb
`heroku list`.split("\n").each do |app|
app = app.strip
# Some "heroku apps" lines have === formatting for grouping. They're not apps.
next if app[0..2] == "==="
@andrew
andrew / linked_headings.coffee
Created December 4, 2012 15:17
Automatically create anchor links for headings
slugify = (text) ->
text = text.replace(/[^-a-zA-Z0-9,&\s]+/g, "")
text = text.replace(/-/g, "_")
text = text.replace(/\s/g, "-")
text.toLowerCase()
$ ->
$('h1,h2,h3,h4').each (i, elm) ->
heading = $(elm)
anchor = slugify(heading.text())
@brianmario
brianmario / bars.md
Last active June 14, 2019 21:29
Some places to check out in Portland

Bars

PROTIP: Bars in Oregon have to serve food as long as they're serving alcohol. As a result, some of them have amazing food.

PROTIP: You can't buy alcohol (other than beer or wine) anywhere else but a state-controlled liquor store. Most of them are closed on Sundays and close around 7pm every other night of the week.

Southeast

  • The Night Light - This was our favorite bar just before we moved to Italy. Right in the heart of the quiet Clinton district (where we were living at the time).
  • The Doug Fir Lounge - I hate to use the word swanky again but that's the only way I can describe it. The entire place is built to look like a log cabin. Used to go here all the time. Pretty good bar. The restaurant is open until 3am (or at least was when I lived there) and has some DAMN good gastro pub style food. The halibut fish and chips and burger are insane. Funny enough, I saw the GitHub guys here (including maddox and Tek I think?) after
@iangreenleaf
iangreenleaf / a_b_helper.rb
Created November 27, 2012 19:59
Helper to provide alternate configuration syntax for Split, the A/B testing tool.
module ABHelper
def split_test(name)
experiment = YAML.load_file("config/experiments.yml")[name]
given_probability, num_with_probability = experiment[:variants].inject([0,0]) do |a,v|
p, n = a
if v.kind_of?(Hash) && v[:percent]
[p + v[:percent], n + 1]
else
a
@max-mapper
max-mapper / helloworld.js
Created November 27, 2012 06:55
droneduino
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
})
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
})
@karlwestin
karlwestin / gist:4051467
Created November 10, 2012 15:55
Make the AR Drone connect to a network
#telnet into the drone (telnet 192.168.1.1)
#paste the following command:
killall udhcpd; iwconfig ath0 mode managed essid [ssid]; ifconfig ath0 [wanted ip] netmask 255.255.255.0 up;
#ex. killall udhcpd; iwconfig ath0 mode managed essid Roflcopter; ifconfig ath0 192.168.43.201 netmask 255.255.255.0 up;
@jarek-foksa
jarek-foksa / safari6-webkit-inspector.md
Created October 16, 2012 08:32
How-to: Restore WebKit Web Inspector on Mountain Lion

Restore WebKit Web Inspector on Mountain Lion

  1. Download WebKit build r121872: http://builds.nightly.webkit.org/files/trunk/mac/WebKit-SVN-r121872.dmg
  2. Right-click on WebKit.app and choose Show Package Contents
  3. Navigate to ./Contents/Frameworks/10.x/WebCore.framework/Versions/Current/Resources/ and you will find a folder called inspector. This contains the HTML/CSS/JavaScript for the Web Inspector, awesome! Keep this Finder window open!
  4. Open a new Finder window and navigate to /System/Library/PrivateFrameworks/WebInspector.framework/Versions/Current/Resources. This is where the 'new' Web Inspector is located.
  5. Now copy the contents from the WebKit Web Inspector folder (from Step 3.) to the new Web Inspector folder from Step 4. Do not remove anything, but when it prompts to 'keep newer' files press the Replace button.
  6. Now there is only one thing left to do, remove of rename the Main.html file (this is the main frame for the new Web Inspector) and rename inspector.html to `Main.ht
@davidjrice
davidjrice / redcarpet.rb
Created June 29, 2012 00:34
Rails 3.2 Markdown Template Handler
# config/initializers/redcarpet.rb
module ActionView
module Template::Handlers
class Markdown
class_attribute :default_format
self.default_format = Mime::HTML
def call(template)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
markdown.render(template.source).html_safe.inspect