Skip to content

Instantly share code, notes, and snippets.

View betzerra's full-sized avatar

Ezequiel Alejandro Becerra betzerra

View GitHub Profile
import sys, math, random
class Point:
def __init__(self, coords, reference=None):
self.coords = coords
self.n = len(coords)
self.reference = reference
def __repr__(self):
return str(self.coords)
@betzerra
betzerra / gist:d3259ae845105acd76b5
Created May 25, 2014 18:49
CLGeocoder: kCLErrorDomain == 2
// Error reported in http://stackoverflow.com/questions/23819466/error-return-address-clgeocoder
NSString *anAddressString = @"568 Broadway, New York, NY"
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
void (^geocodeBlock)(NSArray *placemarks, NSError *error) = ^(NSArray *placemarks, NSError *error) {
if (error) {
/*
* Printing error gets -> Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be
@betzerra
betzerra / gist:68957450ed5d6e9dd912
Last active August 29, 2015 14:02
Spring animation using iOS 7
// Set startFrame and endFrame for _contentView
CGRect endFrame = _contentView.frame;
CGRect startFrame = endFrame;
startFrame.origin.y = -startFrame.size.height;
_contentView.frame = startFrame;
void (^animationBlock)(void) = ^(void){
_contentView.frame = endFrame;
};
@betzerra
betzerra / gist:2771906
Created May 22, 2012 21:59
Git Commands
# Add Git Repository as a subRepository
git submodule add git@mygithost:billboard lib/billboard
@betzerra
betzerra / pointInTriangle.m
Created May 27, 2012 21:19
Detect a point in a triangle in Cocos2d
// found in http://www.cocos2d-iphone.org/forum/topic/9138
CGFloat GBDot(const CGPoint v1, const CGPoint v2) {
return v1.x*v2.x + v1.y*v2.y;
}
CGPoint GBSub(const CGPoint v1, const CGPoint v2) {
return CGPointMake(v1.x - v2.x, v1.y - v2.y);
}
@betzerra
betzerra / resources.sh
Created June 11, 2012 15:15
Finds unused resources (images actually) from an XCode project
#!/bin/bash
# Found at http://gr3p.com/2012/06/encontrar-recursos-no-usados-en-un-proyecto-de-xcode
for i in `find . -name "*.png" -o -name "*.jpg"`; do
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x`
result=`ack -i "$file"`
if [ -z "$result" ]; then
echo "$i"
fi
@betzerra
betzerra / gist:3184872
Created July 26, 2012 22:08
Objective-C fancy stuff for code
__attribute__ ((deprecated))
@betzerra
betzerra / gist:3421052
Created August 22, 2012 01:00
Steps to initialise a git repository and push to an existing remote repository
git init
git remote add origin https://github.com/username/Hello-World.git
#make some commits here
git push origin master
@betzerra
betzerra / gist:3830789
Created October 4, 2012 00:31
Get a NSString with current song's title and artist
-(NSString *) currentSong {
NSString *retVal = nil;
MPMusicPlayerController* iPodMusicPlayer = [MPMusicPlayerController iPodMusicPlayer];
MPMediaItem *mediaItem = [iPodMusicPlayer nowPlayingItem];
if (mediaItem) {
NSString *artist = [mediaItem valueForProperty: MPMediaItemPropertyArtist];
NSString *song = [mediaItem valueForProperty: MPMediaItemPropertyTitle];
retVal = [NSString stringWithFormat:@"NLT: %@ - %@", song, artist];
@betzerra
betzerra / gist:4236646
Created December 7, 2012 21:22
Curl commands
#GET
curl -HAccept:text/plain http://example.com/base
#PUT
curl -XPUT -HContent-type:text/plain --data "stuff:morestuff" http://example.com/base?param=val
#DELETE
curl -XDELETE http://example.com/base/user/123
#POST