Skip to content

Instantly share code, notes, and snippets.

View pier-oliviert's full-sized avatar

Pier-Olivier Thibault pier-oliviert

View GitHub Profile
@pier-oliviert
pier-oliviert / UITableViewCell.m
Created February 9, 2011 16:30
UITableViewCell subclass to handle indentationLevel
- (void)layoutSubviews {
[super layoutSubviews];
float indentPoints = self.indentationLevel * self.indentationWidth;
if (indentPoints > 0) {
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
UIView *view = (UIView *)obj;
CGFloat width = CGRectGetWidth(view.frame);
if (width > indentPoints * 2)
width -= indentPoints;
CGFloat x = CGRectGetMinX(view.frame);
NSArray *receivedInstances = [[[request responseString] JSONValue] valueForKeyPath:@"groups.instances"];
NSMutableArray *ids = [NSMutableArray array];
for (NSDictionary *dict in receivedInstances) {
[ids addObject:[dict valueForKey:@"id"]];
}
//Do something with the ids...
[placeRequest setPredicate:[NSPredicate predicateWithFormat:@"longitude BETWEEN %@ && latitude BETWEEN %@",
[NSArray arrayWithObjects:
[NSExpression expressionForConstantValue:
[NSNumber numberWithDouble:(self.locationManager.location.coordinate.longitude - 0.35f)]],
[NSExpression expressionForConstantValue:
[NSNumber numberWithDouble:(self.locationManager.location.coordinate.longitude + 0.35f)]],
nil],
[NSArray arrayWithObjects:
[NSExpression expressionForConstantValue:
@pier-oliviert
pier-oliviert / gist:907021
Created April 7, 2011 04:08
Rakefile to launch/stop postgres process
namespace :database do
task :start do
pid_file = File.open("#{Rails.root}/tmp/pids/postgres.pid", 'a+')
pid = pid_file.gets.to_i
begin
Process.kill('TERM', pid.to_i) unless pid.nil?
rescue
end
@interface MyObject : NSObject {
BOOL publicBoolean;
@private
BOOL privateBoolean
}
@end
MyObject *object = [[MyObject alloc] init];
[object->someRetainedProperty release];
object->someRetainedProperty = [aProperty retain];
#! /bin/bash
function retina-resize-image {
IMAGES=$@
RADIUS='1'
SIGMA='0.0'
FILTER=Catrom
for image in $IMAGES;
- (void)layoutSubviews {
[self.fullNameLabel sizeToFit];
[self.bioTitleLabel sizeToFit];
[self.emailLabel sizeToFit];
self.profilePictureView.frame = CGRectOffset(self.profilePictureView.bounds, 15, 15);
self.fullNameLabel.frame = CGRectOffset(self.fullNameLabel.bounds, CGRectGetMaxX(self.profilePictureView.frame) + 10,
CGRectGetMidY(self.profilePictureView.frame) - 25);
if (self.rightItem == item) {
item.layer.anchorPoint = CGPointMake(1, 0.5);
} else {
item.layer.anchorPoint = CGPointMake(0, 0.5);
}
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script
$.morpheus = require("morpheus")
$.sugare = require("sugar")
class PHIntroList
PHIntroList.prototype.setPageView = (pageviewEl) ->
@pageView = pageviewEl