Skip to content

Instantly share code, notes, and snippets.

View jensendarren's full-sized avatar

Darren Jensen jensendarren

View GitHub Profile
@jensendarren
jensendarren / contracts...Address Data Type...AddressType.sol
Created March 11, 2022 04:03
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.7.0 <0.9.0;
contract AddressType {
address public basicAddress = 0xeCc6425dB956125989C2c1a58A817bD90f86B3C0;
address public basicAddress2 = 0x9Fa413fad794c18fdd3A5Ead5734f042Eb920A20;
address payable anotherPayableAddress = payable(0x94fe479322fa107933d67b9e230a9B12B6c9a96d);
@jensendarren
jensendarren / contracts...Elementary Data Types...AddressType.sol
Created March 11, 2022 03:04
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.7.0 <0.9.0;
contract AddressType {
address public aDefaultAddress;
// Example of a non checksum address (not allowed by solidity compiler)
// Can fix using:
// web3.utils.toChecksumAddress('0xecc6425db956125989c2c1a58a817bd90f86b3c0')
@jensendarren
jensendarren / contracts...Elementary Data Types...IntegerType.sol
Created March 11, 2022 03:04
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.7.0 <0.9.0;
contract IntegerType {
// uint type is same as uint256
uint256 aUint;
// int type is same as int256
int256 anInt;
@jensendarren
jensendarren / contracts...Elementary Data Types...BoolType.sol
Created March 11, 2022 01:20
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.7.0 <0.9.0;
contract BoolType {
//a basic bool
bool public aBool;
function notBool() public view returns (bool) {
return !aBool;
@jensendarren
jensendarren / contracts...Elementary Data Types...BoolType.sol
Created March 11, 2022 01:07
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.7.0 <0.9.0;
contract BoolType {
bool public aBool;
function notBool() public view returns (bool) {
return !aBool;
}
from decimal import *
#Sets decimal to 10000 digits of precision
getcontext().prec = 10000
def plouffBig(n): #http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula
pi = Decimal(0)
k = 0
while k < n:
pi += (Decimal(1)/(16**k))*((Decimal(4)/(8*k+1))-(Decimal(2)/(8*k+4))-(Decimal(1)/(8*k+5))-(Decimal(1)/(8*k+6)))
@jensendarren
jensendarren / listNumbersPossibleSum.js
Created July 13, 2020 10:13
Given a list of numbers an a number k, return whether any two number from the list add up to k
/*
Given a list of numbers an a number k, return whether any two number from the list add up to k
For example. given [10,15,3,7] and k of 17 return true sine 10 + 7 is 17.
Bonus can you do in a single pass?
*/
array = [7,15,3,7,8,3,4,100]
k = 23
@jensendarren
jensendarren / update-keypair-in-ec2.md
Last active February 19, 2020 03:09
Add new SSH Keypair to an EC2 instance when you have lost your .pem file!

How to update your EC2 instance with a new keypair

  1. Create a new keypair in AWS Console

  2. Start a new temporary recovery EC2 instance

  3. Stop the lost keypair instance

  4. Detach the EBS drive from the lost keypair instance

@jensendarren
jensendarren / App.vue
Last active February 25, 2020 09:26
A VueJS Prototype for logging console output to the component
<!--Make sure to install @vue/cli-service-global first-->
<!--Serve this up using `vue serve` at the command line-->
<!--Details here: https://cli.vuejs.org/guide/prototyping.html -->
<template>
<div>
<h1>{{name}}</h1>
<b>Logging To Vue Component? <span>{{logging}}</span></b>
<br />
<button @click="testLog">Test Log</button>|<button @click="testWarn">Test Warn</button>|<button @click="toggleLogging">Toggle Logging</button>
<hr/>
@jensendarren
jensendarren / VueJS Rapid Prototyping Example
Created February 11, 2020 07:40
A basic VueJS Rapid Prototyping Example
<!--Make sure to install @vue/cli-service-global first-->
<!--Serve this up using `vue serve` at the command line-->
<!--Details here: https://cli.vuejs.org/guide/prototyping.html -->
<template>
<h1>Hello {{name}}</h1>
</template>
<script>
export default {
data() {