This file contains hidden or 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
// install sinon via npm | |
// npm install sinon --save-dev | |
// require sinon in your test/client_api.js | |
var sinon = require("sinon"); | |
// add this test expectation | |
it("cover error", function (done) { | |
var url = URL_ROOT + "/client"; |
This file contains hidden or 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
{ | |
init: function(elevators, floors) { | |
var upQueue = [], downQueue = [], pressedButtons = []; | |
elevators.forEach(function(elevator) { | |
console.log('max', elevator.maxPassengerCount()); | |
elevator.clearDestination = function() { | |
this.destinationQueue = []; | |
this.checkDestinationQueue(); |
Criando um função construtora tarefas diárias:
function DailyTask() {}
e um método para lidar com a execução dessas tarefas:
DailyTask.perform_sync = function(task) {
return task;
}
Basicamente a implementação é uma função que recebe uma tarefa como argumento e retorna a tarefa executada.
This file contains hidden or 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
{ | |
"snippets": [ | |
{ | |
"match": {"global": true, "pkgname": ".", "fn": ".*_test.go"}, | |
"snippets": [ | |
{"text": "func Test", "title": "", "value": "func Test${1:ObjectName}${2:TestName}(t *testing.T) {\n\t$0\n}"}, | |
{"text": "func Benchmark", "title": "", "value": "func Benchmark${1:ObjectName}${2:BenchmarkName}(b *testing.B) {\n\n\tb.StopTimer()\n\n\t$0\n\n\tb.StartTimer()\n\n\tfor i := 0; i < b.N; i++ {\n\t\t\n\t}\n\n}"}, | |
{"text": "func Example", "title": "", "value": "func Example${1:ObjectName}${2:ExampleName}() {\n\n\t$0\n\n\t// Output:\n\t// \n\n}"} | |
] | |
} |
This file contains hidden or 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 'rack' | |
# Thin SSL workaround | |
module Rack | |
module Handler | |
class Thin | |
def self.run(app, options={}) | |
app = Rack::Chunked.new(Rack::ContentLength.new(app)) | |
server = ::Thin::Server.new(options[:Host] || '0.0.0.0', |
This file contains hidden or 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
Javascript | |
document.querySelectorAll('a[href$=reject]') // all elements with a link terminated by reject | |
document.querySelectorAll('a[href^=reject]') // all elements with a link started by reject | |
document.querySelectorAll('[src*=graph\\.facebook]') // all elements that contains graph.facebook as content src | |
document.querySelectorAll('tr td:nth-child(2)') |
This file contains hidden or 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
http://stackoverflow.com/questions/8511919/how-to-scope-last-week-by-date-object | |
https://nandovieira.com.br/trabalhando-com-datas-no-ruby-on-rails | |
https://nandovieira.com.br/formatando-datas-no-ruby-on-rails | |
Date.today.beginning_of_month | |
scope :completed_at_last_week, -> { | |
where( | |
completed_at: 1.week.ago.beginning_of_week..1.week.ago.end_of_week |
This file contains hidden or 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
.inject{|a, b| | |
a.merge(b){ |_, x, y| x.is_a?(String) && x.eql?(y) ? x : x + y | |
}} |