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
@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 / 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 / OCMacros.h
Created June 8, 2013 16:19
Objective-C Macros
#define OR ? :
#define NSStringFromValue(value) [@(value) description]
@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;
}
/* 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 / Objective-C Code Snippt
Created April 15, 2013 15:25
Objective-C Code Snippt
[method]
mm
[<#object#> <#method#>]
{block}
bb
[<#object#> <#method#>]
#pragma mark -
pp
@iwill
iwill / which-and.sh
Last active December 15, 2015 23:50
wa mate xx.sh = which xx.sh | xargs mate
# which and
function wa() {
which "$2" | xargs "$1"
}
export -f wa
# which and mate
function wamate() {
wa mate "$1"
}
@iwill
iwill / repeat.sh
Created April 8, 2013 14:08
repeat for bash like csh repeat
#! /bin/bash
function repeat() {
if [[ $# < 2 ]]; then
echo "repeat: Too few arguments."
return 1
else
n=$1
shift
seq $n | xargs -I{} "$@"
/*
html5doctor.com Reset Stylesheet
v1.6.1
Last Updated: 2010-09-17
Author: Richard Clark - http://richclarkdesign.com
Twitter: @rich_clark
*/
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
@iwill
iwill / nodejs.sh
Last active October 12, 2015 15:28
JSON Parsing and Editing, run Javascript Function and Statements in Shell via Node.js
#!/bin/bash
# @see https://www.npmjs.org/package/json
## nodejs [js-statement ...] js-expression
function nodejs() {
local statements=""
while [[ $# > 1 ]]; do
statements="${statements:+$statements; }$1"
shift