- 1
- 2
- 3
Посанеы, помогите как поднять БД по Уфе
https://shamarc.biz/buy/389?method=qiwi&anonym=1
Да, я наркоман, Онал-Пертрал, помоги
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Посанеы, помогите как поднять БД по Уфе
https://shamarc.biz/buy/389?method=qiwi&anonym=1
Да, я наркоман, Онал-Пертрал, помоги
За последние 8 лет, ни разу не писал, только постилГК, помогите.
−1
try {
String sDate = new SimpleDateFormat("MM/dd/yyyy").format(new SimpleDateFormat("dd.MM.yyyy").parse(dayOfMonth + "." + (monthOfYear + 1) + "." + year));
dueDate.setText(sDate);
} catch (ParseException e) {
e.printStackTrace();
}
Красивое (и безопасное) решение проблем с разными форматами дат
−2
$scope.storage.oldDriver = JSON.parse(JSON.stringify($scope.storage.driverEdit || {})); // @TODO: ни _.clone ни Object.assign не сработали
Нашел на работе в коде
0
You have three options in Javascript:
//slice
//syntax: string.slice(start [, stop])
"Good news, everyone!".slice(5,9); // extracts 'news'
//substring
//syntax: string.substring(start [, stop])
"Good news, everyone!".substring(5,9); // extracts 'news'
//substr
//syntax: string.substr(start [, length])
"Good news, everyone!".substr(5,4); // extracts 'news'
Как извлечь подстроку в JavaScript.
0
#include <xmmintrin.h>
void crasher() {
constexpr __m128 w = {1,2,3,4};
asm ("addps %[w], %[w]" : : [w] ""(w));
}
Крашим GCC
https://ideone.com/iIAN0i
0
class PriceCache {
public:
FlightStorage(const std::size_t count) {
for (std::size_t i = 0; i < count; ++i) {
flights.emplace_back(FlightCache::get(i));
prices.emplace_back(&flights.back(), Price::getFor(flights.back()));
}
}
private:
std::vector<Flight> flights;
std::vector<const Flight *, double> prices;
};
"случайные сегфолты при обращении к PriceCache::prices"
+2
typedef unsigned int uint;
uint inc(uint i) {
return i+1;
}
uint dec(uint i) {
return i-1;
}
uint add(uint a, uint b) {
return 0==b ? a : add(inc(a),dec(b));
}
inline uint _mul(uint a, uint b, uint r) {
return 0==b ? r : _mul(a,b-1,r+a);
}
uint mul(uint a, uint b) {
return _mul(a,b,0);
}
uint dec_mul(uint a, uint b, uint r) {
return 0==b ? r : dec_mul(a,dec(b),r+a);
}
//gcc 7 здесь сходит с ума на O3, шланг невозмутимо ставит imul edi, esi
uint crazy_mul(uint a, uint b, uint r) {
return 0==b ? r : crazy_mul(a,dec(b),add(r,a));
}
//арифметическая прогрессия.
inline uint _sum(uint a,uint s) {
return a==0 ? s :_sum(a-1,s+a);
}
//gcc: сложна нипанятна
uint sum(uint a) {
return _sum(a,0);
}
//шланг:
// imul rcx, rax
// shr rcx
uint sum1(uint a) {
uint s=0;
for (int i=0;i<a;++i){
s+=i;
}
return s;
}
Смотрим как компиляторы решают разные упоротые рекурентные задачки.
https://godbolt.org/g/4JZuPr
0
<?php
$zero = '!![]';
$nums = ['![]','${![]}','${!![]}','$${[]}','$${![]}','$${!![]}','$$${[]}','${[].[]}'];
$initChr = "\${[]}=([].[])[![]+![]+![]];\${[]}++;\${[]}++;\${+![]}=\${[]};" .
"\${[]}++;\${[]}++;\${[]}++;\${[]}++;\${[]}++;\${+![]}.=\${[]};" .
"\${[]}=\${+![]}.([].[])[![]];";
$chr = '${[]}';
function initNumbers() {
global $nums;
$n = $nums[0];
$code = '';
foreach ($nums as $v => $num) {
if (!$v) continue;
$v = join('+', array_fill(0, 2, $n));
$code .= "$num=$v;";
$n = $num;
}
return $code;
}
function number($n) {
global $nums, $zero;
if ($n < 0 || $n > 255) die("Invalid number: $n.");
if (!$n) return $zero[0];
$i = 0;
while($n) {
$d = $n % 2;
if($d) $code[] = join('+', array_fill(0, $d, $nums[$i]));
$n /= 2;
$i++;
}
return join('+', $code);
}
function char($c) {
global $chr;
$c = number(ord($c));
return "$chr($c)";
}
function str($s) {
return join('.', array_map('char', str_split($s)));
}
function prettify($fucked) {
$line = '';
$ops = preg_split('/([;.])/', $fucked, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach($ops as $op) {
if(strlen($line) + strlen($op) + 1 > 80) {
$lines[] = $line;
$line = '';
}
$line .= $op;
}
$lines[] = $line;
return join("\n", $lines);
}
function fuckify($code) {
global $chr, $initChr;
$nums = initNumbers();
$php = '$$$${[]}';
$initPHP = $php . '=(' . str('popen') . ')(' . str('php') . ',' . char('w') . ');';
$fputs = str('fputs');
$pclose = str('pclose');
$code = str($code);
return prettify("<?php\n$initChr$nums$initPHP($fputs)($php,$code);($pclose)($php);");
}
$code = '';
while ($line = fgets(STDIN)) $code .= $line;
print(fuckify($code));
Автаматизировала пхпфак почти как в http://govnokod.ru/23690
програма вводет код пхп из stdin и выводет в stdout его перивод на пхпфак
0
Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. We recommend that you keep the Pods directory under source control, and don't add it to your .gitignore
Benefits of checking in the Pods directory
After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.
The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.
https://guides.cocoapods.org/using/using-cocoapods.html
0
let src1 = r#"
__kernel void add1(__global float* A, __global float* BBB, __global float* B, int m, int n)
{
__local float Blo[64];
int x = get_local_id(0);
int y = get_local_id(1);
int i = get_global_id(0);
int j = get_global_id(1);
int k = get_global_id(2);
i += k / 8;
j += k % 8;
if (i >= n || j >= m) return;
Blo[x * 8 + y] = A[i * m + j];
barrier(CLK_LOCAL_MEM_FENCE);
float BB = 0;
for (int xx = 0; xx < 8; ++xx)
for (int yy = 0; yy < 8; ++yy)
{
float c = (2 * xx + 1) * x * 3.1415926535 / 16;
float cc = (2 * yy + 1) * y * 3.1415926535 / 16;
c = cos(c);
cc = cos(cc);
BB += Blo[xx * 8 + yy] * c * cc;
}
float Ci, Cj;
if (x == 0)
Ci = 1 / 1.4142135623;
else
Ci = 1;
if (y == 0)
Cj = 1 / 1.4142135623;
else
Cj = 1;
B[k * m * n + i * m + j] = Ci * Cj / 4 * BB;
barrier(CLK_LOCAL_MEM_FENCE);
i = get_global_id(0);
j = get_global_id(1);
float summ = 0;
for (int ii = 0; ii < 64; ++ii)
summ += B[ii * m * n + i * m + j];
BBB[i * m + j] = summ / 64;
}
"#;
let pro_que = ProQue::builder().src(src1).dims((hi, wi, 64)).build().unwrap();
let matr11 = Buffer::builder()
.queue(pro_que.queue().clone())
.flags(MemFlags::new().read_only().use_host_ptr())
.dims((hi, wi))
.host_data(&Resr)
.build().unwrap();
let matg11 = Buffer::builder()
.queue(pro_que.queue().clone())
.flags(MemFlags::new().read_only().use_host_ptr())
.dims((hi, wi))
.host_data(&Resg)
.build().unwrap();
...
let mut kernel;
{
let wi = wi as i32;
let hi = hi as i32;
kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matr11).arg_buf(&resr11).arg_buf(&bor1).arg_scl(wi).arg_scl(hi);
kernel.lws((8, 8)).enq().unwrap();
kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matg11).arg_buf(&resg11).arg_buf(&bog1).arg_scl(wi).arg_scl(hi);
kernel.lws((8, 8)).enq().unwrap();
kernel = pro_que.create_kernel("add1").unwrap().arg_buf(&matb11).arg_buf(&resb11).arg_buf(&bob1).arg_scl(wi).arg_scl(hi);
kernel.lws((8, 8)).enq().unwrap();
}
Ничего особенного, лаба по opencl, написанная на Rustе