Skip to content

Instantly share code, notes, and snippets.

View zmax's full-sized avatar
🇹🇼

Starck Lin zmax

🇹🇼
View GitHub Profile
@zmax
zmax / features.js
Last active February 25, 2020 15:02
Mixin Decorator
const features = (...features) => BaseClass =>
features.forEach(feature => {
for (const methodName of Object.getOwnPropertyNames(feature)) {
if (BaseClass.prototype.hasOwnProperty(methodName)) {
throw Error(
`Method <${methodName}> in <${BaseClass.name}> exists in a feature.`
);
}
}
@zmax
zmax / generateCert.sh
Last active November 27, 2018 15:30
Generating a self-signed cert on macOS
#!/bin/bash
HOST=${1}
mkdir -p ~/.ssl
# generate cert and key
openssl req -newkey rsa:2048 -x509 -nodes -keyout ~/.ssl/$HOST.key -new -out ~/.ssl/$HOST.crt -subj /CN=$HOST -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:${HOST}")) -sha256 -days 3650
# add to keychains
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.ssl/${HOST}.crt
@zmax
zmax / deleteBackups.sh
Last active November 9, 2015 20:06
Delete timemachine backups
#!/bin/bash
BACKUP_PATH=/Volumes/WD-BACKUP-DUO/Backups.backupdb/xx/$1*
echo "want to delete: $1";
for i in $BACKUP_PATH ;
do
echo "$i";
done
@zmax
zmax / nginx
Last active August 29, 2015 14:19
craft cms nginx conf
server {
listen 80;
server_name domain.com;
root /var/www/domain.com/public;
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript image/svg+xml text/xml text/css;
@zmax
zmax / field1.blade.php
Last active August 29, 2015 14:08
Nested section (blade template)
@section('css')
<link rel="stylesheet" href="css/field1.css" />
@parent
@stop
@section('js')
<script src="js/field1.js"></script>
@parent
@stop
@zmax
zmax / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zmax
zmax / bootstrap3.index.html
Created August 2, 2013 09:03
Bootstrap3 101 Template
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Bootstrap -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">
</head>
<body>
@zmax
zmax / EventUtil.js
Last active December 20, 2015 12:18
EventUtil
var EventUtil = {
addHandler: function(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else if ( element.attachEvent ) {
element.attachEvent("on" + type, handler);
} else {
element["on"+type] = handler;
}
@zmax
zmax / mvim
Created June 30, 2013 09:13
MacVim Script
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
#
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).
@zmax
zmax / llcmd.sublime-snippet
Created June 22, 2013 17:10
sublime laravel custom command template
<snippet>
<content><![CDATA[
namespace ${1:Vendor}\\${2:Package};
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ${2:Package}CreatorCommand extends Command {