Skip to content

Instantly share code, notes, and snippets.

Junio Vitorino juniovitorino

View GitHub Profile
@juniovitorino
juniovitorino / remove-extension.conf
Created Jun 28, 2013
Remove file extension from urls's
View remove-extension.conf
# http://www.niallflynn.com/seo-news/remove-file-extension-from-urls/
<IfModule mod_rewrite.c>
AddType text/x-component .htc
RewriteEngine On
RewriteBase /
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
@juniovitorino
juniovitorino / ievm.zsh
Last active Dec 18, 2015
ZSH Function to download and install Windows and Internet Explorer VirtualBox VM from xdissent ievms project.
View ievm.zsh
function ievm {
curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | env IEVMS_VERSIONS="$1" bash
}
@juniovitorino
juniovitorino / xss_sanitization.php
Last active Dec 17, 2015
WordPress Recursive XSS Sanitization
View xss_sanitization.php
// XSS HTTP Treatment
add_filter('init', 'xssTreatment');
function xssTreatment() {
foreach(array($_GET, $_POST, $_REQUEST) as $httpConst) XSSSanitization( $httpConst );
}
function XSSSanitization(&$param) {
if(!is_array( $param ) && is_string( $param ) ) $param = filter_var($param, FILTER_SANITIZE_STRING);
@juniovitorino
juniovitorino / gist:5587839
Created May 15, 2013
Hotlink Protection
View gist:5587839
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?youralloweddomain.com [NC]
RewriteRule \.(jpeg|jpg|gif|pdf)$ - [NC,F,L]
</IfModule>
@juniovitorino
juniovitorino / Guardfile
Last active Dec 17, 2015
Guard simple boilerplate
View Guardfile
# More info at https://github.com/guard/guard#readme
guard 'sass', :input => 'sass', :output => 'css', :style => :compressed, :no => :cache
guard :livereload do
watch %r{.+\.(php|html|css|js)$}
end
guard :concat, type: 'js', files: %w(), input_dir: 'js', output: 'js/app'
@juniovitorino
juniovitorino / invoke_class_method.m
Last active Dec 12, 2015
Invoking class methods
View invoke_class_method.m
@interface Person : NSObject
+(BOOL) walking;
@end
@interface Philip : Person
+(BOOL) walking;
@end
@implementation Philip
View gist:4677039
#import "Kiwi.h"
#import "User.h"
SPEC_BEGIN(User)
describe(@"User", ^{
context(@"User creation", ^{
it(@"it should have a name", ^{
User *user = [[User alloc] init];
[user setName: @"Junio Vitorino"];
@juniovitorino
juniovitorino / gist:4642436
Last active Dec 11, 2015
Rails: Postgres database connection in Rails 3
View gist:4642436
development:
adapter: postgresql
encoding: unicode
database: your_database_name
pool: 5
username: your_username
password: your_password
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
@juniovitorino
juniovitorino / gist:4642417
Last active Dec 11, 2015
Rails: SQLite database connection in Rails 3
View gist:4642417
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
@juniovitorino
juniovitorino / gist:4642403
Last active Dec 11, 2015
Rails: MySQL database connection in Rails 3
View gist:4642403
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: your_database_name
pool: 5
username: your_username
password: your_password
socket: /tmp/mysql.sock
You can’t perform that action at this time.