Skip to content

Instantly share code, notes, and snippets.

View rdeguzman's full-sized avatar

Rupert de Guzman rdeguzman

View GitHub Profile
@rdeguzman
rdeguzman / capybara cheat sheet
Last active August 29, 2015 14:04 — forked from zhengjia/capybara cheat sheet
Capybara Cheatsheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@rdeguzman
rdeguzman / MainViewController.m
Created March 4, 2011 04:58
Do we need to release button?
- (void)initButtons{
NSLog(@"MainViewController.initButtons");
CGFloat totalHeight = BUTTON_ORIGIN_Y;
for(NSDictionary* section in arraySections){
NSString* title = [section objectForKey:@"title"];
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];
[button setTitle:title forState:UIControlStateNormal];
#define PADDING_VERTICAL 5.0f
#define BUTTON_HEIGHT 40.0f
#define BUTTON_WIDTH 160.0f
#define BUTTON_ORIGIN_X (320.0f - BUTTON_WIDTH)/2.0f
#define BUTTON_ORIGIN_Y 20.0f
- (void)initButtons{
NSLog(@"MainViewController.initButtons");
CGFloat totalHeight = BUTTON_ORIGIN_Y;
@rdeguzman
rdeguzman / passing object to a UIButton
Created March 7, 2011 07:47
how to pass arraySection element or [arraySection objectForKey:@"id"] to a button?
#define PADDING_VERTICAL 5.0f
#define BUTTON_HEIGHT 40.0f
#define BUTTON_WIDTH 160.0f
#define BUTTON_ORIGIN_X (320.0f - BUTTON_WIDTH)/2.0f
#define BUTTON_ORIGIN_Y 20.0f
- (void)initButtons{
NSLog(@"MainViewController.initButtons");
if(arraySections == nil){
@rdeguzman
rdeguzman / application_controller.rb
Created November 23, 2011 03:15
How to test if @fleet_group exists in rspec2 + rails3 + devise
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!, :store_location
def stored_location_for(resource)
nil
end
def after_sign_in_path_for(resource)
@rdeguzman
rdeguzman / report_controller.rb
Created November 28, 2011 05:19
How to merge conditions hash with parameters
def gps_activity
@sidebar_units = Unit.where(:fleet_id => @chosen_fleets_array).not_hidden.order("NAME")
unless params[:unit_ids].blank?
@chosen_units_array = params[:unit_ids]
else
@chosen_units_array = @sidebar_units.collect{ |u| [u.id]}
end
conditions = {:fleet_id => @chosen_fleets_array}
@rdeguzman
rdeguzman / gist:1464086
Created December 12, 2011 01:30
brew install libxml++ problem
==> Installing libxml++ dependency: glibmm
==> Downloading http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.22/glibmm-2.22.2.tar.gz
File already downloaded in /Users/rupert/Library/Caches/Homebrew
==> ./configure --prefix=/usr/local/Cellar/glibmm/2.22.2
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
@rdeguzman
rdeguzman / gist:1464734
Created December 12, 2011 03:57
Makefile
PROG = ncm
INCDIR = include libsai
BUILDDIR = build
LIBSAI = libSAI.a
DEPENDS = .depend
HOST := $(shell hostname)
USER := $(shell id -un)
#import "HJImageView.h"
#import "JSONKit.h"
#import "ASIHTTPRequest.h"
#import "Country.h"
#import "ApplicationConstants.h"
#import "MainTableViewConstants.h"
@rdeguzman
rdeguzman / install
Created December 19, 2011 01:04
brew install php --with-apache --with-mysql FAILS!
/usr/local/Cellar[master]% brew install gmp
==> Downloading http://ftpmirror.gnu.org/gmp/gmp-5.0.2.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gmp/5.0.2 --enable-cxx --build=x86_64-apple-darwin
==> make
==> make install
==> make check
/usr/local/Cellar/gmp/5.0.2: 11 files, 2.4M, built in 3.2 minutes
brew install gmp 158.17s user 68.52s system 116% cpu 3:14.86 total
/usr/local/Cellar[master]% brew install php --with-apache --with-mysql