- 1
- 2
In [42]: os.path.join(r'c:\asd', r'c:\www')
Out[42]: 'c:\\www'
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
In [42]: os.path.join(r'c:\asd', r'c:\www')
Out[42]: 'c:\\www'
Нахуя???
+2
https://habr.com/post/358974/
"Как обновление Rust 1.26 ускорило мой код в три с лишним раза"
Яркий пример того, как человек не понимает как работает его код.
И кое-то говорит, что Си - говно
0
def sql_select_filter(sql, flt, order=None, limit=None, offset=None, group_by=None, lock=None, withSelectWrapper=True):
if withSelectWrapper and group_by is None:
if re.search(r'^\s*select\s+', sql, flags=re.IGNORECASE | re.MULTILINE):
sql = "SELECT * FROM ( " + sql + " ) as z99 "
else:
sql = "SELECT * FROM " + sql + " "
sql = sql.replace("%", '%%')
where, vals = _make_where_conditions(flt)
if where is not None:
sql += " WHERE " + where
if group_by is not None and len(group_by):
sql += " GROUP BY " + ",".join(group_by)
if order is not None and len(order):
order_fields = []
for field, direction in order.items():
order_fields.append(field + " " + direction)
sql += " ORDER BY " + ",".join(order_fields)
if limit is not None:
sql += " LIMIT %s"
vals.append(limit)
if offset is not None:
sql += " OFFSET %s"
vals.append(offset)
if lock is not None:
sql += " FOR " + lock
return sql, vals
Конструктор SQL запроосов, все очень секурно!
0
if(!preg_match('/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i', $email)){
0
try:
assert isinstance(tag, bs4.element.Tag)
except AssertionError:
raise TypeError
−2
if (query) {
searchParams.area = query.area_from && query.area_from !== 'all' && query.area_from.length !== 0 && query.area_to && query.area_to !== 'all' && query.area_to.length !== 0 ? [query.area_from, query.area_to] : ['0', '100']
searchParams.price = query.price_from && query.price_from !== 'all' && query.price_from.length !== 0 && query.price_to && query.price_to !== 'all' && query.price_to.length !== 0 ? [query.price_from, query.price_to] : ['0', '10']
searchParams.floor = query.floor_from && query.floor_from !== 'all' && query.floor_from.length !== 0 && query.floor_to && query.floor_to !== 'all' && query.floor_to.length !== 0 ? [query.floor_from, query.floor_to] : ['0', '100']
searchParams.last_first = query.last_first && query.last_first !== 'all' && query.last_first.length !== 0 ? query.last_first : null
searchParams.promo = query.promo && query.promo !== 'all' && query.promo.length !== 0 ? query.promo : null
searchParams.assignment = query.assignment && query.assignment !== 'all' && query.assignment.length !== 0 ? query.assignment : null
no coments
−2
https://hsto.org/webt/ho/0r/ms/ho0rms80hfva2hnwlptdhoz4ysy.png
https://habr.com/company/rambler-co/blog/358762/
Всё что можно, какие есть технологии и базы данных, захуярили в одну схему. Не хватает только "PHP" для полной картины.
−2
echo $(printf '1\xff0.0.0.0:0\0\\gamedir\\valve' |nc -u ms.xash.su 27010 -w 1 | od -j6 -t x1 -An -w6 |sed -s 's/\ /\ 0x/g'|while read line; do printf '%d.%d.%d.%d' $(echo $line|cut -d ' ' -f1-4) ; echo \ $(( $(printf %d $(echo $line|cut -d ' ' -f5))*256 + $(printf %d $(echo $line|cut -d ' ' -f6)) )); done| while read line1; do printf \\xff\\xff\\xff\\xffinfo\ 48|nc -w 1 -u $line1 |sed -e s/\\\\/\\\ /g -e "s/\xff\xff\xff\xffinfo/_br_$line1/g" & done;sleep 2s;echo)|sed -e s/_br_/\\n/g
Работаем с бинарными протоколами однострочно
−5
Эмуляторы
Объясните пожалуйста, почему пишут эмуляторы всяких там GBA, но нет ни одного транслятора в самодостаточную программу? И почему все заботься о том, что бы эмулятор работал с такой же скоростью, как и настоящий процессор?
−2
import json
import time
import requests
from multiprocessing.dummy import Pool as ThreadPool
max_threads = 10
fname = "data.json"
headers = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36", "referer":"https://datmusic.xyz/?q=Home+resonance", "authority":"api-2.datmusic.xyz"}
def api(url):
while True:
try:
r = requests.get(url, headers=headers)
r = r.json()
if r['status'] == 'error':
pass
else:
return r['data'][0]['download']
except Exception as e:
pass
def download(a):
# open in binary mode
while True:
try:
with open(a[1]+".mp3", "wb") as file:
response = requests.get(a[0],headers=headers)
if not (response.status_code == 503):
file.write(response.content)
print(a[1],"downloaded")
break
else:
pass
except Exception as e:
pass
songs = []
with open(fname) as json_data:
data = json.load(json_data)
for mp3 in data['list']:
song = []
autor = mp3[4]
title = mp3[3][:-5]
song.append(autor)
song.append(title)
songs.append(song)
links = []
def linker(a):
song = []
link = api("https://api-2.datmusic.xyz/search?q=" + a[0] + "+" + a[1] + "&page=0")
song.append(link)
song.append(a[0] + ' - ' + a[1])
links.append(song)
print(a[1])
for a in songs:
linker(a)
#if len(links) > 10:
# break
pool = ThreadPool(max_threads)
results = pool.map(download, links)
pool.close()
pool.join()
#Наговнокодил загрущик плейлистов с контача. Как получить json плейлиста подумай сам (перейди в музыку, открой Network в f12 и мониторь запрос при открытии плейлиста)
#Парсер 1 поточный, загрущик многопоточный. Работает через апи datmusic.xyz спс им
#vk.com music downloader v1.0a
#загрущик музыки вк
json = https://gist.githubusercontent.com/alekxeyuk/a1ccd2c62ab56a71320a02582cfc06f9/raw/4f2622c4beeddfa7e3082c276e1c138c87478e83/data.json