Skip to content

Instantly share code, notes, and snippets.

View dufferzafar's full-sized avatar
🏠
Working from home

Shadab Zafar dufferzafar

🏠
Working from home
View GitHub Profile
@dufferzafar
dufferzafar / capslock_to_backspace.sh
Created January 9, 2015 10:24
Remap Capslock to Backspace
# Tested on Ubuntu 12.04
# Copied from: http://askubuntu.com/questions/74904/how-can-i-swap-capslock-for-backspace
setxkbmap -option caps:backspace
setxkbmap -option shift:both_capslock
xmodmap -e "clear Lock"
@dufferzafar
dufferzafar / del_file.sh
Created January 9, 2015 11:22
Delete a file with special characters in its name.
# First find out the inode by
# ls -il .
# Then delete file
sudo find . -inum $1 -exec rm -rf {} \;
@dufferzafar
dufferzafar / wvdial.conf
Created January 14, 2015 06:53
MTS Details for wvdial. (/etc/wvdial.conf)
[Dialer Defaults]
Phone =
Username =
Password =
New PPPD = yes
[Dialer mts]
Stupid Mode = 1
Inherits = Modem0
Password = mts
@dufferzafar
dufferzafar / Download-File-Github.md
Created January 20, 2015 15:37
Download a single file from Github #github #userscript #ideabin

Add a button to initiate download of a single file from a file page on Github.

@dufferzafar
dufferzafar / tfidf.py
Last active August 29, 2015 14:14 — forked from sloria/tfidf.py
import math
from text.blob import TextBlob as tb
def tf(word, blob):
return blob.words.count(word) / len(blob.words)
def n_containing(word, bloblist):
return sum(1 for blob in bloblist if word in blob)
def idf(word, bloblist):
@dufferzafar
dufferzafar / lastfm-make.log
Last active August 29, 2015 14:14
Output of 'make -i -j4' - trying to build lastfm-desktop on Ubuntu 14.04
cd lib/logger/ && make -f Makefile
make[1]: Entering directory `/home/dufferzafar/dev/clones/lastfm-desktop/lib/logger'
compiling ../../common/c++/Logger.cpp
rm -f liblogger.a
ar cqs liblogger.a _build/Logger.o
rm -f ../../_bin/liblogger.a
mv -f liblogger.a ../../_bin/
make[1]: Leaving directory `/home/dufferzafar/dev/clones/lastfm-desktop/lib/logger'
cd lib/unicorn/ && make -f Makefile
make[1]: Entering directory `/home/dufferzafar/dev/clones/lastfm-desktop/lib/unicorn'
@dufferzafar
dufferzafar / reset-postgres.sh
Created February 14, 2015 08:25
Reset Postgres (Ubuntu 14.04)
#!/bin/sh
sudo service postgresql stop
sudo pg_dropcluster 9.1 main
sudo pg_createcluster 9.1 main
sudo pg_ctlcluster 9.1 main start
sudo service postgresql start
@dufferzafar
dufferzafar / Openage-Build-172.log
Created February 16, 2015 22:24
Building Pull 172 for Openage.
~/d/c/openage (pr/172) > ./configure
_________________________________________
/ ./configure is a convenience script \
| that creates the build directory and |
| invokes cmake for an out-of-source |
| build. |
| |
| don't feel obliged to use this, |
\ especially if you're packaging openage. /
-----------------------------------------
@dufferzafar
dufferzafar / view_html.py
Created February 21, 2015 09:19
Python function to view html file in a browser.
def view(html, rm=False):
"""View HTML in a browser."""
# So many imports :O
import os
import webbrowser
import string
import random
# Remove preview random files
@dufferzafar
dufferzafar / hexa.cpp
Created March 10, 2015 16:18
Hexagon Rotation
/*
* GL05IdleFunc.cpp: Translation and Rotation
* Transform primitives from their model spaces to world space (Model Transform).
*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h
// Global variable
GLfloat angle = 0.0f; // Current rotational angle of the shapes