Skip to content

Instantly share code, notes, and snippets.

@gmhawash
gmhawash / gist:4043232
Created November 9, 2012 01:54
Reset jenkins password
0. SSH to server
1. Edit /opt/bitnami/apps/jenkins/jenkins_home/config.xml
2. set userSecurity to false: <userSecurity>false</userSecurity>
3. delete
<authorizationStrategy> and <securityRealm>
4. /etc/init.d/bitnami restart
@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 / Rename Postrgres Database
Last active October 19, 2018 04:31
Rename a postgresql database with open connection
Ref: http://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
Postgres (rightfully) stops you from renaming a database while it has connections open connections. To test an exception handler which attempts to handle lost database connection, I was able to do the following:
1. \c (database that you are not trying to rename)
\c template1
2. select pg_terminate_backend(pid) from pg_stat_activity where datname ~ 'db_name_you_are_trying_to_rename';
3. alter database db_name_you_are_trying_to_rename rename to new_name;
@gmhawash
gmhawash / gist:8294627
Last active January 2, 2016 11:09
Create scrollable tables
http://jsfiddle.net/gmhawash/6FT8T/
How about doing something like this? I've made it from scratch...
What I've done is used 2 tables, one for header, which will be static always, and the other table renders cells, which I've wrapped using a div element with a fixed height, and to enable scroll, am using overflow-y: auto;
Also make sure you use table-layout: fixed; with fixed width td elements so that your table doesn't break when a string without white space is used, so inorder to break that string am using word-wrap: break-word;
<html>
@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 / pather
Created December 10, 2013 16:39
pather code.
#!/usr/bin/env ruby
class Pather
def initialize(input)
@input = input.split("\n")
end
def output
x1 = nil
@input.each do |line|
@gmhawash
gmhawash / ofp.json
Last active December 23, 2015 15:41
Maps
[
{
"title": "Portland HRC",
"body": "Something",
"location": [123.333, 98.2323]
}
]