Skip to content

Instantly share code, notes, and snippets.

View passandscore's full-sized avatar

Jason Schwarz passandscore

View GitHub Profile
@passandscore
passandscore / TokenLockers.sol
Created February 12, 2024 21:25
Manages the timelock logic for external tokens.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./ERC20.sol";
import "./interfaces/IERC20.sol";
contract TokenLockers is ERC20 {
error InsufficentFunds();
error InsufficentInputValue();
error InvalidLocktime();
@passandscore
passandscore / userAvatar.js
Created September 3, 2021 23:30 — forked from SylarRuby/userAvatar.js
NodeJs AWS S3 Upload
/**
* This gist was inspired from https://gist.github.com/homam/8646090 which I wanted to work when uploading an image from
* a base64 string.
* Updated to use Promise (bluebird)
* Web: https://mayneweb.com
*
* @param {string} base64 Data
* @return {string} Image url
*/
const imageUpload = async (base64) => {
@passandscore
passandscore / cloudSettings
Created August 7, 2021 10:26
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-08-07T10:26:38.950Z","extensionVersion":"v3.4.3"}
@passandscore
passandscore / iterm2-solarized.md
Last active July 12, 2021 13:38 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)
@passandscore
passandscore / htmlForm.js
Created May 6, 2021 19:07
Basic HTML Form
<form>
<h3>FORM</h3>
<label>TITLE</label>
<input type="title" id="title" placeholder="Title...">
<label>AUTHOR</label>
<input type="title" id="author" placeholder="Author...">
<label>ISBN</label>
<input type="title" id="isbn" placeholder="Isnb...">
<button>Submit</button>
</form>
function get(url) {
// Return a new promise.
return new Promise(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
@passandscore
passandscore / kinvey.js
Last active May 5, 2021 16:33
Kinvey DB request library
//How to use it in a JS file
document.addEventListener('DOMContentLoaded', main)
const kinvey = new Kinvey('kid_BkYBymjvd', 'ed0eed3599fa4d5d9d062fae8755f43c');
const data = {
username: 'guest',
password: 'guest'
}
@passandscore
passandscore / httpClient.js
Created May 5, 2021 16:28
httpClient - DB fetch library
class httpClient {
// Get Request
get(url) {
return new Promise((resolve, reject) => {
fetch(url)
.then((res) => {
if (res.ok) {
return res.json();
}
}).then(data => resolve(data))
@passandscore
passandscore / arrayToLinkedList.js
Created April 26, 2021 19:38
Convert an Array to a Linked List
function linkedList(arr) {
return arr.reduceRight((next, value) => ({ value, next }), null);
}
let l = [3, 1, 2, 3, 4, 5];
console.log(linkedList(l));
@passandscore
passandscore / linkedLists.js
Last active April 27, 2021 17:37
DataStructure - Linked List Principles
//Algorithms - Linked List Principles
//Language: JavaScript
class Node {
constructor(data, next = null) {
this.data = data;
this.next = next;
}
}