Skip to content

Instantly share code, notes, and snippets.

@argctl
argctl / .deps...remix-tests...remix_accounts.sol
Created October 24, 2022 23:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
address[15] memory accounts;
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
@argctl
argctl / moodle_on_do.md
Created April 12, 2021 16:11 — forked from burningTyger/moodle_on_do.md
How To Install Moodle via git with Postgres, Nginx and PHP on an Ubuntu 16.04 VPS

How To Install Moodle via git with Postgres, Nginx and PHP on an Ubuntu 16.04 VPS

Introduction

Moodle is a common online learning platform used in many educational settings around the world. This tutorial aims at giving admins a solid and speedy foundation for serving moodle to a small to medium sized institution. The setup focuses on simple maintenance and fast updates.

Prerequisites

  • Create a small droplet with Ubuntu 16.04 (64Bit is great)
  • Follow the tutorial on setting up Ubuntu 16.04
  • git should be installed by default
const test = [
[60, 80, 40], // Weights
[2, 3, 5], // Destinations
5, // Floors
2, // Max passengers
200 // Max weight
]
function elevator (weights, destinations, floors, maxPassengers, maxWeight, total = 0) {
let numOfPeople = 0
@argctl
argctl / index.html
Created March 4, 2019 04:05
Dynamic copyright symbol w/year. (Why the date is meaningless)
<html>
<head>
<script src="index.js"></script>
</head>
<body>
<div id="copyright"></div>
</body>
</html>
@argctl
argctl / uuid_pool.js
Last active March 3, 2019 01:45
A way to generate unique uuids, verifying they're unique, fixing uniqueness if they aren't, maintaining amount.
const u = require('uuid/v4');
function uniqueIDs(idList, length){
const s = new Set(idList);
const sa = Array.from(s);
if(sa.length === length) return sa;
const remaining = length - sa.length;
const a = new Array.fill(remaining).map(()=>u());
return uniqueIDs(a.concat(sa), length);
@argctl
argctl / package.json
Created August 19, 2018 19:14
React Environment Variable Example with Custom Build Command
//scripts portion of your package.json file
"scripts": {
"start": "REACT_APP_URL=http://localhost:8081 react-scripts start",
"build": "REACT_APP_URL=https://www.example.com react-scripts build",
"dev" : "REACT_APP_URL=http://localhost:8081 react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
//dev command is added to run build with a different environmental variable for use in development environment.
@argctl
argctl / api.js
Created August 19, 2018 19:04
Generic Fetch Request with Environmental Base URL
//fetch a request with an environmentally defined base url
fetch(`${process.env.REACT_APP_URL}/${api_url}`)
.then(callback)
.catch(errorCallback);
@argctl
argctl / api.js
Created August 19, 2018 18:58
Generic Fetch Request with Hardcoded Base URL
//fetch a request with a hardcoded base url
fetch(`http://localhost:8081/${api_url}`)
.then(callback)
.catch(errorCallback);
@argctl
argctl / package.json
Last active August 19, 2018 18:57
React Environment Variable Example
//the scripts object in your package.json file before
"scripts" : {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
//the object after adding environmental variables to your paths:
"scripts": {
"start": "REACT_APP_URL=http://localhost:8081 react-scripts start",