- 1
- 2
- 3
- 4
try:
assert isinstance(tag, bs4.element.Tag)
except AssertionError:
raise TypeError
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
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
−2
public class Parameter
{
public string Name { get; }
public int Value { get; }
private Parameter(string name, int value)
{
Name = name;
Value = value;
}
public static Func<int, Parameter> GetDeferredConstructor(string name)
{
return value => new Parameter(name, value);
}
}
public class Program
{
public static void Main(string[] args)
{
var dc = Parameter.GetDeferredConstructor("param");
var p = dc(5);
}
}
−2
// this method is used for storing name instead of password
@Override
public String getPassword() { return name; }
+3
using namespace std;
#include <typeinfo>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <stdarg.h>
template <unsigned FRA,unsigned EXP>
struct F {
union{
float f;
unsigned ui;
unsigned ef : FRA+EXP;
struct
{
unsigned f : FRA;
unsigned e : EXP;
unsigned s : 1;
} s;
};
F (double x){f=x;}
F operator =(const double x) {
f=x; return *this;
}
#define NOOP ;
#define UN(OP,BODY, RET) float operator OP( ) { BODY; return RET;}
#define BIN(OP,BODY, RET) F operator OP(F other ) { BODY; return RET;}
#define BINF(OP,BODY,RET) F operator OP(const float other) { BODY; } BIN(OP,BODY,RET)
#define CMP(OP) bool operator OP(const F& other)
UN ( - , s.s^=1 , (f) )
BIN( += , f+=other.f , ( *this ) )
BIN( + , NOOP , { f+other.f} )
BIN( - ,++other.s.s , {*this+other} )
BIN( * , NOOP , fmul(f,{other}) )
BIN( / , div(other), ( *this ) )
BINF(*=, ui=fmul(*this ,{other}).ui, ( *this ) )
BINF(/=, ui=fmul(*this,rcp(other)).ui, ( *this ) )
CMP(==){
return other.ui==ui;
}
F out(string s) const{
printf("> %s%f\n",s.c_str(),f);
}
F plus(F other)
{
f+=other.f;
return *this;
}
F div(F other)
{
ui=fmul(rcp(other),{f}).ui;
return *this;
}
F sqrt()
{
s.e-=127;
ui>>=1;
s.f-=(s.f>>4);
s.e+=127;
return *this;
}
F pow(int n)
{
s.e-=127;
ui*=n;
ef+=(ef>>4);
ef-=(ef>>9);
s.e+=127;
return *this;
}
private:
static F rcp(F f) {
f.s.e=(~f.s.e-2);
f.s.f=(~f.s.f-2);
return f;
}
static F fmul(F r,F b)
{
r.s.s ^= b.s.s;
r.ef += ((r.s.f&b.s.f)>>4);
r.ef += b.ef ;
r.s.e+= 129;
return r;
}
};
using F32 = F<23,8>;
static F32 of32(float x)
Царь был прав. Во всём.
Патамучто это плавающий питух, который априори говно. И чем вы быстрее это поймёте, чем будет лучше.
В соответствии со своим пониманием сделал мммаксимально простую реализацию плавающих питухов произвольного размера.
Строго на интах.
Пример здесь:
uhttps://ideone.com/dDrj7s
−1
if (context instanceof Activity) {
activity = (MainActivityMVI) context;
try {
listener = (OnOfferItemClickListenerS) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + "must implement OnOfferItemClickListenerS");
}
try {
listener2 = (OnLoadDataSearchMainFragmentListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + "must implement OnLoadDataSearchMainFragmentListener");
}
App.getComponent(activity).inject(this);
}