Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Roman christianroman

  • Mexico
View GitHub Profile
@christianroman
christianroman / gist:2e86522765badb7682ef
Created Sep 2, 2014
Reset the iOS Simulator from the command line in Xcode 6
View gist:2e86522765badb7682ef
# /Applications/Xcode6-Beta7.app/Contents/Developer/usr/bin/simctl
simctl erase C24126D7-51CD-4731-848A-267E711E1ECD
View gist:16b407f17c81b384cfa1
Objective: {objective 0x79f56080: <750:560, 251:-24108, 250:384> + <251:1>*0x79f5aff0:IB auto generated at build time for view with fixed frame.marker{id: 84} + <251:1>*0x79f5b0a0:IB auto generated at build time for view with fixed frame.marker{id: 86} + <250:1>*0x79f5d690.marker{id: 225} + <250:1>*0x79f5dd60.marker{id: 227} + <250:1>*0x79f5ecc0.marker{id: 229} + <250:1>*0x79f5ecf0.marker{id: 231} + <250:1>*0x79f5f5c0.marker{id: 221} + <250:1>*0x79f5f5f0.marker{id: 223} + <251:1>*0x79f611d0.marker{id: 122} + <251:1>*0x79f620f0.marker{id: 124} + <251:1>*0x79f62120.marker{id: 126} + <251:-1>*0x79f62150.marker{id: 128} + <251:-1>*0x79f621b0.marker{id: 132} + <251:-1>*0x79f621e0.marker{id: 135} + <251:-1>*0x79f62210.marker{id: 138} + <251:-1>*0x79f62240.marker{id: 140} + <250:1>*0x79f62430.marker{id: 146} + <750:1>*0x79f62460.marker{id: 148} + <250:-1>*0x79f62490.marker{id: 150} + <250:-1>*0x79f624c0.marker{id: 152} + <750:1>*0x79f624f0.marker{id: 154} + <251:1>*0x79f62820.marker{id: 163} + <251:1>*0x79f63430.mar
@christianroman
christianroman / FHC1.swift
Last active Aug 29, 2015
Facebook Hacker Cup 2015 Qualification Round: Cooking the Books
View FHC1.swift
import Foundation
let location = "~/input.in".stringByExpandingTildeInPath
let content = String(contentsOfFile: location, encoding: NSUTF8StringEncoding, error: nil)!
var lines = split(content, { $0 == "\n"}, maxSplit: Int.max, allowEmptySlices: false)
let cases = lines.removeAtIndex(0)
for (i, n) in enumerate(lines) {
let digits = map(n) { String($0).toInt()! }
View ReactNative.js
This file has been truncated, but you can view the full file.
__SSTOKENSTRING = "@generated SignedSource<<dbe928e1275c495c1922c1bf063ffb70>>";
! function(e) {
function t(e) {
function t() {
var t = Array.prototype.map.call(arguments, function(e) {
if (null == e) return null === e ? "null" : "undefined";
if ("string" == typeof e) return '"' + e + '"';
try {
return JSON.stringify(e)
@christianroman
christianroman / Alumno.java
Created Apr 23, 2012
Hibernate Many-To-Many with Extra Columns
View Alumno.java
package org.cobaem.domain;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
@christianroman
christianroman / AES-RSA.java
Created May 11, 2012
Generate AES secret key
View AES-RSA.java
public static void main(String[] args) {
String plainText = "Very secret data";
AES aesClient = new AES("client");
SecretKey AESKey = aesClient.getEncodedSecret();
RSA rsaClient = new RSA();
byte[] RSAcipher = rsaClient.EncryptSecretKey(AESKey);
String cipherData = aesClient.encryptAndSerialize(plainText);
// Assume that client sends the cipherData and RSAcipher to the server...
@christianroman
christianroman / OCR.java
Created May 15, 2012
Captcha OCR + Tessaract Complex
View OCR.java
public class OCR {
private static final String INPUT = "C:/captcha/ex.png";
private static final String OUTPUT = "C:/captcha/captcha-out.png";
private static final String TESSERACT_BIN = "C:/Program Files/Tesseract-OCR/tesseract.exe";
private static final String TESSERACT_OUTPUT = "C:/captcha/out.txt";
private static final int WHITE = 0x00FFFFFF, BLACK = 0x00000000;
public static void main(String... args) throws Exception {
BufferedImage image = ImageIO.read(new FileInputStream(INPUT));
int average = 0;
@christianroman
christianroman / gist:3191095
Created Jul 27, 2012
UITableViewCell gradient using Quartz 2D
View gist:3191095
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGGradientRef glossGradient;
CGColorSpaceRef rgbColorspace;
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = { 1.0, 1.0, 1.0, 1,
0.95, 0.95, 0.95, 1 };
rgbColorspace = CGColorSpaceCreateDeviceRGB();
@christianroman
christianroman / gist:3242465
Created Aug 3, 2012
Switch Object in Objective-C
View gist:3242465
BOOL switchObject(id anObject, ...)
{
va_list args;
va_start(args, anObject);
id value = nil;
BOOL matchFound = NO;
while ( (value = va_arg(args,id)) )
{
@christianroman
christianroman / gist:3248993
Created Aug 3, 2012
Check if UITextFields are empty using Objective-C
View gist:3248993
- (BOOL)emptyTextFields:(id)toCompare, ...
{
va_list args;
va_start(args, toCompare);
id value = nil;
BOOL match = NO;
while ((value = va_arg(args,id)))
if([toCompare isKindOfClass:[NSString class]] && [value isKindOfClass:[UITextField class]])
if([[(UITextField *)value text] isEqualToString:toCompare])