Skip to content

Instantly share code, notes, and snippets.

View alecchampaign's full-sized avatar

Alec Champaign alecchampaign

View GitHub Profile
@alecchampaign
alecchampaign / 001 - Journal Homepage.md
Last active January 11, 2020 00:52 — forked from trentgoing/001 - Journal Homepage.md
SDC Engineering Journal

SDC Engineering Journal

This gist details the decisions I made, the tests I conducted, the observations recorded, and the directions I took while building out an API for Project Greenfield.

Goals

Achievements

:root {
--primary-font: "Poppins", "sans-serif";
--font-color: #525252;
--font-light: #707070;
}
body {
font-family: var(--primary-font);
margin: 0;
overflow-x: hidden;
// Numbers pipeline
const nums = [10, 20, 30, 40]; // Array of numbers
let addNums = nums => nums.reduce((acc, x) => acc + x); // Adds all numbers in an array together
let divideByTwo = number => number / 2;
// Function to be used as callback in reduce. Will pass function a as an argument (callback) in function b (higher order function).
let _pipe = (a,b) => arg => b(a(arg))
// Reduces a potentially infinite number of operations using the above '_pipe' function.
// This allows two function at a time, one as a callback to the other (higher order) function. The result of which is then
// ES5 Syntax
function Person(firstName,lastName,age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.sayName = function() {
return 'Hello, my name is ' + this.firstName + ' ' + this.lastName + '.';
}
}
pragma solidity ^0.4.8;
contract FunBucks {
struct accounts {
string name;
uint balance;
bool active;
bool funOfficer;
}
@alecchampaign
alecchampaign / login.sol
Created December 5, 2017 22:23
Smart contract for logging into a front-end with public address
pragma solidity ^0.4.18;
contract login {
address creator;
struct account {
bytes32 username;
bool admin;
}
@alecchampaign
alecchampaign / identity.sol
Last active December 5, 2017 22:11
Smart contract for storing a database of identities
pragma solidity ^0.4.18;
contract ID {
address creator;
struct identity {
string name;
uint age;
uint height;
@alecchampaign
alecchampaign / escrow.sol
Last active December 3, 2017 00:53
A simple escrow contract between two parties.
pragma solidity ^0.4.18;
contract Escrow {
address public buyer;
address public seller;
uint public balance;
uint public requiredDeposit;
uint public price;
uint public sellerCollateral;
uint public buyerCollateral;
@alecchampaign
alecchampaign / donate.sol
Last active December 1, 2017 02:58
A simple fund raising contract.
pragma solidity ^0.4.18;
/** Simple fund raising contract */
contract Donation
{
address beneficiary;
uint donations;
uint goal;
uint amountRaised;
@alecchampaign
alecchampaign / vault.sol
Last active December 3, 2017 11:32
Simple contract to store Ether.
pragma solidity ^0.4.18;
/** Simple contract to store Ether */
contract Vault
{
address owner;
uint balance;
// Modifier for authenticating owner
modifier ownerOnly(address _owner) {