- 1
console.log(24000);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+7
console.log(24000);
0
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Provider } from 'react-redux';
import Store from './src/Store';
import { Header, CryptoContainer, ControlPanel, Homepage } from './src/components';
import Drawer from 'react-native-drawer';
import {
Scene,
Router,
Actions,
Reducer,
ActionConst,
Overlay,
Tabs,
Modal,
Stack,
Lightbox,
} from 'react-native-router-flux';
export default class App extends Component {
constructor(props) {
super(props);
this.state = { isOpen: false };
}
toggleSidebar = () => {
console.debug(this.state.isOpen);
if (this.state.isOpen) {
this._drawer.close();
} else {
this._drawer.open();
}
}
onOpen = () => {
console.debug('onOpen');
this.setState({ isOpen: true });
}
onClose = () => {
console.debug('onClose');
this.setState({ isOpen: false });
}
render() {
// <View>
// <Header toggleSidebar={this.toggleSidebar} />
// <CryptoContainer />
// </View>
return (
<Provider store={Store}>
<View>
<Drawer
content={<ControlPanel />}
ref={(ref) => this._drawer = ref}
openDrawerOffset={100}
onOpen={this.onOpen}
onClose={this.onClose}
openDrawerOffset={0.5}
tapToClose={true}
// open={true}
>
</Drawer>
<View>
<Header toggleSidebar={this.toggleSidebar} />
{/* <CryptoContainer /> */}
</View>
<Router>
<Stack key="root">
<Scene key="homepage" component={Homepage} title="Homepage" />
</Stack>
</Router>
</View>
</Provider>
);
}
}
0
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Provider } from 'react-redux';
import Store from './src/Store';
import { Header, CryptoContainer, ControlPanel, Homepage } from './src/components';
import Drawer from 'react-native-drawer';
import {
Scene,
Router,
Actions,
Reducer,
ActionConst,
Overlay,
Tabs,
Modal,
Stack,
Lightbox,
} from 'react-native-router-flux';
export default class App extends Component {
constructor(props) {
super(props);
this.state = { isOpen: false };
}
toggleSidebar = () => {
console.debug(this.state.isOpen);
if (this.state.isOpen) {
this._drawer.close();
} else {
this._drawer.open();
}
}
onOpen = () => {
console.debug('onOpen');
this.setState({ isOpen: true });
}
onClose = () => {
console.debug('onClose');
this.setState({ isOpen: false });
}
render() {
// <View>
// <Header toggleSidebar={this.toggleSidebar} />
// <CryptoContainer />
// </View>
return (
<Provider store={Store}>
<Drawer
content={<ControlPanel />}
ref={(ref) => this._drawer = ref}
openDrawerOffset={100}
onOpen={this.onOpen}
onClose={this.onClose}
openDrawerOffset={0.5}
tapToClose={true}
// open={true}
>
<View>
<Router>
<Stack key="root">
<Scene key="homepage" component={Homepage} title="Homepage" />
</Stack>
</Router>
</View>
</Drawer>
</Provider>
);
}
}
0
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/9f1b89379a64f87a275f9d932128870a8292fb1e/modules/quoter/models/quote.php
0
<?
if(get($_REQUEST, 'class') && $class = "{$conf['db']['prefix']}{$arg['modpath']}_". ($t = first(explode(" ", $_REQUEST['class'])))){
if($arg['admin_access'] > 1){
mpevent("ajax://{$arg['modpath']}:ajax/class:{$t}", $conf['user']['uid'], $_REQUEST);
$where = array_diff_key($_REQUEST, array_flip(array("class", "m", "null")));
$w = array("time"=>time()) + array_diff_key($_REQUEST, array("id"=>false));
if($arg['admin_access'] >= 2){
if(get($_POST, 'id') < 0){
qw("DELETE FROM {$class} WHERE ". implode(" AND ", array_map(function($k, $v){
return "`$k`=". (is_numeric($v) ? (int)$v : "\"". mpquot($v). "\"");
}, array_keys($where), array_values($where))));
exit("{}");
}elseif(!$fdk = fdk($class, $where, $w = ($where + ($_POST ? $w : [])), $w)){ exit(mpre("Ошибка запроса к БД", $class, $where, $w));
}else{
if(array_key_exists("sort", $fdk) && ($fdk['sort'] == 0)){
$fdk = fdk($class, array("id"=>$fdk['id']), null, array("sort"=>$fdk['id']));
} if($_FILES) foreach($_FILES as $f=>$v){
$file_id = mpfid($class, $f, $fdk['id']);
}elseif($img = get($_POST, $f = 'img')){
$file_id = mphid($class, $f, $fdk['id'], $img);
} exit(json_encode($fdk));
}
}else{
$error = "Прав доступа {$arg['admin_access']} недостаточно для изменения данных";
mpevent("Аякс запрос /{$arg['modpath']}:{$class[0]}", $conf['user']['uid'], $error, $_REQUEST);
exit($error);
}
}else{
$error = "Недостаточно прав доступа";
mpevent("Аякс запрос /{$arg['modpath']}:{$class[0]}", $conf['user']['uid'], $error, $_REQUEST);
exit($error);
}
}else{
$error = "Не указана таблица";
mpevent("Аякс запрос /{$arg['modpath']}:{$class[0]}", $conf['user']['uid'], $error, $_REQUEST);
exit($error);
}
https://github.com/mpak2/mpak.su/blob/master/modules/seo/ajax.php
+1
class UserFixture extends ActiveFixture
{
public function getDataMorozov() {
return $this->getData();
}
protected function getData() {
...
Yii 2 fixtures. Называем костыли правильно
−3
NSString* bodyParams = [NSString stringWithFormat:@"username=%@&password=%@&client_secret=very_secret", username, password];
// Ниже по коду
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[bodyParams dataUsingEncoding:NSUTF8StringEncoding]];
И ведь имя переменной не врёт
0
class NTPTime {
public:
static NTPTime getInvalidTime() { NTPTime t; t.setInvalid(); return t; }
public:
NTPTime() : m_Time(0) {}
NTPTime(const uint64_t time) : m_Time(time) {}
NTPTime(const uint32_t sec, const uint32_t frac)
: m_Time(0)
{
this->set(sec, frac);
}
NTPTime(const boost::posix_time::ptime& timestamp);
public: // Assignment operators
NTPTime& operator=(const uint64_t u) { m_Time = u; return *this; }
NTPTime& operator+= (const NTPTime& Q) { m_Time += Q.m_Time; return *this; }
NTPTime& operator-= (const NTPTime& Q) { m_Time -= Q.m_Time; return *this; }
public: // Cast operators
operator uint64_t() { return this->m_Time; }
public: // comparison operators
bool operator==(const NTPTime& other) const { return (m_Time == other.m_Time); }
bool operator!=(const NTPTime& other) const { return (m_Time != other.m_Time); }
bool operator>=(const NTPTime& other) const { return (m_Time >= other.m_Time); }
bool operator>(const NTPTime& other) const { return (m_Time > other.m_Time); }
bool operator<=(const NTPTime& other) const { return (m_Time <= other.m_Time); }
bool operator<(const NTPTime& other) const { return (m_Time < other.m_Time); }
public: // arithmetic operators
NTPTime operator+(const NTPTime& other) const
{
NTPTime result = *this;
result += other;
return result;
}
NTPTime operator-(const NTPTime& other) const
{
NTPTime result = *this;
result -= other;
return result;
}
public:
uint32_t getSeconds() const { return ((uint32_t)(m_Time >> 32));}
uint32_t getFracSeconds() const { return ((uint32_t)(m_Time & 0xFFFFFFFF));}
uint32_t getMilliseconds() const { const uint64_t t = 1000*m_Time ; return (uint32_t)((t>>32)&0xFFFFFFFF);}
uint32_t getMicroseconds() const { const uint64_t t = 125*m_Time/536871; return (uint32_t)(t&0xFFFFFFFF);}
void getTime_s_us(uint32_t& sec, uint32_t& us) const { sec = getSeconds(); us = getFracSeconds()/4295;}
uint64_t getTime(void) const {return m_Time;}
public:
/// set the time in seconds and microseconds (micros: 0..1000 0000)
///This routine uses the factorization: 2^32/10^6 = 4096 + 256 - 1825/32
void setTime_s_us(const uint32_t sec, const uint32_t us) { m_Time = ((uint64_t)sec<<32) | ((us<<12)-((us*1852)>>5)+(us<<8));}
void set(const uint64_t& u) {m_Time = u;}
void set(const uint32_t sec, const uint32_t frac)
{
m_Time = sec;
m_Time = m_Time<<32;
m_Time |= frac;
}
void setInvalid() { m_Time = uint64_t(NOT_A_DATE_TIME) << 32; }
/// 2^32/10^6 = 4096 + 256 - 1825/32
void setMicroseconds(const uint32_t u) { const uint64_t t = ((uint64_t)u * 1825) >> 5; m_Time = ((uint64_t)u << 12) + ((uint64_t)u << 8) - t;}
void setMicroseconds(const uint64_t u) { const uint64_t t = (u * 1825) >> 5; m_Time = (u << 12) + (u << 8) - t;}
void setMilliseconds(const uint32_t u) { m_Time = (uint64_t)u * 536870912 / 125;}
void addMilliseconds(const uint32_t u) { NTPTime t; t.setMilliseconds(u); *this += t;}
void addMicroseconds(const uint32_t u) { NTPTime t; t.setMicroseconds(u); *this += t;}
protected:
static double round(const double v);
private:
static const double secondFractionNTPtoNanoseconds;
static const double nanosecondsToSecondFractionNTP;
static const uint32_t NOT_A_DATE_TIME;
static const uint64_t NOT_A_DATE_TIME64;
static const boost::posix_time::ptime m_epoch;
protected:
uint64_t m_Time; ///< NTP time in 1/2^32 seconds (~233 ps)
}; // NTPTime
Чуть г-на и несколько комментов удалил, чтоб влезло. Чтоб понятно было, m_Time хранит время в единицах 1/2^32 сек.
+1
// OK
class foo {};
void foo();
// не ОК: error: 'void bar()' redeclared as different kind of symbol
namespace bar {}
void bar();
"Двойные стандарты"
−1
<?php
switch ($type) {
case 'text';
echo 'А вы знали';
break;
case 'number';
echo 'что так можно?';
break;
}