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
aalvarado / .psqlrc
Last active Aug 29, 2015
postgresql DEVELOPMENT configuration
View .psqlrc
\pset null 'NULL'
\set HISTFILE ~/.psql_history- :HOST - :DBNAME
\set HISTSIZE 100000
\timing
\set PROMPT1 '(%n@%M:%>) [%/] > '
\set PROMPT2 ''
\encoding unicode
\timing
\pset pager always
\setenv LESS '-iMSsx2 -FX'
View 99-displaymagic.rules
#/etc/udev/rules.d/99-displaymagic.rules
# enable LVDS on HDMI disconnect
SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/bin/displaymagic.sh"
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 inverse_of_test.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
View sti_scope.rb
# http://stackoverflow.com/questions/28711074/undefined-method-error-for-scope-on-sti-subclass
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'arel'
gem 'sqlite3'
GEMFILE
@aalvarado
aalvarado / solution.rb
Created Mar 10, 2015
PermMissingElem
View solution.rb
def solution(a)
((( a.size + 2 ) * ( a.size + 1 )) / 2) - ( a.reduce(&:+) || 0 )
end
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
@aalvarado
aalvarado / gist:df2c783f76938cba8408
Created Apr 3, 2015
Pensamientos acerca de la violencia
View gist:df2c783f76938cba8408
Ser inclusivo y tolerante hacia todos los gustos es un buen camino para extender tu circulo de empatia mas alla de familiares y amigos.
Al hacer esto, hay resultados que benefician a la mayoria de forma mas igualitaria. Hay sumas positivas en el cooperacio
View presentation
* Acerca de Git
- ¿Por que es necesario?
- Otras opciones en control de versiones
- Distribuidos y centralizados
* Recursos
- Pro Git book. http://git-scm.com/book
- StackOverflow
- Internet
@aalvarado
aalvarado / fizzbuzz.rb
Created Jun 1, 2015
FizzBuzz Ruby without any integer modulus or division
View fizzbuzz.rb
limit = 100
fizz = ['']*2 << 'fizz'
buzz = ['']*4 << 'buzz'
(1..limit).to_a.zip(fizz.cycle(limit).to_a.zip(buzz.cycle(limit).to_a)).each{ |n| puts n.join(' ') }
You can’t perform that action at this time.