Skip to content

Instantly share code, notes, and snippets.

View xtranophilist's full-sized avatar

Dipesh Acharya xtranophilist

View GitHub Profile
@xtranophilist
xtranophilist / install-mscorefonts.sh
Created December 27, 2012 14:28
Install 'Times New Roman' and other proprietary fonts in Fedora
yum install rpm-build cabextract ttmkfdir
wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec
rpmbuild -bb msttcorefonts-2.5-1.spec
rpm -ivh $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm
fc-cache -f -v
@xtranophilist
xtranophilist / _pagination.html
Last active January 17, 2019 10:03
Bootstrap 4 Pagination template for django-pure-pagination
{% load i18n %}
{% if is_paginated %}
<nav aria-label="navigation" class="p-3">
<ul class="pagination">
{% if page_obj.has_previous %}
<li class="page-item">
<a href="?{{ page_obj.previous_page_number.querystring }}"
class="page-link previous">&lsaquo;&lsaquo; {% trans "Previous" %}</a>
</li>
{% else %}
@xtranophilist
xtranophilist / ko-chosen.js
Last active January 11, 2019 23:42
Collection of Knockout.js custom bindings.
//http://stackoverflow.com/questions/13210663/how-to-order-knockout-bindings
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);
@xtranophilist
xtranophilist / provinces_districts.json
Created April 10, 2018 09:03
Provinces and Districts of Nepal [WIP]
[
{
"province": "1",
"name": "Sagarmatha",
"districts": [
"Bhojpur",
"Dhankuta",
"Ilam",
"Jhapa",
"Khotang",
@xtranophilist
xtranophilist / transfer.py
Created October 19, 2012 11:20
Script to transfer a website from one host to another. Moves files with FTP and MySQL data with dumping and importing.
#!/usr/bin/python
#SSH into the new server, and run this from the home directory. Granted ~/public_html is the Apache DocumentRoot for
#the user
import getpass
import os
print '\nThis script will automate the process of moving a website from one server to another.'
@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';
@xtranophilist
xtranophilist / 1-uptime
Created October 12, 2017 15:39
Useful motd
#!/bin/sh
echo
exec /usr/bin/uptime
@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 / 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
#!/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