Skip to content

Instantly share code, notes, and snippets.

quote = '"A person who never made a mistake never tried anything new"'
quotee = "- Albert Einstein"
print(quote +"\n"+ quotee)
@0xCourtney
0xCourtney / 2.1.js
Created March 26, 2018 15:45
DiceRoll - ToyProblem
// Create a function that returns the result of a dice roll
// Then modify the function to accept rolling multiple dice of the same size and return the cumulative sum of .
// Then modify the function to return an array of objects containing the cumulative sum at the current roll, the dice roll value, and the index.
function diceRoll(size = 6, numDice) {
let diceSum = 0;
let diceArr = [];
for (let i = 0; i < numDice; i++) {
let roll = Math.floor(Math.random() * (size - 1) + 1);
@0xCourtney
0xCourtney / 1.2.js
Created March 26, 2018 15:46
FizzBuzz - Toy Problem
// FizzBuzz
// write a function that takes in one number.
// Starting at 1, console log every number up to the number passed in.
// If the number being logged is divisible by 3 log 'Fizz' instead.
// If the number is divisible by 5 we will log 'Buzz' instead.
// If they are divisible by both 3 and 5 we will log 'FizzBuzz'
function fizzBuzz(num) {
for (let i = 1; i <= num; i++) {
if (i % 3 === 0 && i % 5 === 0) {
@0xCourtney
0xCourtney / 1.3.js
Created March 26, 2018 15:47
SwapCase - ToyProblem
// Swap Case
// Below is a function that takes in a string and reverses the case of every character and returns the new string.
// It is currently in a broken state and does not run properly.
// It is possible to fix the code by only modifying the existing code, not adding new lines.
//test data
//'This Is An Example' becomes 'tHIS iS aN eXAMPLE'
//'boB rOss IS thE OrIgInAl GanGster' Becomes 'BOb RoSS is THe oRiGiNaL gANgSTER'
function caseReverse(str) {
@0xCourtney
0xCourtney / App.js
Created August 13, 2018 01:51
Uploads file to IPFS via Infura
// Note this only shows the function being called in the parent component. The child component
// passes the event and contract address to the parent... I can make this more complete if requested...
uploadFile = async (event, contractAddress) => {
event.stopPropagation();
event.preventDefault();
const { web3, accounts } = this.state;
@0xCourtney
0xCourtney / xgrid.js
Created December 1, 2018 19:13
HTML Canvas Grid of X's
function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
ctx.beginPath();
var scale = 10;
var spacing = 20;
const spawnedProcess = spawn('python3', ['./python/pdfConverter.py'])
spawnedProcess.stderr
.on('data', (data) => {
console.log(`error:${data}`);
res.sendStatus(500)
})
.on('close', () => {
try {
createInterface({
const spawnedProcess = spawn('python3', ['./python/pdfConverter.py'])
var referenceJson = { turfs: [] }
spawnedProcess.stderr
.on('data', (data) => {
console.log(`error:${data}`);
res.sendStatus(500)
})
.on('close', () => {
try {
var returnedArray = [];
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);
// Fork workers
for (let i = 0; i < numCPUs; i++) {
const worker = cluster.fork();
}
} else {
app.post('/api/multiThread', (req, res) => {
@0xCourtney
0xCourtney / example.md
Created October 7, 2020 17:14 — forked from leetrout/example.md
Markdown Diffs

The current code looks like this:

type Demo struct {
  Field        int
  AnotherField string
}

We actually need to track the Thing