Skip to content

Instantly share code, notes, and snippets.

View ViktorStiskala's full-sized avatar

Viktor Stískala ViktorStiskala

View GitHub Profile
@ViktorStiskala
ViktorStiskala / .gitconfig
Created August 13, 2013 13:27
Pycharm as a default git difftool and git mergetool. Add the following to ~/.gitconfig
[diff]
tool = pycharm
[difftool "pycharm"]
cmd = /usr/local/bin/pycharm diff "$LOCAL" "$REMOTE" && echo "Press enter to continue..." && read
[merge]
tool = pycharm
keepBackup = false
[mergetool "pycharm"]
cmd = /usr/local/bin/pycharm merge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
viktor@haree-nb /tmp/test/greenlet (git)-[master] % ./run-tests.py
running build_ext
Linking /tmp/test/greenlet/build/lib.linux-x86_64-2.7/greenlet.so to /tmp/test/greenlet/greenlet.so
python 2.7.4 (64 bit) using greenlet 0.4.0 from /tmp/test/greenlet/greenlet.so
test_dead_weakref (tests.test_weakref.WeakRefTests) ... ok
test_dealloc_weakref (tests.test_weakref.WeakRefTests) ... ok
test_inactive_weakref (tests.test_weakref.WeakRefTests) ... ok
test_version (tests.test_version.VersionTests) ... ok
test_exception_disables_tracing (tests.test_tracing.TracingTests) ... ok
test_greenlet_tracing (tests.test_tracing.TracingTests) ... ok
# 1 "greenlet.c"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "greenlet.c"
# 1 "greenlet.h" 1
.file "greenlet.c"
.text
.p2align 4,,15
.type green_is_gc, @function
green_is_gc:
.LFB142:
.cfi_startproc
cmpq $-1, 24(%rdi)
je .L3
xorl %eax, %eax
@ViktorStiskala
ViktorStiskala / gist:3479130
Created August 26, 2012 13:15
Amazon Glacier tree hash calculation
import math
import hashlib
def bytes_to_hex(str):
return ''.join( [ "%02x" % ord( x ) for x in str] ).strip()
def chunk_hashes(str):
"""
Break up the byte-string into 1MB chunks and return sha256 hashes
for each.
@ViktorStiskala
ViktorStiskala / include.sh
Created November 27, 2011 16:52
Display highlighted C include file
#!/bin/bash
if [ -z $1 ]
then
echo "Usage: include filename" 1>&2
exit 1
fi
filename="/usr/include/$1"
if [ ! -f $filename ]; then
echo "File not found" 1>&2
@ViktorStiskala
ViktorStiskala / xsendfile.py
Created July 8, 2011 08:53
XSendFileResponse for Django with fallback when XSendFile is disabled
from django.http import HttpResponse
from mimetypes import guess_type
import settings
import re, os
class XSendFileError(Exception):
pass
class XSendFileResponse(HttpResponse):
def __init__(self, file_path, content_type=None):
@ViktorStiskala
ViktorStiskala / gist:969558
Created May 12, 2011 22:03
Simple MySQL backup script
#!/bin/bash
# MySQL backup script
# Creates database dump file for each database.
# Created: 2010-09-27
# config
BACKUP_USER=backup
BACKUP_DIR=/var/backups/mysql
LOGFILE=/var/log/mysql_backup
@ViktorStiskala
ViktorStiskala / gist:969269
Created May 12, 2011 19:38
Allow users from www-data group to change owner of files under /var/www
#!/bin/bash
# Resursively change owner to www-data
#
# Created: 2011-05-12
# Author: Viktor Stiskala <viktor@stiskala.cz>
LOGFILE=/var/log/wwwdata
## Add following line tu sudoers file (using visudo command) in order to allow
## users from www-data group to change owners under /var/www/
@ViktorStiskala
ViktorStiskala / gist:900053
Created April 3, 2011 00:26
Simple browser recognition
/*
Requires browscap.ini configuration, more info at http://php.net/manual/en/function.get-browser.php
*/
$this->template->registerHelper('browser', function($s) {
$brs = get_browser($s);
if($brs === false)
return 'N/A';
// ex.: Firefox 3.6/Linux
return $brs->browser . ' ' . $brs->version . '/' . $brs->platform;
});