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 / 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;
describe('GIVEN I am not an admin user', function () {
describe('WHEN Navigate to the page /admin ', function () {
it('THEN I see a warning box stating: "You do not have access to this page" ', () => {
Page.navigate('/admin')
expect(Page.elementContains('#error-message', 'You do not have access to this page')).toBeTrue();
});
});
});
@loujaybee
loujaybee / stripeSubscriptionsCreate.js
Created November 14, 2017 09:28
Stripe Create Subscriptions
stripe.subscriptions.create({
customer: "your-customers-id",
plan: "monthly-membership",
application_fee_percent: 5
}, {
stripe_account: req.body.account
})