Skip to content

Instantly share code, notes, and snippets.

vorce / absinthe_helper.ex
Created Jun 24, 2020
Absinthe import_fields from module
View absinthe_helper.ex
defmodule AbsintheHelper do
@moduledoc """
A way to `import_fields` from a specific module.
The idea is to make it more explicit in your schema where
object fields are coming from at a glance.
Usage in your schema:
require EvaticContractsApi.AbsintheHelper
vorce / jerry.swift
Last active May 17, 2021
Mouse move and click test thing for macos in swift
View jerry.swift
import Cocoa
import Foundation
// Move around and click automatically at random places in macos, kinda human like in a cheap way.
// Moves the mouse pointer to `moves` random locations on the screen and runs the `action` function at
// each point with the point as argument.
func mouseMoveWithAction(moves: Int, action: (CGPoint) -> Void = defaultAction) {
let screenSize = NSScreen.main?.visibleFrame.size
vorce / fn.lua
Created Aug 18, 2019
Some functional utilities
View fn.lua
-- functional programming utilities
-- usage: local fn = require "fn"
NAME = "fn"
local M = { }
-- Invokes the reducer function for each element in the collection with the accumulator.
-- The initial value of the accumulator is initial. The function is invoked for each
-- element in the enumerable with the accumulator. The result returned by the
vorce / memory.ex
Last active Jun 15, 2019
Show what's using memory
View memory.ex
# show top memory using processes
|> pid ->
[:erlang.process_info(pid, :memory), :erlang.process_info(pid, :current_function)]
|> Enum.sort()
|> Enum.reverse()
|> Enum.take(25)
# show top memory using ETS tables

Keybase proof

I hereby claim:

  • I am vorce on github.
  • I am vorce ( on keybase.
  • I have a public key ASB3SC08McO8-tJmvv3Mg3UbfhXyQKHZi_xXORoKAxVukwo

To claim this, I am signing this object:

View henon.clj
(defn _henon [x y]
(let [x1 (* 1.4 (Math/pow x 2))]
[(+ y (- 1 x1)), (* x 0.3)]))
(defn henon [x y]
(let [[hx hy] (_henon x y)]
(lazy-seq (cons [hx hy] (henon hx hy)))))
; Example usage: (take 100 (henon 1 1))
vorce / simplex.clj
Created Nov 28, 2014
Clojure simplex 2d noise (translated from java)
View simplex.clj
(ns vorce.procedural.simplex)
; Direct translation of
; to clojure.
; ...... friday night fun.
; Only supports 2d right now.
(defstruct grad :x :y :z :w)
vorce / gist:10004442
Created Apr 6, 2014
Example usage of raev
View gist:10004442
(ns symmetri.core
(:use quil.core
(def mid-x 400)
(def mid-y 300)
(defrecord Point [x y z])
(defrecord Sym [s1 s2 col])
(defrecord Colors [r g b a])
vorce / gist:9791756
Created Mar 26, 2014
View gist:9791756
* Observes an {@link Observable<T>} and returns a new Observable<R> that emits
* items based on the predicate<T> and the <R> onTrue and <R> onFalse functions.
public class ObservableCondition<R, T> {
private final rx.Observable<T> condition;
private Func0<? extends R> onTrue = {}
private Func0<? extends R> onFalse = {}
private Predicate<T> predicate;
vorce / gist:9709863
Last active Aug 29, 2015
Conditional Observable stuff
View gist:9709863
// First sketch, with just functions.
// Usage:
// Observable<Boolean> myCondition = ...
// Observable<List<Foo>> foos = onCondition(myCondition,
// fetchFoos(a1, a2, a3), // returns a Func0<Observable<List<Foo>>>
// { empty() })
// .flatMap({it})
public final static <R> Observable<R> onCondition(Observable<Boolean> observable,
final Func0<? extends R> onTrue,
final Func0<? extends R> onFalse) {