Skip to content

Instantly share code, notes, and snippets.

@devsli
devsli / unbound-parent-method.py
Last active August 29, 2015 14:01
Invoke unbound method
class A(object):
def __init__(self):
self.name = 'Andy'
def tell(what):
def inner(self):
print(" -- %s, %s!" % (what, self.name))
return inner
hi = tell("Hello")
@devsli
devsli / site-permissions.sh
Last active August 29, 2015 14:06
Recursive site permissions set
#!/bin/sh
if [ "$1" = "" ]; then
echo "usage: $0 website-dir";
echo;
# echo "Set owner of <website-dir> to www:nogroup,";
echo "Set permissions rw-r-r for regular files";
echo "and rwx-rx-rx for directories";
echo;
echo "Root permissions might be required.";
@devsli
devsli / calc.c
Last active April 2, 2016 17:45
Simple function ptr
// $ a.out 1 "+" 2
// 3
// $ a.out 2 "*" 3
// 6
// $ a.out 6 "/" 2
// 3
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@devsli
devsli / flooder.c
Last active August 29, 2015 14:06
Client-server flood generator
#include <assert.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
@devsli
devsli / Clicker Heroes.au3
Last active August 29, 2015 14:10
Clicker Heroes rapid clicker. http://clickerheroes.com
; [1] Useless
; [2] 2xDPS
; [3] 1,5xCritClick
; [4] 2xGold
; [5] 1%Gold/Click
; [6] Dark Ritual
; [7] 3xClick
; [8] Double next
; [9] Reload prev
@devsli
devsli / testch.sh
Last active August 29, 2015 14:12
OpenWRT WiFi channel checker
#!/bin/sh
CURRENT=$(uci get wireless.radio0.channel)
HOST=$(echo $SSH_CONNECTION | awk '{print $1}') # host to ping
echo "Initial channel: $CURRENT"
set_channel()
{
uci set wireless.radio0.channel=$1
@devsli
devsli / README.rst
Last active March 13, 2016 14:26
py.test SMTPd fixture

Secure SMTPd py.test fixture

Test outgoing messages of your app.

It's possible to replace secure-smtpd with default smtpd if AUTH is not forced by your application.

@devsli
devsli / gist:75ea21bbc8333c5bfe6a8ef8030861ab
Last active August 26, 2019 12:43
Test uploads with big file
# 1. Create big file
# ------------------
# If the number ends with a ``b'', ``k'', ``m'', ``g'', or ``w'',
# the number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G)
# or the number of bytes in an integer, respectively.
# Two or more numbers may be separated by an ``x'' to indicate a product.
fallocate -l 512m my-big-file
# 2. Upload big file
@devsli
devsli / keybase.md
Created July 29, 2016 19:00
keybase.md

Keybase proof

I hereby claim:

  • I am devsli on github.
  • I am unpunk (https://keybase.io/unpunk) on keybase.
  • I have a public key whose fingerprint is E215 B8D1 1A92 A994 593F 53C2 634D FB12 8626 D6FF

To claim this, I am signing this object:

@devsli
devsli / put-in-bubble.scm
Created September 10, 2016 19:46
GIMP: Put text in bubble script
(define (script-fu-bubble image drawable tail-length tail-offset tail-width)
(let* (
(selected-layer (car (gimp-image-get-active-layer image)))
(width (car (gimp-image-width image)))
(height (car (gimp-image-height image)))
(image-mode 1)
(bubble-layer-name "Bubble")
(bubble-opacity 100)
(overlay-mode NORMAL-MODE)
(bubble-layer (car (gimp-layer-new image width height image-mode bubble-layer-name bubble-opacity overlay-mode)))