Skip to content

Instantly share code, notes, and snippets.

View coffeesam's full-sized avatar
:octocat:
GitHubbing..

Sam Hon coffeesam

:octocat:
GitHubbing..
View GitHub Profile
@coffeesam
coffeesam / resign.sh
Created April 29, 2020 11:22 — forked from RichardBronosky/resign.sh
A simple tool for resigning an iOS app ipa with a new certificate/mobileprovision
#!/usr/bin/env bash
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
# 2nd arg is an existing regular file
-f "$2" &&
# ...and it has an .mobileprovision extension
@coffeesam
coffeesam / paynow.js
Created April 15, 2020 07:10 — forked from chengkiang/paynow.js
SG PayNow QR Code Generator Sample
String.prototype.padLeft = function (n, str) {
if (n < String(this).length) {
return this.toString();
}
else {
return Array(n - String(this).length + 1).join(str || '0') + this;
}
}
function crc16(s) {
background: #fff;
border-radius: 8px;
-webkit-box-shadow: 0 30px 60px -12px rgba(50,50,93,.25), 0 18px 36px -18px rgba(0,0,0,.3), 0 -12px 36px -8px rgba(0,0,0,.025);
box-shadow: 0 30px 60px -12px rgba(50,50,93,.25), 0 18px 36px -18px rgba(0,0,0,.3), 0 -12px 36px -8px rgba(0,0,0,.025);
@coffeesam
coffeesam / checkVersion.js
Created October 29, 2019 03:44
Check Node Version from package.json file vs runtime
// source: https://stackoverflow.com/questions/29349684/how-can-i-specify-the-required-node-js-version-in-package-json
import semver from 'semver';
import { engines } from './package';
const version = engines.node;
if (!semver.satisfies(process.version, version)) {
console.log(`Required node version ${version} not satisfied with current version ${process.version}.`);
process.exit(1);
}
@coffeesam
coffeesam / is-nric.js
Last active June 11, 2018 10:03 — forked from eddiemoore/nric-validation.js
Validation for Singapore NRIC and FIN number
//Based on http://www.samliew.com/icval/
const isNRIC = (str) => {
if (str.length != 9)
return false;
str = str.toUpperCase();
let i;
const icArray = [];
for(i = 0; i < 9; i++) {
#!/usr/bin/env bash
##############################################################################
# MIT License (MIT)
# Copyright © 2017 Silicon Jungles Pte Ltd
#
# git-flow-feature-close: merge squash feature commits to develop.
#
# References:
#
@coffeesam
coffeesam / sanfrancisco-font.css
Created September 19, 2017 07:27
San Francisco Web Font
/**
* http://applemusic.tumblr.com/
* https://jsfiddle.net/xq56dmrh/
*/
/** Ultra Light */
@font-face {
font-family: "San Francisco";
font-weight: 100;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-ultralight-webfont.woff");
@coffeesam
coffeesam / nginx_reload.sh
Created February 14, 2017 06:18
Nginx configuration reload script
#!/usr/bin/env bash
echo
echo Checking Nginx config file...
ERR_MSG=$((sudo nginx -t) 2>&1)
if [ $? -eq 0 ]; then
echo -e "Nginx configuration file test : \e[32mPASSED\e[39m"
sudo nginx -s reload
if [ $? -eq 0 ]; then
echo Nginx configuration reloaded.
else
@coffeesam
coffeesam / create_install.sh
Created October 17, 2016 14:00
Create Mountain Lion Installer
sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mountain\ Lion.app --nointeraction

Keybase proof

I hereby claim:

  • I am coffeesam on github.
  • I am coffeesam (https://keybase.io/coffeesam) on keybase.
  • I have a public key whose fingerprint is 0C5D 71A0 3F72 2CC3 6F6C 3469 2D95 9234 A6B2 EA34

To claim this, I am signing this object: