Skip to content

Instantly share code, notes, and snippets.


Adan Alvarado aalvarado

Block or report user

Report or block aalvarado

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
aalvarado / solution.rb
Created Mar 10, 2015
View solution.rb
def solution(a)
((( a.size + 2 ) * ( a.size + 1 )) / 2) - ( a.reduce(&:+) || 0 )
View missing_int_solution.rb
# Missing int from unsorted array and with arbitrary starting int
def solution(a=[])
sum = 0
min = a.first
max = a.last
a.each do |e|
sum += e
min = e if e < min
View sti_scope.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source ''
gem 'rails'
gem 'arel'
gem 'sqlite3'
View inverse_of_test.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source ''
gem 'rails', '4.2.0'
gem 'arel'
gem 'sqlite3'
system 'bundle'
View gist:46e5678f3c65492010e5
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
View 99-displaymagic.rules
# enable LVDS on HDMI disconnect
SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/bin/"
aalvarado / .psqlrc
Last active Aug 29, 2015
postgresql DEVELOPMENT configuration
View .psqlrc
\pset null 'NULL'
\set HISTFILE ~/.psql_history- :HOST - :DBNAME
\set HISTSIZE 100000
\set PROMPT1 '(%n@%M:%>) [%/] > '
\set PROMPT2 ''
\encoding unicode
\pset pager always
\setenv LESS '-iMSsx2 -FX'
aalvarado / calls.rb
Last active Mar 4, 2019
Faraday calls with cookies against Sinatra / Rack
View calls.rb
require 'faraday-cookie_jar'
#all one liners because it's easier for irb/pry
conn = => 'http://localhost:3535'){ |f| f.request :url_encoded; f.response :logger; f.adapter Faraday.default_adapter; f.use :cookie_jar }
res = conn.get('/route')
cookie2 = res.headers['set-cookie']
aalvarado / my.cnf
Last active Dec 20, 2015
Faster mysql restores
View my.cnf
# /opt/local/etc/mysql5/my.cnf
key_buffer = 32M
max_allowed_packet = 32M
View crap.cpp
#include <iostream>
class Crap {
int times;
Crap() {
times = 0;
You can’t perform that action at this time.