Skip to content

Instantly share code, notes, and snippets.

View dodops's full-sized avatar

Douglas Costa dodops

View GitHub Profile
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;
# 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
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 = ->
@dodops
dodops / gist:f60f90f8258ab64c1554
Created May 26, 2015 12:23
Arduino ultrasonic
#include <Ultrasonic.h>
#define echoPin 13
#define triPin 12
#define ledPin 9
Ultrasonic ultrasonic(12,13);
void setup()
{
Serial.begin(9000);
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);
#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
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]);
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();
@dodops
dodops / bubble.c
Last active December 21, 2015 08:59
Implementation of a "Bubble Sort" algorithm in C programming language.
#include <stdio.h>
#include <stdlib.h>
#define TAM 7
main()
{
int vetor[TAM],
x = 0,
y = 0,
aux = 0;
@dodops
dodops / user.rb
Created September 30, 2011 00:54
Paperclip: Help a friend with the problematic gem...
class Pessoa < ActiveRecord::Base
has_attached_file :imagem, :styles => { :tamanho_pequeno => "150x150",
:tamanho_medio => "300x300",
:tamanho_grande => "600x600" }
validates_attachment_presence :imagem
end