Skip to content

Instantly share code, notes, and snippets.

View loujaybee's full-sized avatar
🖥️
Codin'

Lou Bichard loujaybee

🖥️
Codin'
View GitHub Profile
@loujaybee
loujaybee / simpleApacheServerTerraform.tf
Created April 20, 2020 06:49
A Simple Apache Terraform Instance AWS
resource "aws_instance" "myInstance" {
ami = "ami-06ce3edf0cff21f07"
instance_type = "t2.micro"
user_data = <<-EOF
#!/bin/bash
sudo su
yum -y install httpd
echo "<p> My Instance! </p>" >> /var/www/html/index.html
sudo systemctl enable httpd
sudo systemctl start httpd
@loujaybee
loujaybee / start_apache.sh
Last active April 19, 2020 18:30
Super small script to start apache
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
echo "Started User Data"
sudo su
yum install httpd
echo "<p> Instance 2! </p>" >> /var/www/html/index.html
sudo systemctl enable httpd
sudo systemctl start httpd
@loujaybee
loujaybee / microservice.component.test.js
Last active December 11, 2019 07:36
An example set of component tests
/* ----- Your Microservice ----- */
// An imaginary database
const DATABASE = [{ id: 2, name: "Lou" }]
// library.js
function databaseLibrary() {
return {
findByID: (searched_id) => DATABASE.find(id => searched_id)
}
@loujaybee
loujaybee / upload.js
Last active November 16, 2019 16:42
A crude but working upload example
import React, { Component } from "react";
import axios from "axios";
export default class extends Component {
constructor(props) {
super(props);
this.state = {
upload_file: null
};
}
@loujaybee
loujaybee / zipped-lambda-s3-github-action.yaml
Created October 12, 2019 14:09
Push A Lambda Zipped Artifact to S3 Using Github Actions
- name: Make artifact directory
run: mkdir -p ./artifacts/${{ github.repository }}
- name: Create Zip File
uses: montudor/[email protected]
with:
args: zip -r ./artifacts/${{ github.repository }}/${{ github.sha }}.zip ./src
- name: Push Zip to S3
uses: jakejarvis/[email protected]
@loujaybee
loujaybee / circular.js
Last active May 13, 2019 11:34
Get out of the circular!
class Initialisation {
constructor() {
this.aFunctionThatThrowsImmediately();
this.aFunctionThatThrowsLater();
}
// Fake stuff to show the return values of module
aFunctionThatThrowsImmediately() {
console.log(this.errorCallback()); // error thrown, but platform not set
}
@loujaybee
loujaybee / gist:160973a023193a6f3567772b87218671
Created April 9, 2019 14:33
Break IE10 with console.warn
var toCurry = function (func) {
return function (val) {
func(val);
}
};
toCurry(console.warn)('sdfsdf');
@loujaybee
loujaybee / toggleDAZN
Created March 8, 2019 12:05
Toggle DAZN 2.0 / 1.0 (add to your bookmarks)
javascript:
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 *1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
@loujaybee
loujaybee / postgres-transaction-api-clean-up.js
Last active October 1, 2018 08:13
Postgres transaction clean up
const db = require('../../database/db.js');
// The following would be library code, touched barely ever
const _executeTransaction = async(transaction) => {
try {
return await db.tx(transaction);
} catch (e) {
console.log(e);
// Handle DB error
}
@loujaybee
loujaybee / gist:60f54c9fbedcae7b4ea5e8f6f49ba73e
Created July 10, 2018 09:06
Basic Reduce Implementation
Array.prototype.reduceLou = function( func, start = 0 ){
let state = start;
for(let i = 0; i < this.length; i++) {
state = func(state, this[i]);
}
return state;