Skip to content

Instantly share code, notes, and snippets.

View christianroman's full-sized avatar

Christian Roman christianroman

  • Mexico
View GitHub Profile
@christianroman
christianroman / _flash.html.erb
Last active December 18, 2015 02:09 — forked from potomak/_flash.html.erb
Rails flash messages using Twitter bootstrap 2
<% [:notice, :error, :alert].each do |level| %>
<% unless flash[level].blank? %>
<div class="alert <%= flash_class(level) %>">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<span><%= flash[level] %></span>
</div>
<% end %>
<% end %>
@christianroman
christianroman / training.sh
Last active November 22, 2024 21:52
Tesseract OCR training new font
#! /bin/bash
# build the environment
mkdir tessenv; cd tessenv
TROOT=`pwd`
mkdir $TROOT/stockfonts; mkdir $TROOT/build; mkdir $TROOT/build/eng
echo "Environment built"
# Get the stock english fonts from Google (old, but they work)
cd $TROOT/stockfonts
GET http://tesseract-ocr.googlecode.com/files/boxtiff-2.01.eng.tar.gz > boxtiff-2.01.eng.tar.gz
@christianroman
christianroman / implementation.mm
Created June 10, 2013 05:28
Mixing C, C++, Objective-C
#if defined _cplusplus
extern "C" {
#endif
void your_c_function()
{
...
}
#if defined _cplusplus
}
#endif
@christianroman
christianroman / NSString+Concatenation.h
Last active January 29, 2018 14:08
NSString+Concatenation
#import <Foundation/Foundation.h>
@interface NSString (Concatenation)
- (NSString *):(NSString *)a;
- (NSString *):(NSString *)a :(NSString *)b;
- (NSString *):(NSString *)a :(NSString *)b :(NSString *)c;
- (NSString *):(NSString *)a :(NSString *)b :(NSString *)c :(NSString *)d;
- (NSString *)concat:(NSString *)strings, ...;
@christianroman
christianroman / gist:5835899
Created June 22, 2013 04:41
Install PostgreSQL 9.2 + PostGIS on CentOS 6
rpm -Uvh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
yum install postgresql92 postgresql92-server postgresql92-contrib postgis2_92 postgis2_92-utils
chkconfig postgresql-9.2 on
service postgresql-9.2 initdb
service postgresql-9.2 start
@christianroman
christianroman / Asset.sh
Created June 22, 2013 05:01
Prepare PgRouting database
# su - postgres
psql testgisdb -f /usr/share/postlbs/routing_core.sql
psql testgisdb -f /usr/share/postlbs/routing_core_wrappers.sql
psql testgisdb -f /usr/share/postlbs/routing_topology.sql
psql testgisdb -f /usr/share/postlbs/routing_tsp.sql
psql testgisdb -f /usr/share/postlbs/routing_tsp_wrappers.sql
psql testgisdb -f /usr/share/postlbs/routing_dd.sql
psql testgisdb -f /usr/share/postlbs/routing_dd_wrappers.sql
NSString *address = @"http://gdata.youtube.com/feeds/api/playlists/PLH6Z1vsFvaeTMmRL8GfC3i_rAwLKOOtNF?v=2";
NSURL *url = [[NSURL alloc] initWithString:address];
NSError *error;
NSString *XML = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
NSData *data = [XML dataUsingEncoding:NSUTF8StringEncoding];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
jQuery.ajax({
type: 'POST',
url: 'validarCodigoInvitacion',
data: {inputCodigo : '41F8**** tu codigo'},
dataType: 'json',
success: function(response) { console.log(response) ;},
error: function(req, err){ console.log(err); }
});
@christianroman
christianroman / gist:6147093
Created August 3, 2013 16:48
Github repository random name suggestion
sh -c 'cat /usr/share/dict/words | sed -n $(echo $((`cat /dev/urandom | od -N3 -An -i` % `cat /usr/share/dict/words | wc -l`)))p'
@christianroman
christianroman / nginx
Created August 31, 2013 05:13
Nginx init script for CentOS 6/RHEL after running passenger-install-nginx-module
#!/bin/sh
#
# nginx Startup script for nginx
#
# chkconfig: - 85 15
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# description: nginx is an HTTP and reverse proxy server