Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@aalvarado
aalvarado / pg_change_db_owner.sh
Created September 29, 2015 18:03 — forked from jirutka/pg_change_db_owner.sh
Some convenient scripts to manage ownerships and privileges in PostgreSQL.
#!/bin/bash
#
# The MIT License
#
# Copyright 2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
struct Person;
impl Person {
fn hello(&self) -> &'static str {
return "hello";
}
}
fn main() {
println!("Hello, world!");
let p = Person;
@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 / 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 / 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 / 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 / fizzbuzz.rb
Created June 1, 2015 14:42
FizzBuzz Ruby without any integer modulus or division
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(' ') }
@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