Skip to content

Instantly share code, notes, and snippets.

Dipesh Acharya xtranophilist

Block or report user

Report or block xtranophilist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
xtranophilist /
Last active Aug 29, 2015 — forked from ptone/gist:4102528
Git pre-commit hook for Python
#!/usr/bin/env python
import glob
import os
import sys
# git usurbs your bin path for hooks and will always run system python
site_packages = glob.glob('%s/lib/*/site-packages' % os.environ['VIRTUAL_ENV'])[0]
sys.path.insert(0, site_packages)
xtranophilist / TAOUP_13
Last active Aug 29, 2015
Quotes about FOSS, Programming, Software Design and Technology.
View TAOUP_13
Rule of Repair: When you must fail, fail noisily and as soon as possible.
View ko_selectize.js
var inject_binding = function (allBindings, key, value) {
return {
has: function (bindingKey) {
return (bindingKey == key) || allBindings.has(bindingKey);
get: function (bindingKey) {
var binding = allBindings.get(bindingKey);
if (bindingKey == key) {
binding = binding ? [].concat(binding, value) : value;
xtranophilist /
Last active Dec 23, 2015
Conditional Django template tag to check if one or more apps exist. Usage: {% ifappexists tag %} ... {% endifappexists %}, or {% ifappexists tag inventory %} ... {% else %} ... {% endifappexists %}
from django.template import Library
from django import template
from app import settings
register = Library()
def ifappexists(parser, token):
""" Conditional Django template tag to check if one or more apps exist.
xtranophilist /
Last active Jun 24, 2016
Django template tag to check to see if the currently logged in user belongs to one or more groups. Supports {% else %} block. Mod of to support multi-word group names (with single/double quotes, e.g. {% ifusergroup 'Store Keeper' %}).
from django import template
from django.template import resolve_variable, NodeList
from django.contrib.auth.models import Group
register = template.Library()
def ifusergroup(parser, token):
""" Check to see if the currently logged in user belongs to one or more groups
xtranophilist / ko-chosen.js
Last active Jan 11, 2019
Collection of Knockout.js custom bindings.
View ko-chosen.js
ko.bindingHandlers.chosen = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
var allBindings = allBindingsAccessor();
var options = {default: 'Select one...'};
$.extend(options, allBindings.chosen)
$(element).attr('data-placeholder', options.default);
if [ ! -f sublime_text_3.tar.bz2 ]; then
curl -L "" -o "sublime_text_3.tar.bz2"
tar -xvjf sublime_text_3.tar.bz2
sudo cp -fr "sublime_text_3/sublime_text.desktop" "/usr/share/applications/sublime_text.desktop"
sudo sed -i 's/Icon=sublime-text/Icon=\/opt\/sublime_text\/Icon\/128x128\/sublime-text.png/g' /usr/share/applications/sublime_text.desktop
rm -rf /opt/sublime_text
xtranophilist / sms
Created Apr 12, 2013
Android SMS backup/restore w/ adb
View sms
adb remount
adb pull /data/data/ mmssms.db
adb remount
adb push mmssms.db /data/data/
xtranophilist /
Last active Jun 20, 2019
Install Broadcom (B43) wireless driver in Linux
su -
yum install b43-fwcutter wget # apt-get or whatever your package manager is
export FIRMWARE_INSTALL_DIR="/lib/firmware"
tar xjf broadcom-wl-5.100.138.tar.bz2
sudo b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" broadcom-wl-5.100.138/linux/wl_apsta.o
echo 'modprobe b43' > /etc/sysconfig/modules/b43.modules
xtranophilist / imdb-getglue.js
Last active Apr 12, 2017
Opens up relative GetGlue Page for the current IMDB page
View imdb-getglue.js
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
You can’t perform that action at this time.