Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'elasticsearch'
require 'time' # To get Time#iso8601.
#### Testing in development ###
#
# Install & configure:
#
# $ brew install elasticsearch logstash kibana
@botanicus
botanicus / test.js
Last active August 29, 2015 14:27
I wish ES7 decorators would work with testing frameworks.
@freezeTime('2015-10-10T10:00:00Z')
it('shows a list of the sessions that were passed in', function() {
// The test with frozen time.
}
[31/07/2015 11:47:03] James C Russell: BTW "I knew this would be slow if it worked, but it ended up running the child processes async meaning the seeds would not finish before it tried to run the test. After a few hours of messing around I dropped this approach, instead aiming to focus on compartmentalizing the users so their actions would have no affect on each other."
[31/07/2015 11:47:11] James C Russell: https://philsturgeon.uk/api/2015/01/28/dredd-api-testing-documentation/
[31/07/2015 11:47:16] James C Russell: Je to tak s tim async?
[31/07/2015 11:47:43] James C Russell: "For example, you can only have one request for each “URL” + “HTTP Method” combination. This has been a pain in the past when I have wanted to document multiple POST /oauth/tokens requests showing the various inputs and outputs for different OAuth grant types, but API Blueprint wouldn’t let me."
[31/07/2015 12:01:40] James C Russell: Chapu dobre ze nemuzu mit vice responses? Nejsem si presne jistej co tim mysli.
info: Beginning Dredd testing...
Spawning `ruby` hooks handler
Hook hadnler stdout: spec/hooks/app.rb
Hook handler stderr: /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- spec/hooks/app.rb (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/dredd_hooks-0.0.1/lib/dredd_hooks/file_loader.rb:14:in `block in load'
from /Library/Ruby/Gems/2.0.0/gems/dredd_hooks-0.0.1/lib/dredd_hooks/file_loader.rb:12:in `each'
from /Library/Ruby/Gems/2.0.0/gems/dredd_hooks-0.0.1/lib/dredd_hooks/file_loader.rb:12:in `load'
from /Library/Ruby/Gems/2.0.0/gems/dredd_hooks-0.0.1/bin/dredd-hooks-ruby:10:in `<top (required)>'
'use strict';
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
var webpackDistConfig = require('./webpack.dist.config.js'),
webpackDevConfig = require('./webpack.config.js');
module.exports = function (grunt) {
@botanicus
botanicus / meetups.rb
Created June 4, 2015 07:04
What's going on in business and tech on Meetup.com?
#!/usr/bin/env ruby
# This doesn't click 'More', so it's not the same as
# using the Meetup API, but fuck that, it's simple and
# works just fine.
require 'open-uri'
require 'nokogiri'
require 'pry'
URLS = {
@botanicus
botanicus / qa.rb
Created January 20, 2015 07:35
Script for QA. It will snapshot your production, start given number of Terminals and reset the app to the given Git ref.
#!/usr/bin/env ruby
require 'terminal.com/api'
require 'date'
# Usage: ./qa.rb [production Terminal container_key] [how many Terminals to spin up] [Git ref]
def usage
abort("Usage: #{$0} [container_key] [x] [y]")
end
@botanicus
botanicus / billable_hours.rb
Created January 20, 2015 07:33
Bill your clients based on times when a Terminal with their project was running (assuming that's the time you spent developing it).
#!/usr/bin/env ruby
require 'terminal.com'
require 'date'
# Usage: ./billable-hours.rb 2015/9/1
invoice_from = Date.parse(ARGV.shift).to_time
# response = Terminal.terminal_usage_history("user_token", "access_token")
response = JSON.parse(DATA.read)