Skip to content

Instantly share code, notes, and snippets.

@gmhawash
gmhawash / behaviors.rb
Created January 18, 2024 20:58 — forked from timnew/behaviors.rb
Rails MultiSchema utility for Postgres multi-schema database
module MultiSchema
module Behaviors
@@disable_message = false
def disable_message=(val)
@@disable_message = val
end
def disable_message
@@disable_message
@gmhawash
gmhawash / AuthyToOtherAuthenticator.md
Created October 13, 2020 22:49 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My guess is that Brian used the

@gmhawash
gmhawash / net_http_debug.rb
Created September 13, 2020 13:48 — forked from brainlid/net_http_debug.rb
Enable debug for all Ruby HTTP requests
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)
@gmhawash
gmhawash / when-proc.rb
Created February 11, 2014 21:24 — forked from mrb/when-proc.rb
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby)
#
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses!
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165
#
# ... kudos to @chadfowler for the tip!
#
# (note: works on 1.8.7 as well :-))
def am_i_awesome?
@gmhawash
gmhawash / gist:8293620
Last active January 2, 2016 10:59 — forked from ivanvanderbyl/gist:4222308
Upgrade Postgresql 9.1 to 9.3
# Add pg ppa to your respository list; go here: http://www.postgresql.org/download/
# For ubuntu percise (12.04)
# Add the file: /etc/apt/sources.list.d/pgdg.list and in it add:
deb http://apt.postgresql.org/pub/repos/apt/ YOUR_UBUNTU_VERSION_HERE-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
#!/usr/bin/env bash
# call like this on the target server:
# NODENAME='foo' CHEF_ENV='production' RUNLIST='["role[foo]","recipe[bar]"]' CHEFREPO='git@example.com:repo.git' bash <( curl -L https://raw.github.com/gist/1026628 )
# You will need to ensure that the ssh key is already set up on the server.
set -e
export CHEF_DIR="${HOME}/chef"
sudo rm -rf $CHEF_DIR
mkdir -p "$CHEF_DIR"
@gmhawash
gmhawash / switch.rb
Created February 12, 2013 21:29 — forked from jbr/switch.rb
# In response to:
# http://mlomnicki.com/ruby/tricks-and-quirks/2011/02/10/ruby-tricks2.html
# Ruby 1.9.2 has some neat stuff that lets us make a readable
# alternative case statement that calls each method in turn.
# 1.9.2 features used:
# * hashes are ordered in 1.9.2
# * cool JSON-style hash syntax
# * concise lambda syntax