Skip to content

Instantly share code, notes, and snippets.

Shaun shaunlee

  • Beijing, China
Block or report user

Report or block shaunlee

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
shaunlee / CorsMiddleware.php
Last active Mar 14, 2017
Lumen with CORS and OPTIONS requests
View CorsMiddleware.php
namespace App\Http\Middleware;
use Closure;
class CorsMiddleware
* Handle an incoming request.
View circle_byte_buffer.go
package main
import (
var ErrBufferIsNotEnough = errors.New("buffer is not enough")
type ByteBuffer struct {
shaunlee / gist:dfbf5d805d4f5a3f9a54
Created Oct 26, 2015 — forked from jessedearing/gist:2351836
Create self-signed SSL certificate for Nginx
View gist:dfbf5d805d4f5a3f9a54
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key
openssl rsa -in -out myssl.key
View angularjs_demo.js
angular.module('App', []).config(['$interpolateProvider', function($interpolateProvider) {
shaunlee / router.php
Created Aug 28, 2015
Phalcon Micro MVC Router
View router.php
$filename = $_SERVER['REQUEST_URI'];
if ($i = strpos($filename, '?')) {
$filename = substr($filename, 0, $i);
if (file_exists(__DIR__ . $filename)) {
return false;
shaunlee / clear_tube.php
Last active Mar 2, 2016
beanstalkd: clear tube
View clear_tube.php
include 'pheanstalk/pheanstalk_init.php';
$ph = new Pheanstalk_Pheanstalk('');
while ($job = $ph->reserve(0)) {
fwrite(STDOUT, $job->getId() . "\r");
shaunlee / main.js
Last active Jun 10, 2018
NodeJS Cluster
View main.js
var cluster = require('cluster'),
numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
while (numCPUs-- > 0) cluster.fork();
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + + ' died');
shaunlee /
Last active Mar 2, 2016
Git hooks for phpcs
EXEC=`php -r "echo 'php ', implode(DIRECTORY_SEPARATOR, [__DIR__, 'vendor', 'bin', 'phpcs']);"`
FILES=`git diff --cached --name-only | grep -i php$ | grep ^app`
ARGS='--standard=psr2 --encoding=utf8 -p'
for fn in $FILES; do
if [ ! -f $fn ]; then
shaunlee / queue.go
Last active Mar 2, 2016
Recycle Queue
View queue.go
package main
import (
const (
shaunlee / restful.go
Last active Sep 29, 2017
Simple RESTful web dispatcher
View restful.go
package main
import (
You can’t perform that action at this time.