Skip to content

Instantly share code, notes, and snippets.

View thedavidmeister's full-sized avatar

David Meister thedavidmeister

View GitHub Profile
@rouzwelt
rouzwelt / DiagOrder.md
Last active June 13, 2024 06:10
Diag Rain Orderbook Orders Running on Arb Bot
  • you need foundry installed on your machine for this process, as well as having forge-std lib for contract dependencies.
  • download or copy the DiagOrder.sol file below and put it in ./script folder (or any other folder of your choice)
  • replace the import path with the location of forge-std/src/Script.sol on you disk.
  • replace the to address with the arb contract address on the desired network.
  • replace the data with the calldata without leading 0x taken from otel (hyperdx).
  • save the file and now you can run the following command to get the traces:
forge script path/to/DiagOrder.sol:DiagOrder -vvvvv --fork-url <url> --fork-block-number <blocknumber> --sender <addres>
  • replace the path with the location of the saved file in previous step,
@thedavidmeister
thedavidmeister / .gitignore
Last active July 29, 2017 15:53
basic setup for hoplon project
/target_dev
@CMCDragonkai
CMCDragonkai / functions_and_closures.rs
Last active July 29, 2019 22:05
Rust: Higher Order Functions & Closures (Rust 1.7 Stable) - Creating the Haskell's `$` function in Rust.
fn main() {
let closure_immutable_pure = |x: i32| x + 1;
let result1 = apply_pure(& closure_immutable_pure, 1);
// let result2 = apply_mut(&mut closure_immutable_pure, 2); // not typeable
let result3 = apply_once(closure_immutable_pure, 3);
let mut closure_mutable_pure = |x: i32| x + 1;
@micha
micha / throttle.cljs.hl
Last active October 30, 2016 02:23
Create a cell that only updates at most once every so many milliseconds
(defn throttle [c ms]
(let [queued? (atom false)]
(with-let [ret (cell @c)]
(add-watch c (gensym)
#(when-not @queued?
(reset! queued? true)
(with-timeout ms
(reset! queued? false)
(reset! ret @c)))))))
@john2x
john2x / 00_destructuring.md
Last active July 9, 2024 01:38
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@edw
edw / delete-recursively.clj
Last active November 12, 2021 20:31
To delete a directory recursively in Clojure.
(defn delete-recursively [fname]
(let [func (fn [func f]
(when (.isDirectory f)
(doseq [f2 (.listFiles f)]
(func func f2)))
(clojure.java.io/delete-file f))]
(func func (clojure.java.io/file fname))))
@alandipert
alandipert / maptemplate.md
Created January 30, 2013 00:28
ClojureScript macros: kinda, sorta, not really.

ClojureScript macros: kinda, sorta, not really.

ClojureScript does not have a standalone macro system. To write ClojureScript macros, one must write them in Clojure and then refer to them in ClojureScript code. This situation is workable, but at a minimum it forces one to keep ClojureScript code and the macros it invokes in separate files. I miss the locality of regular Clojure macros, so I wrote something called maptemplate that gives me back some of what I miss. The technique may be useful in other scenarios.

Problem

Suppose you're wrapping functionality in another namespace or package so that you can have your own namespace of identically named but otherwise decorated functions:

ClojureScript:

@hsablonniere
hsablonniere / README.md
Created May 2, 2012 22:42
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

@gorsuch
gorsuch / gist:1418850
Created December 1, 2011 18:37
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))