Skip to content

Instantly share code, notes, and snippets.

View rla's full-sized avatar

Raivo Laanemets rla

View GitHub Profile
@rla
rla / readme.md
Last active May 26, 2023 12:24
BeagleBone Black Industrial disk benchmark
:- use_module(library(gensym)).
:- dynamic student/3.
do_stuff:-
gensym(student, S1),
gensym(student, S2),
assertz(student(S1, john, doe)),
assertz(student(S2, jane, doe)).
show_id_of_john :-
@rla
rla / order.jsx
Created November 26, 2018 10:43
React-Flatpickr integration
const pickr = require('../common/pickr');
// ...
const OrderForm = FormHoc(class extends React.Component {
constructor(props) {
super(props);
this.state = { };
this.setLoadingDateInput = this.setLoadingDateInput.bind(this);
@rla
rla / code.pl
Last active May 31, 2018 11:35
Arouter http_daemon
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_unix_daemon)).
:- use_module(prolog/arouter).
:- route_get(hello/Name, handle_hello(Name)).
handle_hello(Name):-
format('Content-Type: text/plain; charset=UTF-8~n~n'),
format('Hello ~w', [Name]).
@rla
rla / config.js
Created February 19, 2018 11:54
Node.js Express config file pattern
const config = require('../config.json');
module.exports = config;
@rla
rla / code.sql
Created November 24, 2017 06:53
A typical query in this app
SELECT
`orders`.`id` AS `id`,
`orders`.`name` AS `order_name`,
`orders`.`loading_date` AS `loading_date`,
`orders`.`info` AS `info`,
`orders`.`notes` AS `notes`,
`orders`.`vehicle` AS `vehicle`,
`orders`.`price` AS `price`,
`orders`.`country` AS `country`,
`orders`.`invoice` AS `invoice`,
@rla
rla / file.nsi
Created October 30, 2017 11:16
Electron NSIS example (dist folder created with electron-packager)
!define setup "LCB-installer.exe"
!define company "Infdot"
!define prodname "LCB"
!define exec "LCB.exe"
!define srcdir "dist\LCB-win32-ia32"
!define regkey "Software\${company}\${prodname}"
!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${prodname}"
!define startmenu "$SMPROGRAMS"
@rla
rla / data.json
Created October 29, 2017 13:28
Visual package editor data format
{
"version":4,
"id":254,
"name":"Osto 6",
"length":"13.5",
"height":"2.64",
"sideWidth":800,
"sideHeight":340,
"clients":[
{
@rla
rla / code.js
Created September 30, 2017 13:30
React form submit
class SomeForm extends React.Component {
// constructor, render() etc are form-specific
async submit(e) {
e.preventDefault();
const errors = validate(this.state);
if (errors.hasError()) {
this.setState({ errors: errors.extract() });
return;
@rla
rla / code.js
Created August 9, 2017 18:35
Node.js MySQL transaction with async/await
// Executes the given function inside
// a transaction.
exports.transaction = async (fn) => {
assert.equal(typeof fn, 'function');
// Aquire a connection.
const connection = await aquire(pool);
debug('Aquired a connection.');
try {
// Begin the transaction.