Skip to content

Instantly share code, notes, and snippets.

View navinpai's full-sized avatar

Navin Pai navinpai

View GitHub Profile
@navinpai
navinpai / wrttn.rb
Created March 9, 2012 08:28
Create notes on wrttn (http://wrttn.me)
#For some reasons, Fonts aren't getting rendered in Firefox. Not sure why!
#Using gectechnix.in as a temp filestore. Will prolly be deleting the fonts from the server soon
#If it works right, this is how your note looks: Default: http://wrttn.me/bf1081/ ( http://www.diigo.com/item/image/x9o0/vm2u?size=o ) Black: http://wrttn.me/537a88/ ( http://www.diigo.com/item/image/x9o0/q02j?size=o )
require 'net/http' #For making the actual POST
require 'json' #For parsing the POST data
require 'launchy' #For opening generated link in default browser
$/ = "~~"
uri=URI('http://wrttn.me/api/v1/notes.json')
print "Create Notes on http://wrttn.me via command line\n"
@navinpai
navinpai / resizer.js
Created February 1, 2012 15:55 — forked from codepo8/resizer.js
Resize image to thumbnail size
function resize( imagewidth, imageheight, thumbwidth, thumbheight ) {
var w = 0, h = 0, x = 0, y = 0,
widthratio = imagewidth / thumbwidth,
heightratio = imageheight / thumbheight,
maxratio = Math.max( widthratio, heightratio );
if ( maxratio > 1 ) {
w = imagewidth / maxratio;
h = imageheight / maxratio;
} else {
w = imagewidth;
@navinpai
navinpai / forms_flask.py
Created January 3, 2012 19:03
Form Processing with Flask
#From http://flask.pocoo.org/docs/quickstart/
from flask import request
@app.route('/login', methods=['POST', 'GET'])
def login():
error = None
if request.method == 'POST':
if valid_login(request.form['username'],
request.form['password']):
@navinpai
navinpai / sopa_emergency.txt
Created January 3, 2012 13:44
SOPA Emergency IP list
SOPA Emergency IP list:
So if these ass-fucks in DC decide to ruin the internet, here’s how to access your favorite sites in the event of a DNS takedown
tumblr.com 174.121.194.34
wikipedia.org 208.80.152.201
# News
bbc.co.uk 212.58.241.131
aljazeera.com 198.78.201.252
@navinpai
navinpai / config.ru
Created December 26, 2011 19:20
Sinatra :: Get Dropbox public folder contents as JSON file
#Basically the heart of the Publicbox (https://github.com/hmans/publicbox) code
# See whole file at: https://github.com/hmans/publicbox/blob/master/config.ru
get '/*' do |path|
doc = Nokogiri::HTML(open("https://www.dropbox.com/#{path}").read)
files = []
doc.css('#list-view div.filerow').each do |row|
files << {
filename: row.css('div.filename a').first.content.strip,
size: row.css('div.filesize span.hidden').first.content.to_i,
modified: row.css('div.modified span.hidden').first.content.to_i,
@navinpai
navinpai / convert.bat
Created November 23, 2011 16:14
Convert M4A to MP3 With VLC
@ECHO OFF
REM Use this to convert m4a's to mp3's using VLC (http://www.videolan.org/vlc/).... Had to find this to convert songs
REM downloaded with https://github.com/navinpai/8Tracks-Downloader :P :)
:START
FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
FOR /R %%G IN (*.m4a) DO (del "%%G")
sleep 1000
GOTO :START
GOTO :eof
@navinpai
navinpai / fixplymouth.sh
Created August 15, 2011 11:50
Fix Plymouth(by D0rkye)
#!/bin/bash
# ----------------------------------
# Author: D0rkye
# Homepage: http://d0rkye.zsenialis.com/
# Most code probably by kyleabaker: http://kyleabaker.com/2010/07/11/how-to-fix-your-ubuntu-boot-screen/
# ----------------------------------
sudo apt-get install v86d hwinfo -y
sudo hwinfo --framebuffer
echo "---------------------------------------------------------------"
echo "Please enter the best resolution from the list above"
@navinpai
navinpai / lulzhunter.php
Created August 15, 2011 11:45
Lulzhunter - Find Lulzsec's IP from CloudFlare config (by th3j35t3r)
<?php
// lulzhunter.php - by th3j35t3r
// Linux only really.
// This is a PHP Command line script.
// So you are gonna need PHP5 and PHP5-CLI
// If ya don't got that you can get em using this (on Ubuntu):
// 'sudo apt-get install php5 php5-cli'
// Then from your shell just execute 'php lulzhunter.php'
@navinpai
navinpai / terminal_tricks
Created August 14, 2011 22:44
Terminal Tricks
//Search all files in current folder for a text string and return filenames
find . -type f -exec grep -l "text to look for" {} \;
//Turn off Monitor
xset dpms force off
@navinpai
navinpai / getresults.php
Created August 14, 2011 22:23
PHP Curl script to get results of all students from Goa University site
<?php
//Stupid Univ. didn't release results, instead each student had to enter seat number to get his result!
// Wrote this script to automate the process and get the results of students from Seat No. 1-999 (Think that's the
// complete range of seat numbers)
// You end up with a seatno.html files for all seat nos in the range 1-999 ... Result of seat no. 'a' is 'a.html'
// Ran this on Ubuntu running LAMPP and it worked as expected! Nothing platform specific, so should work for you too!
// Edit if you need to find results of another semester (or if u are disgusted by the shitty code I've written and
//want to improve the code!)
$id = '4'; //Was a hidden field... Dunno what it is for