Skip to content

Instantly share code, notes, and snippets.

View Snawoot's full-sized avatar

Snawoot

  • Odessa, Ukraine
View GitHub Profile
yarmak@linux-commander:~$ cowsay -f sodomized-sheep "Schwooolah!!!"
_______________
< Schwooolah!!! >
---------------
\ __
\ (oo)
\ ( )
\ /--\
__ / \ \
UooU\.'@@@@@@`.\ )
int handleError(bool success, int errorCode) {
QHash<int, const char *> cm;
cm[400] = "Bad Request";
cm[401] = "Unauthorized";
cm[402] = "Payment Required";
cm[403] = "Forbidden";
cm[404] = "Page not found";
cm[405] = "Method Not Allowed";
cm[500] = "Internal Server Error";
cm[501] = "Not Implemented";
root@cache5:~# vc_file | figlet
_ _ ___ ___ _____ _____ _ _ __
| | | |___ __ _ __ _ ___ _ / _ \ / _ \___ |___ / (_)/ /
| | | / __|/ _` |/ _` |/ _ (_) | (_) | (_) | / / / /| | / /
| |_| \__ \ (_| | (_| | __/_ \__, |\__, |/ / / / | |/ /_
\___/|___/\__,_|\__, |\___(_) /_(_) /_//_/ /_/ |_/_/(_)
|___/
____ _ _ _ ____ ___ ____
/ ___|| |_ ___ _ __ ___ __| |_ / | ___| ( _ ) / ___|
\___ \| __/ _ \| '__/ _ \/ _` (_) | |___ \ / _ \| | _
root@ci:~# cat > hello.js
// A simple function.
function hello(longName) {
alert('Hello, ' + longName);
}
hello('New User');
root@ci:~# java -jar /usr/share/java/closure-compiler.jar --js hello.js --js_output_file hello-compiled.js
root@ci:~# cat hello-compiled.js
function hello(a){alert("Hello, "+a)}hello("New User");
#!/usr/bin/make -f
ifeq ($(PACKAGE),tvigle-app)
VENV_OPTS = --with python-virtualenv
endif
%:
dh $@ $(VENV_OPTS)
#!/usr/bin/python
import sys
bits = 32
def ip2bin(ip):
return reduce(lambda acc, (octet,power): acc+int(octet)*256**power, zip(ip.split(".")[0:4], range(3,-1,-1)), 0)
def bin2ip(i):
return "%d.%d.%d.%d" % ( i >> 24, (i >> 16)&0xFF, (i >> 8)&0xFF, i & 0xFF)
#!/usr/bin/python
# -*- coding: utf-8 -*-
from random import randint, randrange
def roll(change_decision):
all_doors = set([1,2,3]) # Множество дверей
auto = randint(1,3) # Счастливая дверь
openable_doors = all_doors.copy() # Двери, которые мог бы открыть ведущий
first_choice= randint(1,3)
root@nal-2:~# hpacucli ctrl slot=2 pd all show
Smart Array P420 in Slot 2
array A
physicaldrive 2I:1:1 (port 2I:box 1:bay 1, SAS, 450 GB, OK)
physicaldrive 2I:1:2 (port 2I:box 1:bay 2, SAS, 450 GB, OK)
array B
@Snawoot
Snawoot / replace_blocks
Last active August 29, 2015 14:07
Replace blocks in HTML
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import re
def usage():
sys.stderr.write("Usage: %s <block1> [block2] ... -- [file1] [file2] ...\n" % sys.argv[0])
if __name__ == "__main__":
#!/usr/bin/env python
import sys
from multiprocessing import Pool, log_to_stderr
from subprocess import Popen, PIPE
from urlparse import urlparse, parse_qs
import logging
import csv
nproc = 16