Skip to content

Instantly share code, notes, and snippets.

polypus74 polypus74

Block or report user

Report or block polypus74

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
polypus74 /
Created Jul 3, 2018
atomic enum in rust
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
pub enum RunFlagState {
Running = 0,
Paused = 1,
Cancelled = 2,
// TODO: is there some mechanism to automate this (nightly)?
polypus74 / newsbt
Last active Mar 20, 2018
Create new sbt project with git & ensime setup
View newsbt
function err {
echo "error: $1, exiting."
exit 1
if [[ -z "$1" ]]
polypus74 / dptc.nim
Last active Mar 7, 2018
default params with type classes
View dptc.nim
let i: int64 = 0
let j: float64 = 1.1
proc g(x: distinct SomeNumber = 1, y: distinct SomeNumber = 1.1) = discard
g(i,j) # OK
g(j,i) # Error
# I have tried other combinations without use of distinct. Not sure
# why the compiler complains about this, seems it should be ok?
View hlist_question.hs
module A where
import Data.HList.CommonMain
data A = A deriving (Show)
ls = hCons "hi" $ hCons A $ hNil
upls = hUpdateAtType "bye" ls
View hooks-problems.clj
;; the project file
(defproject lein-javafx "0.1.0"
:dependencies [[javafxc "1.3.1"]]
:hooks [leiningen.hooks.lein-javafx-hooks])
;; the javafxc task file
(ns leiningen.javafxc
View XBindTrial.fx
import org.jfxtras.lang.XBind;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.HBox;
import javafx.scene.control.*;
function run():Void {
try {
View wrap_fxfn.clj
(ns fxtrial.core
(:import javax.script.ScriptEngineManager
(def engine (.getEngineByName (ScriptEngineManager.) "javafx"))
(defn wrap-fxfn [fxfn]
(let [invoke
(first (filter #(= (.getName %) "invoke")
View dynamic-record.clj
(defn dynamic-record [base-name field-names & init-values]
(let [klass (eval `(defrecord ~(gensym base-name) ~(vec field-names)))
ctor (first (.getConstructors klass))
vals (take (count field-names)
(concat init-values (repeat nil)))]
(.newInstance ctor (into-array Object vals))))
(dynamic-record "MyRecord" '(foo bar) :foo)
;; -> #:user.MyRecord14544{:foo :foo, :bar nil}
View letp.clj
(defmacro letp [expr bindings & body]
(let [parted
(partition 3 bindings)
(vec (apply concat
(map #(take 2 %) parted)))
(vec (apply concat
(map #(list (first %) (last %)) parted)))]
You can’t perform that action at this time.