Skip to content

Instantly share code, notes, and snippets.

View iwill's full-sized avatar
Growing Well 🌱🌱

Míng iwill

Growing Well 🌱🌱
View GitHub Profile
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
@iwill
iwill / isNumber.js
Last active September 6, 2022 07:53
isNumber(aNorNaN) === !isNaN(aNorNaN)
function isNumber(x, object, bigint, string) {
let type = typeof x;
if (object && type == "object") {
x = x instanceof Number ? x.valueOf() : NaN;
type = typeof x;
}
else if (bigint && type == "bigint") {
x = x >= Number.MIN_SAFE_INTEGER && x <= Number.MAX_SAFE_INTEGER ? Number(x) : NaN;
type = typeof x;
}
@iwill
iwill / OCMacros.h
Created June 8, 2013 16:19
Objective-C Macros
#define OR ? :
#define NSStringFromValue(value) [@(value) description]
@iwill
iwill / trash.sh
Created July 24, 2013 15:47
move files to trash
#! /bin/bash
# http://hints.macworld.com/article.php?story=20091003083125659
function trash() {
for arg in "$@"; do
if [ -e "$PWD/$arg" ]; then
osascript -e "tell application \"Finder\" to delete POSIX file \"$PWD/$arg\"" &>/dev/null
elif [ -e "$arg" ]; then
osascript -e "tell application \"Finder\" to delete POSIX file \"$arg\"" &>/dev/null
else
@iwill
iwill / ARCWeakRef.h
Last active December 22, 2015 10:58
Use ARC Weak Reference in MRC file.
//
// ARCWeakRef.h
// M9
//
// Created by iwill on 2013-07-08.
// Copyright (c) 2013年 iwill. All rights reserved.
//
#import <Foundation/Foundation.h>
@iwill
iwill / newbash.sh
Created March 25, 2014 02:26
newbash
# new bash script and mate
function newbash() {
if [[ ! -f "$1" ]]; then
echo '#!/bin/bash' > "$1"
fi
if [[ -f "$1" ]]; then
chmod +x "$1"
mate "$1"
fi
}
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
@iwill
iwill / javascript_resources.md
Created May 28, 2014 10:41 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@iwill
iwill / css_resources.md
Created May 28, 2014 10:42 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@iwill
iwill / git-cb.sh
Last active October 30, 2023 09:19
git checkout with grep patterns
#!/bin/bash
# alias in gitconfig:
# cb = "!sh ~/.git-cb.sh"
# usage:
# git cb ev lo # *ev*lo* - `develop` will be matched
# cb = "!checkoutbranch() { local branches=`git branch | grep -i $1 | tr -d '* '`; if [[ `echo \"$branches\" | wc -l | tr -d ' '` != 1 ]]; then echo \"Matched multiple branches:\"; git branch | grep --color -i $1; exit 1; fi; git checkout $branches; }; checkoutbranch"
branches=`git branch`