Skip to content

Instantly share code, notes, and snippets.

View rahuljiresal's full-sized avatar

Rahul Jiresal rahuljiresal

View GitHub Profile
import csv
import argparse
from datetime import datetime
import os
from rich import print
key_website = 'Website'
key_order_date = 'Order Date'
key_total_cost = 'Total Owed'
key_name = 'Product Name'
@rahuljiresal
rahuljiresal / bash_profile.sh
Created November 5, 2018 02:49
bash_profile
[[ -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 August 10, 2016 17:24
Bitbar Menubar script to track the daily performance and total worth of your stock portfolio.
#!/usr/bin/python
import urllib2
import json
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
RED = "#ff0000"
GREEN = "#00af00"
@rahuljiresal
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 https://github.com/goloroden/node-force-domain, modified to work on Openshift platform.
/*
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 / nginx-Dockerfile
Created May 19, 2016 23:00
Docker file to build nginx with `--with-debug` flag to enable debugging. (run.sh is a custom script we used at AeroFS)
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 / mysql-s3-backup.rb
Last active February 8, 2016 17:24
Backup MySQL Database to Amazon S3 Bucket
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
@rahuljiresal
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.
//
// 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 November 30, 2014 21:35
Shell Script to convert many files in the folder to MP4 files using Handbrake CLI
#!/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 / geocode-to-cities.rb
Created February 11, 2014 17:17
Reverse Geocode Coordinates to City
# 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: