Skip to content

Instantly share code, notes, and snippets.

View madis's full-sized avatar
🧑‍💻
code mode

Madis Nõmme madis

🧑‍💻
code mode
View GitHub Profile
@madis
madis / first.cljs
Created April 17, 2023 13:40
Ethers & hardhat with ClojureScript & nbb (Node Babashka)
(ns first
(:require
["@nomicfoundation/hardhat-chai-matchers/withArgs" :refer [anyValue]]
["@nomicfoundation/hardhat-network-helpers" :as hnh :refer [hh-time loadFixture]]
["ethers" :as ethers-js]))
(def test-seed "easy leave proof verb wait patient fringe laptop intact opera slab shine")
(defn ** [x n]
(loop [acc 1 n n]
(if (zero? n) acc
@madis
madis / gist:4650014
Created January 27, 2013 19:40
Testing CORS OPTIONS request with curl
curl \
--verbose \
--request OPTIONS \
http://localhost:3001/api/configuration/visitor \
--header 'Origin: http://localhost:9292' \
--header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \
--header 'Access-Control-Request-Method: GET'
# http://nils-blum-oeste.net/cors-api-with-oauth2-authentication-using-rails-and-angularjs/#.UQJeLkp4ZyE
@madis
madis / README.md
Last active October 12, 2022 06:27
Clojure vs Ruby
@madis
madis / move-from-lein-to-shadow.md
Last active June 14, 2022 09:09
Moving CLJS libraries form leiningen to shadow-cljs (deps.edn, transitive NPM deps)

To resume the changes required to move a CLJS library from leiningen to shadow-cljs:

  1. Create shadow-cljs.edn in the project root
  1. Create deps.edn in the project root and translate the Clojars dependencies from project.clj to there
  1. If there are direct NPM dependencies for that library / project, define these in src/deps.cljs
  • NB! note the extension, it's .cljs not .edn, this is important
@madis
madis / approval-transfer-from.cljs
Last active July 21, 2021 07:16
Debugging ERC20 approval & transferFrom flow in ClojureScript
; To run in Ethlance repl
; 1. ./bin/repl
; 2. (shadow/repl :dev-server)
; 3. (in-ns 'ethlance.server.contract.ethlance)
(require '[cljs-web3-next.eth :as web3-eth])
(require '[cljs.core.async :refer [go <!]])
(require '[district.server.web3 :refer [web3]])
(require '[district.shared.async-helpers :refer [<?]])
(require '[ethlance.shared.smart-contracts-dev :as addresses])
@madis
madis / callbacks-to-async-channels.cljs
Created July 3, 2021 04:25
Converting callbacks to async channels
(ns kanalid.core
; (:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [cljs.core.async :refer [go <! put!] :as async]
["events" :as EventEmitter]))
(def global-emitter (new EventEmitter))
(defn emit [event data]
(.emit global-emitter event data))
#!/usr/bin/env bash
function check_arguments() {
if [ -z "$1" ]
then
echo "No argument supplied"
echo " Usage : ./track-study.sh <seconds to study>"
echo " Example: ./track-study.sh 10"
exit
fi
@madis
madis / callback_server.rb
Last active March 14, 2019 12:38
Simple Webrick server for testing callbacks in ruby tests
require 'webrick'
require 'rack'
require 'rack/query_parser'
class CallbackServer
ENDPOINT = '/callbacks'
attr_reader :requests
def initialize
@madis
madis / palindrome.rb
Created December 28, 2018 11:14
Palindrome
#!/usr/bin/env ruby
# You can try the running code at http://tpcg.io/FnffuR
# More explicit implementation. The algorithm you described:
# iterating over characters from both ends of string.
# Returning false as soon as first mismatch is found
def palindrome_by_manual_reversing?(word)
word_string = word.to_s
# Return early because a word is always a palindrome if
@madis
madis / bash_movement.md
Created September 1, 2017 05:47
Bash movement and delete by word