Skip to content

Instantly share code, notes, and snippets.

View imyelo's full-sized avatar
🥽
Not here

yelo imyelo

🥽
Not here
View GitHub Profile
@imyelo
imyelo / lockable.js
Created July 8, 2014 10:59
lockable.js
var lockable = function (func) {
var isLocking = false;
var unlock = function () {
isLocking = false;
};
return function () {
var args = arguments;
if (isLocking) {
return;
}
@imyelo
imyelo / Lockable.js
Created July 11, 2014 06:22
Lockable.js
var Lockable = function () {
var exports = {};
var _locks = {};
exports.lock = function (name) {
_locks[name] = true;
};
exports.unlock = function (name) {
_locks[name] = false;
@imyelo
imyelo / toJSON.js
Last active August 29, 2015 14:08
Better Backbone.Model/Collection.toJSON
Backbone.Model.prototype.toJSON = function () {
var result = {};
_.each(this.attributes, function (val, key) {
if (typeof val === 'undefined') {
result[key] = val;
} else if (typeof val.toJSON === 'function') {
result[key] = val.toJSON();
} else if (!_.isObject(val)) {
result[key] = val;
} else {
@imyelo
imyelo / Makefile
Created January 21, 2015 16:26
webapp workflow - nodejs
FOREVER_COMMAND = "node --harmony"
FOREVER_UID = "webapp"
FOREVER_OUTFILE = "./logs/out.log"
FOREVER_ERRFILE = "./logs/err.log"
FOREVER_LOGFILE = "./logs/forever.log"
FOREVER = forever start \
-c ${FOREVER_COMMAND} \
--uid ${FOREVER_UID} \
-l ${FOREVER_LOGFILE} \
@imyelo
imyelo / oss.js
Created January 12, 2016 07:21
upload files to oss
#!/usr/bin/env node
var co = require('co');
var parallel = require('co-parallel');
var globby = require('globby');
var oss = require('ali-oss');
var store = oss({
accessKeyId: process.env.OSS_ACCESS_KEY_ID,
accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
@imyelo
imyelo / Makefile
Last active August 27, 2016 12:30
Makefile of nodejs application with kubernates
CONFIG_DIR = "./config"
HOSTNAME = "0.0.0.0"
DEBUG = project-name:*
NODE_ENV = production
TARGET_ENV = intranet
DOCKER_IMAGE = your-registry-host.com/your-name/project-name
KUBE_SECRET_NAME = project-name-secret
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>android wx.startRecord NO touchend</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
</head>
<body>
<h1>在 Android 微信上 touchstart 时调用 wx.startRecord 会导致不会触发 touchend 事件</h1>
<div>
@imyelo
imyelo / redis-server-for-init.d-startup
Created August 3, 2016 04:26 — forked from lsbardel/redis-server-for-init.d-startup
Init.d Redis script for Ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@imyelo
imyelo / profiling.js
Created October 9, 2016 09:17
profiling
const ENABLE = 'ENABLE'
;(function () {
if (process.env.PROFILING_HEAPDUMP === ENABLE) {
// heapdump
require('heapdump')
}
if (process.env.PROFILING_MEMORY_STAT === ENABLE) {
@imyelo
imyelo / backup.sh
Last active November 22, 2016 12:07
backup raspberry image
#!/bin/sh
dd if=/dev/zero of=raspberrypi.img bs=1MB count=2500
parted raspberrypi.img --script -- mklabel msdos
parted raspberrypi.img --script -- mkpart primary fat32 8192s 122879s
parted raspberrypi.img --script -- mkpart primary ext4 122880s -1
loopdevice=`losetup -f --show raspberrypi.img`
device=`kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
device="/dev/mapper/${device}"
partBoot="${device}p1"