Skip to content

Instantly share code, notes, and snippets.

View guilleiguaran's full-sized avatar
💭

Guillermo Iguaran guilleiguaran

💭
View GitHub Profile
@chrisboulton
chrisboulton / ip_blacklist.lua
Last active April 2, 2024 10:43
Redis based IP blacklist for Nginx (LUA)
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
defmodule ApplicationRouter do
use Dynamo.Router
prepare do
# Pick which parts of the request you want to fetch
# You can comment the line below if you don't need
# any of them or move them to a forwarded router
conn.fetch([:cookies, :params])
end

OpenShift Install in EC2

Before of start

  • Use official CentOS 6 AMI, for details check the wiki

  • Enable SELinux, Check this tutorial of Red Hat to do it.

  • Create a security group for both Broker and Node with the ports 22, 80, 443 open

@guilleiguaran
guilleiguaran / file.md
Last active October 12, 2015 13:57
Why Google V8 is not suited for integration into servers

Why Google V8 is not suited for integration into servers

06/09/2010

Last time I studied the ability to embed javascript in nginx using the library Google V8 Javascript Engine , it should be noted, was no easy task, as all that complicated the classic "Hello World!", reflected in the documentation is extremely sketchy. Because V8 developed primarily for Chrome, then this left a significant imprint on him and, to paraphrase Henry Ford's statement about the color of the machine, it can be said that the V8 will work well in any application, provided that this program is called Chrome.

First of all, V8 does not know how to handle memory allocation errors - it just ends the process. This is acceptable for such a browser like Chrome, which displays each page in a separate process, and the crash of one process does not affect the other pages, but for the server to process in one process thousands of simultaneous connections, it does not fit. While V8 allows you to set your own error handler memory allocation, ho

@stevej
stevej / board_searcher.rb
Created November 2, 2012 22:28
Letterpress board searcher
#/usr/bin/env ruby
# A brute-force letterpress board searcher. It takes about 90 seconds to search a board.
#
# Good uses: train on your vocabulary with boards you lost on.
#
# LAZY AND STUPID CHEATERS: DO NOT USE THIS FOR CHEATING. CHEATERS NEVER WIN.
class BoardSearcher
attr_reader :board
@mattetti
mattetti / gist:3850240
Created October 8, 2012 01:19
Rakefile to generate a mruby mandelbrot example
# Change the path to match the path to your machine.
$mrb_path = File.expand_path("~/src/mruby")
$mrbc = File.join($mrb_path,"/bin/mrbc")
task :default do
# dumps the Ruby file to disk
File.open("mandelbrot.rb", "w"){|f| f << mandelbrot_ruby_code }
# creates the .c file containing mandelbrot char array for the bytecode
`#{$mrbc} -Bmandelbrot_bytecode ./mandelbrot.rb`
example_file = wrapper_code(File.read("./mandelbrot.c"))
@gealgaro
gealgaro / gist:3796724
Created September 27, 2012 22:03
TableView Snnipet
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"patientCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSString* letter = [[self sectionsTitlesArray] objectAtIndex:indexPath.section];
NSString* filterString = [NSString stringWithFormat:@"last_name beginswith[cd] '%@'", letter];
NSArray* filteredPatients = [GeneralFunctions filterArrayWithString:filterString objectsToFilter:patients];
cell.textLabel.text = [(Patient *)[filteredPatients objectAtIndex:indexPath.row] fullName];
@josevalim
josevalim / 0_README.md
Created September 13, 2012 21:52
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

@bellbind
bellbind / Info.plist.json
Created July 25, 2012 08:22
[macosx][ios][objective-c]Building iOS 5.1 app with command line (completely Xcode-less programming)
{"UIDeviceFamily":[1,2]}
@igrigorik
igrigorik / gist:3148848
Created July 20, 2012 05:24
Convert any YouTube video into an audio file you can listen to on the go...
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
{ ~ } > ./youtube-dl -s -F http://www.youtube.com/watch?v=vT1KmTQ-1Os