Skip to content

Instantly share code, notes, and snippets.

View tanb's full-sized avatar
:shipit:
🐁🗯

Tomonori Tanabe tanb

:shipit:
🐁🗯
View GitHub Profile
@tanb
tanb / gist:11094235
Created April 19, 2014 19:06
FileThumbnail
NSArray *fileURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:self.url
includingPropertiesForKeys:[NSArray array]
options:0
error:nil];
[fileURLs enumerateObjectsUsingBlock:^(NSURL *fileURL , NSUInteger idx, BOOL *stop) {
NSImage *elementIcon = [[NSWorkspace sharedWorkspace] iconForFile:[fileURL path]];
CFStringRef fileExtension = (__bridge CFStringRef)[fileURL pathExtension];
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
if (UTTypeConformsTo(fileUTI, kUTTypeImage)) {
// MyViews.xib に複数のViewをいれました
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"MyViews" owner:nil options:nil];
// RestorationIDに適当な名前をつけておいて取り出しました
__block UIView *targetView = nil;
[nibContents enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) {
if ([view.restorationIdentifier isEqualToString:@"MyView"]) {
*stop = YES;
targetView = (UIView *)view;
}
@tanb
tanb / launchctl
Last active August 29, 2015 14:00
wifi接続の変更を監視してscriptを実行
# root所有にしておかないと実行されない
sudo chown root ~/Library/LaunchAgents/me.tanb.sample.plist
sudo launchctl load ~/Library/LaunchAgents/me.tanb.sample.plist
+ (void)initialize
{
_singleton = @[@"hoge",
@(100),
[UIImage new]];
}
+ (id)getSettingsAtIndex:(NSUInteger)index
{
NSArray *settings = [[NSArray alloc] initWithArray:_singleton copyItems:YES];
@tanb
tanb / gist:02808db1e86b820f4fb3
Created August 3, 2014 08:10
xattr to display sjis on quicklook
$ xattr -p com.apple.TextEncoding ~/Desktop/myfile.txt
xattr: /Users/tanb/Desktop/myfile.txt: No such xattr: com.apple.TextEncoding
$ xattr -p com.apple.TextEncoding ~/Desktop/myfile.txt
SHIFT_JIS;2561
@tanb
tanb / flymake-swift.el
Last active August 29, 2015 14:08
flymake - swift
(when (require 'flymake nil 'noerror)
;; ignore syntax check error http://d.hatena.ne.jp/sugyan/20100705/1278306885
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
(setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)
;; swift
(defvar swift-sdk-path "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk")
(defvar swift-configure-target "i386-apple-ios8.1")
(defun flymake-swift-init ()
- App Entry Point
app_event_loop()
- Bluetooth module's sniff interval
void app_comm_set_sniff_interval(const SniffInterval interval)
SniffInterval app_comm_get_sniff_interval(void)
enum SniffInterval {
SNIFF_INTERVAL_NORMAL
SNIFF_INTERVAL_REDUCED
- drowing path
GPath * gpath_create(const GPathInfo * init)
void gpath_destroy(GPath * gpath)
void gpath_draw_filled(GContext * ctx, GPath * path)
void gpath_draw_outline(GContext * ctx, GPath * path)
void gpath_rotate_to(GPath * path, int32_t angle)
void gpath_move_to(GPath * path, GPoint point)
struct GPath {
uint32_t num_points
GPoint points
- PROPERTYANIMATION
struct PropertyAnimation * property_animation_create_layer_frame(struct Layer * layer, GRect * from_frame, GRect * to_frame)
struct PropertyAnimation * property_animation_create(const struct PropertyAnimationImplementation * implementation, void * subject, void * from_value, void * to_value)
void property_animation_destroy(struct PropertyAnimation * property_animation)
void property_animation_update_int16(struct PropertyAnimation * property_animation, const uint32_t distance_normalized)
void property_animation_update_gpoint(struct PropertyAnimation * property_animation, const uint32_t distance_normalized)
void property_animation_update_grect(struct PropertyAnimation * property_animation, const uint32_t distance_normalized)
struct PropertyAnimation {
Animation animation
struct PropertyAnimation::@13 values
@tanb
tanb / setup_cocoapods.md
Last active December 17, 2015 18:18
Cocoapods導入
$ brew install ruby
$ gem install cocoapods
$ gem env

add /usr/local/Cellar/ruby/2.0.0-p0/bin to $PATH

$ pod setup