Skip to content

Instantly share code, notes, and snippets.

View yonekawa's full-sized avatar

Kenichi Yonekawa yonekawa

  • freee K.K.
  • Japan
View GitHub Profile
@yonekawa
yonekawa / defer.go
Created October 18, 2017 07:16
Defer playground
package main
import "sync"
// deferはreturnの後だよ
func A() string {
str := "A"
defer func() {
str = "B"
}()
@yonekawa
yonekawa / fastlane-actions-appium.rb
Last active April 6, 2016 20:30
Appium support action for fastlane
module Fastlane
module Actions
class AppiumAction < Action
INVOKE_TIMEOUT = 30
APPIUM_PATH_HOMEBREW = '/usr/local/bin/appium'
APPIUM_APP_PATH = '/Applications/Appium.app'
APPIUM_APP_BUNDLE_PATH = 'Contents/Resources/node_modules/.bin/appium'
def self.run(params)
Actions.verify_gem!('rspec')
import APIKit
import SwiftFlux
struct TodoActions {
struct Fetch {
typealias Payload = Todo
func invoke(dispatcher: Dispatcher) {
Session.sendRequest(TodoFetch(id: 1)) { (result) in
switch response {
case .Success(let todo):
import SwiftFlux
struct CounterActions {
struct Plus: Action {
typealias Payload = Int
let number: Int
func invoke(dispatcher: Dispatcher) {
dispatcher.dispatch(self, result: Result(value: number))
}
@yonekawa
yonekawa / gist:57d44a440b798b25b32d
Created May 7, 2014 08:45
AttributionIdentifiers without facebook app
diff --git a/facebook/src/com/facebook/internal/AttributionIdentifiers.java b/facebook/src/com/facebook/internal/AttributionIdentifiers.java
index 1c8f630..f142f25 100644
--- a/facebook/src/com/facebook/internal/AttributionIdentifiers.java
+++ b/facebook/src/com/facebook/internal/AttributionIdentifiers.java
@@ -104,25 +104,23 @@ public class AttributionIdentifiers {
try {
String [] projection = {ATTRIBUTION_ID_COLUMN_NAME, ANDROID_ID_COLUMN_NAME, LIMIT_TRACKING_COLUMN_NAME};
Cursor c = context.getContentResolver().query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
- if (c == null || !c.moveToFirst()) {
- return null;
<?xml version='1.0'?>
<signatures version='1.0'>
<enum name='kDynamicBodyType' value='2'/>
<enum name='kKinematicBodyType' value='1'/>
<enum name='kStaticBodyType' value='0'/>
<class name='B2DBody'>
<method selector='addFixureForShape:friction:restitution:density:isSensor:'>
<arg name='shape' index='0' declared_type='B2DShape*' type='@'/>
<arg name='friction' index='1' declared_type='id' type='@'/>
<arg name='restitution' index='2' declared_type='id' type='@'/>

現象

HTML5版(Canvas)のLWFで、あるフレームを実行するとrootMovieがdestroyされる。 そのフレーム以降のアニメーションも同様。 iOS6のUIWebView, Chromeで確認。その他は未確認。

クライアントコード

以下を使ってmainを回してexec & renderしている。 https://github.com/yonekawa/lwf.enchant.js/blob/master/lwf.enchant.coffee

flaファイルの構成

@yonekawa
yonekawa / CDVCommandDelegate.h.patch
Created November 28, 2012 07:37
Fix PhoneGap2.2-iOS does not work with RequireJS
diff --git a/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h b/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h
--- a/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h
+++ b/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h
@@ -42,6 +42,8 @@
// without reason. Without the run-loop delay, alerts used in JS callbacks may result
// in dead-lock. This method must be called from the UI thread.
- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
+// Patch for using RequireJS.
+- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop useNativeEvalAndFetch:(BOOL)useNativeEvalAndFetch;
// Runs the given block on a background thread using a shared thread-pool.
@yonekawa
yonekawa / gist:3945014
Created October 24, 2012 09:14
Leak code
enchant();
var NewScene = enchant.Class.create(enchant.Scene, {
initialize: function() {
enchant.Scene.call(this);
for (var i = 0; i < 100; i++) {
var sprite = new Sprite(32, 32);
sprite.image = enchant.Game.instance.assets['chara1.png'];
this.addChild(sprite);
}
@yonekawa
yonekawa / CDVViewController.m.patch
Created October 3, 2012 01:08
Fix PhoneGap2.1-iOS does not work with RequireJS
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index a0a29f0..520050d 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -510,7 +510,7 @@
// The iOSVCAddr is used to identify the WebView instance when using one of the XHR js->native bridge modes.
// The .onNativeReady().fire() will work when cordova.js is already loaded.
// The _nativeReady = true; is used when this is run before cordova.js is loaded.
- NSString* nativeReady = [NSString stringWithFormat:@"cordova.iOSVCAddr='%lld';try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady = true;}", (long long)self];
+ NSString* nativeReady = [NSString stringWithFormat:@"window.iOSVCAddr='%lld';try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady = true;}", (long long)self];