- 1
- 2
- 3
- 4
- 5
- 6
- 7
'use strict';
const isOdd = require("is-odd");
module.exports = function isIsOdd(func) {
return func == isOdd;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+4
'use strict';
const isOdd = require("is-odd");
module.exports = function isIsOdd(func) {
return func == isOdd;
}
https://www.npmjs.com/package/is-is-odd
Why
Some functions are not is-odd but they might make you think they're is-odd, this package helps you identify these functions with a simple interface.
Нить бессмысленных npm-модулей.
0
public class Main {
public static void uh() {
try {
} catch (Exception e) {
throw e;
}
}
// <no errors>
public static void oh() {
try {
throw new RuntimeException();
} catch (Exception e) {
throw e;
}
}
// <no errors>
public static void snap() {
try {
throw new Exception();
} catch (Exception e) {
throw e;
}
}
// /tmp/Main.java:8: error: unreported exception Exception; must be caught or declared to be thrown
// throw e;
// ^
// 1 error
}
Где-то посередке между хорошим inference и остутствием интуитивности
+59
std::transform( keyframes.begin(), keyframes.end(), std::back_inserter( result ),
boost::bind( & qMakePair< KeyframeType::first_type, KeyframeType::second_type >,
boost::bind( & Prm::TType::view, _1 ),
boost::bind( & Prm::Time::value, boost::bind( & Prm::TType::time, _1 ) ) ) );
boost bind головного мозга
+128
isParallel :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Bool
isParallel x1 y1 x2 y2 x3 y3 x4 y4 = if (((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)) == 0) then True else False
лаба по хаски
параллельны ли 2 прямые?
+138
Викиучебник по хаскелю такой викиучебник
Задание - написать frequency — функция, возвращающая список пар (символ, частота). Каждая пара определяет атом из заданного списка и частоту его вхождения в этот список.
Решение
frequency :: [a] -> [(a : Integer)]
frequency l = f [] l
f :: [a] -> [a] -> [(a : Integer)]
f l [] = l
f l (h:t) = f (corrector h l) t
corrector :: a -> [a] -> [(a : Integer)]
corrector a [] = [(a : 1)]
corrector a (a:n):t = (a : (n + 1)) : t
corrector a h:t = h : (corrector a t)
Логика-то верна, но код тупо не скомпилится. И как тут быть нубцу?
Задание - Описать следующие классы типов. При необходимости воспользоваться механизмом наследования классов.
Show — класс, объекты экземпляров которого могут быть выведены на экран.
Думаю что-то мегасложное, сделать самому руками show
Решение
class Show a where
show :: a -> String
/-*)
Викиучебник по хаскелю такой викиучебник
0
enum class Measures {
B, KB, MB, GB;
private val size = BigDecimal.valueOf(1024L).pow(ordinal)
companion object {
fun toHumanSize(value: Long): String {
val decValue = value.toBigDecimal()
val measure = values().reversed().find { it.size < decValue } ?: B
return "${decValue.divide(measure.size, 3, RoundingMode.UP)} $measure"
}
}
}
+2
А что Рутубом кто то пользуется ?
http://habrahabr.ru/company/rutube/blog/271143/
+78
wb.getApplication().run(macro, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null);
Использование библиотеки для взаимодействия с мелкософтовскими COM-объектами
+165
function register()
{
if (!empty($_POST)) {
$msg = '';
if ($_POST['user_name']) {
if ($_POST['user_password_new']) {
if ($_POST['user_password_new'] === $_POST['user_password_repeat']) {
if (strlen($_POST['user_password_new']) > 5) {
if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 1) {
if (preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) {
$user = read_user($_POST['user_name']);
if (!isset($user['user_name'])) {
if ($_POST['user_email']) {
if (strlen($_POST['user_email']) < 65) {
if (filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
create_user();
$_SESSION['msg'] = 'You are now registered so please login';
header('Location: ' . $_SERVER['PHP_SELF']);
exit();
} else $msg = 'You must provide a valid email address';
} else $msg = 'Email must be less than 64 characters';
} else $msg = 'Email cannot be empty';
} else $msg = 'Username already exists';
} else $msg = 'Username must be only a-z, A-Z, 0-9';
} else $msg = 'Username must be between 2 and 64 characters';
} else $msg = 'Password must be at least 6 characters';
} else $msg = 'Passwords do not match';
} else $msg = 'Empty Password';
} else $msg = 'Empty Username';
$_SESSION['msg'] = $msg;
}
return register_form();
}
Из рассылки PHPWeekly: "A Clean and Secure Open Source PHP Login Script"
https://github.com/panique/php-login/blob/master/0-one-file/index.php#L98
Что-то уж очень сильно "Clean".
−136
sub parse_http_date($)
{
my ($date)=@_;
my %months=(Jan=>0,Feb=>1,Mar=>2,Apr=>3,May=>4,Jun=>5,Jul=>6,Aug=>7,Sep=>8,Oct=>9,Nov=>10,Dec=>11);
if($date=~/^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$/)
{ return eval { timegm($6,$5,$4,$1,$months{$2},$3-1900) } }
return undef;
}
Вакаба.