Skip to content

Instantly share code, notes, and snippets.

View christiearcus's full-sized avatar

Christie christiearcus

  • Sharesies
  • Wellington
View GitHub Profile
@christiearcus
christiearcus / session1.scala
Created September 22, 2017 07:06
Scala - Session 1
// Base types
val a: Int = 10
// Functions
// first class citizens - can be passed as values.
def add(a: Int, b:Int): Int = {
a + b
}
@christiearcus
christiearcus / adding-remote-repos.md
Last active March 10, 2017 00:36
Pulling the latest changes from 'upstream'

When we refer to 'upstream' in our project, we are referring to the central version (and not our personal forks). By default, when you clone your fork, there will be no reference to the upstream version. But it's necessary to add this, as this allows us to pull the latest changes when pull requests are merged.

To set this up use the following steps:

  • Check your remote versions on your project:

git remote -v- if you want to look at it in your project code, you can check the config file of the .git folder.

  • Add the reference to the upstream repository:
// add an option to your query, which forces apollo to make the request on the client.
export default graphql(Query, {
options: { ssr: false }
});
@christiearcus
christiearcus / ops-weekly-hangs-02.md
Last active January 18, 2017 05:35
Ops weekly hangs 02

There are a couple of issues with our Wordpress deployment.

The EC2 instances running our wordpress site have databases running within them. Each of the databases is keeping state of the app for that instance. If the instance dies, and a new one is started by our ASG, our state will be lost.

To improve this, we can separate our database out from the instance running our app. This means that if our instance dies, our state is safe.

We will need:

  • A RDS instance to run our MySQL database.
  • An S3 bucket to store a tarball of our customised Wordpress app (with the correct database access file).
@christiearcus
christiearcus / launchconfig.sh
Last active May 15, 2017 09:57
Ops weekly hangs 01
#!/bin/bash
wget https://wordpress.org/latest.tar.gz
yum install mysql-server mysql php php-mysql mysql-devel mysql-libs httpd -y
tar xvfz latest.tar.gz -C /var/www/html/
service httpd start
service mysqld start
chown -R apache /var/www/html
@christiearcus
christiearcus / DecoratorPattern.md
Last active September 16, 2016 02:03
Design Patterns Course Lynda.com

Decorator Pattern

The decorator pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub-classing for extending functionality.

Aims to avoid 'class chaos'. Uses open / closed principle. Add new behaviour, but without implementing regression. Uses delegation and composition.

@christiearcus
christiearcus / destructuring.js
Created August 4, 2016 06:37
array-object-destructuring
const avengers = ['Natasha Romanoff', 'Tony Stark', 'Steve Rogers'];
const ['blackWidow', ...theOthers] = avengers;
// blackWidow = 'Natasha Romanoff
// theOthers = ['Tony Stark', 'Steve Rogers']
@christiearcus
christiearcus / react-env-setup.md
Last active July 24, 2016 08:54
Setup react build tools

Do a blog post on this, as it’s so annoying to re-remember!

1 Set up libraries & dependencies

Set up blank project folder:

  • npm init (and follow the prompts)
  • npm install react react-dom —save
  • npm install webpack webpack-dev-server -g
  • npm install babel -g
@christiearcus
christiearcus / node-debugging.md
Created July 20, 2016 11:51
Debugging tools for node.

To be able to debug & reload for node apps (e.g. express), here are some steps:

npm install -g nodemon npm install -g node-inspector

  • When running your app, instead of node app.js, you can now run nodemon app.js and it will restart the app on change.
  • To run in debug mode, start your app with nodemon --debug app.js. Then start node-inspector node-inspector.
  • Use the localhost URL provided by node-inspector to view your app in the console.
  • When you want to debug, put a debugger statement in your code. When you refresh your browser (on your app process), node-inspector will break at that point and allow you to debug.