Skip to content

Instantly share code, notes, and snippets.

Michael Amor Righi righi

Block or report user

Report or block righi

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
@righi
righi / gist:c0aaa4c21325f837283e
Created Oct 18, 2015 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
View gist:c0aaa4c21325f837283e

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
PostgreSQL : List all primary keys
View gist:2f35bad8ee5d97431963
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';
View 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 # ?
View how-to-set-up-stress-free-ssl-on-os-x.md

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

View keybase.md

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 Jul 20, 2014
Postgres Aggregate Median
View postgres_median.sql
-- 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 Sep 12, 2019
git-reup
View 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 Dec 31, 2015
ActionController::UrlGenerationError ... missing required keys
View output.txt
› 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.
You can’t perform that action at this time.