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 RegistrationsController < Devise::RegistrationsController | |
before_action :configure_sign_up_params, only: [:create] | |
protected | |
def configure_sign_up_params | |
attributes = { pessoa_attributes: [:nome, :cpf, :telefone, :data_nascimento, :sexo] } | |
devise_parameter_sanitizer.for(:sign_up) << attributes | |
end | |
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
$.ajax({ | |
url: 'url-chamada', | |
success: function(a,b,c) { | |
// Do something if sucess | |
}, | |
statusCode: { | |
401: function() { | |
//Do something if status code is 401. | |
} | |
} |
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
import React from 'react'; | |
let {Component, PropTypes} = React; | |
export default class CoolComponent extends Component { | |
handler = (e) => { | |
// Do somthing cool here | |
} | |
render() { | |
return <div onClick={this.handler}></div>; |
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 'sinatra' | |
require 'securerandom' | |
module OS | |
class << self | |
def get | |
linux || mac || windows | |
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
module Chainable | |
def chain(*methods) | |
chain!(*methods) | |
rescue NoMethodError | |
nil | |
end | |
def chain!(*methods) | |
methods.inject(self) do |object, method| | |
object.public_send(method) |
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
package solution | |
// You are given an array A consisting of N integers. | |
// For each number A[i] such that 0 ≤ i < N, we want to count the number of elements of the array that are not the divisors of A[i]. We say that these elements are non-divisors. | |
// For example, consider integer N = 5 and array A such that: | |
// A[0] = 3 | |
// A[1] = 1 |
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
Warming up -------------------------------------- | |
lists 14.525k i/100ms | |
select 8.124k i/100ms | |
pluck 258.000 i/100ms | |
Calculating ------------------------------------- | |
lists 157.648k (± 7.4%) i/s - 798.875k in 5.096596s | |
select 85.202k (± 7.1%) i/s - 430.572k in 5.079725s | |
pluck 2.414k (± 9.8%) i/s - 12.126k in 5.072495s | |
Comparison: |
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
=begin | |
In this problem you will write a function called populate_template which will take in a template string e.g. " Hello {!first_name} - How are you?" and a hash of fields e.g { "first_name" : "John" } as arguments and will return the template string with the fields inserted in the correct place. | |
The usecase for a function like this would be for instance for answer templates to be used by a support team at a company. | |
So in the previous example you would get: | |
populate_template("Hello {!first_name} - How are you?", {"first_name" => "John"}) | |
and you would get: |
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
package bfs | |
import "fmt" | |
type City struct { | |
Name string | |
Population uint32 | |
neighbors []Node | |
} |
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
def Ok(value) | |
Okay.new(value) | |
end | |
def Err(value) | |
Error.new(value) | |
end | |
class Result | |
attr_reader :value |
OlderNewer