Skip to content

Instantly share code, notes, and snippets.

@wpsteak
wpsteak / gist:6333272
Last active December 21, 2015 16:28
solve ssh error message "Write failed: Broken pipe."http://blog.jmoz.co.uk/mac-terminal-ssh-disconnecting/
~/.ssh/config
Host *
ServerAliveInterval 240
ServerAliveCountMax 3
@wpsteak
wpsteak / params from url
Last active December 24, 2015 15:29
get params from url
usage
NSDictionary *param = [self dictionaryFromEncodedURLStr:[[request URL] query]];
/*
RFC 1808 (2.1. URL Syntactic Components)
<scheme>://<net_loc>/<path>;<params>?<query>#<fragment>
*/
- (NSString *)decodeForURL:(NSString *)urlStr {
NSString *result = (NSString *)CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
@wpsteak
wpsteak / resizeLabel
Created October 7, 2013 02:26
resize label
- (void)resizeLabel:(UILabel *)label {
int frameWidth = CGRectGetWidth(label.frame);
CGSize maximumLabelSize = CGSizeMake(frameWidth,9999);
CGSize expectedLabelSize = [label.text sizeWithFont:label.font
constrainedToSize:maximumLabelSize
lineBreakMode:NSLineBreakByWordWrapping];
[label setFrame:CGRectMake(CGRectGetMinX(label.frame), CGRectGetMinY(label.frame), frameWidth, expectedLabelSize.height)];
}
build
Builds a job, and optionally waits until its completion.
cancel-quiet-down
Cancel the effect of the "quiet-down" command.
clear-queue
Clears the build queue
connect-node
Reconnect to a node
copy-job
Copies a job.
@wpsteak
wpsteak / gist:8515935
Created January 20, 2014 06:36
iOS unit test with jenkins use kiwi + xctool
install xctool
*create test scheme for Kiwi test target
*check the "shared" checkbox to test scheme , let jenkins can see it.
*in jenkins job configure add run shell phase
xctool -workspace SampleProject.xcworkspace \
-scheme ExampleApp \
@wpsteak
wpsteak / pr.md
Created March 20, 2014 07:25 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

/**
* Several macros simplifying use of weak references to self inside blocks
* which goal is to reduce risk of retain cycles.
*
* Example:
* @code
@interface Example : NSObject{
int _i;
}
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y <= sectionHeaderHeight
&& scrollView.contentOffset.y>=0)
{
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
}
else if (scrollView.contentOffset.y >= sectionHeaderHeight)
{