Skip to content

Instantly share code, notes, and snippets.

View panlw's full-sized avatar
🎯
Focusing

Neo Pan panlw

🎯
Focusing
View GitHub Profile
@panlw
panlw / Copy Path to Clipboard.workflow
Last active December 27, 2015 08:59
[Finder] Copy Path to Clipboard
on run {input, parameters}
tell application "Finder"
set sel to the selection as text
set the clipboard to POSIX path of sel
end tell
return input
end run
@panlw
panlw / Start iTerm Here.workflow
Last active December 27, 2015 08:59
[Finder] Start iTerm Here
on run {input, parameters}
tell application "Finder"
set dirPath to "\"" & (POSIX path of (input as string)) & "\""
end tell
CdTo(dirPath)
end run
on CdTo(theDir)
tell application "iTerm"
activate
@panlw
panlw / MyLanguage.g4
Created August 29, 2013 02:06
Antlr v4 Sample - MyLanguage.g4
grammar MyLanguage;
// Rules
code : line+ ;
line : expr NEWLINE
| NEWLINE
;
expr : '(' expr ')' # group
@panlw
panlw / MyLanguageGen.sh
Last active March 22, 2016 06:29
Use Antlr v4 to do code generation for .NET
#!/bin/sh
# Generate Lexer/Visitor for syntax tree of MyLanguage
# You should download the jar file from
# http://tunnelvisionlabs.com/downloads/antlr/2013-02-27-antlr4-csharp-4.0.1-SNAPSHOT.7z
java -cp .:./antlr4-csharp-4.0.1-SNAPSHOT-complete.jar org.antlr.v4.CSharpTool -Dlanguage=CSharp_v3_5 -no-listener -visitor -package MyNamespace MyLanguage.g4
@panlw
panlw / EnumUtil.cs
Last active December 21, 2015 22:09
List enum values
private static readonly string unknownEnumId = "unknown";
private static readonly Dictionary<Type, object> enumValuesCache =
new Dictionary<Type, object>();
/// <summary>
/// List all values anotated by XmlEnum
/// </summary>
/// <returns></returns>
public static List<XmlEnumValue<TEnum>> GetEnumValues<TEnum>() {
var t = typeof(TEnum);
@panlw
panlw / Detect IE
Created December 26, 2012 05:42 — forked from DevReps/Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@panlw
panlw / core.js
Created December 26, 2012 05:16
Simple JavaScript Inheritance
/**
* Simple JavaScript Inheritance
* @see http://ejohn.org/blog/simple-javascript-inheritance/
*
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
var initializing = false,
fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;