Skip to content

Instantly share code, notes, and snippets.

View Gurpartap's full-sized avatar
:octocat:
Working from home

Gurpartap Singh Gurpartap

:octocat:
Working from home
View GitHub Profile
@Gurpartap
Gurpartap / base_role.rb.sh
Created July 29, 2012 23:12
chef-client cookbook getting started
(cat <<'EOP'
name "base"
description "Base role applied to all nodes"
override_attributes(
"chef_client" => {
"server_url" => "https://api.opscode.com/organizations/ORGNAME",
"validation_client_name" => "ORGNAME-validator"
}
)
run_list(
@Gurpartap
Gurpartap / app_models_server.rb
Created July 27, 2012 22:35
ruote getting started
class Server
...
pdef_provision = Ruote.process_definition do
cursor do
provision
rewind :if => '${not_ok}'
end
end
> bundle install --path .bundle 7 ↵ ✹ ✭Fetching gem metadata from https://rubygems.org/........
Bundler could not find compatible versions for gem "sexp_processor":
In Gemfile:
ruote (>= 2.2.0) ruby depends on
sexp_processor (~> 3.0) ruby
ruote (>= 2.2.0) ruby depends on
sexp_processor (4.0.1)
@Gurpartap
Gurpartap / gist:2622921
Created May 6, 2012 15:28
sed function with escaped keyword and replacement
function sedeasy {
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
}
sedeasy "include /etc/nginx/conf.d/*" "include /apps/*/conf/nginx.conf" /etc/nginx/nginx.conf
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
float rotation;
CGRect frame = CGRectMake(0, 0, 480, 320);
if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
rotation = 0;
frame = CGRectMake(0, 0, 320, 480);
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
rotation = M_PI/2;
}
@Gurpartap
Gurpartap / gist:1625737
Created January 17, 2012 08:56
Custom UILabel in cell
UILabel *messageTextLabel = [[UILabel alloc] init];
messageTextLabel.text = @"Hello World";
CGSize maximumSize = cell.contentView.frame.size; // adjust this.
UIFont *font = [UIFont systemFontOfSize:14];
CGSize stringSize = [messageTextLabel.text sizeWithFont:font
constrainedToSize:maximumSize
lineBreakMode:messageTextLabel.lineBreakMode];
@Gurpartap
Gurpartap / gist:1625722
Created January 17, 2012 08:52
Custom abtableviewcell
#import <UIKit/UIKit.h>
#import "ABTableViewCell.h"
@interface MediaTableViewCell : ABTableViewCell
@end
@implementation MediaTableViewCell
@Gurpartap
Gurpartap / nginx.conf
Created December 29, 2011 01:39
/usr/local/nginx/conf/nginx.conf
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
@Gurpartap
Gurpartap / gist:1530414
Created December 28, 2011 23:28
/etc/init.d/god
#!/bin/bash
#
# god Startup script for god (http://god.rubyforge.org)
#
# chkconfig: - 85 15
# description: God is an easy to configure, easy to extend monitoring \
# framework written in Ruby.
#
CONF_DIR=/usr/local/god
@Gurpartap
Gurpartap / gist:1530397
Created December 28, 2011 23:25
Nginx God config
God.watch do |w|
w.name = "nginx"
w.interval = 30.seconds
w.start = "/etc/init.d/nginx start"
w.stop = "/etc/init.d/nginx stop"
w.restart = "/etc/init.d/nginx restart"
w.start_grace = 10.seconds
w.restart_grace = 10.seconds
w.pid_file = "/var/run/nginx.pid"