This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/snap/bin/fades | |
import logging | |
from functools import wraps | |
from IPython import embed # fades | |
import sh # fades | |
import sys | |
import os | |
import stat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
def encode(number): | |
out = "" | |
while number > 0: | |
first_byte = number & 0b11111111 | |
out = chr(first_byte) + out | |
number = number >> 8 | |
return out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
body, html { | |
margin: 0; | |
padding: 0; | |
height: 100vh; | |
width: 100vw; | |
overflow: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread, Event | |
from Queue import Queue, Empty | |
class DoThreaded(object): | |
def __init__(self, function, concurrent=10, queue_results=None): | |
self.concurrent = concurrent | |
self.stopped = Event() | |
self.queue = Queue(self.concurrent) | |
if queue_results is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import subprocess | |
import json | |
import os | |
# CPU INFO | |
f = open("/proc/cpuinfo") | |
data = f.readlines() | |
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def debounced_wrap(func): | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
key = kwargs.pop("key") # it's required | |
call_count = kwargs.pop("call_count", 1) | |
count = cache.get(key, 1) | |
if count > call_count: | |
# someone called the function again before the this was executed | |
return None | |
# I'm the last call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cached_model_method(time=600, key_uses_args=False): | |
""" | |
Decorates django model methods | |
Use it as: | |
@cached_model_method(time=1200) | |
def functionToCache(arguments): | |
... | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pg_dump -h my.host.com -p 5432 -U db_name db_user | gzip > ~/backups/db_name.`date +"%Y.%m.%d_%H-%M"`.sql.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
l = logging.getLogger('django.db.backends') | |
l.setLevel(logging.DEBUG) | |
l.addHandler(logging.StreamHandler()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#http://stackoverflow.com/a/18767922 | |
function gitlist { | |
git branch -vv --color=always | while read; do | |
# The underscore is because the active branch is preceded by a '*', and | |
# for awk I need the columns to line up. The perl call is to strip out | |
# ansi colors; if you don't pass --color=always above you can skip this | |
local branch=$(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g') | |
# git log fails when you pass a detached head as a branch name. | |
# Hide the error and get the date of the current head. |
NewerOlder