Skip to content

Instantly share code, notes, and snippets.

View hiway's full-sized avatar

Harshad Sharma hiway

View GitHub Profile
@hiway
hiway / hdr_linux_gphoto2_dslr.py
Last active August 29, 2015 14:03
Timelapse Scripts Collection (written at different times, for different devices)
#!/usr/bin/env python
import os, re
from subprocess import call, Popen, PIPE
def run(command):
print 'Running:', command
p = Popen(command, shell=True, stdout=PIPE)
lines = p.stdout.readlines()
for line in lines:
@hiway
hiway / ideavimlockdown.py
Created August 20, 2014 09:22
Create VIM lockdown script where vimscript is not available => IdeaVIM (for PyCharm etc)
"""
Script to create an .ideavimrc comptabile VIM lockdown key-remapper as used by github.com/hiway/po
This will unmap EVERYTHING and render your VIM useless - the idea is to begin with your own keymapping instead of VIM's legacy keymaps. You may refer to github.com/hiway/po for more information.
To create a new .lockdown_ideavim: `python ideavimlockdown.py > ~/.lockdown_ideavim`
Then use it within your ~/.ideavimrc by adding "source ~/.lockdown_ideavim" within the file.
"""
excludes = [":", "\n", "!", chr(0x9), chr(0x16), " ", '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '(', ')', ',']
@hiway
hiway / google_links.py
Created October 31, 2014 11:25
Fetch top X URLs for keywords from Google
@hiway
hiway / ohgodno.lua
Created February 27, 2015 10:11
Here's a script to punch a big hole thru your VPS's security and access your shell over Telegram chat… don't try this on production.
-- To use: telegram-cli -k tg-server.pub -s ohgodno.lua
--
-- Remember to watch for your telegram ID in telegram-cli, update it below.
-- This script will let you message yourself, and will ignore messages from others.
telegram_id = 1234567
message_echo = ""
function on_msg_receive (msg)
if msg.to.id == telegram_id and msg.from.id == telegram_id and msg.text ~= message_echo then
@hiway
hiway / socialpay.php
Created March 17, 2015 13:19
Enable SocialPay on Instamojo Payment Link using API
<?php
// https://github.com/Instamojo/instamojo-php
require "instamojo.php";
$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]',); //In live code API Keys are written here
try {
$response = $api->linkCreate(array(
'title'=>'SocialPay via PHP',
@hiway
hiway / wrldata.sh
Created July 31, 2012 11:03
Scrape Indian Electrical Western Region Data
#!/bin/bash
curl -s http://www.wrldc.com/ | sed -n '/WR Grid Frequency/,/UI Rate/p' | sed -e 's#<[^>]*>##g' | sed 's/&nbsp;/ /g' | sed 's/UI Rate (Rs\/Unit)/ /g' | sed 's/ //g'
@hiway
hiway / follow_via_list.py
Created November 12, 2012 04:41
Utility to trim down your twitter following by moving users to lists and unfollowing automatically.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
try:
import tweepy
except:
raise Exception('Install tweepy library first! (pip install tweepy)')
@hiway
hiway / macosx-activity-logger-boilerplate.py
Created December 22, 2012 12:19
Boilerplate/ minimum code needed to log keyboard and mouse activity on MacOSX. Logs only whether there was any activity or not, not the actual keys/ locations.
import time
from Cocoa import *
from Foundation import *
from PyObjCTools import AppHelper
last_timestamp = time.time()
class AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, aNotification):
@hiway
hiway / macosx-activity-logger-menubar.py
Created December 22, 2012 13:08
Logs activity of key presses and mouse left-click, displays an icon in system menubar to depict activity mode. Can be used as boilerplate for sending activity log to server every x minutes.
import time
from Cocoa import *
from Foundation import *
from PyObjCTools import AppHelper
last_timestamp = time.time()
# put two images, 16*16px in a subdirectory called 'resources'
status_images = {
'inactive':'./resources/inactive.png',
@hiway
hiway / current_song.py
Last active December 10, 2015 11:28
Script to print currently playing track from iTunes on MacOSX — I use this to tweet out my favorite songs. (works on Snow Leopard) Bonus script: youtube_current_song.py will give you a youtube search URL for current song - again useful when tweeting. It also prints exception to stdout, useful for debugging with automation tools like TextExpander.
import appscript
itunes = appscript.app('itunes')
if itunes.isrunning():
track = itunes.current_track()
status = "#music %s by %s" %(track.name(), track.artist())
album = track.album()
if album:
status += " from %s" %(album)