Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env/ruby pr-summary.rb
# USAGE:
# ./pr-summary.rb QUERY_TERM1 [QUERY_TERM2] ...
# Example: ./pr-summary.rb is:closed 'created:>2017-10-01' repo:aptible/foo
# This will print a CSV summary of all PRs opened after 10/1/17, now closed,
# and in the aptible/foo repo
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
headers['strict-transport-security'] = [{
key: 'Strict-Transport-Security',
value: 'max-age=31536000'
}];
AWSTemplateFormatVersion: '2010-09-09'
Description: <Your description>
Parameters:
Domain:
Type: String
Default: <default domain URI>
AllowedValues:
- <list of allowed domain URIs>
@Dawenster
Dawenster / tdd.md
Last active December 15, 2015 16:19
Test-Driven Development Notes

Philosophy of testing

Intro

TDD is an approach where you write a test before you write just enough production code to fulfill that test and then refactor. Red-green-refactor is where you get a test to fail first, then you write code to get it to pass, then you refactor your code. Then repeat! :) Check out: http://betterspecs.org/

You should "test with a purpose" and know why you are testing something and to what level it needs to be tested. An interesting side effect of TDD is that you achieve 100% coverage test – every single line of code is tested – something that traditional testing doesn’t guarantee (although it does recommend it).

In general:

  • Tests should be reliable
  • Tests should be easy to write
@Dawenster
Dawenster / controller - card.rb
Last active December 14, 2015 10:39
Run this in terminal if you want some practice on ruby terms and definitions! Notes: - Put everything in the same folder - Typing 'exit' leaves the program - Typing 'show statistics' shows you your current statistics
class Card
attr_reader :question, :answer, :times_guessed
attr_accessor :status
def initialize(args)
@question = args[:question]
@answer = args[:answer]
@status = :not_attempted
@times_guessed = 0
end
class AI
attr_reader :already_guessed
def initialize
@already_guessed = []
@coordinates = {}
end
def choose_coordinates
@coordinates = {}
@Dawenster
Dawenster / Useful stuff!
Last active December 13, 2015 22:19
Some useful coding stuff! Must review constantly...
ARRAYS---------------------------------------------------------------------------------------------
Q: How to easily create an array of strings?
x = %w[a b c d]
Q: How to pull out items in an array and use that instead of the original array
array.select!{ |x| x.prime? }