Skip to content

Instantly share code, notes, and snippets.

Alex Gonzalez Lacasa aloon

Block or report user

Report or block aloon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nginx
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@aloon
aloon / inout.sh
Created Aug 30, 2014
Simple shell script to test STDIN and STDOUT
View inout.sh
#!/bin/sh
if [ -t 0 ]; then
echo nothing in STDIN
else
while read LINE; do
echo ${LINE}
done
exit 0
View RedisSessionProvider.cs
// http://www.codeproject.com/Articles/636730/Distributed-Caching-using-Redis
// https://raw.githubusercontent.com/chadman/redis-service-provider/master/RedisProvider/SessionProvider/RedisSessionProvider.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections.Specialized;
using System.Web.SessionState;
using ServiceStack.Redis;
View introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@aloon
aloon / overwrite
Created Apr 7, 2015
Overwrite System class
View overwrite
class StringHelper(str: String) {
def info: String = str.length.toString + " chars"
}
implicit def stringWrapper(string: String) = new StringHelper(string)
println("hello".info)
object String {
def info: String = "This is the String class"
@aloon
aloon / gist:3653dbc446ab970667ca
Last active Aug 29, 2015 — forked from kagemusha/gist:1569836
Dump Heroku Postgres DB and load locally
View gist:3653dbc446ab970667ca
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
1. heroku pg:backups:capture
2. heroku pg:backups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
@aloon
aloon / main.rb
Created Mar 10, 2012
download and delete from S3
View main.rb
#!/usr/bin/env ruby
require 'fileutils'
require 'aws/s3'
AWS_ACCESS_KEY_ID = '...'
AWS_SECRET_ACCESS_KEY = '...'
DOWNLOAD_DIR = 'files'
cont = true
@aloon
aloon / threads.rb
Created Mar 17, 2012
download and delete all from S3
View threads.rb
#!/usr/bin/env ruby
require 'fileutils'
require 'right_aws'
AWS_ACCESS_KEY_ID = '...'
AWS_SECRET_ACCESS_KEY = '...'
BUCKET = 'jujuego'
DOWNLOAD_DIR = '../files'
BUCKET_NAME = 'jujuego'
@aloon
aloon / extract_fixtures.rake
Created Apr 3, 2012
extracting data for fixtures
View extract_fixtures.rake
desc "extracting data for fixtures"
task :extract_fixtures => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info","schema_migrations"]
ActiveRecord::Base.establish_connection
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
i = "000"
File.open(Rails.root.join('test','fixtures',"#{table_name}.yml"), 'w' ) do |file|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
file.write data.inject({}) { |hash, record|
@aloon
aloon / gist:4771179
Last active Dec 12, 2015
get UniqueRandomNumbers
View gist:4771179
Private Shared Function UniqueRandomNumbers(NumAleatories As Integer, elements As Integer) As List(Of Integer)
Dim aleatorios As New List(Of Integer)
If elements > 0 Then
Dim temp As List(Of Integer) = Enumerable.Range(0, elements)
If NumAleatories > elements Then
aleatorios = temp.OrderBy(Function(a) Guid.NewGuid())
Else
Dim r As New Random(DateTime.Now.Millisecond)
You can’t perform that action at this time.