Skip to content

Instantly share code, notes, and snippets.

View warriorg's full-sized avatar
🏠
Working from home

warriorg warriorg

🏠
Working from home
View GitHub Profile
@warriorg
warriorg / tmux-cheatsheet.markdown
Created June 1, 2017 02:29 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@warriorg
warriorg / post-receive.sh
Created October 28, 2016 05:42
触发Jenkins构建
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "developer" == $branch ]; then
echo 'start call jenkins'
curl -s --user 用户名:密码 url
echo 'end call jenkins'
fi
done
@warriorg
warriorg / mongo-autostart-osx.md
Created June 30, 2016 10:45 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@warriorg
warriorg / gist:19f1ca39144d9caf1497
Created March 12, 2016 03:21
干掉UITableView 最后一个 separatorLine
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.row == formList!.count - 1) {
cell.separatorInset = UIEdgeInsetsMake(0, cell.bounds.size.width, 0, 0)
return;
}
cell.separatorInset = UIEdgeInsetsZero
if #available(iOS 8.0, *) {
cell.preservesSuperviewLayoutMargins = false
@warriorg
warriorg / java stream group
Created January 25, 2016 07:58
java groupingBy
Map<String, List<Pojo>> map = pojos.stream().collect(Collectors.groupingBy(Pojo::getKey));
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor lightGrayColor];
UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
@warriorg
warriorg / UITableViewCellHeight
Created December 10, 2015 05:37
UITableView row height dynamic
static UITableViewCell *sizingCell = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sizingCell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
});
[sizingCell setNeedsLayout];
[sizingCell layoutIfNeeded];
CGFloat height = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return height;
@warriorg
warriorg / uitableview separator inset
Created December 5, 2015 02:47
UITableView separator inset
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
@warriorg
warriorg / build.gradle
Created November 27, 2015 03:20 — forked from khernyo/build.gradle
Gradle Android configuration with .so hack
// This hack works with com.android.tools.build:gradle:0.2, won't work in later version without modification
apply plugin: 'android'
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = 'android-14'
@warriorg
warriorg / UIViewTouchStyle.m
Created November 7, 2015 05:11
UIView 增加触摸效果
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1.0]];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesCancelled:touches withEvent:event];