Skip to content

Instantly share code, notes, and snippets.

@ktakayama
ktakayama / config.inc.sample
Created April 2, 2015 02:28
King of Time to slack
<?
$SLACK_NAMES = array(
'田中 太郎' => '@tanaka',
'高山 二郎' => '@takayama',
'木村 三郎' => '@kimura'
);
define('ACCESS_TOKEN', 'YOUR ACCESS TOKEN');
define('API_POST_MESSAGE_URL', 'https://slack.com/api/chat.postMessage');
#import <Foundation/Foundation.h>
@interface UIBarButtonItem (appearance)
+ (void) setupAppearance;
@end
#import <Foundation/Foundation.h>
@interface UILabel (ktlib)
- (void) fitSizeOfFont:(UIFont *)font;
@end
@ktakayama
ktakayama / maouyusya2aozora.rb
Created November 14, 2011 07:33 — forked from tdtds/maouyusya2aozora.rb
まとめサイト上の「まおゆう」を青空文庫形式のテキストファイルに変換する
#!/usr/bin/ruby
# -*- coding: utf-8; -*-
#
require 'rubygems'
require 'open-uri'
require 'nokogiri'
puts "魔王「この我のものとなれ、勇者よ」勇者「断る!」"
puts "橙乃ままれ"
puts "\n\n"
@interface NSScrollView (swipe)
- (void) scrollToTop;
- (void) scrollToBottom;
@end
static const CGFloat kSwipeGestureUp = 1.0;
static const CGFloat kSwipeGestureDown = -1.0;
@implementation NSScrollView (swipe)
+ (BOOL) hasExt:(NSString *)ext {
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"check.%@", ext]];
UIDocumentInteractionController *doc =
[UIDocumentInteractionController interactionControllerWithURL:url];
BOOL success = [doc presentOptionsMenuFromRect:CGRectZero inView:[UIApplication sharedApplication].keyWindow animated:NO];
if(success) [doc dismissMenuAnimated:NO];
return success;
}
@interface SampleView : UIView {
UIWebView *html;
}
@property (assign) UIWebView *html;
@end
@implementation SampleView
- (UIImage *) screenImage:(UIView *)view rect:(CGRect)rect {
CGPoint pt = rect.origin;
UIImage *screenImage;
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextConcatCTM(context, CGAffineTransformMakeTranslation(-(int)pt.x, -(int)pt.y));
[view.layer renderInContext:context];
screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// ==UserScript==
// @name iTC time zone
// @namespace http://iphone-dev.g.hatena.ne.jp/ktakayama/
// @description iTC time zone
// @include https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/*
// ==/UserScript==
(function() {
var path = "//div[@class='versionStateHistory-col-0']/p";
var nodes = document.evaluate(
@interface UIImage (shadow)
+ (UIImage *) imageWithContentsOfFile:(NSString *)path withShadow:(BOOL)shadow;
@end
@implementation UIImage (shadow)
+ (UIImage *) imageWithContentsOfFile:(NSString *)path withShadow:(BOOL)shadow {
UIImage *image = [UIImage imageWithContentsOfFile:path];