Skip to content

Instantly share code, notes, and snippets.

from queue import Empty, Queue
import subprocess
import sys
import threading
if sys.version[0] > '2':
import tkinter
else:
import Tkinter as tkinter
def conc(text):
return ''.join(c.split('(')[0]+c.split('(')[1][::-1]
if '(' in c
else c
for c in text.split(')'))
print(conc('(ur)ss(ai)(edocn)c(pu)'))
@Sorseg
Sorseg / chat.py
Last active December 29, 2015 10:39
#!/usr/bin/env python3
import tkinter as tk
import tkinter.ttk as ttk
from threading import Thread
import socket
PORT=1235
root = tk.Tk()
root.title('QIP 0.0')
# параметр сглаживания
a = 1/100
# аппроксимация модуля
ma = (a + x^2)^(1/2)
# выражение максимума через модуль
var('xm1 xm2')
xmax=1/2*(ma(xm1-xm2) + xm1 + xm2)
var_names = 'x1 x2 x3 x4'
args = var(var_names)
#!/usr/bin/python3
#Grabbing pics from nightmaresfearfactory galleries
import re, sys, os
import concurrent.futures
import urllib.request
sfolder = 'pics'
os.makedirs(sfolder,exist_ok=True)
os.chdir(sfolder)
@Sorseg
Sorseg / file_count.py
Created May 18, 2013 02:06
Count all files in . and subfolders of .
import os; print sum(len(f) for _,_,f in os.walk("."))
class AssignOnce:
''' Descriptor, which prevents accidential overwriting of attributes:
>>> class T:
... a = AssignOnce('a')
...
>>> t = T()
>>> t.a
>>> t.a = 3
>>> t.a = 4
Traceback (most recent call last):
#!/usr/bin/python
'''
BeautifulSoup is required:
http://www.crummy.com/software/BeautifulSoup/download/3.x/BeautifulSoup-3.2.1.tar.gz
'''
from BeautifulSoup import BeautifulSoup as soup
from urllib import urlopen as uopen, urlretrieve
import re, os, errno, subprocess as sp, threading
from time import sleep
from urlparse import urljoin