Skip to content

Instantly share code, notes, and snippets.

@vagnerzampieri
vagnerzampieri / index.html
Created October 1, 2013 23:10
Abrindo os conteúdos dos links de forma dinâmica. Também pode ser acessado o teste neste link http://js.do/code/821
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="insertTonalidade">
<h5>Insirar uma tonalidade:</h5>
<a href="#" id="tons-link" class="c">C</a>
<div id="tonalidades-c" style="display: none" >
<label class="checkbox">
<input type="checkbox" name="cordas" value="cordas">
C
</label>
<label class="checkbox">
@vagnerzampieri
vagnerzampieri / disable_multiples.js
Last active December 25, 2015 12:59
Disable Ctrl+c and Ctrl+v with JQuery
$(document).ready(function(){
function bindingElements(element, index, array) {
$(element).bind("copy paste", function(e){
e.preventDefault();
});
};
['#user_confirm_email', '#user_password_confirmation'].forEach(bindingElements);
});
@vagnerzampieri
vagnerzampieri / guake.desktop
Created October 17, 2013 22:37
Initializer guake terminal, create file "vim /home/user_name/.config/autostart/guake.desktop"
[Desktop Entry]
Name=Guake Terminal
GenericName=Guake Terminal
Comment=Guake Terminal
Exec=guake
Terminal=false
Type=Application
Icon=/usr/share/pixmaps/guake/guake.png
Categories=GNOME;GTK;Utility;TerminalEmulator;
StartupNotify=false
@vagnerzampieri
vagnerzampieri / .bash_profile
Last active August 29, 2015 14:04
Bash from Dockerfile
export PS1='\[\e[01;30m\]\t `if [ $? = 0 ]; then echo "\[\e[32m\]✔"; else echo "\[\e[31m\]✘"; fi` \[\e[00;37m\]\u@\h\[\e[01;37m\] : `[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 "(%s)\[\e[00m\]")\[\e[01;34m\]\w\[\e[00m\] \n\$ '
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
tmux -2
@vagnerzampieri
vagnerzampieri / gist:d810a82a25395f3e0772
Created July 25, 2014 17:08
Remove containers and images from docker
#For remove containers
sudo docker ps -a | grep Exit | awk '{print $1}' | sudo xargs docker rm
#For remove images
sudo docker rmi imageid
class DocumentUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(pdf)
end
@vagnerzampieri
vagnerzampieri / nginx
Created October 2, 2014 17:07
Script to start nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@vagnerzampieri
vagnerzampieri / migration.rb
Created October 31, 2014 18:06
Migration with constraint to foreign_key.
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.references :post, null: false
t.references :user, null: false
t.text :description
t.timestamps
end
@vagnerzampieri
vagnerzampieri / .bashrc
Last active August 29, 2015 14:13
Docker rails .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@vagnerzampieri
vagnerzampieri / all_spec.ssh
Created September 4, 2015 21:36
Pegar todos os arquivos que foram modificados no git, olhar dentro deles por paths do VCR, encontrar os paths reais, deletar e depois rodar as specs
#!/bin/bash
vcr='(VCR)'
all_bettewen_quotes='(\".+\")'
declare -a files
count=0
# Read file and get all cassettes from VCR
while read line; do
if [[ $line =~ $vcr ]]; then
[[ $line =~ $all_bettewen_quotes ]]