Skip to content

Instantly share code, notes, and snippets.

View rla's full-sized avatar

Raivo Laanemets rla

View GitHub Profile
@rla
rla / code.cpp
Created July 23, 2012 13:12
Sending JSON POST request with Qt
void SyncService::sync()
{
QUrl url(SYNC_URL);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
@rla
rla / readme.md
Last active May 26, 2023 12:24
BeagleBone Black Industrial disk benchmark
@rla
rla / code.pro
Created January 25, 2013 13:00
Boolean SAT solver in Prolog
solution(V):-
formula(F),
sat(F, V).
formula([[-3, 14, -2], [9, 8, -5], [-7, 15, -1], [5, -6, -7], [4, -10, -11],
[-2, 13, 5], [-1, 4, 14], [9, -2, 5], [-6, 11, -2], [-12, 10, 9], [-15, 9, -6],
[9, 15, 4], [1, 2, -9], [-5, -2, 14], [-8, 15, 10], [13, -9, -4], [11, -10, -3],
[-6, 4, -13], [9, -7, -11], [4, 5, -13], [-10, -1, -9], [-8, -2, 13], [-10, -3, -7],
[-1, 7, 2], [-9, -7, 14], [-11, 2, -5], [13, -8, 9], [13, -2, 12], [-3, -9, -15],
[9, 2, 15], [14, -13, 12], [15, -10, 6], [8, 9, 4], [-3, -10, 9], [-13, -1, 2],
@rla
rla / code.js
Created October 10, 2012 23:17
Prolog runtime in JS
var util = require('util');
// Constructor for variables.
function Var() {
this.ref = this;
}
// Constructor for compound terms.
:- 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 / app.js
Created May 13, 2012 17:41
Node.JS cluster startup
var cluster = require('cluster');
var fs = require('fs');
var config = require('./config.json');
var assets = require('./lib/assets');
// Fork child processes.
if (cluster.isMaster) {
// Run asset cleanup.
@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`,