Skip to content

Instantly share code, notes, and snippets.

John Nunemaker jnunemaker

Block or report user

Report or block jnunemaker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rails_single_file.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
View test_conn.rb
require 'active_support/all'
require 'active_record'
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDOUT)
spec = { 'test' => {adapter: 'sqlite3', database: ':memory:'},
'test_readonly' => {adapter: 'sqlite3', database: ':memory:'},
'shared_test' => {adapter: 'sqlite3', database: ':memory:'},
'shared_test_readonly' => {adapter: 'sqlite3', database: ':memory:'}
@halilim
halilim / move_heroku_pg_to_aws_rds.md
Last active Jun 12, 2019
Move Heroku Postgres to Amazon AWS RDS
View move_heroku_pg_to_aws_rds.md
  1. Prepare your RDS instance and [authorize access to it][1] (basically make it public).

  2. Put your app in maintenance mode:

    heroku maintenance:on
  3. Save the latest SQL dump of the DB:

View pgsql_counters_poc.sql
CREATE OR REPLACE FUNCTION create_sequence_if_not_exists(sequence varchar) RETURNS void AS $$
DECLARE
BEGIN
IF to_regclass(sequence::cstring) IS NULL THEN
EXECUTE 'CREATE SEQUENCE '|| sequence || ' START 0 MINVALUE 0 INCREMENT 1';
PERFORM setval(sequence::regclass, 0);
END IF;
END;
$$ LANGUAGE plpgsql;
@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active Oct 22, 2019
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
View bench_rails_memory_usage.rb
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@acolyer
acolyer / service-checklist.md
Last active Oct 29, 2019
Internet Scale Services Checklist
View service-checklist.md

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
View server.go
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
View disposable-email-provider-domains
0815.ru
0wnd.net
0wnd.org
10minutemail.co.za
10minutemail.com
123-m.com
1fsdfdsfsdf.tk
1pad.de
20minutemail.com
21cn.com
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active Nov 9, 2019
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!
View whiteboardCleaner.md

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@debasishg
debasishg / gist:8172796
Last active Nov 4, 2019
A collection of links for streaming algorithms and data structures
View gist:8172796
  1. General Background and Overview
You can’t perform that action at this time.