- 1
Никто не в курсе где сейчас Clerk с wasm.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−5
Никто не в курсе где сейчас Clerk с wasm.
0
//10 процентов от ширины блока
var blockPercent = ($(".prod").width() / 100) * 10;
//наведение мышью на блок
$('.prod').mouseenter(function(cursor){
//Добавление стиля для определения текущего блока
$(this).addClass('selected-prod');
var offset = $(this).offset();
//left-right
if (cursor.pageX - offset.left < blockPercent) {
$('.selected-prod .prod-description').css({'height': '100%','left':'0px'});
$('.selected-prod .prod-description').animate({'width': '100%'},200);
}
//right-left
if (cursor.pageX - offset.left > $(this).width() - blockPercent) {
$('.selected-prod .prod-description').css({'height': '100%', 'right':'0px'});
$('.selected-prod .prod-description').animate({'width': '100%'},200);
}
//top-down
if (cursor.pageY - offset.top < blockPercent) {
$('.selected-prod .prod-description').css({'width': '100%'});
$('.selected-prod .prod-description').animate({'height': '100%'},200);
}
//down-top
if (cursor.pageY - offset.top > $(this).height() - blockPercent) {
$('.selected-prod .prod-description').css({'width': '100%'});
$('.selected-prod .prod-description').animate({'height': '100%','bottom':'0px'},200);
}
});
Наткнулся на проекте. Первая мысль: "Оно слишком быстро работало!"
+3
// https://github.com/julycoding/The-Art-Of-Programming-By-July/blob/master/ebook/code/c/1.1%EF%BC%9A%E5%B7%A6%E6%97%8B%E8%BD%AC%E5%AD%97%E7%AC%A6%E4%B8%B2.c
#include <stdio.h>
#include <string.h>
//字符串旋转问题,例如abcdef 左旋2位 变成 cdefab
//暴力移位法
void leftShift1(char * arr, int n)
{
size_t tmpLen = strlen(arr);
char tmpChar;
int i, j;
if (n >= 0)
{
for (i = 0; i < n; i++)
{
tmpChar = *arr;
for (j = 0; j < tmpLen - 1; j++)
{
*(arr + j) = *(arr + j + 1);
}
*(arr + tmpLen - 1) = tmpChar;
}
}
else
{
for (i = 0; i < -n; i++)
{
tmpChar = *(arr + tmpLen - 1);
for (j = tmpLen - 1; j > 0; j--)
{
*(arr + j) = *(arr + j - 1);
}
*arr = tmpChar;
}
}
}
Копаясь в гитхабе, нашел я тут The Art Of Programming By July, написанный каким-то китайцем.
https://github.com/julycoding/The-Art-Of-Programming-By-July
0
public static int index(string word, char comp)
{
int k = -1;
for (int i = 0; i < word.Length; i++)
if (word[i] == comp)
{
k = i;
break;
}
return k;
}
public static char[] strtocharr(string str)
{
char[] tmp = new char[str.Length];
for (int i = 0; i < tmp.Length; i++)
tmp[i] = str[i];
return tmp;
}
public static string charrtostr(char[] charr)
{
string tmp = null;
for (int i = 0; i < charr.Length; i++)
tmp = String.Format("{0}{1}", tmp, charr[i]);
return tmp;
}
public static char maskfromword(string word)
{
return word[word.Length - 1];
}
public static string maskfromword(string word, int n)
{
string mask = null;
for (int i = 0; i < n; i++)
mask = String.Format("{0}{1}", mask, word[word.Length - 1]);
return mask;
}
public static char Counter(char crnt, string word)
{
if (crnt != maskfromword(word))
crnt = word[index(word, crnt) + 1];
else
crnt = word[0];
return crnt;
}
public static string Counter(string prev, string word, int k)
{
char[] tmp = strtocharr(prev);
if (k >= prev.Length - 1)
k = prev.Length - 1;
else
for (int i = k + 1; i < prev.Length; i++)
tmp[i] = word[0];
if (tmp[k] == maskfromword(word))
return MultiCounter(prev, word, k - 1);
else
tmp[k] = Counter(tmp[k], word);
return charrtostr(tmp);
}
Список методов, позволяющие сделать счетчик по словарю (полезно для генераторов словарей) на любое количество символов.
+1
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<?
$title = filter_var($_REQUEST["title"], FILTER_SANITIZE_STRING);
$image = filter_var($_REQUEST["image"], FILTER_SANITIZE_STRING);
$text = filter_var($_REQUEST["text"], FILTER_SANITIZE_STRING);
?>
<meta property="og:type" content="article" />
<meta property="og:title" content="<?=$_REQUEST['title'];?>" />
<meta property="og:description" content="<?=$_REQUEST['text'];?>" />
<meta property="og:image" content="<?=$_REQUEST['image']?>" />
<?$d = 'Некий URL?title='.urlencode($title).'&image='.urlencode($image).'&text='.urlencode($text);?>
<meta property="og:url" content="<?=$d?>" />
<title><?=$_REQUEST['title'];?></title>
<script type="text/javascript">
window.location = "Еще один захардкоженый URL";
</script>
</head>
<body>
<img src="<?=$_REQUEST['image']?>" />
</body>
</html>
все секурно
+1
static inline void set0b (const uint8_t at, uint64_t bm[static 4])
{
bm[at / 64] &= ~(1ULL << (at % 64));
}
static inline void set1b (const uint8_t at, uint64_t bm[static 4])
{
bm[at / 64] |= 1ULL << (at % 64);
}
static inline void inv_b (const uint8_t at, uint64_t bm[static 4])
{
bm[at / 64] ^= 1ULL << (at % 64);
}
static inline uint8_t find_empt_pos (const uint64_t bm[static 4])
{
if (bm[0] != UINT64_MAX)
{
return __builtin_ctzll(~bm[0]) + 64 * 0; // __builtin_ctzll - https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
}
if (bm[1] != UINT64_MAX)
{
return __builtin_ctzll(~bm[1]) + 64 * 1;
}
if (bm[2] != UINT64_MAX)
{
return __builtin_ctzll(~bm[2]) + 64 * 2;
}
if (bm[3] != UINT64_MAX)
{
return __builtin_ctzll(~bm[3]) + 64 * 3;
}
fprintf(stderr, "ERROR! No empty space!\n");
exit (-1);
}
static inline uint8_t allocate_ll (uint64_t bm[static 4])
{
uint8_t tmp = find_empt_pos (bm);
set1b (tmp, bm);
return tmp;
}
static inline void inject(const uint8_t prev_p, const uint8_t next_p, const uint8_t at, struct ll_data a[static 256])
{
a[next_p].ll.prev = at;
a[prev_p].ll.next = at;
a[at].ll.prev = prev_p;
a[at].ll.next = next_p;
}
static inline void remove_betw(const uint8_t prev_p, const uint8_t next_p, struct ll_data a[static 256])
{
a[prev_p].ll.next = next_p;
a[next_p].ll.prev = prev_p;
}
static inline void remove_at(const uint8_t at, struct ll_data a[static 256], uint64_t bm[static 4])
{
uint8_t prev_t = a[at].ll.prev;
uint8_t next_t = a[at].ll.next;
set0b (at, bm);
a[at].ll.prev = next_t;
a[at].ll.next = prev_t;
}
void add_elem_next (struct ll_all *a, const uint8_t elm, const int value)
{
uint8_t pos = allocate_ll (a->bm);
inject(elm, a->arr[elm].ll.next, pos, a->arr);
set_elm (pos, value, a->arr);
}
void add_elem_prev (struct ll_all *a, const uint8_t elm, const int value)
{
uint8_t pos = allocate_ll (a->bm);
inject(a->arr[elm].ll.prev, elm, pos, a->arr);
a->arr[pos].data = value;
}
void rem_elem_next (struct ll_all *a, const uint8_t elm)
{
set0b (a->arr[elm].ll.next, a->bm);
remove_betw (elm, a->arr[a->arr[elm].ll.next].ll.next, a->arr);
}
void rem_elem_prev (struct ll_all *a, const uint8_t elm)
{
set0b (a->arr[elm].ll.next, a->bm);
remove_betw (a->arr[a->arr[elm].ll.prev].ll.prev, elm, a->arr);
}
Тру-царская неанскилльная реализация двусвязного списка внутри массива.
К сожалению, весь код не помещается, см https://wandbox.org/permlink/Ky8fnuqyE0Ahxftm
0
if($category_id!='')
$this->db->where('group_category =', $category_id);
if($group_by == TRUE)
$this->db->group_by('blog_cat_name');
У меня создалось впечатление, что здесь специально замаскировали все ифы. Чтобы читающий думал, что это линейный код. На скобках - экономят, на пробелах - экономят.
+1
function is_tor_network($ip)
{
$tor = array(
'101.142.102.237' => 1,'101.98.134.31' => 1,'103.246.244.1' => 1,'106.187.34.237' => 1,'106.187.36.183' => 1,'106.187.36.240' => 1,'106.187.37.158' => 1, /* ... Такой длинный код врядли может быть смешным. Пожалуйста, ограничьтесь сотней строк и 6000 символами. */
);
return isset( $tor[$ip]) ? true : false;
}
Почему бы не захардкодить тор?..
+1
// GetBlockingMode возвращает: 1 - nonblocking | 0 - blocking | -1 - error | -2 - timeout reseted!
int GetBlockingMode(int Sock)
{
int iSize, iValOld, iValNew, retgso;
iSize = sizeof(iValOld);
retgso = getsockopt(Sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&iValOld, &iSize); // Save current timeout value
if (retgso == SOCKET_ERROR) return (-1);
iValNew = 1;
retgso = setsockopt(Sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&iValNew, iSize); // Set new timeout to 1 ms
if (retgso == SOCKET_ERROR) return (-1);
// Ok! Try read 0 bytes.
char buf[1]; // 1 - why not :)
int retrcv = recv(Sock, buf, 0, MSG_OOB); // try read MSG_OOB
int werr = WSAGetLastError();
retgso = setsockopt(Sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&iValOld, iSize); // Set timeout to initial value
if (retgso == SOCKET_ERROR) return (-2);
if (werr == WSAENOTCONN) return (-1);
if (werr == WSAEWOULDBLOCK) return 1;
return 0;
}
+3
#include <stdio.h>
main(t,_,a)
char
*
a;
{
return!
0<t?
t<3?
main(-79,-13,a+
main(-87,1-_,
main(-86, 0, a+1 )
+a)):
1,
t<_?
main(t+1, _, a )
:3,
main ( -94, -27+t, a )
&&t == 2 ?_
<13 ?
main ( 2, _+1, "%s %d %d\n" )
:9:16:
t<0?
t<-72?
main( _, t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#;\
#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/+k#;\
q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){nl]!/n{n#'; \
r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c ;;\
{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:
t<-50?
_==*a ?
putchar(31[a]):
main(-65,_,a+1)
:
main((*a == '/') + t, _, a + 1 )
:
0<t?
main ( 2, 2 , "%s")
:*a=='/'||
main(0,
main(-61,*a, "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry")
,a+1);}
виверни свой мозк, бро !