This file contains hidden or 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 | |
function get_product_ids() { | |
$output = shell_exec( "vip wp -a woocommerce -e staging -y -- db query \"SELECT id FROM wp_posts WHERE post_type = 'product' AND post_status = 'publish'\" --skip-column-names" ); | |
$output = str_replace( array( '|', '-', '+' ), '', $output ); | |
$lines = explode( "\n", trim( $output ) ); | |
return array_map( 'intval', array_filter( $lines ) ); | |
} | |
function generate_scripts( $ids, $chunks = 2 ) { | |
$ids = array_chunk( $ids, $chunks ); |
This file contains hidden or 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
diff --git a/plugins/gravityforms/gravityforms.php b/plugins/gravityforms/gravityforms.php | |
index c5d619eb68a..7826a2a23b5 100644 | |
--- a/plugins/gravityforms/gravityforms.php | |
+++ b/plugins/gravityforms/gravityforms.php | |
@@ -1262,9 +1262,9 @@ public static function no_conflict_mode_script() { | |
*/ | |
private static function no_conflict_mode( &$wp_objects, $wp_required_objects, $gf_required_objects, $type = 'scripts' ) { | |
- $current_page = trim( strtolower( rgget( 'page' ) ) ); | |
+ $current_page = trim( strtolower( (string) rgget( 'page' ) ) ); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 ); |
NewerOlder