Skip to content

Instantly share code, notes, and snippets.

View righi's full-sized avatar

Michael Amor Righi righi

View GitHub Profile
@righi
righi / gist:c0aaa4c21325f837283e
Created October 18, 2015 18:50 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@righi
righi / gist:2f35bad8ee5d97431963
Created May 13, 2015 22:48
PostgreSQL : List all primary keys
SELECT a.attname AS pkey, c.relname as pkey_index_name, c2.relname AS table_name
FROM pg_index i
JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
JOIN pg_catalog.pg_class c ON i.indexrelid = c.oid
JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE i.indisprimary
AND n.nspname = 'public';
@righi
righi / measure.rb
Last active August 29, 2015 14:13 — forked from camertron/measure.rb
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

Keybase proof

I hereby claim:

  • I am righi on github.
  • I am righi (https://keybase.io/righi) on keybase.
  • I have a public key whose fingerprint is 756D C970 6998 86C0 CA0B 0473 C43B BC51 191B BCAB

To claim this, I am signing this object:

@righi
righi / postgres_median.sql
Created July 20, 2014 02:27
Postgres Aggregate Median
-- Source: https://wiki.postgresql.org/wiki/Aggregate_Median
CREATE FUNCTION _final_median(anyarray) RETURNS float8 AS $$
WITH q AS
(
SELECT val
FROM unnest($1) val
WHERE VAL IS NOT NULL
ORDER BY 1
),
@righi
righi / git-reup
Last active September 12, 2019 17:53
git-reup
#!/usr/bin/env ruby
#
# Usage: git-up
# git-reup
#
# Like git-pull but show a short and sexy log of changes
# immediately after merging (git-up) or rebasing (git-reup).
#
# Inspired by Kyle Neath's `git up' alias:
# http://gist.github.com/249223
@righi
righi / output.txt
Last active December 31, 2015 13:59
ActionController::UrlGenerationError ... missing required keys
› ruby rails3_works.rb
Finished in 0.001542s, 648.5084 runs/s, 1297.0169 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
› ruby rails4_fails.rb
Finished tests in 0.013107s, 76.2951 tests/s, 0.0000 assertions/s.