Skip to content

Instantly share code, notes, and snippets.

View elliottdehn's full-sized avatar
🔨
crushing it

elliottdehn

🔨
crushing it
  • Remote
  • NYC
View GitHub Profile
@elliottdehn
elliottdehn / Dockerfile
Created September 15, 2023 01:39
streamer
# syntax=docker/dockerfile:1-labs
# Aptos CLI git metadata.
ARG GIT_REPO=https://github.com/aptos-labs/aptos-core.git
ARG GIT_TAG=aptos-cli-v2.0.3
# Relative to Econia repository root.
ARG MOVE_ROOT=src/move
ARG ECONIA_ROOT=$MOVE_ROOT/econia
ARG FAUCET_ROOT=$MOVE_ROOT/faucet
// how to use this:
// 0. install node.js (https://nodejs.org/en/download/)
// 1. create a `.js` file with this code
// 2. put your songs or whatever in the input
// 3. run `node filename.js`
// 4. answer questions until you have a result
async function merge(A, temp, cmp, frm, mid, to) {
let k = frm;
let i = frm;
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
// CHI:
// https://etherscan.io/address/0x0000000000004946c0e9F43F4Dee607b0eF1fA1c#code
// OneSplit:
// https://etherscan.io/address/0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e#code
/*
from collections import Counter
from itertools import chain
# assumes a null terminating character
def n_grams(s, n):
last_idx = len(s) - n
return (s[i: i + n] for i in range(0, last_idx + 1))
def k_n_grams(s, n):
return (gram for i in range(1, n + 1) for gram in n_grams(s, i))
public String sortConcat(String[] arr) {
return Arrays.stream(arr)
.sorted()
.collect(Collectors.joining(""));
}
@elliottdehn
elliottdehn / ex2.java
Last active March 25, 2020 15:57
Egregrious For Loop
// Sort the words and join them
public String sortConcat(String[] arr) {
String[] temp = Arrays.copyOf(arr, arr.length);
StringBuilder result = new StringBuilder("");
Arrays.sort(temp);
for(int i = 0; i < temp.length; i++) {
result.append(temp[i])
}
return result.toString();
}
@elliottdehn
elliottdehn / ex1.java
Created March 25, 2020 15:33
Intro to Streams
private String paramString(List<Map.Entry<String, String>> params){
return params.stream()
.map(this::escapeEntry)
.sorted(comparingByKeyAndValue())
.map(e -> e.getKey().concat("=").concat(e.getValue()))
.collect(Collectors.joining("&"));
}