Skip to content

Instantly share code, notes, and snippets.

View jagbolanos's full-sized avatar

Jorge Garcia jagbolanos

View GitHub Profile
#just testin'
puts "hallo welt"
int x = 0;
x++;
if (x > 10)
cout << "Hola Mundo" << endl;
@jagbolanos
jagbolanos / fieldsize.m
Created March 3, 2011 21:31
Create a rectangular field
function [nrows, ncols, nslices] = fieldsize(cols, slices)
%cols = 102; % in this particular case FieldSize / 0.0977 right now an even number is necessary
%slices = 40; %in this particular case FieldSize / 0.25 right now an even number is necessary
%edgeS.rows = repmat(256,1,squareFieldSizeCols*squareFieldSizeSlices);
%edgeS.cols = repmat((256-squareFieldSizeCols/2+1):(256+squareFieldSizeCols/2),1,squareFieldSizeSlices); % 512 / 2 => 256
%edgeS.slices = repmat((64-squareFieldSizeSlices/2+1):(64+squareFieldSizeSlices/2),1,squareFieldSizeCols) %1
ncols = zeros(1,cols*slices);
i = 1;
for v=(256-cols/2+1):(256+cols/2)
@jagbolanos
jagbolanos / dfsalgorithms.hs
Created March 5, 2011 23:37
Some DFS based graph algorithms in Haskell
--Proposed solutions to problems 87,88 and 89 of "99 Haskell Problems"
--Not optimal but they work
--If you know haskell and want to solve some problems there are some missing at:
--http://www.haskell.org/haskellwiki/99_questions/80_to_89
import Data.List
type Node = Int
type Edge = (Node,Node)
type Graph = ([Node],[Edge])
@jagbolanos
jagbolanos / gist:1724258
Created February 2, 2012 16:07
Get Directions
// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[self.locationManager stopUpdatingLocation];
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%0.6f,%0.6f&daddr=%@,%@",
newLocation.coordinate.latitude,
newLocation.coordinate.longitude,
@jagbolanos
jagbolanos / gist:1731067
Created February 3, 2012 16:47
Load XiB for TableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
NSArray *screens=[[NSBundle mainBundle] loadNibNamed:@"StatusViewTableViewCell" owner:self options:nil];
[self addSubview:[screens objectAtIndex:0]];
}
return self;
}
@jagbolanos
jagbolanos / gist:1754933
Created February 6, 2012 21:15
TabBarViewController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
UITabBarController *tbc = [[UITabBarController alloc] init];
UINavigationController *nvc = [[UINavigationController alloc] init];
StreamViewController *vc = [[StreamViewController alloc] init];
vc.title = @"Vampire Or Not";
[nvc pushViewController:vc animated:NO];
@jagbolanos
jagbolanos / gist:1755208
Created February 6, 2012 21:58
Publish photo to facebook
- (void) publishToFacebook:(NSData*)image withMessage:(NSString*)message {
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setValue:message forKey:@"message"];
[params setValue:image forKey:@"source"];
[[[Util sharedInstance] facebook] requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
[params release];
}
@jagbolanos
jagbolanos / gist:1755953
Created February 6, 2012 23:45
Load Facebook object
+(BOOL) loadSession {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:ACCESS_TOKEN_KEY] ||
![defaults objectForKey:EXPIRATION_DATE_KEY] ||
![defaults objectForKey:FACEBOOK_USER]) {
[Util clearSession];
return NO;
}
Facebook *facebook = [[Util sharedInstance] facebook];
@jagbolanos
jagbolanos / gist:1773906
Created February 8, 2012 21:10
Get Mac Address
+ (NSString *)getMacAddress
{
int mgmtInfoBase[6];
char *msgBuffer = NULL;
size_t length;
unsigned char macAddress[6];
struct if_msghdr *interfaceMsgStruct;
struct sockaddr_dl *socketStruct;
NSString *errorFlag = NULL;