Skip to content

Instantly share code, notes, and snippets.

import dom
type
CanvasRenderingContext* = ref object
fillStyle* {.importc.}: cstring
strokeStyle* {.importc.}: cstring
width* {.importc.}: int
height* {.importc.}: int
shadowColor* {.importc.}: cstring
typedef struct {
const char *text; // in
image_t *image; // in
int pressed; // out
int released; // out
} button_t;
void do_button(button_t *);
#define button(name, ...) button_t name = {__VA_ARGS__}; do_button(&name)
import React from 'react'
import { api } from 'ducks/user'
const MultiplePatronContext = React.createContext({
isMultiplePatronEnabled: false,
error: '',
})
export class MultiplePatronProvider extends React.Component {
@define-private-public
define-private-public / nim_opengl_shader_example.nim
Last active September 26, 2019 05:59
An example of using OpenGL shaders (and indexed drawing) in Nim
# File: nim_opengl_shader_example.nim
# Author: Benjamin N. Summerton <define-private-public>
# Description: An example of how to use OpenGL shaders in Nim. Draws a simple
# rotating hexagon with 6 colors. Also uses indexed drawing.
#
# Uses this GLFW binding: https://github.com/rafaelvasco/nimrod-glfw, though if
# want to use SDL2, changing out the windowing should be simple.
#
# This was built on Linux using OpenGL ES 3. If you want to use a different
# OpenGL version then you will have to alter the shader source.
@DanielVF
DanielVF / atc.nim
Last active January 28, 2020 01:07
Nim engine, no documentation
import sets
import engine
import strutils
import math
# import log
type
Atc* = ref object of RootObj
available*: HashSet[Ship]
occupied*: seq[bool]
@vurtun
vurtun / api.md
Last active August 6, 2020 06:40
API Design: Modular Data-oriented processes

API Design: Modular Data-oriented processes (June-2017)

This is the second entry in my series about API design. While I wrote about granularity and request based APIs in my last post I want to write about API design and code architecture for modular data-oriented process this time. This is basically the write up of my findings while writing and finishing the core of my current GUI research quarks.

Actually sparking my interest for writing up my findings however was rasmusbarr@github (rasmusbarr@twitter) releasing his small data-oriented and SIMD-optimized 3D rigid body physics library. I noticed a lot of overlap in design between his physics and my GUI library and wanted to write up some general thoughts about what seems

@kbussell
kbussell / ctrlTap.lua
Last active February 13, 2021 17:46
Send escape key if the ctrl key is tapped. (Used along side remapping my Caps Lock key to ctrl) Thanks to @asmagill 's examples for a starting point.
local alert = require("hs.alert")
local timer = require("hs.timer")
local eventtap = require("hs.eventtap")
local events = eventtap.event.types
local module = {}
-- timeout for ctrol key
module.timeFrame = .25
@chrisnordqvist
chrisnordqvist / init.lua
Created February 14, 2018 10:03
My hammerspoon config
logger = hs.logger.new('main')
--- functions
function open(name)
return function()
hs.application.launchOrFocus(name)
if name == 'Finder' then
hs.appfinder.appFromName(name):activate()
end
end
@oleganza
oleganza / gist:8cc921e48f396515c6d6
Last active January 30, 2022 00:06
Proof that Proof-of-Work is the only solution to Byzantine Generals' problem

In reply to "@Vlad_Roberto: No, not a programmer. I just know there's better ways to doing anything without massive energy consumption & Banks."

The problem of blockchain synchronization is the following:

Imagine you are sitting in a bunker. You have no idea what people are out there and what are their intentions. You only receive some incoming messages from strangers that may contain anything. They can be just random garbage or deliberately crafted messages to confuse you or lie to you. You never know. You cannot trust anyone.e

The problem of "money" or any other "social contract" is that everyone should be able to know what the majority agrees to without trusting some intermediaries (otherwise they can easily obuse their special position). If everyone votes for "X", then you sitting in a bunker must somehow independently figure out that all those other people indeed voted for "X" and not for "Y" or "Z". But remember: you cannot trust anyone's message and messages are the only thing you get from the outsi

@meiamsome
meiamsome / hn_search.js
Last active May 4, 2022 13:23 — forked from kristopolous/hn_seach.js
hn job query search
/* Hacker News Search Script
*
* Original Script by Kristopolous:
* https://gist.github.com/kristopolous/19260ae54967c2219da8
*
* Usage:
* First, copy the script into your browser's console whilst on the Hacker News
* jobs page. Then, you can use the query function to filter the results.
*
* For example,