Skip to content

Instantly share code, notes, and snippets.

@bzar
bzar / gist:b0fb12d97801ddf76c84
Last active August 29, 2015 14:16
N-dimensional hypercube single-solution maze generation algorithm with waypoints

Inputs

  • Maze dimensions as an N-vector containing size in each dimension
  • List of waypoints as N-vectors

Algorithm

  1. Define N-dimensional hypercube with given dimensions and intercell wall state
  2. Generate main path
@bzar
bzar / better.cc
Last active August 29, 2015 14:22
Muhkeimmat sanat
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <locale>
#include <codecvt>
#include <bitset>
{reverse, sum, empty, all, fold, concat-map, flatten, span, Obj, sort-by, head} = require 'prelude-ls'
# [[String]] -> Bool
in-order = (xss) -> all (-> it.length == 1), xss
# [[String] -> Data -> [[String]]] -> Data -> [String] -> [[String]]
order-by-one = (fs, d, xs) -->
| xs.length < 2 => [xs]
| otherwise =>
fold ((ys, f) -> if ys.length == 1 then f(ys[0], d) else ys), [xs], fs
@bzar
bzar / plugin.py
Last active January 14, 2016 09:32
import ckan.plugins as plugins
import logging
log = logging.getLogger(__name__)
def admin_only(context, data_dict=None):
return {'success': False, 'msg': 'Access restricted to system administrators'}
@bzar
bzar / deaddrop.md
Last active April 14, 2016 11:49
Dead drop imaginary messaging server spec

Rationale

A centralized messaging system that should impart as little information as possible to any third parties, including the server administrator. Any information accessible by the server administrator is considered public as far as user security is concerned.

The server should be practical and attempt to disencourage unwanted behaviour like spamming. It should also have access control to allow private servers, but not at the cost of revealing message senders.

{reverse, sum, empty, all, fold, concat-map, flatten, span, Obj, sort-by, head} = require 'prelude-ls'
# [[String]] -> Bool
in-order = (xss) -> all (-> it.length == 1), xss
# [[String] -> Data -> [[String]]] -> Data -> [String] -> [[String]]
order-by-one = (fs, d, xs) -->
| xs.length < 2 => [xs]
| otherwise =>
fold ((ys, f) -> if ys.length == 1 then f(ys[0], d) else ys), [xs], fs
import QtQuick 2.0
Rectangle {
property color unpressedColor: "gray"
property color pressedColor: "lightgray"
property alias pressed: ma.pressed
property alias text: label.text
property real size: 1
signal clicked()
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QCursor>
#include "key_emitter.h"
#include "raspberrybacklight.h"
int main(int argc, char *argv[])
Timer {
id: backlightTimer
interval: 1000*60*5
onTriggered: backlight.state = false
running: backlight.state
repeat: false
}
gpu_mem=256
dtoverlay=vc4-kms-v3d
lcd_rotate=2