This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while : | |
do | |
clear | |
git --no-pager log -15 --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all | |
sleep 1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
else | |
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$(git_branch)$ " | |
fi | |
unset color_prompt force_color_prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRJ=$HOME/Proyectos | |
function goto | |
{ | |
case $1 in | |
(mipr) cd $PRJ/miproyecto1;; | |
(pr) cd $PRJ;; | |
esac | |
pwd | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
user ||= User.new # guest user | |
if user.role? :admin | |
can :manage, :all | |
else | |
can :read, :all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in your ~/.irbrc for easy rails route scanning | |
# | |
# Usage: | |
# > routes | |
# => prints all routes | |
# > routes /GET.*user/i | |
# => prints routes matching a given regex | |
# > routes "user" | |
# => matches strings as well |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#These Ruby OOP examples, are based on the Rails 3 presentation by @guilhermecaelum | |
class Person | |
#the attribute name is immutable | |
def initialize(name) | |
@name = name | |
end | |
def name | |
@name | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SchemaPlus::ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do | |
def included(base) #:nodoc: | |
base.alias_method_chain :initialize, :schema_plus | |
end | |
def initialize_with_schema_plus(*args) #:nodoc: | |
initialize_without_schema_plus(*args) | |
adapter = case adapter_name | |
# name of MySQL adapter depends on mysql gem | |
# * with mysql gem adapter is named MySQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# right expression, match | |
str = "12345" | |
eval = str.match /\A\d+\z/ | |
puts eval ? 'match' : 'no match' | |
# right expression, no match | |
str = "hello123world" | |
eval = str.match /\A\d+\z/ | |
puts eval ? 'match' : 'no match' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM mi_tabla | |
WHERE condicion | |
-- Aqui formato de exportación | |
INTO OUTFILE | |
'/tmp/fichero_salida.csv' | |
FIELDS TERMINATED BY ';' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql -u root -p MYDATABASE -e "select * from products" -B > fichero33.csv | |
o en consola podemos utilizar \T: | |
select * from products \T resultadoooooooo.sql; |
OlderNewer