Skip to content

Instantly share code, notes, and snippets.

🐢
Stepping forward

Bing-Sheng Chen gundamew

🐢
Stepping forward
Block or report user

Report or block gundamew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gundamew
gundamew / helper.php
Last active Sep 27, 2019
Simple helpers to run tasks before/until the deadline.
View helper.php
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);
}
@gundamew
gundamew / checkout-gitlab-merge-request.sh
Created Mar 6, 2019
Checkout GitLab merge request locally.
View checkout-gitlab-merge-request.sh
#!/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 / update.sh
Created Sep 1, 2018
Script to update Homebrew and Composer packages.
View update.sh
#!/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 / restart-docker-containers.sh
Created Aug 16, 2018
Stop , remove, and rebuild Docker containers.
View restart-docker-containers.sh
#!/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 / OpensslAes256.php
Last active Jun 1, 2016
An AES encryption implementation in PHP with OpenSSL module.
View OpensslAes256.php
<?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 / McryptAes256.php
Last active Jun 13, 2016
An AES encryption implementation in PHP with Mcrypt module.
View McryptAes256.php
<?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);
View gist:8416349
我先問在場大家一個小小的問題。可以嗎?
如果你知道有一個人他拿一個大家常在用的軟體來當作己網路 ID
比如說把自己叫 Photoshop、把自己叫 Windows 或是把自己叫 Angry Bird
你會不會覺得他很宅?
一定會對不對?
可是這個軟體是他寫的呢?
大家好我是 PCMan
就是裝在你電腦你桌面上那個可以上 BBS 的電腦軟體 PCMan
View The_Unfollow_Manifesto_zh-TW.md

不想再追蹤了

本文修改自: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.

You can’t perform that action at this time.