Skip to content

Instantly share code, notes, and snippets.

View gfx's full-sized avatar

FUJI Goro gfx

View GitHub Profile
@gfx
gfx / foo.gradle
Created February 20, 2014 08:27
AndroidAnnotationsにコントリしたい。
preBuild.dependsOn(task("generateUsageReportActivities") << {
def manifestFile = file("src/main/AndroidManifest.xml")
def manifest = new XmlParser().parse(manifestFile);
def pkg = manifest.@package
def androidNamespace = new Namespace("http://schemas.android.com/apk/res/android", "android")
manifest.find { Node node ->
@gfx
gfx / nil..m
Last active August 29, 2015 13:56
#import <Foundation/Foundation.h>
#define b(x) #x
#define a(x) b(x)
int main() {
NSLog(@"%s", a(nil)); // -> ((void*)0)
return 0;
}
// abbrevation: dispatch_once
// description: GCD: dispatch_once
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
$END$
});
// abbrevation: dispatch_after
// description: GCD: dispatch_after
double delayInSeconds = 2.0;

I'm trying to modify some code in static initializer with m.replace("$_ = ($r)false;"), but I got NPE:

Caused by: java.lang.NullPointerException
	at javassist.bytecode.ConstPool.getMethodrefNameAndType(ConstPool.java:418)
	at javassist.expr.MethodCall.getNameAndType(MethodCall.java:43)
	at javassist.expr.MethodCall.getMethodName(MethodCall.java:107)
	at com.github.gfx.javassistexamp.JavassistExample$2.edit(JavassistExample.groovy:29)
	at javassist.expr.ExprEditor.loopBody(ExprEditor.java:192)
	at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
class _Main {
  static function main(args : string[]) : void {
    var x = 42;
    assert x == 0;
  }
}

http://d.hatena.ne.jp/gfx/20130521/1369159181 の追試。 as of JSX 0.9.89

title command size ratio
original jsx --release src/jsx-node-front.jsx | wc -c 1697 1.00
minify jsx --release --minify src/jsx-node-front.jsx | wc -c 364 0.21
gcc jsx --release src/jsx-node-front.jsx | closure-compiler | wc -c 703 0.41
gcc/A jsx --release src/jsx-node-front.jsx | closure-compiler --compilation_level ADVANCED_OPTIMIZATIONS | wc -c 345 0.20
// generatedy by JSX compiler 0.9.89 (2014-05-20 06:01:03 +0900; 8e8c6105f36f3dfe440ea026a3c93a3444977102)
var JSX = {};
(function (JSX) {
/**
* extends the class
*/
function $__jsx_extend(derivations, base) {
var ctor = function () {};
ctor.prototype = base.prototype;
var proto = new ctor();
package com..github.gfx.toolbox;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.gms.common.annotation.KeepName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
$schema: http://json-schema.org/draft-04/hyper-schema
title: The great new API
description: blah blah blah
properties:
app:
title: The application resource
type: object
properties:
id:
format: uuid
android-ndk
android-sdk
ant
antlr
apktool
aspell
autoconf
automake
bash
bash-completion