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 Pessoa < ActiveRecord::Base | |
has_attached_file :imagem, :styles => { :tamanho_pequeno => "150x150", | |
:tamanho_medio => "300x300", | |
:tamanho_grande => "600x600" } | |
validates_attachment_presence :imagem | |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#define TAM 7 | |
main() | |
{ | |
int vetor[TAM], | |
x = 0, | |
y = 0, | |
aux = 0; |
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 TesteErro { | |
public static void main(String[] args){ | |
System.out.println("Inicio da main"); | |
medoto1(); | |
System.out.println("Fim da main"); | |
} | |
static void medoto1(){ | |
System.out.println("Inicio do método 1"); | |
metodo2(); |
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
var poder = function(name, last){ | |
var conrta = []; | |
for (var i = conrta.length - 1; i >= 0; i--) { | |
conrta[i] | |
}; | |
}; | |
function forEach(array, action){ | |
for(var i = 0; i < array.length; i++){ | |
action(array[i]); |
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
#Credits to Carlos Souza | |
#I've made some changes for search works in strings with special caracters like accents. | |
#In the model | |
scope :search, ->(keyword) { where('keywords LIKE ?', "%#{I18n.transliterate(keyword.downcase)}%") if keyword.present? } | |
before_save :set_keywords | |
validates :title, :author, :description, presence: true | |
protected |
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
var net = require('net'); | |
var chatServer = net.createServer(), clientList = []; | |
chatServer.on('connection', function(client){ | |
client.name = client.remotePort; | |
client.write('Hi ' + client.name + '!\n'); | |
clientList.push(client); | |
console.log("connected clients: " + clientList.length); |
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
#include <Ultrasonic.h> | |
#define echoPin 13 | |
#define triPin 12 | |
#define ledPin 9 | |
Ultrasonic ultrasonic(12,13); | |
void setup() | |
{ | |
Serial.begin(9000); |
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
jQuery -> | |
$('body').prepend('<div id="fb-root"></div>') | |
$.ajax | |
url: "#{window.location.protocol}//connect.facebook.net/en_US/sdk.js" | |
dataType: 'script' | |
cache: true | |
window.fbAsyncInit = -> |
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
# Creditos: https://github.com/celsodantas/br_populate | |
# Models: City - State | |
require 'net/http' | |
require 'net/https' # for ruby 1.8.7 | |
require 'json' | |
def states | |
http = Net::HTTP.new('raw.githubusercontent.com', 443); http.use_ssl = true | |
JSON.parse http.get('/zigotto/br_populate/master/states.json').body |
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
const { el, mount } = redom; | |
// remove variações que serão | |
// escolhidas para gerar grade | |
const removeLabel = () => { | |
let closeElements = Array.from(document.querySelectorAll('i.delete.icon')); | |
closeElements.map(closeIcon => { | |
closeIcon.addEventListener('click', () => { | |
let label = closeIcon.parentElement; |