Skip to content

Instantly share code, notes, and snippets.

@ishida
ishida / adbss.sh
Created May 27, 2015 06:25
Android screen capture shell command
#!/bin/bash
DATE=`date +"%Y-%m-%d-%H-%M-%S"`
FILENAME="s-${DATE}.png"
echo "capturing ${FILENAME}..."
adb shell screencap -p "/sdcard/${FILENAME}"
adb pull /sdcard/"${FILENAME}"
adb shell rm "/sdcard/${FILENAME}"
echo "saved ${FILENAME}."
@ishida
ishida / gist:d76dce6e30eaf0a77dbb
Last active September 28, 2021 17:09
Update line height of UILabel in storyboard
@implementation UILabel (Extensions)
...
- (void)setLineHeight:(float)lineHeight
{
NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init];
paragrahStyle.minimumLineHeight = lineHeight;
paragrahStyle.maximumLineHeight = lineHeight;
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc]
@ishida
ishida / gist:6619161
Created September 19, 2013 04:32
find and grep
find . -exec grep -nHE "foo" {} \;
@ishida
ishida / gist:5722631
Created June 6, 2013 15:57
run server of sinatra-thin
bundle exec thin start -R config.ru --threaded -p 9292
@ishida
ishida / gist:5722607
Created June 6, 2013 15:53
run server of sinatra-puma
bundle exec puma -p 9292 -e development -t 0:20 -C config/puma.rb
@ishida
ishida / gist:5670785
Last active December 17, 2015 20:49
get memory usage @mac
`ps alx | grep \[r\]uby | awk '{printf ("%d", $8)}'`.to_i
`ps -o rss= -p #{Process.pid}`.to_i
@ishida
ishida / gist:4129569
Created November 22, 2012 05:38
Detect touches
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:aView];
NSLog(@"Touch detected: x=%lf, y=%lf", p.x, p.y);
if (0 <= p.y && p.y <= aView.frame.size.height
&& 0 <= p.x && p.x <= aView.frame.size.width)
{
//do something
}
@ishida
ishida / gist:4116621
Created November 20, 2012 07:44
Show ViewController and NavigationController
+ (void)showViewControllerAndNavigationControllerFromParentViewController:(UIViewController *)parentVC
{
AViewController *vc = [[[AViewController alloc] init] autorelease];
UINavigationController* nc = [[[UINavigationController alloc]
initWithRootViewController:vc] autorelease];
nc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
vc.navigationController = nc;
vc.navigationBar = nc.navigationBar;
@ishida
ishida / gist:4086344
Created November 16, 2012 10:45
Objective-C Delegate
//
// AViewController.h
//
@protocol AViewControllerDelegate;
@interface AViewController : UIViewController <AViewControllerDelegate>
{
id <AViewControllerDelegate> delegate;
}
@property (nonatomic, retain) id <AViewControllerDelegate> delegate;
@ishida
ishida / gist:3825662
Created October 3, 2012 07:49
Xcode .gitignore
#--------
# xcode noise
build/*
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/default.*
**/*.xcodeproj/*
!**/*.xcodeproj/project.pbxproj