Skip to content

Instantly share code, notes, and snippets.

View xtranophilist's full-sized avatar

Dipesh Acharya xtranophilist

View GitHub Profile
@xtranophilist
xtranophilist / pre-commit.py
Last active August 29, 2015 14:06 — 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
xtranophilist / 10-synaptics.conf
Last active October 12, 2015 22:28
My Synaptics Touchpad Configuration for Xorg
#vi /etc/X11/xorg.conf.d/10-synaptics.conf
#Supports Horizontal and Vertical Edge Scrolling, Two Finger Right click (tested on Dell XPS)
Section "InputClass"
Identifier "touchpad"
Driver "synaptics"
MatchIsTouchpad "on"
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "VertEdgeScroll" "on"
Option "HorizEdgeScroll" "on"
@xtranophilist
xtranophilist / natgeo_pic_of_the_day.sh
Last active November 5, 2015 04:03 — forked from fabianmaass/National Geographic Picture-Of-The-Day Wallpaper Script
National Geographic Picture-Of-The-Day Wallpaper Script
#!/bin/bash
# Copyright (c) 2011 Josh Schreuder
# http://www.postteenageliving.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@xtranophilist
xtranophilist / ifappexists_tag.py
Last active December 23, 2015 12:48
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()
@register.tag
def ifappexists(parser, token):
""" Conditional Django template tag to check if one or more apps exist.
@xtranophilist
xtranophilist / demo_centos.md
Last active December 30, 2015 20:33
DemocracyOS on Centos

This is a manual for installing DemocracyOS app in CentOS.

Setting up the Requirements

  1. MongoDB =========== Installing MongoDB and starting its daemon:
#!/bin/sh
if [ ! -f sublime_text_3.tar.bz2 ]; then
curl -L "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x32.tar.bz2" -o "sublime_text_3.tar.bz2"
fi
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
xtranophilist / ifusergroup_tag.py
Last active June 24, 2016 12:47
Django template tag to check to see if the currently logged in user belongs to one or more groups. Supports {% else %} block. Mod of http://djangosnippets.org/snippets/2736/ 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()
@register.tag()
def ifusergroup(parser, token):
""" Check to see if the currently logged in user belongs to one or more groups
@xtranophilist
xtranophilist / imdb-getglue.js
Last active April 12, 2017 17:06
Opens up relative GetGlue Page for the current IMDB page
slugify=function(str){
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));
}
@xtranophilist
xtranophilist / 1-uptime
Created October 12, 2017 15:39
Useful motd
#!/bin/sh
echo
exec /usr/bin/uptime
@xtranophilist
xtranophilist / saleor_wysiwyg_trumbowyg.md
Last active October 25, 2017 07:27
Saleor: Adding WYSIWYG to Product Description form in Dashboard

Install trumbowyg

yarn add trumbowyg

Edit saleor/static/dashboard/js/dashboard.js

import 'trumbowyg/dist/trumbowyg.min.js';
import 'trumbowyg/dist/ui/trumbowyg.min.css';
import icons from 'trumbowyg/dist/ui/icons.svg';