Skip to content

Instantly share code, notes, and snippets.

View anmoljagetia's full-sized avatar

Anmol Jagetia anmoljagetia

View GitHub Profile
@anmoljagetia
anmoljagetia / serve_http.py
Created November 20, 2017 12:29 — forked from pankajp/serve_http.py
Simple Python HTTP Server with multi-threading and partial-content support
#! /usr/bin/env python
# Standard library imports.
from SocketServer import ThreadingMixIn
import BaseHTTPServer
import SimpleHTTPServer
import sys
import json
import os
from os.path import (join, exists, dirname, abspath, isabs, sep, walk, splitext,
@anmoljagetia
anmoljagetia / appify
Created August 7, 2017 12:33
Appify script to create MacOS apps from scripts.
#!/usr/bin/env bash
Appify="$(basename "$0")"
if [ ! "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
Appify v5 for Mac OS X
Creates the simplest possible Mac OS X app from a shell script.
Takes a shell script as its first argument:
@anmoljagetia
anmoljagetia / Python_arg_parser.py
Created April 20, 2016 14:07
Python Argument Parser
import argparse
# Initialize argument parse object
parser = argparse.ArgumentParser(description="There are two flags, -f for fraud prevalence and -p to check prevalence in the output file")
# This would be an argument you could pass in from command line
parser.add_argument("-f", "--fraud", action="store", type = float, default = 0.2, help = "Enter the prevalence as a float, the default value is 0.2")
parser.add_argument("-p", "--prevalence", action="store_true", default = False, help = "use the flag to print the prevalence")
def main() :
inargs = parser.parse_args()
@anmoljagetia
anmoljagetia / anmol-terminal.sh
Created September 23, 2015 16:07
This is a script that adds a profile similar to the screenshot shown with Flatabulous in Gnome-Terminal.
#!/usr/bin/env bash
# Base16 - Gnome Terminal color scheme install script
[[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="flatabulous-terminal"
[[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="flatabulous-terminal"
[[ -z "$DCONF" ]] && DCONF=dconf
[[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen
dset() {
local key="$1"; shift
@anmoljagetia
anmoljagetia / terminalFlatTheme.sh
Created September 13, 2015 17:14
This gist shows how to setup terminal colors in the new gnome-terminal (v 3.14) and above. This was generated using a site called http://terminal.sexy
#!/usr/bin/env bash
# Base16 - Gnome Terminal color scheme install script
[[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="terminal.flat.theme"
[[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="terminal-flat-theme"
[[ -z "$DCONF" ]] && DCONF=dconf
[[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen
dset() {
local key="$1"; shift
#!/usr/bin/env sh
#
# Works best with blinking text: the last heart will blink when you have less
# than 25% of your battery life remaining.
#
# Add the following to your `~/.tmux.conf`;
#
# set -g status-right "#[fg=red]#(path/to/zelda-battery-tmux.sh) "
battery="$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\d+)%.*/\1/')"
#!/usr/bin/zsh
# modified from http://ficate.com/blog/2012/10/15/battery-life-in-the-land-of-tmux/
HEART='x'
if [[ `uname` == 'Linux' ]]; then
current_charge=$(upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep percentage | awk '{print $2}' | sed 's/%//g')
total_charge=100
else
battery_info=`ioreg -rc AppleSmartBattery`
@anmoljagetia
anmoljagetia / Tomorrow.sh
Created July 3, 2015 20:36
Run it under Ubuntu to get Tomorrow Dark theme on your terminal
#!/usr/bin/env sh
gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/palette "#000000000000:#919122222626:#777789890000:#AEAE7B7B0000:#1D1D25259494:#68682a2a9b9b:#2B2B66665151:#929295959393:#666666666666:#CCCC66666666:#B5B5BDBD6868:#F0F0C6C67474:#8181A2A2BEBE:#B2B29494BBBB:#8A8ABEBEB7B7:#ECECEBEBECEC"
gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/background_color "#1d1d1f1f2121"
gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/foreground_color "#c5c5c8c8c6c6"
gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/bold_color "#8A8ABEBEB7B7"
gconftool-2 -s -t bool /apps/gnome-terminal/profiles/Default/bold_color_same_as_fg "false"
gconftool-2 -s -t bool /apps/gnome-terminal/profiles/Default/use_theme_colors "false"
gconftool-2 -s -t bool /apps/gnome-terminal/profiles/Default/use_theme_background "false"