Skip to content

Instantly share code, notes, and snippets.

View iammapping's full-sized avatar

iammapping

View GitHub Profile
/**
* set goals to do
*
* Usage:
*
* var meet = enoughToDo('a', 'b', function(goals) {
* // Congratulations! All goals met
* // It's enough to do the final callback
* console.log(goals);
* });
@iammapping
iammapping / execSync
Created July 17, 2014 04:04
simple exec sync in nodejs
var fs = require('fs');
var exec = require('child_process').exec;
/**
* execSync
*
* simple version of execSync
* refer to 'shelljs -> exec', https://github.com/arturadib/shelljs/blob/master/src/exec.js
* @param {String} cmd
* @param {Object} option
@iammapping
iammapping / oneByOne.js
Created January 7, 2015 06:55
do iterator one by one in series
/**
* call iterate one by one
* @param {array|object} collection
* @param {function} iterate
* @param {function} cb the finished callback
*/
function oneByOne(collection, iterate, cb) {
var failed = false,
completed = 0, // record the count of completed iterate
len = 0,
@iammapping
iammapping / Recognize_Score_Model.php
Created May 28, 2016 11:03
自动识别CFM比分截图
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Recognize_Score_Model extends CI_Model
{
private $phashCacheDir;
private $phashMap = array();
protected $imgMap = array(
'1334x750' => array(
'score' => array(
'left' => array(468, 87, 66, 35),
@iammapping
iammapping / tokenize.php
Last active May 15, 2018 04:13
tokenize with substring
<?php
function tokenize($str, $minLength = 3) {
$strLength = mb_strlen($str);
if ($strLength <= $minLength) {
return [
"[{$str}",
"{$str}]",
"[{$str}]"
];
@iammapping
iammapping / catht.awk
Created June 9, 2020 15:12
cat head and tail
#!/usr/bin/awk -f
BEGIN {
line = 0
split_line_outed = 0;
arr[1] = "";
}
{
line = NR