Skip to content

Instantly share code, notes, and snippets.

View Snawoot's full-sized avatar

Snawoot

  • Odessa, Ukraine
View GitHub Profile
class groupby(object):
# [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
# [list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
def __init__(self, iterable, key=None):
if key is None:
key = lambda x: x
self.keyfunc = key
self.it = iter(iterable)
self.tgtkey = self.currkey = self.currvalue = object()
def __iter__(self):
yarmak@linux-commander:~$ whois turboreferat.ru
% By submitting a query to RIPN's Whois Service
% you agree to abide by the following terms of use:
% http://www.ripn.net/about/servpol.html#3.2 (in Russian)
% http://www.ripn.net/about/en/servpol.html#3.2 (in English).
domain: TURBOREFERAT.RU
nserver: ns1.dynamicmedia.info.
nserver: ns2.dynamicmedia.info.
state: REGISTERED, DELEGATED, VERIFIED
#!/bin/bash
cp geo.conf geo.conf.old
wget -OGeoIPCountryCSV.zip -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip
csv_file=`unzip -qq -l GeoIPCountryCSV.zip */GeoLite2-Country-Blocks.csv | awk '{ print $4 }'`
csv_date=`unzip -qq -l GeoIPCountryCSV.zip */GeoLite2-Country-Blocks.csv | awk '{ print $2 }'`
#!/usr/bin/python
import sys
import urllib
import urllib2
import re
url = "http://huifikator.ru/huify_text.php"
values = {
hdparm --user-master u --security-set-pass PasSWorD /dev/sdX
hdparm --user-master u --security-erase PasSWorD /dev/sdX
if isinstance(s, str):
if all([ord(c) in range(0,128) for c in s]):
#handle as ascii
else:
#handle CP1251 (.decode("cp1251").encode("utf-8") or drop nationa chars)
elif isinstance(s, unicode):
#handle as unicode
213.87.121.79 - - [19/May/2014:07:30:58 +0400] "GET /play/shanson/umnichka/?utm_source=adwords&utm_medium=cpc&utm_content=%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%20%D1%88%D0%B0%D0%BD%D1%81%D0%BE%D0%BD&utm_campaign=GA_shanson&ref=1113&gclid=COqFiqKGt74CFcv7cgodyqsAbw HTTP/1.1" 502 742 "http://www.google.com/uds/afs?q=%D1%81%D0%BB%D1%83%D1%88%D0%B0%D1%82%D1%8C%20%D0%BC%D1%83%D0%B7%D1%8B%D0%BA%D1%83%20%D0%B1%D0%B5%D1%81%D0%BF%D0%BB%D0%B0%D1%82%D0%BD%D0%BE%20%D1%88%D0%B0%D0%BD%D1%81%D0%BE%D0%BD&client=aj-ru2&channel=ru16&hl=ru&adtest=off&adsafe=medium&oe=utf-8&ie=utf-8&lo=false&adpage=1&adrep=3&po=true&r=m&fexp=21404&format=p7%7Cn3&ad=n3p7&nocache=9221400481145859&num=0&output=uds_ads_only&v=3&adlh=on&adext=as1%2Csr1&u_his=2&u_tz=240&dt=1400481145861&u_w=1280&u_h=800&biw=-1&bih=-1&psw=-1&psh=-1&frm=0&ui=uv3sr1lo0po1va1hcsl1cc0-lHst15sd13sv13sa13lt18ld16lv16da1-lhst15sd13sv13sa13lt18ld16lv16da1&rurl=http%3A%2F%2Fru.ask.com%2Fweb%3Fq%3D%25D1%2581%25D0%25BB%25D1%2583%25D1%2588%25D0%25B0%25D1%2582%25D1%258C%2B%25D
yarmak@linux-commander:~$ avconv -i 33fb5e0b-17aa-4ee0-bc37-4fc0ed6f3c1b.mp4
avconv version 0.8.10-6:0.8.10-1, Copyright (c) 2000-2013 the Libav developers
built on Feb 5 2014 03:52:19 with gcc 4.7.2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '33fb5e0b-17aa-4ee0-bc37-4fc0ed6f3c1b.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1mp42
creation_time : 2014-04-24 10:12:09
Duration: 01:35:06.06, start: 0.000000, bitrate: 1885 kb/s
from itertools import groupby, chain
LOSE = [['G', 'A', 'M', 'E'], ['O', 'V', 'E', 'R'], ['G', 'A', 'M', 'E'], ['O', 'V', 'E', 'R']]
WIN = [['U', 'W', 'I', 'N'], ['U', 'W', 'I', 'N'], ['U', 'W', 'I', 'N'], ['U', 'W', 'I', 'N']]
def collide_row(row):
tiles = []
for k,g in groupby(filter(bool,row)):
l = len(list(g))
if l % 2:
yarmak@linux-commander:~$ cowsay -f hellokitty "Hello, kitty!"
_______________
< Hello, kitty! >
---------------
\
\
/\_)o<
| \
| O . O|
\_____/