Skip to content

Instantly share code, notes, and snippets.

@kwoktung
kwoktung / jsonp.js
Created September 6, 2016 05:59
JSONP simple implementation
(function(global,document){
var uid = 0 ;
function getJSON(url,callback){
var elem;
uid ++;
getJSON.callbacks[uid] = callback;
url = filterUrlCallback(url);
;(function() {
var canvas = document.getElementsByClassName('runner-canvas')[0];
var ctx = canvas.getContext('2d');
function run(){
var hit = false;
var data = ctx.getImageData(150,180,175,50).data
for(var i=3, len = data.length; i < len; i += 8) {
if (data[i] > 0) {
hit = true;
break;
const babel = require('babel-core');
const fs = require('fs');
const glob = require("glob")
const traverse = require("babel-traverse").default;
const i18n = {}
function get(properties) {
if(Array.isArray(properties)) {
let key, value
@kwoktung
kwoktung / readme.md
Created August 16, 2018 16:22 — forked from irazasyed/readme.md
CSS: Retina Display Media Query

Retina Display Media Query Example:

===

CSS Code for Normal and Retina:

#logo{
    background-image: url(logo.png);
    background-size: 185px 75px;
 background-repeat: no-repeat;
@kwoktung
kwoktung / keys.go
Created October 17, 2019 01:39
generate openssh key pair by golang
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
@kwoktung
kwoktung / install-redis.md
Last active November 28, 2019 14:57 — forked from hackedunit/install-redis.md
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local/
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.github.kwoktung.minio</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/minio</string>
  1. Configure launchctl to start minio on boot

sudo vim ~/Library/LaunchAgents/com.github.kwoktung.minio.local.plist

Copy the contents of this gist to the file, save and close.

  1. Start the minio service and set minio to start on boot