- 1
- 2
- 3
- 4
- 5
https://ru.wikipedia.org/wiki/Деление_с_остатком#В_программировании
Смотрим табличку справа.
Именно поэтому я против PHP
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
https://ru.wikipedia.org/wiki/Деление_с_остатком#В_программировании
Смотрим табличку справа.
Именно поэтому я против PHP
0
from xml.sax.saxutils import unescape
HEADERS = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3'}
GOOGLE_RE = re.compile(r'<h3 class="r"><a href="([^"]+)" ')
YANDEX_RE = re.compile(r'<span class="serp-url__mark">.</span><a class="link serp-url__link" target="_blank" href="([^"]+)"')
PROXY_RE = re.compile(r'(\d+\.\d+\.\d+\.\d+)[:\s]+(\d+)')
def search_google(requests_list, qdr=None, interval=2):
res = []
qdr = 'd' if qdr is None or not qdr in ['w', 'd'] else qdr
REQ_FORMAT = 'https://www.google.com/search?q={0}&num=100&tbs=qdr:' + qdr
i = 0
for term in requests_list:
req = REQ_FORMAT.format(term)
response = requests.get(req, headers=HEADERS)
if response.status_code != 200:
print ('Google returned {0}'.format(response.status_code))
time.sleep(interval)
continue
txt = response.text
found = GOOGLE_RE.findall(txt)
res += found
print ('done term {0}, found {1} URLs'.format(i, len(found)))
i += 1
time.sleep(interval)
map(unescape, res)
return res
Древняя граббилка открытых прокси при помощи поисковых систем. Когда-то даже работала.
+1
<?php
$fin = fopen($argv[1], 'r');
if($fin === false) die();
$fout = fopen('dump.csv', 'w');
if($fout === false) die();
while(!feof($fin)) {
$rawline = fgets($fin);
if(!preg_match('#\[+(.*)\]+,?#', $rawline, $matches)) continue;
$fields = str_getcsv($matches[1]);
$parts = explode(')', $fields[0]);
if(count($parts) < 2) continue;
list($host, $path) = $parts;
$domains = explode(',', $host);
$dirs = explode('/', $path);
if($domains[0] === 'ru' && $domains[1] === 'mail') {
$email = $dirs[2] . '@' . $dirs[1] . '.ru';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
} else if($domains[0] === 'ru' && $domains[1] === 'rambler' && $dirs[1] = 'users') {
if(strpos($dirs[2], '@') === false) {
$email = $dirs[2] . '@rambler.ru';
} else {
$email = $dirs[2];
}
$hash = md5($email);
fputcsv($fout, array($hash, $email));
} else if($domains[0] === 'ru' && $domains[1] === 'ya') {
$email = $domains[2] . '@yandex.ru';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $domains[2] . '@yandex.by';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $domains[2] . '@yandex.ua';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $domains[2] . '@yandex.kz';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $domains[2] . '@yandex.com';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $domains[2] . '@ya.ru';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
} else if($domains[0] === 'ru' && $domains[1] === 'yandex' && $dirs[1] = 'users') {
$email = $dirs[2] . '@yandex.ru';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $dirs[2] . '@yandex.by';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $dirs[2] . '@yandex.ua';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $dirs[2] . '@yandex.kz';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $dirs[2] . '@yandex.com';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
$email = $dirs[2] . '@ya.ru';
$hash = md5($email);
fputcsv($fout, array($hash, $email));
}
}
fclose($fout);
fclose($fin);
Генератор радужных таблиц для е-мейлов.
Особенность программы в том, что «JSON» парсится как «CSV» в целях экономии оперативки.
−8
#include <iostream>
using namespace std;
int_main()
{
double a, c;
char b;
cout << "Enter the example: ";
cin >> a, b, c;
if (b == '+')
{
cout << a+c;
}
if (b == '-')
{
cout << a-c;
}
if (b == '*')
{
cout << a*c;
}
if (b == '/')
{
cout << a/c;
}
return 0;
}
Почему не работает парню на SO так и не ответили...
−98
Давайте рисовать кривые Безьё.
0
var infScroll = throttle(function() {
if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
$scope.loadMoreResults();
}
}, 1500);
var infScrollListener = function(ev) {
if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
infScroll();
}
};
window.addEventListener('scroll', infScrollListener);
$scope.$on('$destroy', function() {
infScroll.cancel();
window.removeEventListener('scroll', infScrollListener);
});
Какой бесконечный скроллинг )))
0
var a = ['a', 'b', 'c'];
var b = ['d', 'e', 'f'];
b.forEach(item => a.push(item)); // a == ["a", "b", "c", "d", "e", "f"]
// Но:
var a = ['a', 'b', 'c'];
var b = ['d', 'e', 'f'];
b.forEach(a.push.bind(a)); // a == ["a", "b", "c", "d", 0, Array(3), "e", 1, Array(3), "f", 2, Array(3)]
Кто поймёт, что за хуйня, тому нихуя.
+2
public void addDisplayMethodNoAttribute()
{
addHeaderMethod();
pyScript.append("def doPrint(row, columns):\n");
pyScript.append(" line=\"\"\n");
pyScript.append(" for column in columns:\n");
pyScript.append(" if(line == \"\"):\n");
pyScript.append(" line = line + str(row[column])\n");
pyScript.append(" else:\n");
pyScript.append(" if(column == \"translations\"):\n");
pyScript.append(" line = line + separator+ \"[\"\n");
pyScript.append(" buf = \"\"\n");
pyScript.append(" for item in row[column]:\n");
pyScript.append(" if(buf != \"\"):\n");
pyScript.append(" buf = buf + \", \"\n");
pyScript.append(
" buf = buf + \"[\" + str(item[\"source\"]) + \", \" + item[\"code\"] + \", \" + item[\"comment\"] + \"]\"\n");
pyScript.append(" line = line + buf + \"]\"\n");
pyScript.append(" else:\n");
pyScript.append(" line = line + separator + str(row[column])\n");
pyScript.append(" print(line)\n");
pyScript.append("\n");
pyScript.append("list = df.collect()\n");
pyScript.append("for row in list:\n");
pyScript.append(" doPrint(row, df.columns)\n");
pyScript.append("\n");
addSessionDestroy();
generatePySparkScript();
}
Мне пытались объяснить что так лучше из-за того что не все люди знают питон, и из-за этого будем генерить его в Java.
0
#include "pch.h"
#include <iostream>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
setlocale(0, "rus");
int a[100], min = 0, sum=0, n, k=0;
double sr;
cout << "введите количество элементов массива: "; cin >> n;
cout << "\n---элементы массива должны быть ЦЕЛЫМИ---\n\n";
for (int i = 0; i < n; i++) {
cout << "a[" << i + 1 << "] = "; cin >> a[i];
if (a[i] > 0) {
k++;
sum += a[i];
}
else {
if (a[i] < min) min = a[i];
}
}
sr = (double)sum / k;
cout << "произведение минимального среди отрицательных (" << min << ") на среднее арифметическое всех положительных (" << sr << ") равно: " << min * sr;
_getch();
return 0;
}
Произведение минимального среди отрицательных на среднее арифметическое всех положительных.
+1
public class Main {
public static void main(String[] args) {
ThreeD[] f = {new ThreeD(5, 9, 7), new FourD(1,3,8,5)};
Coords<ThreeD> c = new Coords<>(f);
showXYZ(c);
FiveD[] x = new FiveD[] {new FiveD(11,22,3,4, 123)};
Coords<FiveD> b = new Coords<>(x);
showAll(b);
FiveD[] z = new FiveD[] {new FiveD(1,2,1,6,5)};
Coords<FiveD> zz = new Coords<>(z);
}
private static void showXY(Coords<? super FourD> c) {
for(int i = 0; i < c.coords.length; i++) {
System.out.println(c.coords[i].x +" "+ c.coords[i].y+" ");
}
}
private static void showXYZ(Coords<? extends ThreeD> c) {
for(int i = 0; i < c.coords.length; i++) {
System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" ");
}
}
private static void showAll(Coords<? extends FiveD> c) {
for(int i = 0; i < c.coords.length; i++) {
System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" "+c.coords[i].t+" "+c.coords[i].m);
}
}
}
class Coords<T extends TwoD> {
T[] coords;
Coords(T[] o) {
coords = o;
}
}
class TwoD {
int x,y;
TwoD(int a, int b) {
x = a;
y = b;
}
}
class ThreeD extends TwoD {
int z;
ThreeD(int a, int b, int c) {
super(a, b);
z = c;
}
}
class FourD extends ThreeD {
int t;
FourD(int a, int b, int c, int d) {
super(a, b, c);
t = d;
}
}
class FiveD extends FourD {
int m;
FiveD(int a, int b, int c, int d, int e) {
super(a, b, c, d);
m = e;
}
}
говнецо или нет