- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
$phsms = '';
for($p=0;$p<strlen($phonesms);$p++)
if(intval($phonesms[$p]) >= 0) $phsms = $phsms.intval($phonesms[$p]);
preg_match('/.*(9[0-9]{2})([0-9]{7})/', $phsms, $match2);
$phsms = $match2[1].$match2[2];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+141
$phsms = '';
for($p=0;$p<strlen($phonesms);$p++)
if(intval($phonesms[$p]) >= 0) $phsms = $phsms.intval($phonesms[$p]);
preg_match('/.*(9[0-9]{2})([0-9]{7})/', $phsms, $match2);
$phsms = $match2[1].$match2[2];
Валидируем телефоны.
+143
function buildUpdateTimestampTrigger($tableName) {
return
sprintf(
file_get_contents(SQL_FILES_PATH . 'updateTimestamp_PlPg.sql'),
strtolower($tableName) . '_updated'
) .
sprintf(
file_get_contents(SQL_FILES_PATH . 'updateTimestampTrigger.sql'),
$tableName
);
}
+141
private List<string> urls = new List<string>();
private int urls_index = -1;
private ProgressBar pb = new ProgressBar()
{
Width = 291,
Height = 26,
Maximum = 100,
Minimum = 0,
Location = new Point(12, 41)
};
public Object SyncIndex = new Object();
public void DownLoad(object index)
{
int indexwhile = (int) index;
while (work)
{
int localIndex;
lock (SyncIndex)
{
urls_index++;
localIndex = urls_index;
}
WebClient webClient = new WebClient();
try
{
webClient.DownloadFile(new Uri(urls[localIndex]), "img/" + localIndex + ".jpg");
webClient.DownloadProgressChanged += (s, a) => Invoke(new Action(() => {progressBars[indexwhile].Value = a.ProgressPercentage;}));
}
catch (Exception exception)
{
Invoke(new Action(() =>
{
listBox2.Items.Add("Ошибка" + listBox1.Items[localIndex]);
}));
DownLoad(index);
}
Invoke(new Action(() =>
{
listBox1.Items[localIndex] = "Загружен" + listBox1.Items[localIndex];
label1.Text = urls.Count.ToString();
richTextBox1.Text += localIndex + @".jpg Загружен" + Environment.NewLine;
}));
Thread.Sleep(500);
}
}
private void button2_Click(object sender, EventArgs e)
{
work = true;
Thread[] threads = new Thread[30];
for (int i = 0; i < 20; i++)
{
int mnoj = i + 1;
progressBars[i] = new ProgressBar()
{
Width = 291,
Height = 26,
Maximum = 100,
Minimum = 0,
Location = new Point(12, 41)
};
progressBars[i].Location = new Point(12, 41 * mnoj);
Controls.Add(progressBars[i]);
threads[i] = new Thread(DownLoad);
threads[i].IsBackground = true;
threads[i].Start(i);
}
}
И все в одной форме..
+141
<?php
require_once 'db.php';
error_reporting(E_ALL);
//полученный масиф (B!) на предыдущей страницы методом Post
$first_name = filter_input(INPUT_POST, 'first_name');
$email = filter_input(INPUT_POST, 'email');
$phone = filter_input(INPUT_POST, 'phone');//PHONE BLYAD
$text = filter_input(INPUT_POST, 'text');
$date = date("Y-m-d H:i:s");
//Теперь сделаем запрос к базе, который внесет наши данные в таблицу:
$query = $dblink->prepare("INSERT INTO `claims` (`date`,`first_name`, `email`, `phone`, `text`) VALUES (?, ?, ?, ?,?);");
$result = $query->execute (array($date, $first_name, $email, $phone, $text));//MAYBE IT'S CAN RAISE PDOException, see more in documentation
//Если запрос пройдет успешно то в переменную result вернется true
if($result)
{ $URL="http://masterdnepr.dp.ua/";
header ("Location: $URL");
}
else {echo "Ваши данные не добавлены";
}
?>
Вот так заработало
+142
class Ship{
public static void main(String []args){
//бла-бла-бла
String s = Ship.getTp22();
}
String getTp22(){
public String tp22 = "-*";
int v1 = (Math.random(8))+1;
if (v1=1)
{ tp22.charAt(1)="a";}
if (v1=2)
{ tp22.charAt(1)="b";}
if (v1=3)
{ tp22.charAt(1)="c";}
if (v1=4)
{ tp22.charAt(1)="d";}
if (v1=5)
{ tp22.charAt(1)="e";}
if (v1=6)
{ tp22.charAt(1)="f";}
if (v1=7)
{ tp22.charAt(1)="g";}
if (v1=8)
{ tp22.charAt(1)="h";}
if (v1=9)
{ tp22.charAt(1)="i";}
return tp22;
}
}
Гениальный способ генерации строки со случайной буквой.
+142
function cvet(){
var i=Math.ceil(Math.random() *80);
if (i > 0 && i <= 10 ) a = 0;
if (i > 0 && i <= 10 ) b = 0;
if (i > 0 && i <= 10 ) c = 255;
if (i > 0 && i <= 10 ) d = 1;
else
if (i > 10 && i <= 20 ) a = 0;
if (i > 10 && i <= 20 ) b = 0;
if (i > 10 && i <= 20 ) c = 255;
if (i > 10 && i <= 20 ) d = 1;
else
if (i > 20 && i <= 30 ) a = 0;
if (i > 20 && i <= 30 ) b = 255;
if (i > 20 && i <= 30 ) c = 0;
if (i > 20 && i <= 30 ) d = 1;
else
if (i > 30 && i <= 40 ) a = 0;
if (i > 30 && i <= 40 ) b = 255;
if (i > 30 && i <= 40 ) c = 255;
if (i > 30 && i <= 40 ) d = 1;
else
if (i > 40 && i <= 50 ) a = 255;
if (i > 40 && i <= 50 ) b = 0;
if (i > 40 && i <= 50 ) c = 0;
if (i > 40 && i <= 50 ) d = 1;
else
if (i > 50 && i <= 60 ) a = 255;
if (i > 50 && i <= 60 ) b = 0;
if (i > 50 && i <= 60 ) c = 255;
if (i > 50 && i <= 60 ) d = 1;
else
if (i > 60 && i <= 70 ) a = 255;
if (i > 60 && i <= 70 ) b = 255;
if (i > 60 && i <= 70 ) c = 0;
if (i > 60 && i <= 70 ) d = 1;
else
if (i > 70 && i <= 80 ) a = 255;
if (i > 70 && i <= 80 ) b = 255;
if (i > 70 && i <= 80 ) c = 255;
if (i > 70 && i <= 80 ) d = 1;
Целиком: https://jsfiddle.net/allcoma/x85w48Lj/
−401
- (void) doSomething {
<...>
if (error.code != NSURLErrorNotConnectedToInternet && error.code != NSURLErrorCancelled && error.code != NSURLErrorTimedOut) {
@synchronized (self.failedURLs) {
{
// javascript-style...
char* xcEnv = getenv("XcodeColors");
BOOL useColors = (xcEnv && !strcmp(xcEnv, "YES"));
NSString *colorWrapper;
if (useColors)
colorWrapper = @"\033[fg0,153,0;%@\033[;";
else
colorWrapper = @"%@";
void (^colorLog)(NSString *format, ...) = ^(NSString *format, ...)
{
va_list args;
va_start(args, format);
NSLog(colorWrapper, [[NSString alloc] initWithFormat:format arguments:args]);
va_end(args);
};
colorLog(@"SDWebImageManager download failed");
colorLog(@"\turl: %@", url.absoluteString);
colorLog(@"\terror: %@", [error description]);
}
[self.failedURLs addObject:url];
}
}
<...>
}
Когда очень хочется извратиться
+141
$time = htmlspecialchars(addslashes(time()));
Паранойя...
+142
'use strict';
var menuContainers = document.getElementsByClassName('menu__container');
for (var i = 0; i < menuContainers.length; i++) {
menuContainers[i].getElementsByClassName('menu__current')[0].setAttribute('onclick', 'menuOpen(' + i + ')');
}
//Changing visibility all elements of menu
function menuOpen(i) {
menuContainers[i].getElementsByClassName('menu__item')[0].classList.toggle('menu__item--visible');
menuContainers[i].getElementsByClassName('menu__item')[1].classList.toggle('menu__item--visible');
menuContainers[i].getElementsByClassName('menu__item')[2].classList.toggle('menu__item--visible');
menuContainers[i].getElementsByClassName('menu__item')[3].classList.toggle('menu__item--visible');
}
+141
@ResponseBody
public String paymentFeedback(@RequestBody MultiValueMap<String, String> requestParameters, @RequestBody String requestBody) {
boolean isValidRequest = myService.hasRequestValidSHASign(requestParameters);
if (isValidRequest) {
String voucherNumber = findParameter(requestParameters, ORDERID_PARAMETER);
if (!StringUtils.isEmpty(voucherNumber)) {
Order order = orderService.getOrderByVoucherNumber(voucherNumber);
if (order != null) {
String status = findParameter(requestParameters, STATUS_PARAMETER);
if (ACCEPT_STATUS_VALUES.contains(status)) {
updateOrderWithPaymentStatus(order, Status.PAID, requestParameters);
orderService.sendEmail(order);
orderService.sell(order);
} else if (CANCELLED_STATUS_VALUE.equals(status)) {
updateOrderWithPaymentStatus(order, Status.CANCELLED, requestParameters);
} else if (DECLINE_STATUS_VALUES.contains(status)) {
updateOrderWithPaymentStatus(order, Status.DECLINED, requestParameters);
} else if (EXCEPTION_STATUS_VALUES.contains(status)) {
updateOrderWithPaymentStatus(order, Status.EXCEPTION, requestParameters);
} else {
logger.warn("Order ID={} got strange status: {}. Ignoring that feedback...", voucherNumber, status);
}
} else {
throw new IllegalArgumentException("Can't find voucher with orderID from feedback: " + voucherNumber);
}
} else {
throw new IllegalArgumentException("Received feedback with missing orderID: " + requestBody);
}
} else {
throw new IllegalArgumentException("Received feedback with invalid SHA sign: " + requestBody);
}
return "";
}