Skip to content

Instantly share code, notes, and snippets.

@wactbprot
wactbprot / sway.config
Last active May 26, 2021 05:31
sway config
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
@wactbprot
wactbprot / index.html
Last active February 14, 2021 13:22
basic html page
<!doctype html>
<html lang="en">
<head>
<title>Wact B. Prot</title>
<meta name="description" content="Wact B. Prot">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family:verdana;
@wactbprot
wactbprot / p.clj
Created January 5, 2021 12:26
p-Registers a listener prints a event table
;;------------------------------
;; p-ubsub events
;;------------------------------
(def p-table (atom []) )
(defn p-start-table
"Registers a listener. Pretty prints a p-table on events.
Example:
```clojure
@wactbprot
wactbprot / make_db_usr.py
Last active August 12, 2021 13:01
Generates a db user and adds it to `--db` as member. (CouchDB, Python3, `os.environ.get()`)
#! /usr/bin/python3
import os
import json
import requests
import argparse
from requests.auth import HTTPBasicAuth
parser = argparse.ArgumentParser()
parser.add_argument("--srv", type=str, nargs=1,
@wactbprot
wactbprot / start-kill-error.clj
Created May 30, 2020 15:15
start, stop, error, clojure, core.async
(ns cmp.system
^{:author "wactbprot"
:doc "study."}
(:require [taoensso.timbre :as timbre]
[clojure.core.async :as a]))
;;------------------------------
;; kill channel
;;------------------------------
(def kill> (a/chan))
@wactbprot
wactbprot / .emacs
Last active December 22, 2021 14:48
.emacs
(setq make-backup-files nil)
(global-set-key [S-dead-grave] "`")
(setq ring-bell-function 'ignore)
(setq visible-bell nil)
(setq ispell-dictionary "british")
(set-language-environment "UTF-8")
(require 'package)
(add-to-list 'package-archives
;'("melpa-stable" . "http://stable.melpa.org/packages/")
@wactbprot
wactbprot / plant.ino
Last active January 17, 2020 15:06
Check plant soil humidity via TCP
#include <Ethernet.h>
#define PORT 9009
#define MAXTCPLENGTH 30
#define MAXDRY 850
#define MINDRY 450
byte mac[] = {0x00, 0x50, 0x56, 0x1E, 0x38, 0x36};
IPAddress ip(192, 168, 98, 135);
EthernetServer server(PORT);
String cmd, param;
@wactbprot
wactbprot / reflect_struct.go
Created December 30, 2016 12:24
not very nice way to iterate over a struct using reflect in golang
// ...
type Config struct {
Db Conf `json:"db"`
Relay Conf `json:"relay"`
Redis Conf `json:"redis"`
}
type Conf struct {
Path string `json:"path"`
Port string `json:"port"`
Server string `json:"server"`
@wactbprot
wactbprot / svg.r
Created June 2, 2016 10:04
extract positions
l <- readLines("svg.html")
l <- unlist( regmatches(l, gregexpr("d=\"M([0-9,]*)A", l)))
l <- gsub("[d=\\\"AM]", "", l)
l <- strsplit(l,",")
m <- lapply(l, function(e){
c(as.numeric(e[1]), as.numeric(e[2]))
})
M <- t(matrix(unlist(m), nrow = 2, ncol=length(l)))
@wactbprot
wactbprot / test.fail.js
Created December 14, 2014 10:29
failing testes crash nodejs if executed inside a ndata callback
var _ = require("underscore")
, ndata = require('../index')
, assert = require('assert')
, conf = {port: 9003}
, server
, client;
describe('ndata#known to fail', function () {