Skip to content

Instantly share code, notes, and snippets.

View gre's full-sized avatar
3 cups required

@greweb gre

3 cups required
View GitHub Profile
@gre
gre / day1.rs
Last active December 1, 2023 10:52
advent of code 2023
fn day1(input: &str) -> usize {
let digits = vec!["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
let digits_rev = vec!["eno", "owt", "eerht", "ruof", "evif", "xis", "neves", "thgie", "enin"];
let values = vec!['1','2','3','4','5','6','7','8','9'];
input.lines().map(|line| {
let regular = line.chars().collect::<Vec<char>>();
let reversed = line.chars().rev().collect::<Vec<char>>();
let mut s = String::new();
for (chars, digits) in vec![(regular, &digits), (reversed, &digits_rev)] {
use std::f64::consts::PI;
use svg::node::element::path::Data;
use svg::node::element::{Group, Image, Path};
fn heart_function(t: f64) -> (f64, f64) {
let x = 16.0 * f64::sin(t).powi(3);
let y = -13.0 * f64::cos(t)
+ 5.0 * f64::cos(2.0 * t)
+ 2.0 * f64::cos(3.0 * t)
+ f64::cos(4.0 * t);
@gre
gre / 0-README.md
Last active January 19, 2023 08:08
Current @greweb's set up to make a Plottable SVG from data (in TS, JS, Rust)

Usage

makeSVG({
  width: 100,
  height: 100,
  layers: [
    {
      color: "#e22",
 name: "Diamine Brilliant Red",
@gre
gre / timelapse
Last active August 28, 2022 17:18
#!/bin/sh
# usage: timelapse <inputvid> <outputvid> <N>
# where <N> is a number with which the video will speed up by 2^(N+1)
set -x
set -e
input=$1
output=$2
tmp=`mktemp -d`
// need libs: rand + bs58
use rand::rngs::StdRng;
fn rng_from_fxhash(hash: String) -> impl Rng {
let mut bs = [0; 32];
let max_chars = 43; // hack to not overflow the bs array
bs58::decode(
hash.chars().skip(2).take(max_chars).collect::<String>(),
)
.into(&mut bs)
@gre
gre / perf.rs
Last active August 14, 2022 11:46
Very simple helpers to record performance
use instant::Instant;
use serde::ser::SerializeStruct;
use serde::{Serialize};
use std::collections::HashMap;
// Helpers for measuring performance
struct Span {
label: String,
start: Instant,
stop: Instant,
@gre
gre / script.js
Created June 13, 2022 19:28
objkt.com batch send script to run on the page of "Actions" of the token
// between the `` you add all the address you want to send to
addresses=``.split("\n").map(_=>_.trim()).filter(Boolean)
async function main() {
$button = [...document.querySelectorAll("button")].filter(
(b) => b.innerText === "Add recipient"
)[0];
let i = 0;
for (a of addresses) {
const $amount = document.getElementById("amount_" + i);
const $address = document.getElementById("address_" + i);
precision highp float;
varying vec2 uv;
uniform float time;
vec3 palette( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d ) {
return a + b*cos( 6.28318*(c*t+d) );
}
vec3 color (float t) {
return palette(
precision highp float;
varying vec2 uv;
uniform float time;
uniform sampler2D img;
vec3 palette( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d ) {
return a + b*cos( 6.28318*(c*t+d) );
}
vec3 color (float t) {
return palette(
t,
#!/bin/bash
cd $(dirname $0)
./genOne.sh sync_Vertcoin Vertcoin
./genOne.sh sync_Dash Dash
./genOne.sh sync_Stakenet Stakenet
./genOne.sh sync_Viacoin Viacoin
./genOne.sh sync_PivX PivX
./genOne.sh sync_Komodo Komodo