Skip to content

Instantly share code, notes, and snippets.

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

Marcelo Andrade R. marceloandrader

🏠
Working from home
View GitHub Profile
+ (Response *)sendRequest:(NSMutableURLRequest *)request withUser:(NSString *)user andPassword:(NSString *)password {
//lots of servers fail to implement http basic authentication correctly, so we pass the credentials even if they are not asked for
//TODO make this configurable?
NSURL *url = [request URL];
if(user && password) {
NSString *authString = [[[NSString stringWithFormat:@"%@:%@",user, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
[request addValue:[NSString stringWithFormat:@"Basic %@", authString] forHTTPHeaderField:@"Authorization"];
NSString *escapedUser = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)user, NULL, (CFStringRef)@"@.:", kCFStringEncodingUTF8);
PS1="\n\[\e[32;1m\](\[\e[37;1m\]\u\[\e[32;1m\])-(\[\e[37;1m\]jobs:\j\[\e[32;1m\])-(\[\e[37;1m\]\w\[\e[32;1m\])\n(\[\[\e[37;1m\]! \!\[\e[32;1m\])-> \[\e[0m\]"
@marceloandrader
marceloandrader / controller.rb
Created March 30, 2011 21:31
bug with layout on rails 3 upgraded from 2.3.8
# on application_controller.rb
layout "application"
# on other_controller.rb
# this doesn't work
render :action => :show
# this work
render :action => :show, :layout => "other_layout"
# I've tried on application_controller this:
@marceloandrader
marceloandrader / convert.sh
Created April 26, 2011 21:01
convert a file from divx to mpeg1 to reproduce on sony 32bx300
#!/bin/bash
INPUT_FILE=$1
SUB_FILE=$2
OUTPUT_FILE=$3
mencoder $INPUT_FILE -sub $SUB_FILE -o $OUTPUT_FILE -ofps 25 -vf scale=1280:720 -of lavf \
-lavfopts format=mpg -oac lavc -lavcopts acodec=mp2:abitrate=224 -ovc lavc \
-lavcopts vcodec=mpeg1video:vrc_buf_size=1835:keyint=15:vrc_maxrate=1152:vbitrate=1152:vmax_b_frames=0:aspect=16/9 \
-of mpeg
@marceloandrader
marceloandrader / commit-msg.rb
Created May 17, 2011 17:15
commit-msg for xtimes
#!/usr/bin/env ruby
# Author: Marcelo Andrade
# this hook check the validity of a commit message in the format we
# can input to xtimes to create a valid event tagged with the tasks
# we are working on
# INSTALLATION
# Copy this file in each repo in the hooks directory and give execution permission:
{
"event_id": 1,
"survey": {
"title": "Survey 1",
"description": "Description 1",
"questions": [{
"question_id": 1,
"title": "Question 1",
"description": "Desc Question 1",
"question_type": "simple",
@marceloandrader
marceloandrader / README.md
Created August 3, 2011 17:08
external diff for git on mac
git config --global diff.external ~/[PATH]/opendiff-git.sh
@marceloandrader
marceloandrader / mail.php
Created August 17, 2011 15:06
Replace sendmail script for avoid sending mails to real people on dev
#!/usr/local/bin/php
<?php
$email = file_get_contents('php://stdin');
$email = preg_replace('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/', '<email_you_want_to_redirect>', $email);
//var_dump($email);
//exit;
$fd = popen("/usr/sbin/sendmail -t","w") or die("Couldn't Open Sendmail");
@marceloandrader
marceloandrader / ios_sdk_download.sh
Created September 30, 2011 16:27
Download ios sdk with wget
# First need to install cookie exporter on firefox
# Enter to the developer site
# Try to download the file
# Copy the url from the downloads
# Export the cookies.txt file
# Then run this command
wget --limit-rate=50k --server-response --continue --no-check-certificate --load-cookies=cookies.txt http://adcdownload.apple.com/Developer_Tools/xcode_4.1_for_snow_leopard_21110/xcode_4.1_for_snow_leopard.dmg
@marceloandrader
marceloandrader / snippets.m
Created October 7, 2011 15:46
ios snippets
// For trace where an object is being released
- (void)release {
NSLog(@"%@",[NSThread callStackSymbols]); // Print the stack trace
[super release]; //Set breakpoint here
}