Skip to content

Instantly share code, notes, and snippets.

View beetleman's full-sized avatar
🐐
💕

Mateusz Probachta-Jeżowski beetleman

🐐
💕
  • Cracow
  • 17:35 (UTC -12:00)
View GitHub Profile
@beetleman
beetleman / clojure-deftype-scaffolding.clj
Created September 16, 2020 15:14 — forked from semperos/clojure-deftype-scaffolding.clj
Clojure Scaffolding for deftype (Christophe Grand) - Show which methods a class implements and for which interfaces
;; Big thanks to Christophe Grand - https://groups.google.com/d/msg/clojure/L1GiqSyQVVg/m-WJogaqU8sJ
(defn scaffold [iface]
(doseq [[iface methods] (->> iface .getMethods
(map #(vector (.getName (.getDeclaringClass %))
(symbol (.getName %))
(count (.getParameterTypes %))))
(group-by first))]
(println (str " " iface))
(doseq [[_ name argcount] methods]
(println
@beetleman
beetleman / byte_range.file.clj
Created March 25, 2020 21:23 — forked from tawus/byte_range.file.clj
byte range aware file-response for ring
(ns byte-range.file
(:require [ring.util.response :as ring-resp :refer
[header status get-header content-type]]
[ring.util.time :refer [parse-date format-date]]
[ring.util.request :as request]
[ring.util.codec :as codec]
[pantomime.mime :refer [mime-type-of]]
[clojure.string :as str]
[clojure.java.io :as io])
(:import [java.io RandomAccessFile]
@beetleman
beetleman / proc.clj
Created March 17, 2020 19:34 — forked from codification/proc.clj
Clojure asynchronous process
(ns proc
(:import [java.lang ProcessBuilder])
(:use [clojure.java.io :only [reader writer]]))
(defn spawn [& args]
(let [process (-> (ProcessBuilder. args)
(.start))]
{:out (-> process
(.getInputStream)
(reader))
diff --git a/.gitignore b/.gitignore
index 00f42c8..e61feea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,4 @@ profiles.clj
/.env
.nrepl-port
/log
+/.m2
diff --git a/docker-compose-base.yml b/docker-compose-base.yml
@beetleman
beetleman / repl.sh
Created July 29, 2018 20:09
start lein with cider-nrepl injected
lein update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] \
-- update-in :plugins conj \[refactor-nrepl\ \"2.4.0-SNAPSHOT\"\] \
-- update-in :plugins conj \[cider/cider-nrepl\ \"0.18.0-SNAPSHOT\"\] \
-- repl :headless :host 0.0.0.0 :port 7000
@beetleman
beetleman / ex-tutorial.clj
Created April 28, 2018 11:47
how to use clojure `ex-info`
(ns erc20-mapper.ex-tutorial)
(defn fail [& args]
(throw (ex-info "OMG!" {:type ::fail :args args})))
(defn funky-fail [& args]
(throw (ex-info "jayyyyy!" {:type ::funky-fail :args args})))
(defn mby [fn]
(try
@beetleman
beetleman / remove-all-from-docker.sh
Created February 27, 2018 09:16 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
Solidity lets you program on Ethereum, a blockchain-based virtual machine that allows the creation and execution of smart contracts, without needing centralized or trusted parties.
Solidity is a statically typed, contract programming language that has similarities to Javascript and C. Like objects in OOP, each contract contains state variables, functions, and common data types. Contract-specific features include modifier (guard) clauses, event notifiers for listeners, and custom global variables.
Some Ethereum contract examples include crowdfunding, voting, and blind auctions.
As Solidity and Ethereum are under active development, experimental or beta features are explicitly marked, and subject to change. Pull requests welcome.
// First, a simple Bank contract
// Allows deposits, withdrawals, and balance checks
// simple_bank.sol (note .sol extension)
/* **** START EXAMPLE **** */
@beetleman
beetleman / install_sassc.sh
Last active November 6, 2016 13:21
instaling sassc in ~/bin/
DIR=/tmp/build_scss
mkdir $DIR -p
cd $DIR
git clone https://github.com/sass/libsass.git
export SASS_LIBSASS_PATH=$DIR/libsass
git clone https://github.com/sass/sassc.git
cd $DIR/sassc
make -j4
@beetleman
beetleman / debouncedEvent.js
Created August 18, 2016 08:25
Handling events in requestAnimationFrame (es2016)
export const debouncedEvent = ({element, event, handler, useCapture=false}) => {
let eventObject = null;
let ticking = false;
const update = _ => {
ticking = false;
handler(eventObject);
};