Skip to content

Instantly share code, notes, and snippets.

// Better way
const getValue = ({value}) => value;
const add = x => y => x + y;
const addTen = add(10);
const multiply = x => y => x * y;
const displayValue = string => value => `${string}::${value}`;
const displayLeverageRatio = displayValue('Leverage Ratio');
@tgrecojs
tgrecojs / UniV3SwapAnalytics.js
Last active August 31, 2021 18:58
JS code for calculating price impact of ETH/USDC swaps
import sampleData from './sampleData.js';
/**
* Uniswaph V3 Subgraph Data
*
* Result of Qu
*/
const queries = {
swaps: `{
swaps(first: 20, where: {pool:
#https://egghead.io/lessons/javascript-how-to-fork-and-clone-a-github-repository
# Step 1 - Fork Repo want to work with & clone it to your machine.
git clone https://github.com/tgrecojs/example-repo
# cd into repo
cd example-repo
# Add upstream branch
git remote add upstream https://github.com/<repoOwner>/example-repo
# fetch upstream branches
git fetch upstream
# Point master branch of forked repo to the upstream repo's master branch

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

@tgrecojs
tgrecojs / drive_sync_settings.sh
Created December 13, 2020 05:46
bash script for excluding
#!/usr/bin/env bash
set -e # always immediately exit upon error
# directory config. ending slashes are important!
# src_dir="$HOME/Projects/"
gdrive_projects-dir="$HOME/Google\ Drive/cloud-based-demo-applications"
# run the sync
rsync -ar --delete \
const Maybe = {
Just: value => ({
value,
map: f => Just(f(value)),
toString: () => `Just(${value})`
}),
Nothing: (value = null) => ({
value: null,
map: f => Nothing(null),
toString: () => `Nothing(${value})`
const Day = ({ get, left, right }) => {
const map = f => Day ({
get: f (extract()),
left, right
})
const extend = f =>
Day ({
get: (left, right) => f (Day ({ get, left, right })),
import curry from 'crocks/helpers/curry'
import or from 'crocks/logic/or'
import pathSatisfies from 'crocks/predicates/pathSatisfies'
import propSatisfies from 'crocks/predicates/propSatisfies'
const list = [
'nice', 'bad', 'super bad'
]
const data = [
@tgrecojs
tgrecojs / machine.js
Created December 20, 2019 03:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
{
"cols": [
"people",
"dates",
"zips",
"companies"
],
"data": [
[
"Nigel",