Skip to content

Instantly share code, notes, and snippets.

@daniel-j
daniel-j / main.nim
Last active September 15, 2022 11:42
super simple nim video player with libmpv. requires nimterop for now
from mpvclient as mpv import nil
proc mpv_check_error(status: cint) =
if status < 0:
echo "mpv API error: ", mpv.mpv_error_string(status)
quit(1)
proc main: int =
result = 1
@honewatson
honewatson / elm.nim
Created July 4, 2018 13:33
Nim Karax Elm Architecture Example
include karax / prelude
import strutils
type
Model = object
counter*: int
Dispatch = proc(model: Model): void
proc init(): Model =
result = Model(counter: 0)
@tesu
tesu / un360.glsl
Last active December 14, 2023 22:38
mpv opengl shader for viewing 360 video
//!HOOK MAINPRESUB
//!BIND HOOKED
//!DESC un360
#define M_PI 3.1415926535897932384626433832795
const float fov = M_PI/2; // [0 to M_PI] horizontal field of view, range is exclusive
const float yaw = M_PI*1; // [any float] polar angle, one full revolution is 2*M_PI
const float pitch = M_PI*0; // [any float] vertical tilt, positive is up
const float roll = M_PI*0; // [any float] view rotation, positive is clockwise
@zacharycarter
zacharycarter / wclwn.md
Last active March 12, 2024 12:45
Binding to C Libraries with Nim
@okdistribute
okdistribute / index.js
Last active January 28, 2019 08:29
dat with webrtc
var webrtc = require('webrtc-swarm')
var signalhub = require('signalhub')
var hyperdrive = require('hyperdrive')
var memdb = require('memdb')
var pump = require('pump')
var DEFAULT_SIGNALHUBS = 'https://signalhub.mafintosh.com'
var drive = hyperdrive(memdb())
@ytomino
ytomino / dt.nim
Created January 12, 2016 22:16
Trying dependent types in nim
type Cell[T] = ref object
car: T
cdr: Cell[T]
type List[T, N] = distinct Cell[T]
proc makeNil[T]: List[T, range[0..0]] = nil
proc makeCons[T, N](car: T; cdr: List[T, N]): auto =
type N1 = range[0..high(N)+1]
@Answeror
Answeror / gist:3832085
Created October 4, 2012 08:02
Activate virtualenv in blender
def activate_virtualenv(name):
"""Activate given virtualenv.
Virtualenv home folder is given by environment variable ``WORKON_HOME`` or
``~/Envs`.
"""
if 'WORKON_HOME' in os.environ:
home = os.environ['WORKON_HOME']
else:
home = os.path.expanduser(os.path.join('~', 'Envs'))
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 22, 2024 20:20
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@stonegao
stonegao / evolvefn.clj
Created November 3, 2011 03:22 — forked from lspector/evolvefn.clj
Clojure code for a simple genetic programming system, for demonstration purposes.
(ns evolvefn) ;; Lee Spector (lspector@hampshire.edu) 20111018
;; This code defines and runs a genetic programming system on the problem
;; of finding a function that fits a particular set of [x y] pairs.
;; The aim here is mostly to demonstrate how genetic programming can be
;; implemented in Clojure simply and clearly, and several things are
;; done in somewhat inefficient and/or non-standard ways. But this should
;; provide a reasonable starting point for developing more efficient/
;; standard/capable systems.