- 1
Эмуляторы
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−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);
}
0
"SELECT " +
"2 AS recType," +
"1 AS cnt," +
"'' AS vndName," +
"'' AS catName," +
"off.orderBy1S AS orderBy1S," +
"off._id AS _id," +
"off.vendorCode AS vendorCode," +
"off.price AS price," +
"off.currencyId AS currencyId," +
"off.thumbnail AS thumbnail," +
"off.name AS name," +
"IFNULL(crt.quantity,0) AS quantityItem," +
"off.queryRest AS queryRest," +
"off.valueRest AS valueRest," +
"off.lastChangedRest AS lastChangedRest," +
"off.price_uah_ir AS price_uah_ir," +
"IFNULL(vlt.[rate],0) AS rate " + //валютный курс для currencyId товара
"FROM tOffer AS off " +
"LEFT JOIN tCart AS crt ON off.vendorCode=crt.offerId " +
"LEFT JOIN tCurrency AS vlt ON off.currencyId=vlt.valute " +
"WHERE off.vendorName='" + BRAND_NAME + "' AND off.categoryId=" + CATEGORY_ID + " AND (off.name LIKE " + nameFilter + ") " +
"UNION " +
"SELECT " +
"1," +
"COUNT(*)," +
"MAX(vnd.name)," +
"IFNULL(cat.name,'')," +
"0," +
"0," +
"0," +
"0," +
"''," +
"''," +
"vnd.name," +
"0," +
"0," +
"''," +
"''," +
"0," +
"0 " +
"FROM tOffer AS off " +
"LEFT JOIN tVendor AS vnd ON off.vendorName=vnd.name " +
"INNER JOIN tCategory AS cat ON off.categoryId=cat._id " +
"WHERE off.vendorName='" + BRAND_NAME + "' AND off.categoryId=" + CATEGORY_ID + " AND (off.name LIKE " + nameFilter + ") " +
"GROUP BY vnd.name HAVING COUNT(*)>0 " +
"UNION " +
"SELECT " +
"3," +
"COUNT(*)," +
"MAX('Другой товар')," +
"''," +
"0," +
"0," +
"0," +
"0," +
"''," +
"''," +
"'Другой товар'," +
"0," +
"0," +
"''," +
"''," +
"0," +
"0 " +
"FROM tOffer AS off " +
"WHERE off.vendorName<>'" + BRAND_NAME + "' AND (off.name LIKE " + nameFilter + ") " +
"GROUP BY 'Другой товар' HAVING COUNT(*)>0 " +
"UNION " +
"SELECT " +
"4," +
"1," +
"''," +
"''," +
"off.orderBy1S," +
"off._id," +
"off.vendorCode," +
"off.price," +
"off.currencyId," +
"off.thumbnail," +
"off.name," +
"IFNULL(crt.quantity,0)," +
"off.queryRest," +
"off.valueRest," +
"off.lastChangedRest," +
"off.price_uah_ir," +
"IFNULL(vlt.[rate],0) " + //валютный курс для currencyId товара
"FROM tOffer AS off " +
"LEFT JOIN tCart AS crt ON off.vendorCode=crt.offerId " +
"LEFT JOIN tCurrency AS vlt ON off.currencyId=vlt.valute " +
"WHERE off.vendorName<>'" + BRAND_NAME + "' AND (off.name LIKE " + nameFilter + ") " +
"ORDER BY recType,orderBy1S ";
Комменты говорят, что это поиск по бренду и названию
+8
<a href="/login">
<?php echo( 'В'. ($isLogged ? 'ы' : '') . 'ход'); ?>
</a>
−2
https://vc.ru/37909-my-stroim-letnyuyu-shkolu-v-poselke-programmistov
как вам мысль учить пхп на природе?
0
...
F = fun(S) ->
ets:give_away(Table, NewOwner),
S
end,
sys:replace_state(OldOwner, F)
...
Паттерн steal