Skip to content

Instantly share code, notes, and snippets.

View bor0's full-sized avatar

Boro Sitnikovski bor0

View GitHub Profile
import random
tries = 12345
def calc_days(seeds):
days = 0
trees = 0
while trees <= seeds:
days += 1
for i in range(0, seeds): # for each seed
<?php
$start = microtime( true );
$book_sections = [ '1.0', '1.1', '1.2', '2.0', '2.1', '3.0', '3.1' ];
$groups = array_group_pair( $book_sections, function( $p1, $p2 ) {
return $p1[0] === $p2[0];
} );
$end = microtime( true );
<?php
$array = [
[ 'id' => 1, 'value' => 'foo' ],
[ 'id' => 1, 'value' => 'bar' ],
[ 'id' => 2, 'value' => 'baz' ],
];
$groups = array_group( $array, function( $a, $b ) {
return $a['id'] == $b['id'];
} );
<?php
if ( empty( $argv[2] ) ) {
exit( sprintf( 'Usage: php %s <repo_name:string> <PR#:int>' . PHP_EOL, $argv[0] ) );
}
$repo = $argv[1];
$id = $argv[2];
$token = getenv( 'GH_TOKEN' );
if ( empty( $token ) ) {
@bor0
bor0 / verzii
Last active December 21, 2022 21:26
bor0@bor0:~$ phpcs --version
PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)
bor0@bor0:~$ which phpcs
/Users/bor0/bin/phpcs
bor0@bor0:~$ ls -al ~/bin/phpcs
lrwxr-xr-x 1 bor0 staff 64 Mar 21 2022 /Users/bor0/bin/phpcs -> /Users/bor0/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs
bor0@bor0:~$ cat ~/.composer/composer.json
{
"require": {
"squizlabs/php_codesniffer": "^3.7"
function computation() {
this.red_tree = [];
this.valid = true;
this.add = function (x, y) {
if (!this.valid) return;
var res;
if (typeof x != 'number' || typeof y != 'number') {
this.valid = false;
res = 'error';
} else {
#! /usr/local/bin/glpsol -m
# https://www.youtube.com/watch?v=VHPnuWGprKc
var x1 >= 0;
var x2 >= 0;
maximize obj: x1 + 2 * x2;
c1 : -3 * x1 + x2 <= 2;
<?php
ini_set( 'memory_limit', '4G' );
define( 'GREENHOUSE_USER_ID', getenv( 'GREENHOUSE_USER_ID' ) );
define( 'GREENHOUSE_TOKEN', getenv( 'GREENHOUSE_TOKEN' ) );
function create_curl_handle( $page, $params = array() ) {
$ch = curl_init();
$url = sprintf( 'https://harvest.greenhouse.io/v1/candidates?per_page=500&page=%d', $page );
@bor0
bor0 / class-based.php
Last active January 4, 2024 20:56
IO foldable
<?php
abstract class IO_Foldable {
public function __call( $method, $args ) {
if ( strpos( $method, 'foldable_' ) === 0 ) {
$file = array_shift( $args );
return $this->fold_io( $file, array( $this, substr( $method, 9 ) ), $args );
}
}
protected function fold_io( $file, $foldable, $args = [] ) {
@bor0
bor0 / test.php
Last active April 5, 2020 20:22
Test rlanvin/php-rrule events
<?php
use RRule\RRule;
use RRule\Proxy;
use RRule\Event;
use RRule\ProxyIterator;
require_once( 'vendor/autoload.php' );
$events = array(
[