Skip to content

Instantly share code, notes, and snippets.

View apux's full-sized avatar

Azarel Doroteo Pacheco apux

View GitHub Profile
@apux
apux / upstream.sh
Created January 30, 2019 16:34
Fetch git from upstream
git remote -v
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
git remote -v
git fetch upstream
git checkout master
git rebase upstream/master # git merge upstream/master
@apux
apux / environment.rb
Created October 19, 2013 22:31
field with errors
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if instance.instance_of? ActionView::Helpers::Tags::Label
html_tag
else
%(<div class="form-field error">#{html_tag}<small class="error">&nbsp;#{[*instance.error_message].join(', ')}</small></div>).html_safe
end
end
@apux
apux / switch-keyboard-layout.sh
Last active December 24, 2015 23:19
change kde keyboard layout
#!/bin/sh
# query xkb map: us,latam -> us is primary; latam,us -> latam is primary
dummy=`setxkbmap -query | grep us,latam`
# return value 0: us,latam; return value != 0, latam,us
if [ $? -ne 0 ]; then
# latam is primary, now make us primary in list
setxkbmap -model pc101 -layout us,latam -variant nodeadkeys
else
@apux
apux / 1_vim_short.md
Last active October 24, 2018 11:50
Plugins for vim
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
set nocompatible
execute pathogen#infect()
syntax on
filetype plugin indent on
require 'spec_helper'
<% module_namespacing do -%>
describe <%= controller_class_name %>Controller do
let(:valid_attributes) { <%= formatted_hash(example_valid_attributes) %> }
let(:valid_session) { {} }
<% unless options[:singleton] -%>
describe "GET index" do
@apux
apux / vim_textwidth
Last active December 23, 2015 15:29
vim 80 columns
:set textwidth=80
gqG
@apux
apux / pryrc.rb
Last active December 17, 2015 00:09
my .pryrc
#.pryrc
# Load plugins (only those I whitelist)
Pry.config.should_load_plugins = false
Pry.plugins["doc"].activate!
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
@apux
apux / 1_install_in_chakra.sh
Last active June 14, 2020 15:39
Packages to install in chakra
sudo pacman -Sy --noconfirm postgresql curl git patch virtualbox nodejs redis
sudo pacman -Sy --noconfirm kde-telepathy yakuake
sudo pacman -Sy --noconfirm clementine gstreamer0.10-base-plugins gstreamer0.10-good-plugins gstreamer0.10-bad-plugins gstreamer0.10-ugly-plugins gstreamer0.10-ffmpeg
sudo pacman -Sy libreoffice
ccr -S vim-qt-git
sudo pacman -Sy --noconfirm firefox chromium
#for rvm, usually all these packages are already installed, but just to be sure
sudo pacman -Sy --noconfirm gcc patch curl zlib readline libxml2 libxslt git autoconf automake diffutils make libtool bison libyaml subversion libnotify
@apux
apux / apux.zsh-theme
Last active October 12, 2015 09:57
Zsh Theme
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
local rvm=''
if which rvm-prompt &> /dev/null; then
rvm='‹$(rvm-prompt i v g)›'
else
if which rbenv &> /dev/null; then
rvm='‹$(rbenv version | sed -e "s/ (set.*$//")›'
fi
@apux
apux / find_and_replace.sh
Last active October 11, 2015 04:48
replace string in multiple files
find . -name "*.rb" | xargs sed -i 's/foo/bar/g'