Skip to content

Instantly share code, notes, and snippets.

@vorce
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
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
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
vorce / memory.ex
Last active Jun 15, 2019
Show what's using memory
View memory.ex
# show top memory using processes
:erlang.processes()
|> Enum.map(fn pid ->
[:erlang.process_info(pid, :memory), :erlang.process_info(pid, :current_function)]
end)
|> Enum.sort()
|> Enum.reverse()
|> Enum.take(25)
# show top memory using ETS tables
View keybase.md

Keybase proof

I hereby claim:

  • I am vorce on github.
  • I am vorce (https://keybase.io/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
vorce / gist:5817721
Created Jun 19, 2013
Spazmo-qore, contribution to the 4k source compo 2004
View gist:5817721
#include "g.h"
#define f float
f P=3.1415,X= 500,Y=400, o;
#define e glEnd
#define g glVertex3d
#define n glEnable
#define N glNormal3d
#define fl for(
#define i int
c(f h) { f j; glBegin(6); N(0,0,-1);g(0,0,0);
View gist:5748534
(defn hex-to-rgb
"Convert hex strings to rgb list. Ex: 'FF0000' -> (255 0 0)"
[hex]
(let [ hex-pairs (partition 2 hex) ]
(for [p hex-pairs]
(java.lang.Integer/parseInt (apply str p) 16))))
@vorce
vorce / gist:5373385
Created Apr 12, 2013
SHahara. Shell script sandbox for VirtualBox. Basically just a wrapper for VBoxManage snapshot.
View gist:5373385
#!/bin/sh
# SHahara
# Inspired by: https://github.com/jedi4ever/sahara
#
# Sandbox for virtualbox for shell scripts
# Wrapper for VBoxManage and snapshots
SH_TEST_SNAPSHOT=sh_test_snapshot
VBOX=VBoxManage
@vorce
vorce / gist:5227527
Last active Dec 15, 2015
Roman numerals kata in Elixir lang. My very first use of the language >_<
View gist:5227527
Code.require_file "../test_helper.exs", __FILE__
defmodule ElixirRoman1Test do
@moduledoc "Tests number to roman numerals"
use ExUnit.Case
defp romans_list do
HashDict.new [ {10, "X"}, {9, "IX"}, {5, "V"},
{4, "IV"}, {1, "I"}]