Skip to content

Instantly share code, notes, and snippets.

View brnrdog's full-sized avatar

Bernardo Gurgel brnrdog

View GitHub Profile
@brnrdog
brnrdog / users_controller.rb
Last active May 1, 2017 01:05
users_controller_spec
class UsersController < ApplicationController
def index
@users = User.all
render json: @users
end
def create
@user = User.create(user_params)
render json: @user, status: :created
end
@brnrdog
brnrdog / votes.rake
Created December 29, 2016 17:11
brtr-votes-task
namespace :votes do
task :to_likes do
Vote.all.each do |vote|
unless Like.exists?(user: vote.user, likeable: vote.votable)
Like.create(user: vote.user, likeable: vote.votable)
end
end
end
end
@brnrdog
brnrdog / category.rb
Created December 29, 2016 17:10
brtr-category-task
namespace :category do
task :count_services do
Category.all.each do |category|
category.update(services_count: category.services.count)
end
end
end
@brnrdog
brnrdog / index.html
Created November 23, 2016 17:09 — forked from anonymous/index.html
JS Bin // source https://jsbin.com/tifuqa
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.css">
<title>JS Bin</title>
<style id="jsbin-css">
* {
box-sizing: border-box;
@brnrdog
brnrdog / things-fetcher.js
Last active August 12, 2016 14:59
things-fetcher.js
import $ from 'jquery'
const ENDPOINT = 'api/v1/some-endpoint'
const DEFAULTS = {
loadingMsg: 'Loading. Please wait...',
successMsg: 'Things fetched with success.',
errorMsg: 'Sorry. Try again later.'
}
@brnrdog
brnrdog / zssn.md
Created June 6, 2016 18:57 — forked from mauricioklein/zssn.md
Zombie Survival Social Network

ZSSN (Zombie Survival Social Network)

Descrição do Problema

O mundo finalmente atingiu o seu estado apocalíptico, onde uma pandemia causada por um virus de laboratório transforma seres humanos e animais em zumbis, seres sedentos por carne.

Você, como membro da resistência (e último sobrevivente com conhecimentos em desenvolvimento de software) foi incubido à desenvolver um sistema para compartilhamento de recursos entre os humanos não infectados.

Funcionalidades

#!/usr/bin/xcrun swift
import AppKit
enum iTermColors: String {
case Ansi0 = "Ansi 0 Color"
case Ansi1 = "Ansi 1 Color"
case Ansi2 = "Ansi 2 Color"
case Ansi3 = "Ansi 3 Color"
case Ansi4 = "Ansi 4 Color"
@brnrdog
brnrdog / pre-commit.rb
Created May 27, 2015 16:30
Hook to force commits to have an existant issue number related
#!/usr/bin/env ruby
require 'net/http'
require 'json'
message_file = ARGV[0]
message = File.read(message_file)
$regex = /#(\d+)/
def get_issues
uri = URI('github.com/user/repo/issues')
#!/usr/bin/env ruby
require 'net/http'
require 'json'
message_file = ARGV[0]
message = File.read(message_file)
$regex = /#(\d+)/
def get_issues
uri = URI('https://api.github.com/repos/bernardog/hypermath_api/issues')