- 1
var result = IsConnected && dataMax != "" ? true : !IsConnected && dataMin != "" ? true : false;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
var result = IsConnected && dataMax != "" ? true : !IsConnected && dataMin != "" ? true : false;
Обфускация условия говнокодом!
+1
function(t) {
switch (t) {
case 1:
return g.emailNotConfirmed;
case 2:
return g.showCaptcha;
case 3:
return g.authFailed;
case 4:
return g.makeRedirect;
case 5:
return g.reload;
case 6:
return g.mobileActivationRequired;
case 7:
return g.showMessage;
case 8:
return g.showError;
case 9:
return g.votesPayment;
case 10:
return g.zeroZone;
case 11:
case 12:
return Object(g.mobileValidationRequired)(t);
case 13:
return g.evalCode;
case 14:
return g.otpBox;
case 15:
return g.passwordValidationRequired;
default:
return Object(g.defaultHandler)(t)
}
}(t)
https://vk.com/js/cmodules/bundles/common.2ce877ca4bd415d95d03.js?51fe80b96 a07a7861643
#байтоклюйство #спичечная-экономика #олимпиадники #ebivk
+1
```rust
impl actix_web::FromRequest for Token {
type Error = ApiError;
type Future = Pin<Box<dyn Future<Output = Result<Self, Self::Error>>>>;
type Config = ();
fn from_request(req: &actix_web::HttpRequest, _: &mut actix_web::dev::Payload) -> Self::Future {
match req.extensions().get::<Option<Self>>().map(Clone::clone) {
Some(Some(v)) => Box::pin(async { Ok(v) }),
None | Some(None) => {
let header = req.headers().get("Authorization").map(Clone::clone);
Box::pin(
web::Data::<Pool>::extract(req)
.map_err(ApiError::from)
.and_then(move |pool| {
async move {
let header = header.ok_or(ApiError::authorization_required())?;
let auth = header.to_str()?;
let uuid = Uuid::parse_str(auth)
.map_err(|_| ApiError::authorization_bad_token())?;
let (_, token) = Self::find(&uuid, pool.get_conn().await?).await?;
let token = token.ok_or(ApiError::authorization_bad_token())?;
Ok(token)
}
})
.boxed_local()
)
}
}
}
}
Было принято решение создать Authorization middleware, который при каждом запросе авторизировал пользователя, если есть нужный хидер. В связи с тем, что некоторые роуты достают модель через ручной экстрактор, пришлось дописать эту хуйню (Второе условие никогда не будет выполнена вообще судя по всему).
0
https://sun1-93.userapi.com/SSu8G4XtIyohtocFhPi9jy7aPkBla7N_ZPnNdw/z5IDchObVcA.jpg
Тушенка из русни
+1
public function isSpecial()
{
$special_ids = array(
2222,
3028,
3333,
5555,
5702,
6666,
6700,
7654,
7777,
8451,
11225
);
return in_array((int)$this->getId(), $special_ids);
//return $this->getId() == 2222 || $this->getId() == 3028 || $this->getId() == 3333 || $this->getId() == 5555 || $this->getId() == 5702;
}
https://github.com/wiistriker/govnokod_legacy/blob/master/modules/quoter/models/quote.php
Рекурсивный говнокод.
0
import sequtils
when not declared(unzip):
proc unzip*[S, T](s: openArray[(S, T)]): (seq[S], seq[T]) =
result[0] = newSeq[S](s.len)
result[1] = newSeq[T](s.len)
for i in 0..<s.len:
result[0][i] = s[i][0]
result[1][i] = s[i][1]
let a = @[('a', 1), ('b', 2), ('c', 3)]
let b = unzip(a) # version 1.0 will use the proc declared above
# version 1.2 will use sequtils' proc
assert b == (@['a', 'b', 'c'], @[1, 2, 3])
Если в библиотеке нет нужного метода, вы можете написать его сами и кинуть в сторону своих пользователей.
0
https://github.com/boundary/wireshark/blob/master/epan/dissectors/packet-rpc.c
/* compare 2 keys */
static gint
rpc_proc_equal(gconstpointer k1, gconstpointer k2)
{
const rpc_proc_info_key* key1 = (const rpc_proc_info_key*) k1;
const rpc_proc_info_key* key2 = (const rpc_proc_info_key*) k2;
return ((key1->prog == key2->prog &&
key1->vers == key2->vers &&
key1->proc == key2->proc) ?
TRUE : FALSE);
}
+2
> At its core, Swarm implements a distributed content-addressed chunk store.
> Chunks are arbitrary data blobs with a fixed maximum size (currently 4KB).
> Content addressing means that the address of any chunk is deterministically derived from its content.
> The addressing scheme falls back on a hash function which takes a chunk as input and returns a 32-byte long key as output.
> A hash function is irreversible, collision free and uniformly distributed (indeed this is what makes bitcoin, and in general proof-of-work, work).
исключая лишнее
> derived from content
> content = 4KB
> 32-byte output
> collision free!
И еще немного несвежых новостей из мира, где «блокчейн» стал устойчивым синонимом слова «распределенный»
https://blog.ethereum.org/2016/12/15/swarm-alpha-public-pilot-basics-swarm/
+2
// I'm interested in using something other than the C preprocessor to preprocess my C and Objective-C source code. Are there good alternatives?
//
// ---
//
// You can use PHP as a C preprocessor. The advantages are:
//
// - very similiar syntax, so syntax highlighting works.
// - <? and ?> are not used in standard C (with non-standard C, the only thing that gets broken is old GCC extension operator that returns min/max)
// - it's rich in libraries.
// - it's turing complete.
// - usage of macros is very explicit. (compared to sneaky C preprocessor macros)
// For serious use though, making PHP print the #line directives is needed for debugging preprocessed code.
<?php include_once "stdio.h"; ?>
int main()
{
<?php
for($i = 0; $i < 20; $i++)
echo 'printf("%d\n", '.$i.');';
?>
}
https://stackoverflow.com/a/16256052
абсолютно невыносимо
0
public static void ActivateChangeHotKeyButtonModeButtonClick(object sender, EventArgs e)
{
TaskBarHidderForm.ChangeHotKeyPanel.Visible = true;
TaskBarHidderForm.KeyButtons[0].Text = TaskBarHidder.HotKeyCodes[0].ToString();
TaskBarHidderForm.KeyButtons[1].Text = TaskBarHidder.HotKeyCodes[1].ToString();
}
кодить под пивко заебись :)