Skip to content

Instantly share code, notes, and snippets.

@wahengchang
wahengchang / ShareCom.js
Last active April 20, 2022 08:45
Unit test, mocking components
import { InstallCom } from 'installComponent' //installed by npm
import UserCom from './userComponent'
export class ShareCom extends Component {
render() {
return (
<div>
<InstallCom para1='title1'/>
<UserCom para2='title2' />
</div>
@wahengchang
wahengchang / middleware-test.js
Created November 4, 2016 07:03 — forked from CodeVachon/middleware-test.js
express middleware mocha test
var middleware = require('middleware'), // the Middleware you want to test
httpMocks = require('node-mocks-http'), // quickly sets up REQUEST and RESPONSE to be passed into Express Middleware
request = {}, // define REQUEST
response = {} // define RESPONSE
;
describe('Middleware test', function(){
context('Valid arguments are passed', function() {
beforeEach(function(done) {
/*
@wahengchang
wahengchang / .gitignore-for-truffle
Last active October 10, 2021 13:24
This is .gitignore for truffle, fork from openzeppelin-contracts: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/.gitignore
// fork: openzeppelin-contracts
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/.gitignore
*.swp
*.swo
# Logs
logs
*.log
# Runtime data
<?php
/**
* @package Dev-Plugin
* @version 1.7.2
*/
/*
Plugin Name: Dev Plugin
Plugin URI: http://wordpress.org/plugins/hello-dolly/
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
Author: Matt Mullenweg
@wahengchang
wahengchang / customPaymentWooCommercePlugin.php
Last active August 27, 2021 10:10
This is a gist note for myself, and the php plugin is created by Lafif Astahdziq: you can save that code as file and place under wp-content/plugins/
WooCommerce
Asked 8 years, 2 months ago
Active 2 months ago
Viewed 28k times
9
7
I want to add a New Payment Method in WooCommerce.
@wahengchang
wahengchang / repeatLoopUrl.sh
Last active January 8, 2021 02:59
curl url call in for loop
url=https://abc.com
max=999999
for ((i=1;i<=$max;i++)); do curl -v --header "Connection: keep-alive" "$url"; done
@wahengchang
wahengchang / f2e-test-note-2019.03.22.md
Last active March 25, 2019 07:46
f2e-test-note-2019.03.22

Welcome to the Challenge

Goal

Scraping the 1000 data from this site and save it as a json file.

From this site: https://f2e-test.herokuapp.com

Username Password
@wahengchang
wahengchang / fetchMacauNews.js
Created November 25, 2018 04:36
decode html-entities
// example of fetching a
(async function(){
const fetch = require('node-fetch')
const fs = require('fs')
const cheerio = require('cheerio')
const html = await fetch(`http://www.macaodaily.com/html/2018-11/25/node_2.htm`).then(res => res.text())
const path = `./temp/${year}-${month}`
@wahengchang
wahengchang / nest-file-under-directory.js
Last active March 16, 2018 08:38
It is a script of printing and counting specific file under directory
const fs = require('fs');
Array.prototype.remove = function(data) {
const dataIdx = this.indexOf(data)
if(dataIdx >= 0) {
this.splice(dataIdx ,1);
}
return this.length;
}
@wahengchang
wahengchang / gist:a3edb3a6ea7fad13872a021d1c27f706
Created March 6, 2018 09:47 — forked from EvanHahn/gist:2587465
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
* * * * * * * * * * * *
For small occasions (like month-anniversaries), I like to make little websites
for people that only "unlock" on the right day.