Skip to content

Instantly share code, notes, and snippets.

/**
* The example of usage for [mt-downloader](https://www.npmjs.com/package/mt-downloader).
*
* ## Installation
*
* npm install mt-downloader muxer
*
* ## Usage
*
* // the URL to download from
#!/bin/bash
#===============================================================================
#
# FILE: getgeo.sh
#
# USAGE: ./getgeo.sh
#
# DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your
# database
#
@generalov
generalov / settings.xdebug_helper.py
Created July 7, 2016 09:47
Toggle django-debug-toolbar with Xdebug-helper Chrome extension.
# Install https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
# then add this to your django project settings.py
def show_toolbar(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
from django.conf import settings
# if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS:
# return False
if request.is_ajax():
def authorize_key_for_root(config, *key_paths)
[*key_paths, nil].each do |key_path|
if key_path.nil?
fail "Public key not found at following paths: #{key_paths.join(', ')}"
end
full_key_path = File.expand_path(key_path)
if File.exists?(full_key_path)
config.vm.provision 'file',
@generalov
generalov / gitconfig
Created September 5, 2014 13:16
gitconfig
[user]
name = Evgeny V. Generalov
email = e.generalov@gmail.com
[alias]
st = status
ci = commit
co = checkout
wc = diff --staged
br = branch
@generalov
generalov / Gruntfile.js
Created May 31, 2014 04:28
Gruntfile config to run python tornado application and node.js fronted with livereload
/* jslint node:true */
'use strict';
module.exports = function(grunt) {
grunt.registerTask('default', [
'serve'
]);
grunt.registerTask('serve', [
@generalov
generalov / chrome-open.js
Created March 26, 2014 08:20
Reload tab in Google Chrome with given url.
// Don't forget to run the shell
// google-chrome --remote-debugging-port=9222
var url = 'http://localhost:9000/';
function startswith(str, prefix) {
return str.substring(0, prefix.length) === prefix;
}
var Chrome = require('chrome-remote-interface');
"""
Usage
-----
>>> class TestTodo(unittest.TestCase):
... def runTest(self):
... raise Todo("I need to test something")
Configuration
@generalov
generalov / apt-purge-old-kernels
Last active December 16, 2015 11:48
Purge old Ubuntu kernels
#!/bin/dash
SUFFIX=$(uname -r | sed "s/^\(.*\)-\([^0-9]\+\)$/\2/")
GENERIC_VERSION=$(dpkg -l linux-$SUFFIX | awk '/^ii/{print $3}' | sed 's#^\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\..*$#\1.\2.\3-\4#g' )
CURRENT_VERSION=$(uname -r | sed "s/^\(.*\)-\([^0-9]\+\)$/\1/")
dpkg -l 'linux-image-*' 'linux-headers-*' \
| grep -v 'linux-image-'$SUFFIX | grep -v 'linux-headers-'$SUFFIX \
| grep -v $GENERIC_VERSION | grep -v $CURRENT_VERSION \
| awk '/^ii/{print $2}' \
#!/bin/sh
# Runs guest session in the Xephyr window.
#
# Usage:
# $ xhost +
# $ sudo ./xguest
#
# Requires:
# Ubuntu 10.04