Skip to content

Instantly share code, notes, and snippets.

View gundamew's full-sized avatar
🐢
Stepping forward

Steven Chen gundamew

🐢
Stepping forward
  • Taipei City, Taiwan
View GitHub Profile

不想再追蹤了

本文修改自:The Unfollow Manifesto

At some point in the past, I've decided to follow you on Twitter or any other social network, because you appeared to be a person whose postings I might be interested in.

我曾經覺得你寫的某些東西很有意思,因此決定在 Twitter,或其他社交網路上追蹤你的狀態。

But recently you noticed me unfollowing you.

我先問在場大家一個小小的問題。可以嗎?
如果你知道有一個人他拿一個大家常在用的軟體來當作己網路 ID
比如說把自己叫 Photoshop、把自己叫 Windows 或是把自己叫 Angry Bird
你會不會覺得他很宅?
一定會對不對?
可是這個軟體是他寫的呢?
大家好我是 PCMan
就是裝在你電腦你桌面上那個可以上 BBS 的電腦軟體 PCMan
@gundamew
gundamew / McryptAes256.php
Last active June 13, 2016 17:31
An AES encryption implementation in PHP with Mcrypt module.
<?php
/**
* An AES encryption implementation in PHP with Mcrypt module.
*
* Key length is 256, CBC mode, and use PKCS#7 padding.
*
* Example:
* $aes = new McryptAes256;
* $encryptedString = $aes->encrypt($rawString);
* $decryptedString = $aes->decrypt($encryptedString);
@gundamew
gundamew / OpensslAes256.php
Last active June 1, 2016 17:34
An AES encryption implementation in PHP with OpenSSL module.
<?php
// Set cipher method
$cipherMethod = 'AES-256-CBC';
// Set encryption key
// The key length must be 256 bits long
$key = (empty($key)) ? openssl_random_pseudo_bytes(32) : '...';
// Set initialization vector
$iv = (empty($iv)) ? openssl_random_pseudo_bytes(openssl_cipher_iv_length($cipherMethod)) : '...';
@gundamew
gundamew / restart-docker-containers.sh
Created August 16, 2018 07:07
Stop , remove, and rebuild Docker containers.
#!/usr/bin/env bash
set -euo pipefail
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images --format "{{.Repository}}" | grep 'bsdock')
[[ -f "$PWD/docker-compose.yml" ]] && docker-compose up -d --build
@gundamew
gundamew / update.sh
Created September 1, 2018 07:12
Script to update Homebrew and Composer packages.
#!/usr/bin/env bash
set -euo pipefail
echo "Updating Homebrew..."
brew update && brew upgrade && brew cleanup
echo "Updating Composer..."
composer self-update --clean-backups && composer g update && composer g dump-autoload
#composer g clear-cache
@gundamew
gundamew / checkout-gitlab-merge-request.sh
Created March 6, 2019 04:08
Checkout GitLab merge request locally.
#!/usr/bin/env bash
set -euo pipefail
# Ref:
# * https://stackoverflow.com/a/44992513
# * https://github.com/jwiegley/git-scripts/blob/master/git-pr
test -z $1 && echo "Merge request number required." 1>&2 && exit 1
git fetch ${2:-origin} merge-requests/$1/head:mr-$1 && git checkout mr-$1
@gundamew
gundamew / helper.php
Last active September 27, 2019 08:51
Simple helpers to run tasks before/until the deadline.
if (! function_exists('stop_before')) {
function stop_before(callable $func, DateTimeInterface $dt)
{
$tz = $dt->getTimezone();
$now = new DateTime('now', $tz);
if ($now > $dt) {
call_user_func($func);
}
<?php
defined( 'ABSPATH' ) || exit;
class WC_REST_API_Key {
// See WC_Auth::create_keys
public static function create( $user_id, $description, $permissions = 'read' ) {
global $wpdb;
@gundamew
gundamew / example.js
Last active January 19, 2021 10:27
IIFE skeleton.
(function($, undefined) {
'use strict';
if (window.className !== undefined) {
return;
}
window.className = {
init: function() {
// code...