Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@aalvarado
aalvarado / presentation
Last active August 29, 2015 14:20
Taller Git
* 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 / solution.rb
Created March 10, 2015 13:41
PermMissingElem
def solution(a)
((( a.size + 2 ) * ( a.size + 1 )) / 2) - ( a.reduce(&:+) || 0 )
end
# 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
# 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
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
#/etc/udev/rules.d/99-displaymagic.rules
# enable LVDS on HDMI disconnect
SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/bin/displaymagic.sh"
@aalvarado
aalvarado / .psqlrc
Last active August 29, 2015 14:03
postgresql DEVELOPMENT configuration
\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'
before_filter :find_position, only: [:show, :destroy, :edit]
def destroy
if @position.destroy
flash[:success] = t('labels.success')
else
flash[:error] = t('labels.error')
end
redirect_to positions_path
end
@aalvarado
aalvarado / ctags.txt
Created April 1, 2013 23:41
Exhuberant ctags with javascript filtering and appending to `tags` file.
ctags -aR --languages=-javascript app
@aalvarado
aalvarado / vim-regex.txt
Created March 28, 2013 04:51
Change Ruby hash syntax to 1.9
%s/\(:\)\(\S\+\)\s\+=>/\2:/