Skip to content

Instantly share code, notes, and snippets.

View a-bx's full-sized avatar

Abraham Barrera a-bx

  • Migrante
  • Chile
View GitHub Profile
# frozen_string_literal: true
require 'sinatra/base'
require 'active_support/core_ext/string'
require 'dotenv/load'
# My rack lambda facade application ohh yeah
class App < Sinatra::Base
def self.parse_route(route_key)
method, route = route_key.split('-')
@a-bx
a-bx / PackageApplication
Created August 7, 2018 02:49
PackageApplication script from Xcode 8.2.1
#!/usr/bin/perl
#
# PackageApplication
#
# Copyright (c) 2009-2012 Apple Inc. All rights reserved.
#
# Package an iPhone Application into an .ipa wrapper
#
use Pod::Usage;
@a-bx
a-bx / multi-database_pattern.md
Created October 12, 2016 03:37 — forked from masciugo/multi-database_pattern.md
Rails multi-database pattern

Rails multi-database pattern

The parent class for models that are persisted on a different database app/models/public_database_model.rb:

# Public: Provide a base class for accessing the public database.
# All models inheriting from this class will use by default the data store DB.
class PublicDatabaseModel < ActiveRecord::Base

Tell Active Record (AR) to not look up for a table called like this class,

@a-bx
a-bx / enable-swap-ec2.sh
Created December 14, 2015 22:18
Enable swap ec2
# To add this extra space to your instance you type:
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
# If you need more than 1024 then change that to something higher.
# To enable it by default after reboot, add this line to /etc/fstab:
@a-bx
a-bx / gist:a50beab969a1938b4764
Created April 23, 2015 19:30
GetOnBoard Scrapp
require 'mechanize'
def parse_offer(link, goal)
agent = Mechanize.new
agent.get link
salary = agent.page.search('[itemprop="baseSalary"]')
salary_value = salary.first.attributes['content'].value
dolars = salary_value.to_i
title = agent.page.search('[itemprop="title"]').first.text
return nil unless dolars >= goal
# String extensions
class String
def cavgsify
gsub /ca([Z b-df-hj-np-tv-z]|[ ]|\Z)/, 'cavg\1'
end
def ochoafy
gsub /a/, 'aaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaAaaaA'
end
@a-bx
a-bx / TideSDK_Guardfile.rb
Created May 27, 2013 15:07
TideSDK working with coffeescript, HAML, SAAS and Sprockets
guard 'sass', input: 'source/styles', output: 'Resources/styles'
guard 'haml', input: 'source', output: 'Resources' do
watch(/^.+(\.html\.haml)/)
end
guard 'rocco', :run_on => [:start, :change], :dir => 'docs', :stylesheet => 'https://raw.github.com/joeharris76/docco-css/master/nuvola.css' do
watch(%r{^source/scripts/.*\.(coffee)$})
end
@a-bx
a-bx / TideSDK_Gemfile.rb
Last active December 17, 2015 18:59
TideSDK working with coffeescript, HAML, SAAS and Sprockets
source 'https://rubygems.org'
gem 'redcarpet', '1.17.2'
gem 'guard', '~> 1.8.0'
gem 'guard-haml', '~> 0.5'
gem 'guard-sass', '~> 1.1.0'
gem 'guard-coffeescript', '~> 1.3.0'
gem 'guard-sprockets'
gem 'guard-rocco'
@a-bx
a-bx / gist:4204247
Created December 4, 2012 14:06
Consultas Git
########################################
#
# GIT
#
########################################
# Mostrar commits que no se han pusheado:
$ git log origin/branch..branch
$ git log origin/master..HEAD
@a-bx
a-bx / install_pear_osx.md
Last active October 11, 2015 13:48
Install Pear on MacOSX

$ curl http://pear.php.net/go-pear.phar > go-pear.php

$ sudo php -q go-pear.php

  • Note: To install default configuration
  • Edit .bash_profile (or .bashrc) and add:

export PATH=/Users/username/pear/bin:$PATH

$ source ~/.bash_profile