Skip to content

Instantly share code, notes, and snippets.

Alejandro E. Babio alejandrobabio

Block or report user

Report or block alejandrobabio

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
@alejandrobabio
alejandrobabio / gist:f14ad6545e24d25eec02
Last active Aug 29, 2015
Script for read google drive
View gist:f14ad6545e24d25eec02
require 'google_drive'
client = Google::APIClient.new(application_name: 'Google Drive Ruby test', application_version: '0.0.1')
key = Google::APIClient::KeyUtils.load_from_pkcs12(
'path to your p12 key file (all the path with file name)',
'your secret here given at download file it seems to be always the same: notasecret')
asserter = Google::APIClient::JWTAsserter.new(
'service account - email address - here',
['https://www.googleapis.com/auth/drive'],
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@alejandrobabio
alejandrobabio / apache_bench.sh
Created Jun 1, 2016 — forked from seyhunak/apache_bench.sh
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
View apache_bench.sh
1.
LOGIN_PAGE=http://localhost/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
@alejandrobabio
alejandrobabio / fixtures.rake
Created Jun 23, 2016 — forked from ZachBeta/fixtures.rake
Rake task to create fixtures from test database in Rails 3.1
View fixtures.rake
#put in lib/tasks/fixtures.rake
namespace :db do
namespace :fixtures do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_migrations"]
ActiveRecord::Base.establish_connection(:development)
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
@alejandrobabio
alejandrobabio / hn_seach.js
Created Aug 17, 2016 — forked from kristopolous/hn_seach.js
hn job query search
View hn_seach.js
function query() {
var
// HN is done with very unsemantic classes.
job_list = Array.prototype.slice.call(document.querySelectorAll('.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')),
query_list = Array.prototype.slice.call(arguments),
shown = 0, total = job_list.length;
// Traverses up the dom stack trying to find a match of a specific class
function up_to(node, klass) {
if (node.classList.contains(klass)) {
View Deploying Sharetribe to Heroku.md

Deploying to Heroku

  1. Deploy the app to heroku following heroku normal instructions (add link to heroku help)

  2. Set heroku environment variables

    Make sure all the options in config.yml are properly set then run:

     bundle exec rake heroku:config
    
@alejandrobabio
alejandrobabio / symbolize.rb
Created Nov 29, 2017
Recursive lambda that symbolize keys of a Hash
View symbolize.rb
Symbolize = (l = ->(h) { h.inject({}) { |m, (k,v)| m[(String === k ? k.to_sym : k)] = (Hash === v ? l.(v) : v); m }})
# Example:
hash = { 'task' => { 'description' => 'Ab@ @example @cd', 'target' => { 'label' => 'cd' } } }
Symbolize.(hash)
# => { :task => { :description => "Ab@ @example @cd", :target => { :label => "cd" } } }
@alejandrobabio
alejandrobabio / application.html.slim
Last active Dec 8, 2017
dry-web-roda & sprockets
View application.html.slim
doctype html
html
head
link rel="stylesheet" href=asset("application.css")
script rel="javascript" type="text/javascript" src=asset("ng_application.js")
body
== yield
@alejandrobabio
alejandrobabio / gist:4578ed310cb4a16cea7902f8f454a99e
Last active Dec 11, 2017
Using flat_map to flatten a nested array
View gist:4578ed310cb4a16cea7902f8f454a99e
flat = (l = ->(x) { x.flat_map {|e| Array === e ? l.(e) : e } })
flat.([1, 2, 3, [4, 5, [6], [ ] ] ])
#==> [1,2,3,4,5,6]
@alejandrobabio
alejandrobabio / README-Template.md
Created Dec 15, 2017 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You can’t perform that action at this time.