Skip to content

Instantly share code, notes, and snippets.

View davehewy's full-sized avatar

David Heward davehewy

View GitHub Profile
#!/bin/bash
INSTANCE_PLACEMENT=$(aws ec2 describe-instances --instance-id ${1} | jq -r ".Reservations[] .Instances[].Placement.AvailabilityZone")
AZ=$(echo ${INSTANCE_PLACEMENT} | awk '{ print substr($1, length($1)) }')
REGION=$(echo ${INSTANCE_PLACEMENT} | awk '{ print substr($1, 0, length($1)-1) }')
aws ec2-instance-connect send-ssh-public-key --instance-id ${1} --availability-zone ${REGION}${AZ} --instance-os-user ec2-user --ssh-public-key file:///Users/your_user/.ssh/id_rsa.pub
aws ssm start-session --target ${1} --document-name AWS-StartSSHSession --parameters portNumber=${2}
# Until further upgrades V3 pearson will not use host name classification and instead will apply common modules and stringently implement passed roles.
node default {
# apply our pmc_common module
class{'profile::common': }
# switch on $::pmc_role custom FACT
# do not fail if no role is specifically applied.
# given that we have only a few roles, a declarative switch statement like this is preferred.
case $::pmc_role {
@davehewy
davehewy / test.json
Created May 5, 2017 08:41
michael look here
{
"orders": [
{
"OrderID": "17157",
"OrderStatus": "3",
"OrderStatusCode": "dispatched",
"CustomerAccount": "PIERI001",
"CustomerVATNumber": "CY00870822R",
"GrossValue": "426.09",
"DeliveryCompanyName": "STIHL MIXALIS PIERI",
# Hello Candidate!
# Welcome to the EE Python Test.
# As I will have mentioned in the interview we are not overly interested
# in the absolute quality of your code, just your ability to approach problems.
# All code solutions should be tar/zip'd up and sent to the recruiter to pass
# back to us. Thanks.
# Task 1
#
@davehewy
davehewy / hybris.pp
Created October 25, 2016 13:53
hybris build example
exec{'buildhybris':
cwd => 'hybris_install_dir',
cmd => './build.sh',
unless => "/usr/bin/test -f /tmp/hybris_build_done",
timeout => 600,
before => File['/tmp/hybris_build_done']
}
file{'/tmp/hybris_build_done':
ensure => present
@davehewy
davehewy / example.py
Last active February 17, 2016 13:37
inheritance pythom
class Base:
templates = {}
def register(self, register):
self.templates.update(register)
def do_something():
for tpl in self.templates.values():
print "Perhaps access the object here? I.e"
# I don't really like this, which led me to question it.
instance = self.templates[tpl]()
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"AppendItemToListFunction": {
"Properties": {
"Code": {
"ZipFile": {
"Fn::Join": [
"",
[
@davehewy
davehewy / phpmig.php
Created February 24, 2015 10:53
Eloquent and PHPmig (note this does not work)
dave:~/sites/bin $ ./phpmig status
PHP Fatal error: Call to a member function schema() on boolean in /Users/davidheward/sites/vendor/davedevelopment/phpmig/src/Phpmig/Adapter/Illuminate/Database.php on line 89
Fatal error: Call to a member function schema() on boolean in /Users/davidheward/sites/vendor/davedevelopment/phpmig/src/Phpmig/Adapter/Illuminate/Database.php on line 89
from fabric.api import *
import boto
from boto import regioninfo
from boto import ec2
from boto.ec2.elb import ELBConnection
import app
# Some default environment settings
env.user = 'ec2-user'
<?
class DevodoCredit_AddCredits extends Backend_Controller
{
public $implement = 'Db_ListBehavior, Db_FormBehavior';
public function __construct(){
parent::__construct();
}