Skip to content

Instantly share code, notes, and snippets.

import dom
type
CanvasRenderingContext* = ref object
font* {.importc.}: cstring
fillStyle* {.importc.}: cstring
ContextAttributes* = ref object
alpha* {.importc.}: bool
import streams, "source/nimpdf"
var fo = newFileStream("book.pdf", fmWrite)
var doc = initPDF()
let pSize = getSizeFromName("A4")
var yPos = 15'f64
doc.addPage(pSize, PGO_PORTRAIT)
doc.setFont("monospace", {FS_REGULAR}, 5'f64, ENC_UTF8)
import streams, "source/nimpdf"
# используется библиотека nimpdf
var iFile = open("oper-instr.txt")
var oFile = newFileStream("book.pdf", fmWrite)
var opts = makeDocOpt()
opts.addFontsPath("/usr/share/fonts/truetype/freefont/")
var doc = initPDF(opts)
import asyncdispatch
import httpclient
proc getres() : Future[string] {.async.} =
var client = newAsyncHttpClient()
result = client.getContent("http://google.com")
echo(waitFor getres())
@x86128
x86128 / anim_manual.nim
Created October 18, 2017 05:40
Async probes
import asyncdispatch
import httpclient
import os
proc task(i: int): Future[void] {.async.} =
echo("Started: " & $i)
await sleepAsync(i*1000+500)
echo("Ended: " & $i)
proc main() {.async.} =
@x86128
x86128 / anim.coffee
Created May 13, 2018 17:31
animation test with coffeescript
canvas = null
ctx = null
old_x = 0
old_y = 0
frame_count = 0
old_frame_num = 0
show_fps = ->
@x86128
x86128 / twi.coffee
Created May 13, 2018 17:36
Twitter list
req = require 'request'
fs = require 'fs'
username = 'x86128'
keys = JSON.parse fs.readFileSync 'keys.json'
auth = Buffer.from("#{keys.key}:#{keys.secret}").toString('base64')
get_auth_token = (keys, cb) ->
opts =
@x86128
x86128 / HEXs.py
Created May 23, 2019 17:18
Python rolling HEXs through MESM-6 UART
#!/usr/bin/python3
from serial import Serial
from time import sleep
ser = Serial('/dev/ttyUSB0')
t0 = -10
hello = '00767938383F'
spin = '240912'
@x86128
x86128 / Dockerfile
Last active June 16, 2021 15:36
Install docker-ce on Ubuntu 20.04 LTS (focal)
FROM python:3.9-alpine
RUN mkdir /app
COPY sputnik.py /app/
WORKDIR /app
CMD python3 sputnik.py
@x86128
x86128 / commands.md
Last active June 16, 2021 07:58
GlusterFS cluster on Ubuntu 20.04 Focal

Assume two disks for gluster bricks is: sdc sdd

add repository

sudo add-apt-repository ppa:gluster/glusterfs-9

if direct internet connection is not available, do:

export http_proxy=http://proxy:port
export https_proxy=http://proxy:port
sudo -E add-apt-repository ppa:gluster/glusterfs-9