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/sh | |
# Redirect output to stderr. | |
exec 1>&2 | |
# enable user input | |
exec < /dev/tty | |
consoleregexp='console.log' | |
# CHECK | |
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0 | |
then |
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
require 'cityhash' | |
keywords = (0..4).to_a.inject(('a'..'z').to_a) do |perms, t| | |
perms = ('a'..'z').to_a.product(perms) | |
end.collect(&:join) | |
mod2_zero = 0 | |
mod2_one = 0 | |
keywords.each { |k| (CityHash.hash32(k) % 2) == 0 ? (mod2_zero += 1) : (mod2_one += 1) } | |
puts mod2_zero | |
puts mod2_one |
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
# INSTALACAO DO ELASTIC SEARCH MAIS NOVO | |
cd ~ | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre-headless -y | |
wget hhttps://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.3.deb | |
sudo dpkg -i elasticsearch-0.90.3.deb | |
sudo service elasticsearch start |
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
// Example usage: | |
// MyCompositeView = Backbone.Marionette.CompositeView.extend({ | |
// template: '#template', | |
// itemView: Namespace.InterchangeableView, | |
// itemViewOptions: function(model, index) { | |
// return { showView: myShowView, | |
// editView: myEditView, | |
// model: model | |
// }; | |
// }, |
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
#!/usr/bin/env ruby | |
require File.expand_path('../config/environment', __FILE__) |
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 A < ActiveRecord::Base | |
def update_attributes_changing_type(attrs) | |
object = if attrs.keys.include?('type') || attrs.keys.include?(:type) | |
self.becomes((attrs['type'] || attrs[:type]).constantize) | |
else | |
self | |
end | |
object.class.instance_variable_set('@finder_needs_type_condition', :false) | |
object.update_attributes(attrs) | |
object.class.instance_variable_set('@finder_needs_type_condition', nil) |
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
# vamos supor: | |
def convert_to_f(argument = nil) | |
argument.tap do |attribute| | |
attribute = attribute.to_f if attribute | |
end | |
end | |
convert_to_f | |
# esperado: nil | |
# obtido: nil |
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 | |
git log --name-only master..HEAD | grep 'spec/' | grep -v 'factories' | grep -v 'spec_helper' | paste -s -d " " - | xargs spring rspec |
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
echo "Ativando: IP FORWARDING" | |
echo | |
echo "1" > /proc/sys/net/ipv4/ip_forward | |
################## | |
### PREROUTING ### |
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
# "O que é mais interessante? Adicionar callbacks(ActiveRecord like) ou criar uma classe encapsulando o comportamento 'extra' desejado." | |
# "What is more interesting? Add callbacks(ActiveRecord like) or create a class that encapsulate the desired 'extra' behavior." | |
class B | |
before :method, :before_method | |
... | |
before :method, :before_methodN | |
after :method, :after_method | |
... | |
after :method, :after_methodN |
NewerOlder