Skip to content

Instantly share code, notes, and snippets.

import os
import asynchttpserver
import asyncdispatch
import strutils
import fsnotify
proc main {.async.} =
var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
@mrotaru
mrotaru / ob-nim.el
Created October 27, 2020 07:19
Attempt at a simple elisp snippet that would enable executing nim code blocks
(defun org-babel-execute:nim (body params)
"Execute a block of Nim code with org-babel."
(message "executing Nim source code block")
(let* (in-file (org-babel-temp-file "nim-")))
(with-temp-file in-file
(insert body))
(org-babel-eval (format "nim r %s" (org-babel-process-file-name in-file))))
{
"CallerReference": "glorious.website-cli",
"Aliases": {
"Quantity": 2,
"Items": [
"glorious.website",
"www.glorious.website"
]
},
"DefaultRootObject": "index.html",
@mrotaru
mrotaru / create-simple-website.bash
Created February 7, 2020 22:19
Creates a simple website in the current directory
tee ./index.html <<EOF
<html>
<head>
<link rel="stylesheet" type="text/css" href="/style.css"/>
<title>Glorious Website</title>
</head>
<body>
<h1>Version 1</h1>
<p>Go to <a href="/blog/first-post">blog/first-post</a></p>
</body>
use std::collections::HashMap;
struct Cacher<T>
where
T: Fn(&u32) -> u32,
{
calculation: T,
values: HashMap<u32, u32>,
}
@mrotaru
mrotaru / 0_reuse_code.js
Created March 16, 2016 09:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mrotaru
mrotaru / foo.test.js
Created May 7, 2015 07:43
foo.test.js
var assert = require("assert")
describe("should break", function(){
it("it doesn't", function(){
console.log("foo");
assert.equal(1,1);
});
});
var Sequelize = require('sequelize');
var sequelize = new Sequelize('db','db_user','db_password');
var chainer = new Sequelize.Utils.QueryChainer
var User = sequelize.define('User', {name: Sequelize.STRING}, {timestamps: false})
var City = sequelize.define('City', {name: Sequelize.STRING}, {timestamps: false})
var joe = User.build({name: 'Joe'});
var london = City.build({name: 'London'});
var Sequelize = require('sequelize');
var sequelize = new Sequelize('db','db_user','password');
var chainer = new Sequelize.Utils.QueryChainer
// define models
var User = sequelize.define('User', {name: Sequelize.STRING})
// build instances
var joe = User.build({name: 'Joe'});
var jane = User.build({name: 'Jane'});
@mrotaru
mrotaru / sequelize-self-referencing.js
Created October 30, 2013 14:19
cannot create a self-referencing has-many association with constrained foreign keys
var Sequelize = require('sequelize');
var sequelize = new Sequelize('db', 'user', 'password');
var Person = sequelize.define('Person', {
name: Sequelize.STRING,
});
var ChildrenPerson = sequelize.define('ChildrenPerson', {
PersonId: {