Skip to content

Instantly share code, notes, and snippets.

View jaredchu's full-sized avatar
🏠
Working from home

Jared Chu jaredchu

🏠
Working from home
View GitHub Profile
@jaredchu
jaredchu / script.php
Created June 2, 2017 04:55
Packagist fake download number
// Usage
// php script.php vendor/package [download-number]
if (!isset($argv[1])) {
die("Missing package name\n");
}
if (!isset($argv[2])) {
die("Missing download times\n");
}
@jaredchu
jaredchu / keybase.md
Last active September 15, 2019 05:39

Keybase proof

I hereby claim:

  • I am jaredchu on github.
  • I am jaredchu (https://keybase.io/jaredchu) on keybase.
  • I have a public key whose fingerprint is 7D45 3874 668F 9B8B 1C5C 0C6C 351C EB42 9280 9AD8

To claim this, I am signing this object:

@jaredchu
jaredchu / Node.php
Last active August 31, 2017 06:30
Binary Search Tree example in PHP
<?php
/**
* Created by PhpStorm.
* User: jaredchu
* Date: 31/08/2017
* Time: 11:40
*/
class Node
{
<?php
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d %d",$n,$k);
$a_temp = fgets($handle);
$a = explode(" ",$a_temp);
array_walk($a,'intval');
function rotate_left($arr, $k){
$left = array_reverse(array_slice($arr,0,$k));
the_reverse_post_navigation( array(
'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
) );
@jaredchu
jaredchu / Input
Last active June 8, 2018 03:12
Convert flat tree to tree
[
[
'id' => 1,
'name_lv1' => 'Parent0',
'name_lv2' => null,
'name_lv3' => null,
'name_lv4' => null,
'name_lv5' => null,
],
[
#!/bin/sh
### BEGIN INIT INFO
# Provides: ProviderName
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: Short description
# Description: Long Description
require(['jquery'], function($){ function Matrix(){}var Sylvester={version:"0.1.3",precision:1e-6};Matrix.prototype={dup:function(){return Matrix.create(this.elements)},canMultiplyFromLeft:function(e){var t=e.elements||e;return t[0][0]===void 0&&(t=Matrix.create(t).elements),this.elements[0].length==t.length},multiply:function(e){var t=e.modulus?!0:!1,n=e.elements||e;if(n[0][0]===void 0&&(n=Matrix.create(n).elements),!this.canMultiplyFromLeft(n))return null;var r,o,a,i,s,l,u=this.elements.length,c=u,f=n[0].length,m=this.elements[0].length,d=[];do{r=c-u,d[r]=[],o=f;do{a=f-o,i=0,s=m;do l=m-s,i+=this.elements[r][l]*n[l][a];while(--s);d[r][a]=i}while(--o)}while(--u);return n=Matrix.create(d),t?n.col(1):n},isSquare:function(){return this.elements.length==this.elements[0].length},toRightTriangular:function(){var e,t,n,r,o=this.dup(),a=this.elements.length,i=a,s=this.elements[0].length;do{if(t=i-a,0===o.elements[t][t])for(j=t+1;i>j;j++)if(0!==o.elements[j][t]){e=[],n=s;do r=s-n,e.push(o.elements[t][r]+o.elements[j][
@jaredchu
jaredchu / Save.php
Last active March 28, 2023 19:23
app/code/Amasty/Feed/Controller/Adminhtml/Feed/Save.php
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Feed
*/
namespace Amasty\Feed\Controller\Adminhtml\Feed;
var results = [];
$('#speedtest_v4 tr').each(function (){
var i = 0;
var name;
var ip;
var link100;
var link1000;
$(this).find('td').each(function (){
switch(i) {
case 0: