Skip to content

Instantly share code, notes, and snippets.


Rahul Jiresal rahuljiresal

View GitHub Profile
rahuljiresal / mysql-s3-backup.rb
Last active February 8, 2016 17:24
Backup MySQL Database to Amazon S3 Bucket
View mysql-s3-backup.rb
require 'date'
require 'aws/s3'
class Settings
attr_accessor :username, :password, :database, :mysql_location, :access_key, :secret_key, :bucket_name
user_settings =
user_settings.username = DATABASE_USERNAME
user_settings.password = DATABASE_PASSWORD
rahuljiresal / geocode-to-cities.rb
Created February 11, 2014 17:17
Reverse Geocode Coordinates to City
View geocode-to-cities.rb
# get the geocoder gem by doing 'gem install geocoder' or adding 'gem geocoder' to your Gemfile
require 'geocoder'
# configure geocoder service -- I'm using bing because it gives more API calls per day
# geocoding service (see below for supported options):
:lookup => :bing,
# IP address geocoding service (see below for supported options):
:ip_lookup => :maxmind,
# to use an API key:
rahuljiresal / openshift-node-force-domain.js
Last active July 22, 2016 08:53
This is a middleware for Connect and Express that redirects any requests to a default domain. Based on, modified to work on Openshift platform.
View openshift-node-force-domain.js
Openshift uses haproxy ( as a front proxy to route request to instances of the app.
This proxy does the job of unwrapping https and sets the 'x-forwarded-proto' header.
Because of this, the Node.JS app never sees the actual protocol of the request, unless it checks the presence of this header.
I modified the code written by goloroden ( to check this header instead of ports.
This gist does exactly what his code does, except checks for actual protocol instead of relying on the port for the protocol.
var rewrite = function (route, options) {
options = _.defaults({
rahuljiresal /
Created November 30, 2014 21:35
Shell Script to convert many files in the folder to MP4 files using Handbrake CLI
[ -d bkp ] || mkdir bkp
# change the file extension to whatever you want, mkv, avi, etc.
for f in *.mkv;
echo "========================== Processing $f ==========================";
HandBrakeCLI -i "$f" -o "${f%}.mp4" --preset="Normal"
mv "$f" bkp
rahuljiresal / StatusBarNotificationManager.h
Last active October 30, 2015 16:34
A small code snippet to show small in-app notifications on iOS. These notifications cover the Status Bar.
View StatusBarNotificationManager.h
// StatusBarNotificationManager.h
// Created by Rahul Jiresal on 2015-09-23.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface StatusBarNotificationManager : NSObject
rahuljiresal / nginx-Dockerfile
Created May 19, 2016 23:00
Docker file to build nginx with `--with-debug` flag to enable debugging. ( is a custom script we used at AeroFS)
View nginx-Dockerfile
FROM alpine:3.3
MAINTAINER NGINX Docker Maintainers ""
ENV GPG_KEYS B0F4253373F8F6F510D42178520A9993A1C052F8
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
rahuljiresal /
Last active August 10, 2016 17:24
Bitbar Menubar script to track the daily performance and total worth of your stock portfolio.
import urllib2
import json
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
RED = "#ff0000"
GREEN = "#00af00"
rahuljiresal /
Created November 5, 2018 02:49
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
export PS1="--------\n\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "