Skip to content

Instantly share code, notes, and snippets.

View Rulexec's full-sized avatar
💭
It's complicated

Alexander Ruliov Rulexec

💭
It's complicated
View GitHub Profile
@Rulexec
Rulexec / build.rs
Created April 28, 2024 00:27
Watch for crate changes and rebuild
use std::env;
use std::fs::read_dir;
use std::path::PathBuf;
use std::process::Command;
fn diffbelt_example_wasm_build_rs() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("No CARGO_MANIFEST_DIR var");
let mut wasm_crate_path = PathBuf::from(manifest_dir);
#!/usr/bin/env node
const child_process = require('child_process');
const texts = process.argv.slice(2);
(async () => {
const commandsDef = texts.map((text, index) => {
const isFirst = index === 0;
const isLast = index === texts.length - 1;
#!/bin/bash
IMAGE_NAME="ubuntu-with-sshd"
CONTAINER_NAME="ubuntu-with-sshd"
SSH_PORT=9022
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ]]; then
cat > $DIR/Dockerfile <<- EOM
FROM ubuntu:22.04
import reapy
import sys
import serial
# Initialize Reaper API
project = reapy.Project()
mic_track = None
for track in project.tracks:
if track.name == "mic":
#define PIN_PEDAL_ANALOG A0
#define PIN_LED 8
#define MIN_LEVEL 590
#define MAX_LEVEL 620
bool pedalEnabled = false;
void setup() {
pinMode(PIN_LED, OUTPUT);
@Rulexec
Rulexec / punycode.lua
Last active July 14, 2020 07:15
Port of punycode encode function in lua from https://github.com/bestiejs/punycode.js
local bit = require "bit"
local _M = {}
local maxInt = 2147483647
local base = 36
local tMin = 1
local tMax = 26
local skew = 38
local damp = 700
@Rulexec
Rulexec / xoroshiro128plus.js
Created May 1, 2020 08:43
JavaScript xoroshiro128+ implementation, can be optimized
export { Xoroshiro128Plus };
function Xoroshiro128Plus(options) {
let { state } = options || {};
if (!state) {
let time = (Date.now() | 0) >>> 0;
state = [
(time & ((Math.random() * 0xffffffff) | 0)) >>> 0,
(time & ((Math.random() * 0xffffffff) | 0)) >>> 0,
let playButton = document.createElement('button');
playButton.textContent = 'Play';
document.body.appendChild(playButton);
playButton.addEventListener('click', () => {
let audioCtx = new AudioContext();
let sampleRate = audioCtx.sampleRate;
let totalSeconds = 2;
const wialon = require('./wialon.node.js').wialon;
// Print message to log
function msg(text) { console.log(text); }
function init() { // Execute after login succeed
var sess = wialon.core.Session.getInstance(); // get instance of current Session
// flags to specify what kind of data should be returned
var flags = wialon.item.Item.dataFlag.base | wialon.item.Unit.dataFlag.lastMessage;