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 / index.html
Created June 18, 2021 08:20
index.html redirect template
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0; url=http://your-domain.com/" />
</head>
</html>
@jaredchu
jaredchu / node.js
Created June 6, 2021 08:05
Node.js test index file
const http = require('http');
const hostname = '';
const port = 4000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
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:
@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;
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][
#!/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
@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,
],
[
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>',
) );
<?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));
@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
{