Skip to content

Instantly share code, notes, and snippets.

View jeffreyiacono's full-sized avatar

Jeff Iacono jeffreyiacono

  • Eight Sleep
  • San Francisco
  • X @jfi
View GitHub Profile
@chrishol
chrishol / gsuite-dig.sh
Created October 16, 2018 22:19
Find G Suite users for a given list of domains
# Step 1: Create list of domains in url-list.txt
# Step 2: Run dig to output a list of MX records
while read url; do
dig $url mx | grep MX | head -n 2 | tail -n 1
done <url-list.txt > mx-results.txt
# Step 3: Grep to isolate and count the Google users
#!/usr/bin/env ruby -wKU
# encoding: UTF-8
class Flip
# sɹǝɔuɐʃɐqpɐoʃ ƃuıʞɔnɟノ(ಠ 益ಠ ノ) -> (ノಠ益ಠ)ノ彡fucking loadbalancers
# add arg support for flipping, reverse flipping, copying to clipboard, text, table, face style
TABLE = {
"a" => "\220\311", "b" => "q", "c" => "\224\311", "d" => "p", "e" => "\235\307", "f" => "\237\311", "g" => "\203\306", "h" => "\245\311", "i" => "\261\304",
"j" => "\276\311", "k" => "\236\312", "l" => "\203\312", "m" => "\257\311", "n" => "u", "r" => "\271\311", "t" => "\207\312", "v" => "\214\312", "w" => "\215\312",
"y" => "\216\312", "." => "\231\313", "[" => "]", "(" => ")", "{" => "}", "?" => "\277\302", "!" => "\241\302", "\"" => ",", "<" => ">", "_" => "\276\200\302",
@mislav
mislav / procs-vs-lambda.md
Last active March 26, 2021 18:34
Jim Weirich on the differences between procs and lambdas in Ruby

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@markpundsack
markpundsack / heroku-CVE-2013-0156.rb
Last active November 27, 2023 15:44 — forked from elliottkember/heroku-CVE-2013-0156.rb
Forked from https://gist.github.com/4489689 by elliottkember. 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] == "==="
@christophergandrud
christophergandrud / source_GitHubData.R
Last active March 31, 2020 04:58
A function for downloading data stored on GitHub in a plain-text format (e.g. CSV, TSV) into R. The function loads the data as a data frame. For more details see: http://christophergandrud.blogspot.com/2013/01/sourcegithubdata-simple-function-for.html.
#####################
# R function for downloading plain-text data from GitHub
# Christopher Gandrud
# 7 January 2013
#####################
# source_GitHubData is directly based on source_url from the Hadley Wickham's devtools package
source_GitHubData <-function(url, sep = ",", header = TRUE)
{

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

@lecram
lecram / escher.py
Last active August 27, 2021 07:05
This is a toy one-file application to manage persistent key-value string data. The file is *both* the application and its data. When you run any of the commands described in `escher.py --help`, the file will be executed and, after data change, it will rewrite itself with updated data. You can copy the file with whatever name to create multiple d…
#! /usr/bin/env python
"""{escher} -- one-file key-value storage.
What?
This is a toy application to manage persistent key-value string data.
The file {escher} is *both* the application and its data.
When you run any of the commands below, the file will be executed and,
after data change, it will rewrite itself with updated data.
You can copy the file with whatever name to create multiple datasets.
class RegistrationsController < ApplicationController
include Injector::ControllerMethods
provided_by Controller::Registration
end
@jeffreyiacono
jeffreyiacono / flocking
Last active October 12, 2015 12:58
a sample script that sleeps
# round 1! => nonblocking example
[process a] $ flock -en sleeper.lock ./sleeper.sh
time to sleep ...
[process b] $ flock -en sleeper.lock ./sleeper.sh
# ^ will exit b/c of n switch: "Fail (with an exit code of 1)
# rather than wait if the lock cannot be immediately acquired.
... waking up # <= process a returning
# round 2! => blocking example
export PATH=${PATH}:/usr/local/sbin
export ARCHFLAGS='-arch x86_64' 
# memcached
alias mcd='memcached -d -l 127.0.0.1 -p 11211'
alias mck='killall memcached'
alias mcst='ps ax | grep memcached | grep -v grep'
# RVM