Skip to content

Instantly share code, notes, and snippets.

View ppeble's full-sized avatar

Phil Peble ppeble

View GitHub Profile
@ppeble
ppeble / ratelimit-tls.py
Created September 16, 2019 19:18
Ambassador - Ratelimit with TLS test example
class RateLimitV1WithTLSTest(AmbassadorTest):
# debug = True
target: ServiceType
def init(self):
self.target = HTTP()
def manifests(self) -> str:
return super().manifests() + """
---
@ppeble
ppeble / co-and-br-example.md
Last active March 18, 2019 21:08
Holidays - definitions - example of slightly different results between calls

We load definitions into memory only when they are referenced or in certain specific cross-loading scenarios. This could lead to a scenario where running a single region returns slightly different results.

That said, even if the results are slightly different they should still be correct in the sense that the user sees what they expect for a specific query.

Here is an example:

~/Code/ppeble/holidays(master ) make console
bundle exec rake console
irb -r rubygems -I lib -r holidays.rb
@ppeble
ppeble / issue24.md
Last active October 22, 2017 02:58
issue-24: change methods to non-ruby YAML

'Common' functions that must be implemented by the client:

  • easter(year)
  • to_monday_if_weekend(year)
  • to_monday_if_sunday(date)
  • to_tuesday_if_sunday_or_monday_if_saturday(date)
  • to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)
  • orthodox_easter(year)
  • orthodox_easter_julian(year)
  • to_weekday_if_weekend(date)
  • to_weekday_if_boxing_weekend(date)
@ppeble
ppeble / definition_example.txt
Created October 23, 2016 04:24
Holiday definition - example test in ruby
# This is the line of 'raw' ruby that I have in my YAML
assert_equal 'Labour Day', Holidays.on(Date.civil(2013,10,7), :au_qld)[0][:name]
# I want to turn it into this
- name: 'Labour Day'
year: 2013
month: 10
day: 7
regions: ['au_qld']
@ppeble
ppeble / proposed.yaml
Created September 15, 2016 02:13
Proposed definition 'test' change
---
months:
1:
- name: Test
regions: [ar]
mday: 1
tests:
@ppeble
ppeble / issue_144_testing.txt
Created April 2, 2016 21:04
Testing for issue 144
# Here is a custom 'on the fly' definition file:
months:
0:
- name: Good Friday
regions: [custom_single_file]
function: easter(year)
function_modifier: -2
- name: Custom Holiday
regions: [custom_single_file]
function: custom_method(year)
@ppeble
ppeble / benchmarks.md
Last active March 5, 2016 17:59
Holidays Gem - Benchmarks - autoload regions vs no autoload

Purpose

I want to see if I can simplify the 'require' process for the loading of this gem. Today we only 'require' a generated definition either when it is explicitly loaded or when the region is used for the first time. This means we have some weird 'requires' logic that is buried in our files.

It would be great if I could simply auto-require all generated definitions and then, when a region was loaded, I could simply call a method to 'merge' that into memory. It would also allow for a lot of other benefits, like allowing for methods to return all of the 'custom methods' and associating those custom methods only with that region. Today 'custom defined methods' are basically global, which sucks. It's just luck that we have not stepped on toes.

Current process

Today a user of the gem will require holidays. This loads the main holidays code but does not require or load any generated definitions.

@ppeble
ppeble / temp.go
Last active February 7, 2016 20:16
Go DI Example
// Target interface
type Repository interface {
Add (uuid.UUID) (Account, error)
}
// This is our test structure. It has an internal function that you can inject.
type funcAccountRepo struct {
add func(uuid.UUID) (Account, error)
}
@ppeble
ppeble / Marketplace-Web Dev Setup
Last active August 29, 2015 14:05
Marketplace-web development setup for service-host vm
Unfortunately there are multiple steps that must be taken to fully set up the environment for marketplace-web development. This is a living document, please let me know if you hit any snags so it can be updated.
These instructions assume that you have fully set up the service-host vm (https://github.com/sittercity/service-host) via the README. If you have any issues setting it up please contact DevOps.
Once you are logged into your VM you must complete all of these steps. These are all one-time steps.
0) Before anything else, make sure that you clone 'stormtrooper' from github into the '~/dev' directory on the VM. This will be important for later steps.
1) Pull all of the variables found at https://gist.github.com/ptrimble/3dd85c7704398f008746 and place it in a file in your home directory on the VM. I recommend that you name it '.sc_service-config' but it can be whatever you want. Add the following line to your ~/.zshrc file:
@ppeble
ppeble / gist:5623dc9aad55fcb797bc
Created August 26, 2014 16:51
HAProxy setup - ptrimble
frontend main-frontend
bind 0.0.0.0:80
mode http
# block if !goodguys
# block if heartbeat_req was_forwarded (disabled until we figure out heartbeats to dependant services)
acl goodguys src 127.0.0.0/8 192.168.0.0/16 10.0.0.0/8
acl heartbeat_req url_beg /heartbeat
acl local-dev-server.dev_host_acl hdr(host) -i 127.0.0.1
acl public-api.dev_host_acl hdr(host) -i public-api.dev
acl rbac.dev_host_acl hdr(host) -i rbac.dev