Skip to content

Instantly share code, notes, and snippets.

@shoheiyokoyama
shoheiyokoyama / FirstApp
Last active August 29, 2015 14:06
my FirstApp
import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
@shoheiyokoyama
shoheiyokoyama / Objective-C
Last active January 13, 2016 05:11
透過性のあるUIViewサブクラスの影の描画と実装方法について ref: http://qiita.com/shoheiyokoyama/items/d7d02f16b4f632ba6584
shadowButton.layer.cornerRadius = 15;
shadowButton.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
shadowButton.backgroundColor = [UIColor clearColor];
CGFloat w = 6.0f;
CGFloat wh = w / 2;
CGFloat sw = shadowButton.frame.size.width;
CGFloat sh = shadowButton.frame.size.height;
CGFloat c = shadowButton.layer.cornerRadius;
@shoheiyokoyama
shoheiyokoyama / Objective-C
Last active December 31, 2015 06:19
UITextFieldのスタイルがRoundedRectの場合、背景色が変わらない(Core Animation) ref: http://qiita.com/shoheiyokoyama/items/c2d2c641757cd8f90557
textField.backgroundColor = [UIColor clearColor];
@shoheiyokoyama
shoheiyokoyama / file0.txt
Last active January 12, 2016 06:10
Git ファイル/ディレクトリ名の大文字・小文字変換 ref: http://qiita.com/shoheiyokoyama/items/0fd9f688a269bbdc9da3
$ git mv -f file.js File.js
public interface Aggregate {
public abstract Iterator iterator();
}
import java.io.*;
public interface FileIo {
public void readFromFile(String filename) throws IOException;
public void writeToFile(String filename) throws IOException;
public void setValue(String key, String value);
public String getValue(String key);
}
@shoheiyokoyama
shoheiyokoyama / AbstractDisplay.java
Last active November 6, 2016 07:16
デザインパターン「Template Method」 ref: http://qiita.com/shoheiyokoyama/items/c2ce16b4f492cd014d50
public abstract class AbstractDisplay {
public abstract void open();
public abstract void print();
public abstract void close();
//Template Method
public final void display() {
open();
for (int i =0; i < 3; i++) {
print();
}
@shoheiyokoyama
shoheiyokoyama / Account.java
Last active August 4, 2017 00:08
デザインパターン「Factory Method」 ref: http://qiita.com/shoheiyokoyama/items/d752834a6a2e208b90ca
public class Account extends Product {
private String owner;
Account(String owner) {
System.out.println("Create account: " + owner);
this.owner = owner;
}
public void use() {
@shoheiyokoyama
shoheiyokoyama / Main.java
Last active November 6, 2016 07:18
デザインパターン「Singleton」 ref: http://qiita.com/shoheiyokoyama/items/c16fd547a77773c0ccc1
public static void main(String[] args) {
Singleton instance1 = Singleton.getInstance();
Singleton instance2 = Singleton.getInstance();
if (instance1 == instance2) {
System.out.println("instance1 and instance2 are same Instance");
} else {
System.out.println("instance1 and instance2 aren't same Instance");
}
}
@shoheiyokoyama
shoheiyokoyama / Main.java
Last active November 6, 2016 07:18
デザインパターン「Prototype」 ref: http://qiita.com/shoheiyokoyama/items/61826e158b3c4a259065
public static void main(String[] args) {
Manager manager = new Manager();
UnderLinepen upen = new UnderLinePen('-');
MessageBox mbox = new MessageBox('@');
MessageBox sbox = new MessageBox('♪');
manager.register("stong message", upen);
manager.register("warning box", mbox);