- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
enum BitNumber {
Bit0 = 0,
Bit1 = 1,
Bit2 = 2,
Bit3 = 3,
Bit4 = 4,
Bit5 = 5,
Bit6 = 6,
Bit7 = 7
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
enum BitNumber {
Bit0 = 0,
Bit1 = 1,
Bit2 = 2,
Bit3 = 3,
Bit4 = 4,
Bit5 = 5,
Bit6 = 6,
Bit7 = 7
};
Из крупного проекта, крупной конторы... Но это еще цветочки, ягодки дальше будут.
0
public function insert(array $data)
{
$hstoreData = array();
if (isset($data['description'])) {
$hstoreData['description'] = $data['description'];
unset($data['description']);
}
if (isset($data['developer'])) {
$hstoreData['developer'] = $data['developer'];
unset($data['developer']);
}
if (isset($data['localizer'])) {
$hstoreData['localizer'] = $data['localizer'];
unset($data['localizer']);
}
if (isset($data['gameplay_video'])) {
$hstoreData['gameplay_video'] = $data['gameplay_video'];
unset($data['gameplay_video']);
}
if (isset($data['news_community_id'])) {
$hstoreData['news_community_id'] = $data['news_community_id'];
unset($data['news_community_id']);
}
if (isset($data['bg_color'])) {
$hstoreData['bg_color'] = $data['bg_color'];
unset($data['bg_color']);
}
if (isset($data['bg_image'])) {
$hstoreData['bg_image'] = $data['bg_image'];
unset($data['bg_image']);
}
if (isset($data['bg_link'])) {
$hstoreData['bg_link'] = $data['bg_link'];
unset($data['bg_link']);
}
$result = parent::insert($data);
$this->updateByID($result, $hstoreData);
return $result;
}
Это зачем, интересно?
+1
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -debug verbose
-include_lib("xmerl/include/xmerl.hrl").
-export([main/1, install_mod/1]).
-record(mod_info, { name :: string()
, links :: [{file:filepath(), file:filepath()}]
}).
main(Args) ->
[ModeDir, GameDir] = Args,
VirtualInstall = filename:absname(ModeDir ++ "/VirtualInstall/"),
RealPath = filename:absname(GameDir),
VirtualModCfg = VirtualInstall ++ "/VirtualModConfig.xml",
io:format( "Mode dir: ~p~n"
"Install dir: ~p~n"
"Current dir: ~p~n"
, [VirtualInstall, RealPath, element(2, file:get_cwd())]),
{Doc, []} = xmerl_scan:file(VirtualModCfg),
Mods = get_mods(VirtualInstall, RealPath, Doc),
[install_mod(I) || I <- Mods],
ok.
get_mods(VirtPath, RealPath, Doc) ->
[ #mod_info
{ name = xpath("/modInfo/@modName", Mod)
, links = get_links(VirtPath, RealPath, Mod)
}
|| Mod <- xmerl_xpath:string( "/virtualModActivator/modList/modInfo"
, Doc)].
get_links(VirtPath, RealPath, Doc) ->
[{ filename:absname( unixify(xpath("/fileLink/@realPath", FL))
, VirtPath)
, filename:absname( unixify(xpath("/fileLink/@virtualPath", FL))
, RealPath)
}
|| FL <- xmerl_xpath:string( "//fileLink[isActive = 'True']"
, Doc)].
xpath(Query, Doc) ->
case xmerl_xpath:string(Query, Doc) of
[#xmlAttribute{value = Val}] ->
Val
end.
unixify(Path) ->
lists:map(
fun($\\) -> $/;
(A) -> A
end,
Path).
install_mod(#mod_info{name = Name, links = Links}) ->
io:format("Installing ~s...~n", [Name]),
lists:foreach(
fun({From, To}) ->
filelib:ensure_dir(To),
file:make_symlink(From, To)
end,
Links).
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е
+2
Запрос = Новый Запрос;
Запрос.Текст="ВЫБРАТЬ
| ЗаказНаряд.Ссылка КАК Ссылка
|ИЗ
| Документ.ЗаказНаряд КАК ЗаказНаряд
|ГДЕ
| ЗаказНаряд.Проведен = ИСТИНА";
Выборка=Запрос.Выполнить().Выбрать();
Выборка.Следующий();
Если обЗначениеНеЗаполнено(Выборка.Ссылка) Тогда
.......
Чуть упростил запрос для быстроты понимания...
Как проверить запрос ПУСТОЙ() или нет... Вот один из разработчиков нашел метод.....
−3
class Huyomoyo
attr_reader :hui_razmer
def initialize(hui_razmer = 0)
@hui_razmer = case hui_razmer
when 0
'Нету'
when 1..3
'Пиздец маленький'
when 4..6
'Ну... Уже лучше'
when 7..9
'Норма'
when 10..12
'Ууажюха'
when 13..17
'Мдаааа'
when 18..22
'НИХУЯСЕБЕ'
when 23..40
'Да ты пиздишь'
else
'Че??'
end
end
def print_hui
puts @hui
end
end
if __FILE__ == $0
9.times do |i|
kusokgovnokoda = case i
when 0
0
when 1
1
when 2
4
when 3
7
when 4
10
when 5
13
when 6
18
when 7
23
when 8
41
end
Huyomoyo.new(kusokgovnokoda).print_hui
end
end
Я не посню што это вообще... Вроде говнокод
+2
<?php
$s = "This";
$is = "an";
$of = "a";
$ninja = "coding";
$This = "is";
$a = "ninja";
$coding = "echo";
$an = "example";
$example = "of";
${null} = ' "$s';
function z($x,$c='$'){return $x==1?$c:z($x-1,$c.'$');}
for($i=1;$i<=7;$i++){${null}.=' ${'.z($i).'s}';}
eval($$$$$$$$$s.${null}.'\n";');
/* Returns:
This is an example of a ninja coding
*/
PHP очарователен
К посту http://govnokod.ru/23540
0
https://github.com/VKCOM/bot-example-php/blob/master/html/bot/bot.php
В великом и недосягаемом "ВКонтакте" переменные в текст по-прежнему включают с помощью фигурных скобок.
+1
#define SPLICE(a,b) a##b
#define LL(a,b) SPLICE(a,b)
#define M(name) LL(NS,name)
#define NS ns1_
void M(somefunction)(){
}
#undef NS
#define NS ns2_
void M(somefunction)(){
}
#undef NS
#define NS ns3_
void M(somefunction)(){
}
#undef NS
неймспейсы в Си на препроцессоре
+2
#include <iostream>
#include <Windows.h>
#define OCT_1 0
#define OCT_2 12
#define OCT_3 24
#define OCT_4 36
#define OCT_5 48
#define OCT_6 60
#define OCT_7 72
#define OCT_8 84
#define OCT_9 96
#define NOTE_C 0
#define NOTE_Ch 1
#define NOTE_Db 1
#define NOTE_D 2
#define NOTE_Dh 3
#define NOTE_Eb 3
#define NOTE_E 4
#define NOTE_F 5
#define NOTE_Fh 6
#define NOTE_Gb 6
#define NOTE_G 7
#define NOTE_Gh 8
#define NOTE_Ab 8
#define NOTE_A 9
#define NOTE_Ah 10
#define NOTE_Bb 10
#define NOTE_B 11
long double notes[200];
#define TEMPO 100
#define LEN1 (120000 / TEMPO)
#define LEN2 (LEN1 / 2)
#define LEN4 (LEN1 / 4)
#define LEN8 (LEN1 / 8)
#define LEN16 (LEN1 / 16)
#define melody_len 28
struct s {
int key, len;
s(int key, int len) {
this->key = key;
this->len = len;
}
} melody[melody_len] = {
s(OCT_4 + NOTE_E, LEN8),
s(OCT_4 + NOTE_E, LEN8),
s(OCT_5 + NOTE_C, LEN4),
s(OCT_4 + NOTE_E, LEN8),
s(OCT_4 + NOTE_E, LEN8),
s(OCT_5 + NOTE_C, LEN4),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_4 + NOTE_B, LEN8),
s(OCT_4 + NOTE_B, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_4 + NOTE_E, LEN4),
s(OCT_5 + NOTE_E, LEN8),
s(OCT_5 + NOTE_E, LEN8),
s(OCT_4 + NOTE_D, LEN8),
s(OCT_4 + NOTE_D, LEN8),
s(OCT_5 + NOTE_E, LEN8),
s(OCT_5 + NOTE_E, LEN8),
s(OCT_4 + NOTE_B, LEN8),
s(OCT_4 + NOTE_B, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_4 + NOTE_B, LEN8),
s(OCT_4 + NOTE_B, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_5 + NOTE_C, LEN8),
s(OCT_4 + NOTE_E, LEN4),
};
int main(int argc, char** argv) {
notes[0] = 32.7032;
for(int i = 1; i < 200; ++i)
notes[i] = notes[i - 1] * 1.05946309436;
for(int i = 0; i < melody_len; ++i) {
int key = melody[i].key;
int len = melody[i].len;
if(key < 0) Sleep(len);
else Beep(notes[key], len);
}
return 0;
}
Дохуя мелодия... с 1 класса музыкалки...