Skip to content

Instantly share code, notes, and snippets.

View KatagiriSo's full-sized avatar

KatagiriSo KatagiriSo

View GitHub Profile
@KatagiriSo
KatagiriSo / gist:d9c11150f98097debc4a
Created July 8, 2014 02:05
JQuery on click event
<html>
<head>
<title>Sample</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>
<script type="text/javascript">
// 動的な要素にも利用できるようなイベント構文について説明
// onメソッドを使えば良い
// 調査範囲.on(イベント名, セレクタ, イベントで実行したい処理)
//
@KatagiriSo
KatagiriSo / gist:744d237a4412e00301e4
Last active August 29, 2015 14:03
JavaScript Objective-C bridge
- (void)startMyJSTest_OBJC_Call_JS
{
JSContext *context = [[JSContext alloc] init];
// by JS
JSValue *result = [context evaluateScript:@"2+2"];
NSLog(@"2 + 2 = %d", [result toInt32]);
// JSValue
@KatagiriSo
KatagiriSo / gist:156d06fdf23b32092fc3
Created July 9, 2014 08:20
CoreGraphics drawCircle
#import "MyView.h"
#import <CoreGraphics/CoreGraphics.h>
struct RGBColor
{
float r;
float g;
float b;
float a;
};
@KatagiriSo
KatagiriSo / gist:a880435cd19952daa093
Last active August 29, 2015 14:03
CGCoreGraphics Funya
struct RGBColor
{
float r;
float g;
float b;
float a;
};
typedef struct RGBColor RGBColor;
void (^drawCircle)(CGContextRef, CGPoint*, RGBColor*, float) = ^(CGContextRef context, CGPoint *point, RGBColor *rgb, float r)
@KatagiriSo
KatagiriSo / gist:9ef53a5da650053f7c3f
Created July 10, 2014 03:20
Javascript call Objective-C blocks
- (void)startMyJSTest_JS_CALL_OBJC
{
//ObJC blocks
JSContext *context = [[JSContext alloc] init];
context[@"myBlock"] = ^(NSString *w) {
return [NSString stringWithFormat:@"==%@===", w];
};
//JScode call blocks
@KatagiriSo
KatagiriSo / gist:9547af776fce3f69eff6
Created July 10, 2014 03:21
JavaScript Objectve-C Object Bridge
@interface RGB : NSObject <RGBExport>
@end
@implementation RGB
@synthesize r = _r;
@synthesize g = _g;
@synthesize b = _b;
@synthesize a = _a;
+ (id)makeRGBWithR:(float)r G:(float)g B:(float)b alpha:(float)a
{
RGB *rgb = [RGB new];
SOLID規則のメモ
S Single responsibility 1クラス1債務
O Open-Closed 
L Liskov substitution
I Interface
Single responsibility principle
@KatagiriSo
KatagiriSo / gist:7f15b66b8cc2b2b06c7c
Created July 12, 2014 09:04
flayout xaml sample
<Grid
x:Name="bgGrid"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
DoubleTapped="bgGrid_DoubleTapped">
<FlyoutBase.AttachedFlyout>
<Flyout x:Name="Flayout1" Placement="Left">
<Grid Background="Aqua" Width="300" Height="400">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
@KatagiriSo
KatagiriSo / gist:6929254f0cd44cffab39
Created July 14, 2014 04:00
webView loadRequest
webView.loadRequest(NSURLRequest(URL: NSURL.URLWithString("http://www.google.com")))
func fire()
{
var date = NSDate();
NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("aaaa"), userInfo: nil, repeats: false);
}
func aaaa()
{
print("hello")