Skip to content

Instantly share code, notes, and snippets.

@finscn
finscn / Toucher.ts
Last active January 25, 2020 18:49
Touch lib for cocos creator 2.x
// export { default as Tap } from "./Tap";
// export { default as DoubleTap } from "./DoubleTap";
// export { default as Swipe } from "./Swipe";
const { ccclass, property } = cc._decorator;
@ccclass
export default class Toucher extends cc.Component {
@property
@finscn
finscn / TouchWrapper.ts
Created January 23, 2020 19:25
TouchWrapper for cocos creator 2.3
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
@finscn
finscn / wx-minigame-error.js
Last active May 5, 2019 08:11
load the error list of weixin minigame
// 需要设置正确的 token
var token = 985700508;
// 开始时间 [年,月,日,时] , 设置为null, 则为今天的整点时刻往前7天.
var startTime = null; // [2019, 4, 28, 14];
// 结束时间 [年,月,日,时] , 设置为null, 则为今天的整点时刻.
var endTime = null; // [2019, 5, 5, 14];
// 关键字 (微信有bug, 不是所有出现在错误信息里的字符串都能被检索)
@finscn
finscn / update-git-repos.sh
Last active May 5, 2019 07:32
update local git repositories in directory
#!/bin/bash
CURRENT=$PWD
echo $CURRENT
function ergodic(){
if [ -n "$1" ] ;then
echo '>>>>>> ENTER [' $1 '] >>>>>>'
cd $1
else
// From http://baagoe.com/en/RandomMusings/javascript/
function Alea() {
return (function(args) {
// Johannes Baagøe <baagoe@baagoe.com>, 2010
var s0 = 0;
var s1 = 0;
var s2 = 0;
var c = 1;
if (args.length == 0) {
// From http://baagoe.com/en/RandomMusings/javascript/
function Alea() {
return (function(args) {
// Johannes Baagøe <baagoe@baagoe.com>, 2010
var s0 = 0;
var s1 = 0;
var s2 = 0;
var c = 1;
if (args.length == 0) {
@finscn
finscn / .bash_profile
Last active April 27, 2016 19:31
My .bash_profile
export TERM=xterm-color
# for color
export CLICOLOR=1
export LSCOLORS=gxfxaxdxcxegedabagacad
# grep
alias grep='grep --color=always'
export COLOR_NC='\\e[0m' # No Color
export COLOR_WHITE='\\e[1;37m'
@finscn
finscn / NewFile.py
Created June 19, 2015 07:39
A plugin of SublimeText 3 : Let the FOLDER of a new untitled file be as same as the folder of current activated file.
# NewFileAtCurrentFolder
import sublime_plugin
import os.path
class NewFileListener(sublime_plugin.EventListener):
def on_new_async(self, view):
if not view.window().active_view():
print("NF: no view")
return
/**
* Detecting vertical squash in loaded image.
* Fixes a bug which squash image vertically while drawing into canvas for some images.
* This is a bug in iOS6 devices. This function from https://github.com/stomita/ios-imagefile-megapixel
*
*/
function detectVerticalSquash(img) {
var iw = img.naturalWidth, ih = img.naturalHeight;
var canvas = document.createElement('canvas');
canvas.width = 1;
@finscn
finscn / dns-setter.sh
Last active July 31, 2019 18:54
dns setter
#!/bin/bash
# Please run this shell with "sudo ..."
SERVICE=Wi-Fi
# You could change the service. List all network services via:
# networksetup -listallnetworkservices
echo ""
echo "Current DNS on ${SERVICE}:"