Skip to content

Instantly share code, notes, and snippets.

View anzfactory's full-sized avatar
:octocat:
Working from home

anz anzfactory

:octocat:
Working from home
View GitHub Profile
@anzfactory
anzfactory / script.cs
Last active August 29, 2015 14:03
Gui.ModalWindow使ってみた
private const int ModalWindowId = 100;
private Rect windowRect;
void OnGUI()
{
windowRect = GUI.ModalWindow(
ModalWindowId,
new Rect(0, 0, Screen.width, Screen.height),
ModalWindowCallback,
"モーダルだよー!"
@anzfactory
anzfactory / slicer.m
Last active August 29, 2015 14:04
動画を指定位置で画像にして切り出す
// フレームワークを2つインポート
// <AssetsLibrary/AssetsLibrary.h> -> AssetLibrary.framework
// <AVFoundation/AVFoundation.h> -> AVFoundation.framework
+ (NSArray *)sliceMovie:(NSURL *)url
{
AVURLAsset* asset = [[AVURLAsset alloc] initWithURL:url options:nil];
if ( ! [asset tracksWithMediaCharacteristic:AVMediaTypeVideo]) {
NSLog(@"MovieUtil : ビデオタイプのファイルを指定して下さい [%@]", url);
return nil;
@anzfactory
anzfactory / generator.m
Last active March 27, 2016 08:11
複数画像からGIFをつくる
// フレームワークを2つインポート
// #import <ImageIO/ImageIO.h> -> ImageIO.framework
// #import <MobileCoreServices/MobileCoreServices.h> -> MobileCoreService.framework
+ (NSData *) generateGifDataWithImages:(NSArray *)images
{
// 何秒間隔で画像を切り替えるか
NSDictionary *frameProperties =
@{ (NSString *)kCGImagePropertyGIFDictionary: @{ (NSString *)kCGImagePropertyGIFDelayTime : @(1) } };
@anzfactory
anzfactory / twitterViewController.m
Last active August 29, 2015 14:04
twitter投稿さんぷる(SLComposeViewController使わない版)
// #import <Social/Social.h> -> Social.framework
// #import <Accounts/Accounts.h> -> Accounts.framework
// 投稿ボタンタップとか?
- (IBAction)postTwitter:(id)sender {
// Twitterアカウントが端末に設定されているか?
if ( ! [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
return;
}
@anzfactory
anzfactory / SquareView.java
Last active May 4, 2018 06:06
縦(あるいは横)にあわせる形で正方形にするView
public class SquareView extends View {
private boolean mAdjustWidth;
public SquareView(Context context) {
super(context, null);
}
public SquareView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@anzfactory
anzfactory / MyEventObject.java
Last active March 26, 2016 05:47
NSNotificationCenterのようなことをandroidでもやるために
/**
* NSNotificationのようなもの
* 通知で送る情報が詰まったオブジェクト
*/
public class MyEventObject extends EventObject {
public static final String TAG = "MyEventObject";
public enum EventType {
Hoge,
@anzfactory
anzfactory / InterstitialActivity.java
Created October 19, 2014 04:38
Admobインタースティシャル広告さんぷる
public class InterstitialActivity extends Activity {
private InterstitialAd mInterstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setup
setupInterstitialAd();
@anzfactory
anzfactory / provision_init.sh
Last active August 29, 2015 14:12
vagrantのprovisionでローカル開発環境作成用の初期化init。必要に応じて、コメントアウトしたり外したり。ポイントはVagrantfileでprovision指定するときに、`privileged`でfalseを指定すること。じゃないと実行ユーザーがrootになるので、rubyインストールあたりでパスが通ってなかったりする
# local develop env initialize shell command
##### yum update all
sudo yum -y update
##### edit resolv.conf
sudo sed -i -e "1i options single-request-reopen" /etc/resolv.conf
##### firewall stop
sudo service iptables stop
@anzfactory
anzfactory / circleImageViewSample.m
Created January 14, 2015 17:08
UIImageViewを円形にして枠線つける
// もともとのUIImageViewを正方形にしてるんで、長さの半分
imgView.layer.cornerRadius = imgView.frame.size.width / 2.f;
// はみ出たトコをclipするか
imgView.layer.masksToBounds = YES;
// 枠線色
imgView.layer.borderColor = [UIColor colorWithRed:255.f/255.f green:192.f/255.f blue:203.f/255.f alpha:1.f].CGColor;
// 枠線太さ
imgView.layer.borderWidth = 5.f;
@anzfactory
anzfactory / HogeNavigationController.swift
Last active August 29, 2015 14:15
UINavigationControllerのBackButtonのタイトルを一括で変更
class HogeNavigationController: UINavigationController, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self; // delegateセット
}
// MARK: UINavigationControllerDelegate
func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
let backButton: UIBarButtonItem = UIBarButtonItem()