Skip to content

Instantly share code, notes, and snippets.

View f3ath's full-sized avatar
🐴
I am most seriously displeased.

Alexey f3ath

🐴
I am most seriously displeased.
View GitHub Profile
import 'dart:async';
import 'package:rxdart/rxdart.dart';
void main() {
ZipStream([
Stream.fromIterable(<int>[1, 2, 3, 4, 5, 6, 7]),
Stream.periodic(Duration(seconds: 1))
], (_) => _.first).listen(print);
}
def substrings_exist(line, size):
max_possible_offset = len(line) - size * 2
for offset in range(0, max_possible_offset + 1):
border = offset + size
substring = line[offset:border]
the_rest_of_the_string = line[border:]
if the_rest_of_the_string.find(substring) != -1:
return True
return False
@f3ath
f3ath / .Xresources
Last active April 24, 2018 19:24
dotfiles
URxvt.font: -*-terminus-medium-*-*-*-*-180-*-*-*-*-*-*
URxvt.scrollBar: false
URxvt.saveLines: 100000
URxvt.background: black
URxvt.foreground: white
URxvt.termName: xterm
URxvt.transparent: false
Xcursor.size: 16
<?php
class PdoArgs implements IteratorAggregate
{
/**
* @var array
*/
private $state;
public static function factory(string $username = null, string $password = null)
<?php
namespace Foo {
function bar() {
echo 'yo';
}
}
namespace {
function myFunction(callable $c) {
$c();
class IMappable {
}
class MyList<P extends IMappable> {
final List<P> _list;
MyList.fromJson(Map<String, dynamic> json, P func(v))
: _list = new List<P>.from(json.values.map(func));
P operator[] (int index) {
return _list[index];
@f3ath
f3ath / bar.php
Created January 18, 2018 20:39
Local scope in included files
<?php
$foo = require __DIR__ . '/foo.php';
var_dump($foo);
var_dump(isset($innerVar));
<?php
class IntCollection {
private $items = [];
function set(int $a) {
$this->items[] = $a;
}
function sum(): int {
return array_sum($this->items);
}
}
connect() {
return paginaton
.combineLatest(sorting)
.do(table.showSpinner)
map(tableState => AJAX.getPageFromDataSource(...tableState))
.do(table.hideSpinner);
}
<?php
echo "preparing test data file\n";
if (!file_exists('tmp')) {
$s = '';
for ($i = 0; $i < 1000000; $i++) {
$s .= rand() . 'asd';
}
file_put_contents('tmp', $s);
echo "file generated\n";
} else