Skip to content

Instantly share code, notes, and snippets.

View AyumuKasuga's full-sized avatar
🤔
🤔

Andrei Kostakov AyumuKasuga

🤔
🤔
View GitHub Profile
/etc/iptables.rules
# Generated by iptables-save v1.4.14 on Thu Jun 5 19:52:31 2014
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
-A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040
@AyumuKasuga
AyumuKasuga / gist:718e45841c4a081a38fd
Last active August 29, 2015 14:05
router iptables
#iptables -t nat -A PREROUTING -i br0 -p udp --dport 53 -j DNAT --to-destination 192.168.47.100:9053
#iptables -t nat -A PREROUTING -i br0 -p tcp -m tcp -d ! 192.168.47.100 -j DNAT --to-destination 192.168.47.100:9040
#iptables -t nat -A PREROUTING -i br1 -j DROP
@AyumuKasuga
AyumuKasuga / .vimrc
Created December 4, 2014 13:14
vimrc
set hidden
set nocompatible
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set scrolloff=10
set autoindent
set smartindent
set number
@AyumuKasuga
AyumuKasuga / backlight.py
Created April 12, 2012 13:33
backlight up/down on samsung R428
import sys
import os
class backlight():
def __init__(self, cmd):
self.path = "echo '%s' > /sys/class/backlight/samsung/brightness"
self.limit_down, self.limit_up = 1, 7
self.current = int(os.popen("cat /sys/class/backlight/samsung/brightness").read().strip())
self.cmd = cmd.strip()
self.setbacklight()
#coding: utf-8
import pyinotify
import os
class action(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
l = open(os.path.join(event.path, event.name)).readlines()[-1]
#print os.path.join(event.path, event.name), l
@AyumuKasuga
AyumuKasuga / miralinks.py
Created May 10, 2012 12:20
miralinks.ru finance parser
@AyumuKasuga
AyumuKasuga / gist:2838980
Created May 30, 2012 21:05
expiremantal generator
all = '0123456789abcdefghijklmnopqrstuvwxyz'
l=len(all)
t=8248398492887
r=list()
while True:
p,t=t%l,t//l
r.append(p)
if t<l:
r.append(t) if t is not 0 else None
break
@AyumuKasuga
AyumuKasuga / saveimage.py
Created June 21, 2012 14:11
save images from 2ch.so
#!/usr/bin/env python2
#coding: utf-8
import gevent.monkey
gevent.monkey.patch_socket()
import sys
import os
from urlparse import urlparse
import urllib
@AyumuKasuga
AyumuKasuga / templater.js
Created August 16, 2012 19:50
simple js templater
function render(template, kwargs){
this.template = template
this.kwargs = kwargs
this.render_str = function(temp, kwargs){
re = /{{(.*?)}}/g
if(kwargs == undefined){kwargs=this.kwargs}
return temp.replace(re, function(a,b){
clean_key = b.trim();
if(kwargs[clean_key]){
@AyumuKasuga
AyumuKasuga / gist:6619898
Created September 19, 2013 06:55
django csrf ajax
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));