Skip to content

Instantly share code, notes, and snippets.

View arpanpal010's full-sized avatar

Arpan Pal arpanpal010

View GitHub Profile
@arpanpal010
arpanpal010 / cache-service.ts
Created October 19, 2017 14:37
A generic caching mechanism that stores in localstorage.
export static class CacheService {
// static $inject = ["localStorageService", "$rootScope", "$timeout"]
private static ls : localStorageService = undefined; // wrap localstorage to hide data
private static instance : CacheService = undefined;
private callables : Object = {};
private asyncCallables : Object = {};
constructor(ls : any, rootScope : any, timeout : any) {
if(!this.instance) {
@arpanpal010
arpanpal010 / ytp.sh
Last active May 18, 2016 17:02
Youtube player for raspberry pi. Using pip version of Youtube-DL and omxplayer that comes default in Raspbian.
#!/bin/bash
# youtube url player for raspberry pi,
# ------------------------------------------------------------------
ytdlCmd="youtube-dl";
ytdlArgs="-f 140 --prefer-ffmpeg -g"; # 141 - 256k audio, 140 - 128k audio, 22 - best quality available
playerCmd="omxplayer";
playerArgs="--vol -300";
#!/bin/sh
# System Update
pacman --noconfirm -Syu
#The essentials
pacman --noconfirm -S base-devel vim git
# Packer (AUR Helper)
cd /tmp
@arpanpal010
arpanpal010 / ctags definitions for Javascript
Created December 8, 2015 16:36 — forked from tim-smart/ctags definitions for Javascript
CTags Definitions for Javascript
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*[ \t]*([,;]|$)/\5/,variable/
@arpanpal010
arpanpal010 / libnotify-skype.sh
Created November 25, 2015 12:22
Skype notification handler, executes libnotify commands on skype events using notify-send
#!/bin/sh
# all variables found so far
# execute the below line for all events
# ~/bin/libnotify-skype.sh "%type" "%sname" "%sskype" "%smessage" "%fpath" "%fname" "%fsize" "%fprogress" "%fspeed"
# below line prints all the param values on any event
# notify-send "$1 $2 $3 $4 $5 $6 $7 $8 $9";
# shorthand for notification
notif () {
@arpanpal010
arpanpal010 / awsetbg.sh
Last active December 5, 2023 16:02
wallpaper cropper and setter for awesomeWM, also generates theme and shell colors
#!/bin/bash
# default location of theme and wallpaper
# replace 'awtheme' with your current theme
wallpaperDestination="$HOME/.config/awesome/themes/awtheme/wallpaper";
# add #include "/home/arch/.Xresources_colors" to .Xresources
colorScriptDestination="/home/arch/.Xresources_colors"
# add [[ -f "$HOME/.bash_colors" ]] && . "$HOME/.bash_colors"; to .bashrc
# bashColorsDestination="/home/arch/.bash_colors"
@arpanpal010
arpanpal010 / mockServer.py
Created September 29, 2015 07:11 — forked from mandalpuspendu/mockServer.py
api test
from __future__ import print_function #from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import http.server, urllib, datetime, json
#=================================================================
sUrl="/testServer" #server url
port=8000 #server port
#=================================================================
# data
#=================================================================
jsonDict = {
"login" : { # sent at login
@arpanpal010
arpanpal010 / new-session.sh
Created August 27, 2015 07:42
TMUX session creator / manager
#!/bin/bash
sessionPWD="/home/$USER/";
sessionName="new-session"; #must be same as filename
#check if already created
cd ${sessionPWD};
#create SESSION
tmux new-session -s ${sessionName} -n vim -d
#first window 1: vim
tmux send-keys -t ${sessionName} 'vim' C-m
@arpanpal010
arpanpal010 / mkpng.py
Created August 1, 2015 05:41
Crop and Convert any image into a wallpaper that fits the screen by default.
#!/bin/python2.7
import os, sys, re
from PIL import Image, ImageChops, ImageOps
def show_usage () :
print("""Simple JPEG to monitor sized wallpaper generator\nDeps: PIL(2.7)\nUsage:\n[python2.7] %s /path/to/image [/path/to/outfile] [WIDTHxHEIGHT]\n""" % (sys.argv[0],))
def makeThumb(f_in, f_out, size=(80,80), pad=False):
image = Image.open(f_in)
@arpanpal010
arpanpal010 / ipup.sh
Created May 7, 2015 03:30
auto-login and IP chooser for my raspberry pi, run with a crontab entry
#!/bin/bash
loginPortal=""; #link to send the post req to
userName=""; #username for logging into the service
password=""; #password
dynDnsUpdateLink=""; #link to update the dynDNS service.
firstNumber01=""; #first number to precede the IP say 101.*.*.*
firstNumber02=""; #alternate
#get an ip beginning with $firstNumber01 or $firstNumber02 else reconnect