Skip to content

Instantly share code, notes, and snippets.

View swapi's full-sized avatar
🏊‍♂️
Swimming

Swapnil swapi

🏊‍♂️
Swimming
View GitHub Profile
@swapi
swapi / DoodleRobot.java
Created August 8, 2012 13:47
Beat the Google doodle
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class TestRobot {
public static void main(String args[]) throws Exception {
Robot r = new Robot();
int sleep = 500;
int i = 0;
for(;;) {
r.keyPress(KeyEvent.VK_SPACE);
@swapi
swapi / sync.py
Created December 20, 2012 13:01 — forked from anonymous/sync.py
from java.io import File
from java.nio.file import Files
from java.nio.file import FileSystems
from java.nio.file.StandardWatchEventKinds import *
from java.nio.file.StandardCopyOption import *
from java.nio.file import Paths
source = '/source/file/path'
target = '/dest/file/path'
@swapi
swapi / link_list
Created April 10, 2013 16:50 — forked from hemanth/link_list
#!/usr/bin/env python
import wx, time, webbrowser
import random
import urllib2
import time
from threading import Thread
#https://readertray.googlecode.com/svn/trunk/lib/tools.py
from tools import file
@swapi
swapi / vlcrc.py
Created July 5, 2013 19:29
VLC Remote Control for Pebble Watch
#Dependency:
#-libpebble with other required libs (e.g. lightblue etc)
#-py-vlcclient (https://github.com/DerMitch/py-vlcclient.git)
#it is assumed that pebble is already paired.
from vlcclient import VLCClient
import pebble as libpebble
import sys
import time
@swapi
swapi / .bash_profile
Created August 13, 2013 13:00
Bash PS1
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h:\w\$(parse_git_branch) $ "
@swapi
swapi / large_sum
Created October 11, 2013 19:15
Max Consecutive Sum
def large_sum(el):
class _helper:
large_pos = len(el)
current_pos = len(el)
large = []
current = []
h = _helper()
def _large_sum(_el, pos):
if pos == len(_el) - 1:
h.large_pos -= 1
@swapi
swapi / checker.sh
Last active December 27, 2015 03:09
Waiting for the Nexus 5
#!/bin/sh
while [ true ]; do
found=`curl --no-progress-bar "https://play.google.com/store/devices/details/Nexus_5_32GB_Black?id=nexus_5_black_32gb" 2> /dev/null | grep "Coming soon" | wc -l`
if [ $found -eq "0" ]; then
python ~/gcsms.py send
if [ $? -eq 0 ]; then
break
else
python ~/gcsms.py send
fi
@swapi
swapi / Automata.txt
Created November 24, 2013 20:08
Automata
I have personally enjoyed several Aha! moments from studying basic automata theory. NFAs and DFAs form a microcosm for theoretical computer science as a whole.
Does Non-determinism Lead to Efficiency? There are standard examples where the minimal deterministic automaton for a language is exponentially larger than a minimal non-deterministic automaton. Understanding this difference for Turing machines is at the core of (theoretical) computer science. NFAs and DFAs provide the simplest example I know where you can explicitly see the strict gap between determinism and non-determinism.
Computability != Complexity. NFAs and DFAs both represent regular languages and are equivalent in what they compute. They differ in how they compute.
Machines Refine Languages. This is a different take on what we compute and how we compute. You can think of computable languages (and functions) as defining an equivalence class of automata. This is a fundamental perspective change in TCS, where we focus not just on the what, but the
@swapi
swapi / .vimrc
Created February 5, 2014 05:49
VIMRC file
set gfn=Courier_New
set nobackup
filetype plugin indent on " required!
set laststatus=2 " Always show the statusline
set t_Co=256 " Explicitly tell Vim that the terminal supports 256 colors
set mouse=a
set tabstop=4