Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@aalvarado
aalvarado / changeLineRecorded.py
Created October 27, 2010 23:50
Snippet from my record line file for pythonscript plugin in n++
class FilePosition:
def __init__(self, bufferId):
self.bufferId = bufferId #sets the bufferId
self.filePositions = [] # where the modified lines will be stored
self.lastPos = 0
self.counter = 0
def addFilePosition(self, pos):
self._findDelete(pos) # checks if the line number is already in the list
@aalvarado
aalvarado / namespace_encapsulation.js
Created April 20, 2011 15:29
namespace and object encapsulation in js
/*
sources:
http://www.justatheory.com/computers/programming/javascript/emulating_namespaces.html
http://www.dustindiaz.com/namespace-your-javascript/
http://www.crockford.com/javascript/private.html
http://yuiblog.com/blog/2007/06/12/module-pattern/
http://stackoverflow.com/questions/881515/javascript-namespace-declaration
*/
@aalvarado
aalvarado / reabase-on-upstream
Created September 29, 2011 16:39
bashscript for rebasing on upstream master.
#!/bin/sh
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
current_branch=$(parse_git_branch)
if [[ -n "$current_branch" ]]; then
git fetch -v upstream
git checkout master
@aalvarado
aalvarado / .bashrc
Last active September 27, 2015 13:17
.bash_profile
# Probaby windows with msys (old times)
alias ls='ls -A --color=yes'
alias dir='ls -A --color=yes'
alias vi='vim'
alias gb='git branch'
alias gba='git branch -a'
alias gc='git commit -v'
alias gfu='git fetch upstream master:upstream'
alias gf='git fetch origin master:remote-master'
alias gp='git push'
@aalvarado
aalvarado / vim-regex.txt
Created March 28, 2013 04:51
Change Ruby hash syntax to 1.9
%s/\(:\)\(\S\+\)\s\+=>/\2:/
@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
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 / .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'
#/etc/udev/rules.d/99-displaymagic.rules
# enable LVDS on HDMI disconnect
SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/bin/displaymagic.sh"
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