Skip to content

Instantly share code, notes, and snippets.

View xionglun's full-sized avatar

Jafar Stein xionglun

  • TBD
  • Freedom, China
View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@xionglun
xionglun / ie.js
Last active December 19, 2015 17:49 — forked from padolsey/gist:527683
// ----------------------------------------------------------
// 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) {}
@xionglun
xionglun / jsconvert.md
Last active December 20, 2015 22:29
Javascript convert __string__ to __number__

convert a string to number at JavaScript.

  1. +
   +'12';     // 12
   typeof +'12'     // number
  
   +'12s';    // NaN
   typeof +'12s';   // number
@xionglun
xionglun / double_slash.md
Last active December 21, 2015 00:48
double slash has not been replaced.

replace double slash

At seajs/src/util-path.js, double slash has not been replaced!

  var DOT_RE = /\/\.\//g
  var DOUBLE_DOT_RE = /\/[^/]+\/\.\.\//
  
  function realpath(path){
    path = path.replace(DOT_RE, '/')
@xionglun
xionglun / package.json
Created December 4, 2013 10:16
task_automation_with_npm_run
{
"name": "rando",
"version": "0.6.1",
"description": "random generator",
"main": "rando.js",
"bin": {
"rando": "bin/rando.js"
},
"engines": [
"node >= 0.8.0"
@xionglun
xionglun / iOSReadFileInProject.md
Last active January 3, 2016 13:58
iOS read file in project.

If you use add file add some files in your project. You can access them like this:

    NSError *error;
    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"hello" ofType:@"txt"];  // I add __hello.txt__ into my project.
    NSString *filecontent = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:&error];
    NSLog(@" content: %@", filecontent);
    
@xionglun
xionglun / android_studio_gradle.markdown
Created May 26, 2014 19:03
Android Studio Gradle version

在build.gradle这个文件中:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}
@xionglun
xionglun / proguard-project
Created May 30, 2014 10:50
Android Proguard Example
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
@xionglun
xionglun / android_webview.md
Last active August 29, 2015 14:02
Android WebView EventHub.removeMessages(int what = 107)

WebView Lifecycle

We ran into a problem when leaving the activity. WebView will display the following message in logcat:

EventHub.removeMessages(int what = 107) is not supported before WebViewCore is set up

To prevent this message from showing up use WebView stopLoading() method:

  // !!! This method is wrong!
  // !!! Do not solve problem
  @Override
 public void onStop() {
@xionglun
xionglun / android_custom_user_agent.md
Created June 10, 2014 17:39
Android WebView custom User-Agent

At Activity:

  //...
  webView.getSettings().setUserAgentString("CUSTOM_USE_AGENT");
  //...