Skip to content

Instantly share code, notes, and snippets.

@ngopal
ngopal / alarm_clock_spotify.scpt
Created August 13, 2012 21:02
Setup your mac to use Spotify as your alarm clock
# In order to use this script, you must replace 'YOURUSERNAMEHERE' with your Spotify username.
# Execute this script like so: 'osascript alarm_clock_spotify.scpt' (without single-quotes obviously)
# Full explanation here: http://www.nikhilgopal.com/2011/08/show-and-tell-applescript-spotify-alarm.html
# If you would like to specify a playlist, please refer to this gist: https://gist.github.com/3344118
set volume 2
open location "spotify:user:YOURUSERNAMEHERE:playlist:muzic"
tell application "Spotify"
set the sound volume to 0
play
@ngopal
ngopal / start_spotify_with_playlist.scpt
Created August 13, 2012 21:07
Setup your mac to use Spotify as your alarm clock--but also specify a playlist
# In order to use this script, you must replace 'YOURUSERNAMEHERE' with your Spotify username.
# Execute this script like so: 'osascript start_spotify_with_playlist.scpt' (without single-quotes)
# Full explanation here: http://www.nikhilgopal.com/2011/08/show-and-tell-applescript-spotify-alarm.htm
delay 2
open location "spotify:user:YOURUSERNAMEHERE:playlist:muzic"
tell application "Spotify"
play
end tell
@ngopal
ngopal / quote_generator_parse_quotes.py
Created September 17, 2012 00:38
a script used to parse a txt file I found on the internet.
import sqlite3
file = open('quotes_file.txt', 'r')
line = ''
quotes = []
for i in file.readlines():
if i == '\r\n':
print "BLANK", i
quotes.append(line)
@ngopal
ngopal / quote_generator_main.py
Created September 17, 2012 00:41
the main program for the quote generator web app example (built with Flask)
from flask import Flask, url_for, render_template, g, redirect
import random
import sqlite3
DATABASE = 'quotes.db'
app = Flask(__name__)
def connect_db():
return sqlite3.connect(DATABASE)
@ngopal
ngopal / simpleserver.go
Created October 7, 2013 18:30
Simple server in golang. Build with go and run ./simpleserver. Pages will be served @ http://localhost:8080/elysianIPA
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Why in the world are you looking for %s on your localhost? lolz.", r.URL.Path[1:])
}
@ngopal
ngopal / cypher_query
Created February 22, 2014 23:23
a simple cypher query to find all of the shortest paths in the neo4j shell
START source=node(10), destination=node(144)
MATCH p = allShortestPaths(source-[r:interacts*..3]->destination)
RETURN NODES(p);
@ngopal
ngopal / consensuspathdb_to_neo4j.py
Last active August 29, 2015 13:56
a quick python script to take consensuspathdb data and throw it into a running neo4j instance
# This program takes the PPI data from ConsensusDB and populates the NEO4J database with it
# By Nikhil Gopal
#
# To run: python populate_running_db.py ConsensusDB_Human_PPI nodes_list.txt
# The code to generate the nodes_list.txt file exists here: https://gist.github.com/ngopal/9164294
import os, sys
from neo4jrestclient.client import GraphDatabase
from itertools import chain, combinations
brew install neo4j
@ngopal
ngopal / neo4j_start_stop
Created February 22, 2014 23:39
how to start and stop neo4j
# To start server
neo4j start
# To stop server
neo4j stop
@ngopal
ngopal / make_node_list.py
Created February 22, 2014 23:52
make a list of nodes from human PPI data
import os, sys
from itertools import chain, combinations
genes_set = set([])
for i in open(sys.argv[1], 'r').readlines():
if '#' in i:
continue
else:
line = i.strip('\r\n').split('\t')
genes = line[2].replace('_HUMAN','').split(',')