Skip to content

Instantly share code, notes, and snippets.

View christianroman's full-sized avatar

Christian Roman christianroman

  • Mexico
View GitHub Profile
@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 / gist:6516864
Last active February 10, 2020 16:28
Install PostgreSQL 9.3.1 + PostGIS + PGRouting on CentOS 6.4
rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
yum install postgresql93 postgresql93-server postgresql93-contrib postgresql93-devel postgis2_93 postgis2_93-utils
#Configure PostgreSQL
chkconfig postgresql-9.3 on
service postgresql-9.3 initdb
service postgresql-9.3 start
# Create PostGIS template
<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 / UIImage+ImageEffects.m
Created September 27, 2013 04:23
UIImage+ImageEffects.m
//
// UIImage+ImageEffects.m
// AnimationExamples
//
// Created by Timothy Patrick Johnson on 7/3/13.
// Copyright (c) 2013 Meister. All rights reserved.
//
#import "UIImage+ImageEffects.h"
@christianroman
christianroman / gist:6828452
Created October 4, 2013 16:08
Rails grep before renaming a project
grep -Ri 'oldprojectame' * | cut -f1 -d':' | sort | uniq
@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 / blur.rb
Created October 11, 2013 18:33
Blurring images in Rails with Paperclip custom processor
module Paperclip
class Blur < Processor
def initialize file, options = {}, attachment = nil
super
@format = File.extname(@file.path)
@basename = File.basename(@file.path, @format)
end
@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 / 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;
}
- (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur {
if (blur < 0.f || blur > 1.f) {
blur = 0.5f;
}
int boxSize = (int)(blur * 100);
boxSize = boxSize - (boxSize % 2) + 1;
CGImageRef img = image.CGImage;
vImage_Buffer inBuffer, outBuffer;