Skip to content

Instantly share code, notes, and snippets.

View jubnzv's full-sized avatar

Georgiy Komarov jubnzv

View GitHub Profile
@jubnzv
jubnzv / aam.ml
Created August 5, 2022 12:10
Abstracting Abstract Machine in OCaml
open Core_kernel
open Printf
type var = string [@@deriving eq, ord, sexp]
type term = Ref of var
| Lam of var * term
| App of term * term [@@deriving eq, ord, sexp]
let rec pp_term = function
| Ref v -> v
@jubnzv
jubnzv / dir.ml
Created August 5, 2021 10:43 — forked from lindig/dir.ml
OCaml - list recursively regular files in a directory
(** [dir_is_empty dir] is true, if [dir] contains no files except
* "." and ".."
*)
let dir_is_empty dir =
Array.length (Sys.readdir dir) = 0
(** [dir_contents] returns the paths of all regular files that are
* contained in [dir]. Each file is a path starting with [dir].
@jubnzv
jubnzv / 1.Instructions.md
Created April 25, 2021 16:43 — forked from WesThorburn/1.Instructions.md
Linux: Compile C++ to WebAssembly and JavaScript using Emscripten and CMake

Linux: Compile C++ to WebAssembly and JavaScript using Emscripten and CMake

Download and Install Emscripten

  • My preferred installation location is /home/user
  • Get the latest sdk: git clone https://github.com/emscripten-core/emsdk.git
  • Enter the cloned directory: cd emsdk
  • Install the lastest sdk tools: ./emsdk install latest
  • Activate the latest sdk tools: ./emsdk activate latest
  • Activate path variables: source ./emsdk_env.sh
  • Configure emsdk in your bash profile by running: echo 'source "/home/user/emsdk/emsdk_env.sh"' >> $HOME/.bash_profile
@jubnzv
jubnzv / table_to_string.lua
Created August 11, 2020 13:46 — forked from justnom/table_to_string.lua
Lua table to string
-- Convert a lua table into a lua syntactically correct string
function table_to_string(tbl)
local result = "{"
for k, v in pairs(tbl) do
-- Check the key type (ignore any numerical keys - assume its an array)
if type(k) == "string" then
result = result.."[\""..k.."\"]".."="
end
-- Check the value type
#define __define_initcall(level,fn,id) \
static initcall_t __initcall_##fn##id __used \
__attribute__((__section__(".initcall" level ".init"))) = fn
#define core_initcall(fn) __define_initcall("1",fn,1)
#define subsys_initcall(fn) __define_initcall("4",fn,4)
#define late_initcall(fn) __define_initcall("7",fn,7)
/* trimmed, obviously... */
1. connect to host localhost port 22: Connection refused
Stopping namenodes on [localhost]
localhost: ssh: connect to host localhost port 22: Connection refused
localhost: ssh: connect to host localhost port 22: Connection refused
Stopping secondary namenodes [0.0.0.0]
0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
Fix:
thanooj@ubuntu:/$ sudo apt-get install openssh-server
Reading package lists... Done
@jubnzv
jubnzv / Build Emacs for Windows 64bit.md
Created February 16, 2019 14:14 — forked from nauhygon/Build Emacs for Windows 64bit with Native Compilation.md
Step-by-step instructions to build Emacs for Windows 64 bit with MSYS2 and MinGW-w64.

Build Emacs-w64 with MSYS2/MinGW-w64

Instructions are modified from emacs-w64 Wiki page by zklhp. Many thanks for sharing!

  1. Download MSYS2 (msys2-x86_64-20161025.exe) from this download page.

  2. Install MSYS2 to, for example, C:\msys2 (make sure no space in path).

  3. Optionally prettify the MSYS2 console mintty with ~/.minttyrc to make it more pleasing to eyes. Thanks to this awesome theme!

@jubnzv
jubnzv / drestivo-org-download-method.el
Created January 20, 2019 10:10 — forked from daviderestivo/drestivo-org-download-method.el
This is an helper function for org-download. It creates an \"./image\" folder within the same directory of the org file. Images are separated inside that image folder by additional folders one per org file.
(defun drestivo/org-download-method (link)
"This is an helper function for org-download.
It creates an \"./image\" folder within the same directory of the org file.
Images are separated inside that image folder by additional folders one per
org file.
More info can be found here: https://github.com/abo-abo/org-download/issues/40.
See the commit message for an example:
https://github.com/abo-abo/org-download/commit/137c3d2aa083283a3fc853f9ecbbc03039bf397b"
(let ((filename
(file-name-nondirectory