Skip to content

Instantly share code, notes, and snippets.

@beanieboi
beanieboi / gist:ad526faf063181f336a2
Last active May 11, 2023 15:59
Codeship Nginx Config for Heroku
daemon off;
# Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections 1024;
}
@danveloper
danveloper / fuck.txt
Created July 8, 2015 00:15
Comcast Cares
for i in $(seq 1 1000); do bash -c "time dig @8.8.8.8 redhat.com>/dev/null &"; done 2>&1 | grep "^real" | grep -v "0m0"
@evanwhalen
evanwhalen / gist:f74879e0549b67eb17bb
Last active February 18, 2018 18:54
circleci-parallel-codeclimate
#!/usr/bin/env ruby
require "codeclimate-test-reporter"
branch = ENV['CIRCLE_BRANCH']
node_index = ENV['CIRCLE_NODE_INDEX'].to_i
node_total = ENV['CIRCLE_NODE_TOTAL'].to_i
artifacts_dir = ENV['CIRCLE_ARTIFACTS']
coverage_dir = File.join("..", "..", "..", ENV['CIRCLE_ARTIFACTS'], "coverage")
filename = '.resultset.json'
@claudijd
claudijd / update.rb
Created June 18, 2015 12:57
I way to manually update RubyGems without susceptibility to CVE-2015-3900
require 'digest'
require 'net/http'
gem_file = 'rubygems-update-2.4.8.gem'
# Reference: https://rubygems.org/gems/rubygems-update/versions/2.4.8
sha256hash = "dbed858db605923d9cc77080de1a5f1ce6ac3c68924877c78665e0d85d7b3e73"
##################################################
# Download the Gem from RubyGems.org (over HTTPS)
@ef4
ef4 / select.hbs
Last active October 7, 2021 09:41
Goodbye old Select View
<select onchange={{action (mut vehicle) value="target.value"}}>
{{#each vehicles key="@item" as |vehicleChoice|}}
<option value={{vehicleChoice}} selected={{eq vehicle vehicleChoice}}>{{vehicleChoice}}</option>
{{/each}}
</select>
require 'securerandom'
require 'benchmark'
# written to allow 65,536 unique array items
array_of_x = lambda {|x| SecureRandom.hex(x*2).scan(/..../) }
module Refinements
module BooleanUniqWithDupUniqBang
refine Array do
def uniq?
@thom-nic
thom-nic / chunked_transfer_decoder.rb
Last active February 5, 2020 15:23
Rack middleware to decode chunked transfer HTTP request
#require 'rack/request'
# Rack middleware to decode a `Transfer-Encoding: chunked` HTTP request.
#
# USAGE NOTE:
#
# Some HTTP servers (Webrick and Unicorn/Rabinbows/Zbatery) already decode the
# chunked stream, but they leave the 'Transfer-Encoding' header and don't bother
# to add a 'Content-Length' header, which causes rails ActionDispatch::Request
# to not parse the whole request body.
#!/bin/bash
# Copied from http://willwarren.com/2014/07/03/roll-dynamic-dns-service-using-amazon-route53/
# Externalizing the zone ID and CNAME
if [ -z "$1" ]
then
echo "The first argument needs to be the Hosted Zone ID, i.e. BJBK35SKMM9OE"
exit 1
fi
@schneems
schneems / gist:e09c95da37a8c50047a8
Created May 12, 2015 18:23
Find 50 most popular Gems that have mime-types as a dependency
require 'net/http'
require 'json'
def rubygems_get(gem_name: "", endpoint: "")
path = File.join("/api/v1/gems/", gem_name, endpoint).chomp("/") + ".json"
JSON.parse(Net::HTTP.get("rubygems.org", path))
end
results = rubygems_get(gem_name: "mime-types", endpoint: "reverse_dependencies")
@isaacs
isaacs / notes.md
Last active August 29, 2015 14:20

New approach:

  • spawn('sh', ...)

    Find the -c arg.

    Parse, and split up by && and || and | and ;, expanding each bit.

    Then spawn the exploded command line. When we explode it, we need to do the same thing with looking up env and shebang results.