Skip to content

Instantly share code, notes, and snippets.

View JustinTW's full-sized avatar
🎯
Focusing

Justin Liu JustinTW

🎯
Focusing
  • MarsBlockchain
  • Taipei, Taiwan
View GitHub Profile
@JustinTW
JustinTW / CFtoCWLogs.yaml
Created September 13, 2022 02:50
CFtoCWLogs.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Template that will create a Lambda Function to send CF Logs to CloudWatch. Template will create CW Contributor Insight rules, metric filters and a dashboard.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "S3 Logging Location"
Parameters:
@JustinTW
JustinTW / cheatsheets.md
Last active March 31, 2017 01:43
Linux 大量檔案操作 Cheatsheets (最快速的方法蒐集)

產生檔案

產生 1000 個 500kb 的隨機檔案

for i in {1..100000}; do head -c 500 /dev/urandom > dummy$i; done

產生隨機內容大檔案 (1G)

{
"max-line-length": 250,
// list codes for fixes; used by --ignore and --select
"list-fixes": "",
// do not fix these errors / warnings(e.g. E4, W)
"ignore": "E24, E226",
// select errors / warnings(e.g. E4, W)
@JustinTW
JustinTW / login-cht-wifi.sh
Last active April 22, 2024 02:58
Auto login cht-wifi for dd-wrt
#!/bin/sh
# description: check cht-wifi login status, and auto login if no login.
# default script path: /mnt/sda1/mnt/scripts/login-cht-wifi.sh
# author: JustinTWD <justintwd@gmail.com>
# date: 2016/03/12
USERNAME=YOUR_CHT_ACCOUNT
PASSWD=YOUR_CHT_PASSWORD
LOGFILE=/mnt/sda1/log/cht-wifi.log
TMPSESSION=/tmp/cht_session.tmp
@JustinTW
JustinTW / klass.js
Created January 25, 2016 10:05
klass.js
var klass = function (Parent, props) {
var Child, F, i;
// 1.
// new constructor
Child = function () {
if (Child.uber && Child.uber.hasOwnProperty("__construct")) {
Child.uber.__construct.apply(this, arguments);
}
@JustinTW
JustinTW / update.xml
Last active September 18, 2015 05:38
<?xml version="1.0" encoding="UTF-8"?>
<owncloudclient>
<version>2.0.9.0</version>
<versionstring>2.0.9.0</versionstring>
<web>https://drive.hopebaytech.com/downloads/arkease-pro_win.exe</web>
<downloadurl>https://drive.hopebaytech.com/downloads/arkease-pro_win.exe</downloadurl>
</owncloudclient>
@JustinTW
JustinTW / client.js
Last active August 29, 2015 14:02
udp multicast test
var PORT = 8088;
var HOST = '192.168.67.91';
var dgram = require('dgram');
var client = dgram.createSocket('udp4');
client.on('listening', function () {
var address = client.address();
console.log('UDP Client listening on ' + address.address + ":" + address.port);
client.setBroadcast(true)
client.setMulticastTTL(128);
@JustinTW
JustinTW / Vagrant.rb
Last active August 29, 2015 14:02
vagrant + docker + puppet
Vagrant.configure("2") do |config|
# define dev_docker for web development
config.vm.define "dev_docker" do |dkr|
dkr.vm.provider "docker" do |d|
d.cmd = ["/sbin/my_init", "--enable-insecure-key"]
d.image = "phusion/baseimage"
d.has_ssh = true
end
dkr.ssh.username = "root"
dkr.ssh.private_key_path = "deploy/docker/phusion.key"
@JustinTW
JustinTW / Docker-Cheatsheets.md
Last active May 25, 2017 08:23
Docker Cheatsheets

Clean all

docker stop `docker ps -a -q` 
docker rm `docker ps -a -q` 
docker rmi -f `sudo docker images -q`
docker volume rm $(docker volume ls -f dangling=true -q)

Clean image

@JustinTW
JustinTW / zh-TW.inc.php
Last active December 19, 2015 14:58
Self Service Password 中文化
<?php
#==============================================================================
# LTB Self Service Password
#
# Copyright (C) 2009 Clement OUDOT
# Copyright (C) 2009 LTB-project.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2