Skip to content

Instantly share code, notes, and snippets.

View alvareztech's full-sized avatar
:octocat:
Coding...

Daniel Alvarez alvareztech

:octocat:
Coding...
View GitHub Profile
@alvareztech
alvareztech / gist:8742404
Last active August 29, 2015 13:55
iOS: Call phone direct.
NSString *phNo = @"+919876543210";
NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",phNo]]; // ok tel:
if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
[[UIApplication sharedApplication] openURL:phoneUrl];
} else {
calert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Call facility is not available!!!" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[calert show];
}
@alvareztech
alvareztech / gist:8866627
Created February 7, 2014 16:47
iOS: Ask if location service is enabled and with permission.
if ([CLLocationManager locationServicesEnabled]) {
NSLog(@"Servicio de localización habilitado.");
if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
NSLog(@"Servicio de localización habilitado sin permiso de uso.");
} else {
NSLog(@"Servicio de localización habilitado con permiso de uso.");
}
} else {
NSLog(@"Servicio de localización deshabilitado.");
}
@alvareztech
alvareztech / gist:9128249
Created February 21, 2014 03:31
Android: Change Font Family TextView.
From android 4.1 / 4.2, the following Roboto font families are available:
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
in combination with
android:textStyle="normal|bold|italic"
@alvareztech
alvareztech / gist:57de52b004c6f9bad427
Created May 30, 2014 20:40
Get url img parse xml
-(NSString *)getImgUrl:(NSString *)inputString{
NSString *url = nil;
NSScanner *theScanner = [NSScanner scannerWithString:inputString];
// find start of IMG tag
[theScanner scanUpToString:@"<img " intoString:nil];
if (![theScanner isAtEnd]) {
[theScanner scanUpToString:@"src" intoString:nil];
NSCharacterSet *charset = [NSCharacterSet characterSetWithCharactersInString:@"\"'"];
[theScanner scanUpToCharactersFromSet:charset intoString:nil];
[theScanner scanCharactersFromSet:charset intoString:nil];
//
// VistaPrincipalViewController.m
// Proyecto2
//
// Created by Fabiola Ramirez on 29/06/14.
// Copyright (c) 2014 Fabiola Ramirez. All rights reserved.
//
#import "VistaPrincipalViewController.h"
#import "Annotation.h"
//
// VistaPrincipalViewController.m
// Proyecto2
//
// Created by Fabiola Ramirez on 29/06/14.
// Copyright (c) 2014 Fabiola Ramirez. All rights reserved.
//
#import "VistaPrincipalViewController.h"
#import "Annotation.h"
@alvareztech
alvareztech / gist:3929148
Created October 22, 2012 01:03
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@alvareztech
alvareztech / Main.java
Last active December 20, 2015 07:19
My hello gist.
public class Main {
public static void main(String[] args) {
System.out.print("Hello Gist!");
}
}
@alvareztech
alvareztech / gist:6131694
Last active December 20, 2015 12:29
iOS: Label with fit size (wrap content)
label.text = @"some text";
[label sizeToFit];
@alvareztech
alvareztech / gist:6390210
Last active December 22, 2015 00:38
Parse JSON with Objective-C.
NSError *error = nil;
id jsonObject = [NSJSONSerialization
JSONObjectWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:&error];
if (jsonObject != nil && error == nil) {
NSLog(@"Successfully deserialized...");
if ([jsonObject isKindOfClass:[NSDictionary class]]) {
NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
NSLog(@"Deserialized JSON Dictionary = %@", deserializedDictionary);
} else if ([jsonObject isKindOfClass:[NSArray class]]) {