This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']; | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 = [] ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use RRule\RRule; | |
use RRule\Proxy; | |
use RRule\Event; | |
use RRule\ProxyIterator; | |
require_once( 'vendor/autoload.php' ); | |
$events = array( | |
[ |
NewerOlder