Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile
@corpix
corpix / remove.old.packs.py
Last active August 29, 2015 14:04
Remove old skipper packs(>1 month)
from datetime import datetime as dt
import datetime
from time import mktime
import sys
from skipper.db import DB
from skipper.app import App
from skipper.package import Package
from skipper.packages import Packages
App.init()
@corpix
corpix / golang-like-blocking.py
Created August 21, 2014 01:38
Python blocking main thread
from __future__ import print_function
from threading import Thread
from Queue import Queue as Channel
import time
def threaded(callback):
time.sleep(1)
callback(True)
ch = Channel(1)
@corpix
corpix / rt_tables.py
Last active August 29, 2015 14:05
Simple rt_tables parser
import re
rt_tables = '/etc/iproute2/rt_tables'
def get_tables():
res = {}
state = {}
def line_filter(s):
@corpix
corpix / vk_feed_ads.block.js
Last active August 29, 2015 14:06
Block vk.com bullshit(Scriptish userscript)
// ==UserScript==
// @id vk_ads
// @name Ads blocker for vkontakte
// @version 1.0
// @namespace corpix.ru
// @author Dmitry Moskowski
// @description
// @include https://vk.com/*
// @run-at window-load
// @grant none
@corpix
corpix / stderr
Created September 14, 2014 13:08
Class method collision
src/capturer.cpp:63:52: error: no matching function for call to ‘Capturer::open(char*&, int, int)’
fd = open(settings->device, O_RDWR | O_NONBLOCK, 0);
^
# Resolved by prefixing C's open with `::`
@corpix
corpix / mdadm.sh
Last active August 29, 2015 14:06
mdadm snippets
sudo mdadm -D /dev/md0 | tail -n 2 | grep -F removed
cat /proc/mdstat | grep '^md' | awk '{print $1}'
sudo lshw -class disk
sudo lshw -class disk | grep -F 'logical name' | awk '{print $3}' | tr '\n' ' '
sudo mdadm -D /dev/md0 | grep -F /dev | awk '{print $NF}' | grep -v '^/dev/md' | tr '\n' ' '
rsync
tar cz /path/to/repo | ssh vitya tar x -C /path/to/
fuse (roma ----fuse---> vitya), rome reads vitya's packages index, install and download only what he needs
http://askubuntu.com/questions/974/how-can-i-install-software-or-packages-without-internet-offline
@corpix
corpix / 1251-utf8
Created October 12, 2014 18:14
1251-utf8
#!/usr/bin/env python2
import codecs
import sys
sys.stdin = codecs.getreader('cp1251')(sys.stdin)
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
for l in sys.stdin:
sys.stdout.write(l)
@corpix
corpix / urlencode.py
Last active August 29, 2015 14:08
urlencoder
#!/usr/bin/env python2
# cat foo.svg | ./urlencode.py
import urllib
import codecs
import sys
sys.stdin = codecs.getreader('utf-8')(sys.stdin)
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
for l in sys.stdin:
sys.stdout.write(urllib.quote_plus(l))
@corpix
corpix / serve-dump.py
Created November 7, 2014 13:44
Server dumps
from __future__ import unicode_literals, print_function
import sys
import socket
import threading
host = ''
port = int(sys.argv[1])
Каждая секция("*.css"...) == 1 проход инструмента. Соответственно можно запускать так для *.css, например:
porshik --handlers='["css", "freeze"]' --parameters='{}' /path/to/file.css