Skip to content

Instantly share code, notes, and snippets.

<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@stisa
stisa / Unproject.md
Last active August 29, 2015 14:15
Libgdx unproject

Use camera.unproject(vector3)

vector3 is:

x = Gdx.input.getX();
y = Gdx.input.getY();
z=0;
Vector3 vector3 = new Vector3 (x,y,z);

To use this hook, add the following to project.flow:

build : {
  dependencies : {
    luxe : '*',
  },
  post : {    
    priority : 1,
    name : 'move-to-gh-pages',
import zmq
# Example in cpp:
# http://zguide.zeromq.org/cpp:mspoller
var spm2 = zmq.connect("tcp://localhost:5556", zmq.Dealer)
var conn2 = zmq.listen("tcp://*:5556", zmq.ROUTER)
var spm = zmq.connect("tcp://localhost:5555",zmq.Dealer)
var conn = zmq.listen("tcp://*:5555", zmq.ROUTER)
@stisa
stisa / ipynb2nim.nim
Last active September 11, 2016 11:24
Parse nim based jupyter notebook into a sort of literate nim, markdown goes into documentation blocks and code is kept
import os,json,strutils
## TODO:
# - check input file type
# - a parser for markdown->html
let arguments = commandLineParams() # [0] should always be the input file
var nbf = arguments[0].readFile
var outfile :string
@stisa
stisa / dynprocptr.nim
Last active September 22, 2016 19:26
## lib.nim #########
proc test1(): string {.exportc, dynlib .}=
result = "test"
## user.nim ########
import dynlib, osproc
# compile libs so I don't have to do it by hand
let l1 = execCmd("nim c --app:lib lib.nim")
@stisa
stisa / fromimport.nim
Last active September 23, 2016 08:56
## first.nim ###
proc test*(): string = "test1"
echo test()
## second.nim ###
from first import test
proc test2*(): string = "test2"
echo test2()
@stisa
stisa / benchshift.nim
Last active September 25, 2016 08:04
import times
proc possiblyleakingshift[T](a: var openarray[T]; d: int) =
if d == 0: discard # do nothing
elif abs(d) >= a.len: # reset all
zeroMem(addr a[0], a.len*sizeof(T))
elif d > 0: # right shift
moveMem(addr a[d], addr a[0], (a.len - d)*sizeof(T))
zeroMem(addr a[0], d*sizeof(T))
elif d < 0: # left shift
## Original: https://nim-by-example.github.io/oop/
## Running the above with non ref objects errors ##
type Animal = object of RootObj
name: string
age: int
method vocalize(this: Animal): string = "..."
method ageHumanYrs(this: Animal): int = this.age
type A = object
data: ref seq[float]
proc `$`[T](a:ref seq[T]):string = $(a[])
var ar : A
new ar.data
ar.data[] = @[0.0,1.0,2.0]
echo ar