Skip to content

Instantly share code, notes, and snippets.

View mactive's full-sized avatar
🎯
Focusing

mactive mactive

🎯
Focusing
View GitHub Profile
@mactive
mactive / gist:6218472
Created August 13, 2013 06:49
git operation
To remove a local branch from your machine:
git branch -d the_local_branch
To remove a remote branch:
git push origin :the_remote_branch
@mactive
mactive / jQuery Functions
Created August 14, 2013 04:27
jQuery Learning
  $.trim() 去除字符串两端的空格。
  $.each() 遍历一个数组或对象。
  $.inArray() 返回一个值在数组中的索引位置。如果该值不在数组中,则返回-1。
  $.grep() 返回数组中符合某种标准的元素。
  $.extend() 将多个对象,合并到第一个对象。
  $.makeArray() 将对象转化为数组。
  $.type() 判断对象的类别(函数对象、日期对象、数组对象、正则对象等等)。
  $.isArray() 判断某个参数是否为数组。
  $.isEmptyObject() 判断某个对象是否为空(不含有任何属性)。
  $.isFunction() 判断某个参数是否为函数。
@mactive
mactive / gist:6350388
Last active December 21, 2015 18:49
js array minus
// console.log(itemUsedCurrencys);
// console.log(itemOriginCurrencys);
var itemOriginCurrencys = ['USD', 'HKD', 'CNY', 'EUD'];
var itemUsedCurrencys = ['USD', 'HKD'];
var i = itemOriginCurrencys.length;
while (i--) {
var index = itemUsedCurrencys.indexOf( itemOriginCurrencys[i] )
// console.log('check : '+itemOriginCurrencys[i] + " pos: "+ index);
.done-true {
text-decoration: line-through;
color: grey;
}
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@mactive
mactive / CommonListViewController.h
Created April 1, 2014 08:25
类簇 抽象工厂
//
// //
// //
// CommonListViewController.h
// bitmedia
//
// Created by meng qian on 14-1-22.
// Copyright (c) 2014年 thinktube. All rights reserved.
//
#import <UIKit/UIKit.h>
@mactive
mactive / Notification Center
Last active August 29, 2015 14:02
Notification Center
// Instead of using delegation for passing the data, consider using NSNotificationCenter to communicate between your view controllers in this situation.
// In your first view controller you will register to listen for a notification:
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleFourthViewSubmit:)
name:@"fourthViewSubmit"
object:nil];
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@mactive
mactive / cityList.coffee
Created August 24, 2015 10:49
Promise Sequences
cityList = [
{key: "610100", label:"西安", daLabel:"西安市",region:"华南"},
{key: "130100", label:"石家庄", daLabel:"石家庄市",region:"华南"},
{key: "350200", label:"厦门", daLabel:"厦门市",region:"华南"},
{key: "410100", label:"郑州", daLabel:"郑州市",region:"华南"},
{key: "440600", label:"佛山", daLabel:"佛山市",region:"华南"},
{key: "350100", label:"福州", daLabel:"福州市",region:"华南"},
{key: "440100", label:"广州", daLabel:"广州市",region:"华南"},
{key: "230100", label:"哈尔滨", daLabel:"哈尔滨市",region:"华南"},
{key: "110100", label:"北京", daLabel:"北京市",region:"华南"},
@mactive
mactive / refactor.js
Last active June 16, 2016 09:05
用 node写了一段脚本 重构代码, 整理一下头部的 import 以及单例的初始化
import * as fs from 'fs';
import * as path from 'path';
// app 目录
const appFolder = path.resolve(__dirname, '../app');
console.log(appFolder);
// sync version
function walkSync(currentDirPath, callback) {
fs.readdirSync(currentDirPath).forEach(function (name, index) {