Skip to content

Instantly share code, notes, and snippets.

Rahul Jiresal rahuljiresal

Block or report user

Report or block rahuljiresal

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
View bash_profile.sh
[[ -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\] $ "
@rahuljiresal
rahuljiresal / stock-portfolio-bitbar.5m.py
Last active Aug 10, 2016
Bitbar Menubar script to track the daily performance and total worth of your stock portfolio.
View stock-portfolio-bitbar.5m.py
#!/usr/bin/python
import urllib2
import json
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
RED = "#ff0000"
GREEN = "#00af00"
@rahuljiresal
rahuljiresal / nginx-Dockerfile
Created May 19, 2016
Docker file to build nginx with `--with-debug` flag to enable debugging. (run.sh is a custom script we used at AeroFS)
View nginx-Dockerfile
FROM alpine:3.3
MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com"
ENV NGINX_VERSION 1.10.0
ENV GPG_KEYS B0F4253373F8F6F510D42178520A9993A1C052F8
ENV CONFIG "\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
@rahuljiresal
rahuljiresal / convert-copy.sh
Last active Sep 2, 2019
A shell script to add to Transmission so the downloads automatically get added to iTunes library. If conversion (with or without encoding) is required from MKV or AVI formats to MP4, this script automatically does that before adding to library. (HandBrakeCLI and FFMPEG required).
View convert-copy.sh
#!/bin/bash
# development
# if [ -z "$1" ]; then
# TR_DOWNLOADS="$TR_TORRENT_DIR/$TR_TORRENT_NAME"
# else
# TR_DOWNLOADS="$1"
# TR_TORRENT_NAME="Temp_Torrent_Name"
# fi
@rahuljiresal
rahuljiresal / StatusBarNotificationManager.h
Last active Oct 30, 2015
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
rahuljiresal / handbrake_bulk_convert.sh
Created Nov 30, 2014
Shell Script to convert many files in the folder to MP4 files using Handbrake CLI
View handbrake_bulk_convert.sh
#!/bin/bash
[ -d bkp ] || mkdir bkp
# change the file extension to whatever you want, mkv, avi, etc.
for f in *.mkv;
do
echo "========================== Processing $f ==========================";
HandBrakeCLI -i "$f" -o "${f%}.mp4" --preset="Normal"
mv "$f" bkp
@rahuljiresal
rahuljiresal / openshift-node-force-domain.js
Last active Jul 22, 2016
This is a middleware for Connect and Express that redirects any requests to a default domain. Based on https://github.com/goloroden/node-force-domain, modified to work on Openshift platform.
View openshift-node-force-domain.js
/*
Openshift uses haproxy (haproxy.org) 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 (https://github.com/goloroden/node-force-domain) 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
rahuljiresal / geocode-to-cities.rb
Created Feb 11, 2014
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
Geocoder.configure(
# 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
rahuljiresal / mysql-s3-backup.rb
Last active Feb 8, 2016
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
end
user_settings = Settings.new
user_settings.username = DATABASE_USERNAME
user_settings.password = DATABASE_PASSWORD
You can’t perform that action at this time.