Skip to content

Instantly share code, notes, and snippets.

View christianroman's full-sized avatar

Christian Roman christianroman

  • Mexico
View GitHub Profile
@christianroman
christianroman / blendoverlay.m
Created October 26, 2013 07:11
Blend overlay
- (UIImage *)blendOverlay:(UIImage *)topImage withBaseImage:(UIImage *)baseImage toSize:(CGFloat)imageSize
{
UIGraphicsBeginImageContext(CGSizeMake(imageSize, imageSize));
[baseImage drawInRect:CGRectMake(0.0, 0.0, imageSize, imageSize)];
[topImage drawInRect:CGRectMake(0.0, 0.0, imageSize, imageSize) blendMode:kCGBlendModeNormal alpha:0.5];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
@christianroman
christianroman / coloration.m
Created October 26, 2013 07:00
Icon coloration at runtime
-(UIImage *) negativeImage
{
UIGraphicsBeginImageContext(self.size);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
[self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)];
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, self.size.width, self.size.height));
UIImage *negativeImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@christianroman
christianroman / DatePickerDialogWithMinRange.java
Last active December 25, 2015 02:59
Custom DatePickerDialog class with min date (API Level < 11)
package com.chroman.test;
import android.app.DatePickerDialog;
import android.content.Context;
import android.widget.DatePicker;
/**
* Created by chroman on 09/10/13.
*/
@christianroman
christianroman / gist:6828452
Created October 4, 2013 16:08
Rails grep before renaming a project
grep -Ri 'oldprojectame' * | cut -f1 -d':' | sort | uniq
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
@christianroman
christianroman / CentOS_IPTables.sh
Created September 1, 2013 04:54
CentOS_IPTables.sh
#!/bin/sh
#
# A shell script used to setup rules for iptables. Rules gleened from
# various websites.
#
# References:
# http://www.newartisans.com/blog_files/tricks.with.iptables.php
# Wipe the tables clean
iptables -F
@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
@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'
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); }
});
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];