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 Mongoose = require('mongoose'); | |
Mongoose.Promise = Promise; | |
Mongoose.connect(`mongodb://localhost/test-${Date.now()}`); | |
const PersonSchema = new Mongoose.Schema({ | |
name: { | |
first: { type: String }, | |
last: { type: String } | |
} |
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
#!/usr/bin/env bash | |
# `nvm use` the version specified in package.json. | |
source $(brew --prefix nvm)/nvm.sh | |
set -eo pipefail | |
die() { | |
echo "$@" >&2 |
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
#!/usr/bin/env bash | |
# Monitors your tree and runs tests when anything changes. | |
# | |
# Run `make`, `npm test`, etc. automatically detected. | |
# | |
# $ autotest | |
# | |
# Run a specific command on changes: | |
# |
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
babel-preset-stage-2 pulls in the newest version of babel-plugin-transform-async-to-generator, | |
however the async arrow function still has `this` = `undefined`. | |
If I manually install babel-plugin-transform-async-to-generator and add it to the list of plugins | |
in .babelrc, everything works as expected. | |
Steps to reproduce: | |
$ npm install && npm test |
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 "benchmark" | |
$baz = nil | |
class Foo | |
def self.foo | |
@foo || $baz | |
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
require "benchmark" | |
COUNT = 1_000_000 | |
@status = 200 | |
Benchmark.bm(20) do |x| | |
x.report("noop") do | |
COUNT.times { } | |
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
Node = Struct.new(:value, :children) | |
tree = Node.new( | |
1, | |
[ | |
Node.new( | |
2, | |
[Node.new(5, []), Node.new(6, [])] | |
), |
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
#!/bin/bash | |
usage() { | |
cat >&2 <<EOS | |
Usage: vim-install <Git URL> | |
EOS | |
exit 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
# If some requests in your web application fail but subsequent requests don't, | |
# you may be a victim of Kernel#autoload. | |
# | |
# As you know, Kernel#autoload is not thread-safe. Moreover, missing constants | |
# trigger requiring other files, which can some times do more than just provide | |
# that missing constant. Yet many libraries still use it: | |
# https://github.com/search?l=ruby&q=autoload+language%3Aruby&type=Code | |
# | |
# So if you think you're having any of these issues, this middleware should be | |
# able to provide a hint as to which files are the ones you should be requiring |
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 File.expand_path("helper", File.dirname(__FILE__)) | |
setup do | |
users = Cuba.new do | |
on get do | |
on "foo" do | |
res.write "foo" | |
end | |
on "bar" do |