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 socket | |
def get_lock(process_name): | |
get_lock._lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) | |
try: | |
get_lock._lock_socket.bind('\0' + process_name) | |
return True | |
except socket.error: | |
return False |
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
# http://stackoverflow.com/questions/21986602/fixed-length-int-obfuscator-does-anyone-know-how-to-do-this | |
class IntObfuscator(object): | |
m = 1000000000 | |
x = 387420489 | |
inverseX = 513180409 | |
def encode_int(self, value): | |
return value * self.x % self.m | |
def decode_int(self, encoded): |
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
### models.py | |
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager | |
from django.core.mail import send_mail | |
from django.db import models | |
from django.utils import timezone | |
from django.utils.translation import ugettext_lazy as _ | |
class UserManager(BaseUserManager): | |
use_in_migrations = True |
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 get_actions(self, request): | |
actions = super(type(self), self).get_actions(request) | |
if 'delete_selected' in actions: | |
del actions['delete_selected'] | |
return actions | |
def has_delete_permission(self, request, obj=None): | |
return False | |
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/sh | |
PIPE=/tmp/somagic-pipe | |
OUTFILEDIR=~/dirs/Videos/ | |
LOGDIR=~/.somagic-log/ | |
NOW=`date +"%m_%d_%Y_%H_%M_%S"` | |
OUTFILE=${OUTFILEDIR}fpv_video_${NOW}.mp4 | |
mkdir $LOGDIR |
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
http://www.zachtronics.com/kohctpyktop/kohctpyktop.htm | |
KT229: | |
eNrtmVsOgyAQRYHhxzV0C/3vWrr/jTQ8tLYylo7hpRdjTLyOcxjjBdTe7W166umh | |
rZJsCDxT4Bys/ws01u1qOZbPqJZMgoyiQOM3tRxFfdS5/dxWVUurqqXFqRH4WdUa | |
fURVUVVU9RRVfW/ZpnyJodxP5wzfvEpEyf246ppVbOJ2MsXGqLEbslgfyMaGW5eI | |
BTOY+2RO3D3kne3i+4IKtpS2wyy/hLpS3XOjBrFgBjOYG6qwyitYNJjBPCIzwSoH | |
fohuRZFeVZQdo3kRzGA+HXN0SoJVDjzeHVLjFxqJmsNMJdTwRUmk7s8NwAxmGscZ | |
YJV/qryflV0oZeRlbbZj5hHrDOZKzDTeArzMH6VuzXD3v57hJ3+//wk2UsEM5g6Z | |
DTOzDFTx9MaNmzlSplWm9+Nqn/NGYtYNhcf3jK83RWLBDOYWzP6CxJu2ypt4FVs5 | |
0gsHIMls |
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 inspect | |
def get_request(): | |
"""Walk up the stack, return the nearest first argument named "request".""" | |
frame = None | |
try: | |
for f in inspect.stack()[1:]: | |
frame = f[0] | |
code = frame.f_code | |
if code.co_varnames[:1] == ("request",): |
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 Crypto.Cipher import AES | |
from Crypto import Random | |
import base64 | |
AESKEY = "jFa8*!9uiAS0!385&(lla$1dqae8#!da" | |
BS = 16 | |
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) | |
unpad = lambda s: s[0:-ord(s[-1])] |
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
Resize terminal: | |
resize -s 25 80 | |
Test HDD speed: | |
dd if=/dev/zero of=zeros bs=1M count=500 oflag=direct; unlink zeros | |
dd if=/dev/zero of=zeros bs=64k count=16k conv=fdatasync; unlink zeros |
NewerOlder