- 1
- 2
- 3
- 4
- 5
- 6
string Char2Hex(char ch)
{
StringWriter w = new StringWriter();
w.Write("\\u{0:x4}", (int)ch);
return w.ToString();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−320
string Char2Hex(char ch)
{
StringWriter w = new StringWriter();
w.Write("\\u{0:x4}", (int)ch);
return w.ToString();
}
+366
var organizations =
test.ExtensionInformation.Cast<object>()
.Select(ext => ext as GenericPair<string, string>)
.Where(pair => pair.first == "{$idSenderOrganization}")
.Where(pair =>
{
int o_O;
return int.TryParse(pair.second, out o_O);
})
.Select(_ => int.Parse(_.second));
+262
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define e if
#define h while
#define s return
#define v NULL
#define r else
#define u case
#define C switch
#define D for
#define L0 typedef
#define L int
L0 char S;L0 S*Z;L0 Z*U;L0 double N;
L0 struct Q{L Z;union{N b;S c;}M;struct Q*w;struct Q*q;}Q;
Q*K(L w){Q*n=(Q*)malloc(sizeof(Q));e(v==n)exit(1);n->Z=w;s n;}
void A(Z g,U t){h(' '==*g)g++;*t=g;}
Q*V(Z g,U t){Q*n=K(2);n->M.b=strtod(g,t);s n;}
Q*I(Z g,U t){e('+'!=*g)s v;Q*n=K(1);n->M.c='+';++*t;s n;}
Q*W(Z g,U t){e('x'!=*g)s v;Q*n=K(20);g++;e(*g<'0'||*g>'9'){n->M.b=1;*t=g;}r{n->M.b=strtod(g,t);e(*t==g)n->M.b=1;}s n;}
Q*J(Z g,U t){Q*n,*p=v;h(*g){A(g,&g);Q*l=V(g,&g);A(g,&g);Q*m=W(g,&g);Q*o;e(v==m)o=l;r{o=K(1);o->M.c='*';o->w=l;o->q=m;}e(v==p)n=o;r{p->w=n;p->q=o;n=p;}A(g,&g);p=I(g,&g);e(v==p){*t=g;s n;}}}
Q**E(Z g){L n=1,i;Z t=g;h(*t){e(';'==*t)n++;t++;}Q**R=(Q**)malloc((n+1)*sizeof(Q*));e(v==R)s v;D(i=0;i<n;++i){R[i]=J(g,&g);e(*g!=';'&&*g!=0)s v;e(v==R[i])s v;g++;}R[n]=v;s R;}
N P(Q*I,N a){C(I->Z){u 1:C(I->M.c){u '+':s P(I->w,a)+P(I->q,a);u '*':s P(I->w,a)*P(I->q,a);u '/':s P(I->w,a)/P(I->q,a);u '-':s P(I->w,a)-P(I->q,a);}u 2:s I->M.b;u 20:s pow(a,I->M.b);}}
N O(Q*I){N x=0,y=1,z=2,Z=P(I,x),X=P(I, y),H=P(I,z),j=1e-10;L i;D(i=0;i<100&&fabs(z-y)>j&&fabs(x-y)>j&&fabs(X)>j;i++){e(Z*X<0){z=y;H=X;}r e(H*X<0){x=y;Z=X;}r{N d=z-x;x=x-d;z=z+d;Z=P(I,x);X=P(I,y);}y=(z+x)/2;X=P(I,y);}s y;}
Z B(Q**A){L n=0,i,j,d=0;D(;A[n]!=v;n++);Z M=(Z)malloc(n*10+1);e(v==M)s v;D(i=0;A[i]!=v;i++)D(j=0;j<10;j++){
M[i*10+j-d]=(S)fmod(12.51*O(A[i])+j*17,256);
e(!M[i*10+j-d])d++;}M[n*10-d]=0;s M;}
L T(Z g,Z M){Z k=M;h(*g){*g++^=*k++;e(!*k)k=M;}s(0);}
L main(void){
Q**n=E("2.0x5+6.2x2+7;0.3x6.1+6x5+1");
L i;
Z k=B(n);
S w[]={-91,-35,97,113,89,37,113,32,28,-10,124,67,93,32,123,70,63,-19,-71,-123,-114,45,109,64,96,57,13,7,-91,0};
T(w,k);
printf("%s\n",w);
}
+313
<?php
use PHPUnit\Framework\TestCase;
class SecurityTokenTest extends TestCase
{
/**
* @dataProvider getData
*/
public function testGetCookieToken($user, $token, $result)
{
$reflect = new \ReflectionClass('AppBundle\Security\TokenCookieStorage');
/** @var TokenCookieStorage $storage */
$storage = $reflect->newInstanceWithoutConstructor();
$reflect->getProperty('abstractUser')
->setValue($storage, $user);
$reflect->getProperty('cookieDriver')
->setValue($storage, new class($token) {
public $token;
public function __construct($token)
{
$this->token = $token;
}
public function get($id)
{
return ($id) ? $this->token : null;
}
});
$this->assertSame($storage->getToken(), $result);
}
....
PHPUnit. Тяжело написать тесты для говнокода. Чувак не слышал про mockbuilder
+314
<?php
require 'classes/_func.class.php';
$func = new func();
if($_SESSION['user']){
$user_id = func::clear($_SESSION['user'],'int');
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
$db->Query("UPDATE users SET last = '{$time}', ip = '{$ip}' WHERE id = '{$user_id}'");
function stockGen($user_id){
global $db;
$db->Query("SELECT * FROM users WHERE id = '{$user_id}'");
$user_data = $db->FetchArray();
$db->Query("SELECT * FROM users_conf WHERE user_id = '{$user_id}'");
$sub_data = $db->FetchArray();
$data = array_merge($user_data,$sub_data);
$day = time() - 86400;
$db->Query("SELECT
(SELECT ref_1 FROM users_ref WHERE user_id = '{$user_id}') ref_id,
(SELECT COUNT(*) FROM banner_history WHERE user_id = '{$user_id}') banner_views,
(SELECT COUNT(*) FROM link_history WHERE user_id = '{$user_id}') link_views,
(SELECT COUNT(*) FROM users_ref WHERE ref_1 = '$user_id') referals,
(SELECT time FROM auth WHERE user_id = '{$user_id}' ORDER BY id DESC LIMIT 1) last_auth,
(SELECT SUM(money) FROM payments WHERE user_id = '{$user_id}' AND status = '2') pay,
(SELECT SUM(money) FROM inserts WHERE user_id = '{$user_id}' AND status = '2') ins,
(SELECT SUM(to_ref_1) FROM users_ref WHERE ref_1 = '{$user_id}') from_refs_1,
(SELECT SUM(to_ref_2) FROM users_ref WHERE ref_2 = '{$user_id}') from_refs_2,
(SELECT SUM(to_ref_3) FROM users_ref WHERE ref_3 = '{$user_id}') from_refs_3,
(SELECT to_ref_1 FROM users_ref WHERE user_id = '{$user_id}') to_ref");
$data += $db->FetchArray();
$data['from_refs'] = sprintf('%.2f',$data['from_refs_1'] + $data['from_refs_2'] + $data['from_refs_3']);
$data['all_view'] = intval($data['banner_views']) + intval($data['link_views']);
$data['all_money'] = 0;/*sprintf('%.2f',(floatval($data['link_money']) + floatval($data['banner_money']) + floatval($data['mails_money'])))*/
$data['all_money_day'] = 0;/*sprintf('%.2f',(floatval($data['link_money_day']) + floatval($data['banner_money_day']) + floatval($data['mails_money_day'])))*/
$ref_id = $data['ref_id'];
if ($ref_id != '0') {
$db->Query("SELECT login FROM users WHERE id = '{$ref_id}'");
$data['referer'] = $db->FetchRow();
}else $data['referer'] = 'Пришел сам';
$db->Query("SELECT * FROM auth WHERE user_id = '{$user_id}' ORDER BY time DESC LIMIT 10");
if ($db->NumRows() > 0) {
$data['auth_history'] = $db->FetchAll();
}else $data['auth_history'] = '0';
new gen('account/account',$data);
}
if(isset($url[2]) && !empty($url[2])){
$ctrl = $func->clear($url[2]);
$file = 'controllers/account/'.$ctrl.'Ctrl.php';
if(file_exists($file)){
include $file;
}else stockGen($user_id);
}else stockGen($user_id);
}else header('location: /login');
// (SELECT SUM(money) FROM banner_history WHERE user_id = '{$user_id}') banner_money,
// (SELECT SUM(money) FROM link_history WHERE user_id = '{$user_id}') link_money,
// (SELECT SUM(money) FROM mails_history WHERE user_id = '{$user_id}') mails_money,
// (SELECT SUM(money) FROM link_history WHERE user_id = '{$user_id}' AND time > '{$day}') link_money_day,
// (SELECT SUM(money) FROM banner_history WHERE user_id = '{$user_id}' AND time > '{$day}') banner_money_day,
// (SELECT SUM(money) FROM mails_history WHERE user_id = '{$user_id}' AND time > '{$day}') mails_money_day,
источник: https://toster.ru/q/346342
−677
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let rootViewController = LAMainViewController(nibName: nil, bundle: nil)
let navigationController = LANavigationController()
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [UIColor.blackColor().CGColor, UIColor(hexString: "330033", alpha: 1)!.CGColor]
gradientLayer.locations = [0, 1]
gradientLayer.frame = window!.frame
navigationController.viewControllers = [rootViewController]
window!.rootViewController = navigationController
window!.makeKeyAndVisible()
window!.layer.insertSublayer(gradientLayer, atIndex: 0)
return true
}
давайте слой зафигачим на окно
+317
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_company_id = '" . $this->db->escape($data['payment_company_id']) . "', payment_tax_id = '" . $this->db->escape($data['payment_tax_id']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($payment_country) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($payment_zone) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($payment_address_format) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($shipping_country) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($shipping_zone) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($shipping_address_format) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', order_status_id = '" . (int)$data['order_status_id'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");
Строчечка
+318
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char, Allocator>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char, Allocator>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericStringView<Char>&&, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericStringView<Char>&, const GenericString<Char, Allocator>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<GenericString<Char, Allocator>&&, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, GenericStringView<Char>> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, GenericStringView<Char>&&> {typedef GenericString<Char, Allocator> _;};
template<typename Char, typename Allocator> struct CommonTypeRef<const GenericString<Char, Allocator>&, const GenericStringView<Char>&> {typedef GenericString<Char, Allocator> _;};
Кто-нибудь знает, как сократить этот комбинаторный взрыв частичных специализаций без макросов?
+362
http://www.crunchzilla.com/code-maven
Визуальная новелла по манге JS
+267
//форма собственности
$('#sobst').change(function(){
var $radiouch = $('#uchred1, #uchred2');
var valip = 'ИП';
var $ip = $('#ip').attr('id');
var $obsch = $('.obschestvo').attr('class');
var $obsch2 = $('.obschestvo2').attr('class');
if($('option:selected', this).attr('id')==$ip){
$tab24.fadeOut(500);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
$novalid.removeAttr('required');
}
if($('option:selected', this).attr('class')==$obsch){
if($('#i').prop("checked")){
$tab24.fadeOut(500);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
$novalid.removeAttr('required');
}
else{
$tab24.fadeIn(1000);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('disabled').removeClass('err').attr('required','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
$novalid.removeAttr('required');
}
}
if($('option:selected', this).attr('class')==$obsch2){
if($('#i').prop("checked")){
$tab24.fadeOut(500);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
}
else{
$tab24.fadeIn(1000);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('disabled').removeClass('err').removeAttr('required','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
}
}
});
//Выбор учредителя
$('#uchrdiv1').find("input[type='radio']").click(function(){
var $dopuchr = $('#Familia, #Imia, #Otchestvo, #Dola');
var $uchr2elem = $('#uchrdiv2').find('input[type!=button][type!=submit][type!=radio], select, #Opis');
var $rad = $(this).attr('id');
if($rad==$('#uchred2').attr('id')){
$("#labfio").text("Форма собственности *");
$("#labname").text("Наименование *");
$("#labsur").text("УНП *");
$("#zagolovok").text("Наименование учредителя *");
$uchr2elem.removeAttr('required').removeClass('err').attr('disabled','');
$('#surname1').attr('required','');
$('#uchred1').removeClass('err');
$dopuchr.removeAttr('required');
}
else {
$("#labfio").text('Фамилия *');
$("#labname").text("Имя *");
$("#labsur").text("Отчество");
$("#zagolovok").text("Ф.И.О учредителя в именительном падеже *");
$uchr2elem.removeAttr('disabled').attr('required','').val('');
$('#table2').find('input[type!=radio]').removeAttr('disabled').attr('required','');
$('#surname1, #pomeschenieNum3').removeAttr('required','');
$('#uchred2').removeClass('err');
$dopuchr.removeAttr('required');
}
});
//Способ получения
$('.forms5').find("input[type='radio']").click(function(){
var $grd = $('#grd').find('input[id!=pomeschenieNum6], select');
var $ofs = $('#ofs').find('input, select');
var $posrad = $(this).attr('id');
if($posrad==$('#Ofis').attr('id')){
$grd.removeAttr('required').removeClass('err').attr('disabled','').val('');
$ofs.removeAttr('disabled').attr('required','').val('');
$('#Viezd').removeAttr('required').removeClass('err');
$('#Ofis').attr('required');
}
if($posrad==$('#Viezd').attr('id')){
$ofs.removeAttr('required').removeClass('err').attr('disabled','').val('');
$grd.removeAttr('disabled').attr('required','').val('');
$('#Ofis').removeAttr('required').removeClass('err');
$('#Viezd').attr('required');
}
});
//кнопка submit
$('#otpravit').on({
mousedown: function(){
$(this).css('background','linear-gradient(to bottom right, #D77024, #E49656)');
},
mouseup: function(){
$(this).css('background','linear-gradient(to bottom right, #EC841C, #EDA24E)');
страница с формами
название файла (ВНИМАНИЕ!): dubische_gaz