Skip to content

Instantly share code, notes, and snippets.

# from http://stackoverflow.com/questions/11476664/easy-way-to-run-explain-on-query-sets-in-django
from django.db import connections
from django.db.models.query import QuerySet
def explain(qs):
cursor = connections[qs.db].cursor()
query, params = qs.query.sql_with_params()
cursor.execute('explain %s' % query, params)
print(qs.query)
print('\n'.join(r[0] for r in cursor.fetchall()))
#!/bin/bash
set -e
: ${IP?Missing desired ip to configure}
: ${HOSTNAME?Missing desired hostname to configure}
: ${ROLE?Missing desired role to configure (master,node)}
: ${NVIDIA?Missing nvidia flag (true,false)}
: ${INGRESS?Missing ingress flag (true,false)}
# Common functions to use in different files

General

datetime (If you want to revert to the hardware clock being in UTC, do:)
timedatectl set-local-rtc 0

Docker

Also making sure we can do docker commands without sudo

yaourt -S --noconfirm docker
usermod -a -G docker $USER
@snelis
snelis / boxstarter
Last active February 10, 2017 11:46
Set-TaskbarOptions -Size Small -Lock -Combine Never
Set-CornerNavigationOptions -DisableUpperRightCornerShowCharms -DisableUpperLeftCornerSwitchApps
Set-WindowsExplorerOptions -EnableShowFileExtensions -EnableShowHiddenFilesFoldersDrives
Enable-RemoteDesktop
Disable-BingSearch
Disable-GameBarTips
choco feature enable -n=allowEmptyChecksums
choco feature enable -n=allowGlobalConfirmation
// Automatically generated configuration file for 'Hyperion daemon'
// Generated by: HyperCon (The Hyperion deamon configuration file builder
{
/// Device configuration contains the following fields:
/// * 'name' : The user friendly name of the device (only used for display purposes)
/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'ldp8806',
/// 'lpd6803', 'sedu', 'adalight', 'lightpack', 'philipshue', 'test' and 'none')
/// * 'output' : The output specification depends on selected device. This can for example be the
/// device specifier, device serial number, or the output file name
@snelis
snelis / 0_reuse_code.js
Created February 7, 2014 10:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import functools
def time_execution(function=None, *args, **kwargs):
"""
Time the execution of a method.
If the optional kwargs contain the warning or error threshold, log it if it exceeds it.
"""
print 'args', args
print 'kwargs', kwargs
-- Empty tweet table
TRUNCATE TABLE `tweets_feeds`;
-- Empty tweet archive table
TRUNCATE TABLE `tweets_archive`;
-- Empty feeds archive table
TRUNCATE TABLE `predef_archives`
-- Delete all feeds which are archived
@snelis
snelis / football-details-1621945
Created December 7, 2011 09:52
football-details-1621945
"lineup":{
"0":{
"c_Team":"sc Heerenveen",
"c_Person":"Brian Vandenbussche",
"c_Function":"Keeper",
"n_Position":1,
},
"1":{
"c_Team":"sc Heerenveen",
"c_Person":"Daryl Janmaat",
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<meta name="viewport" content="width=device-width, user-scalable=0, minimum-scale=0, maximum-scale=1.0">
</HEAD>
<BODY>
<DIV id='map' style='position:absolute; left:0px; top:000px; width:320px; height:415px;'></div>