Skip to content

Instantly share code, notes, and snippets.

View kshaa's full-sized avatar

Krišjānis Veinbahs kshaa

View GitHub Profile
@kshaa
kshaa / browser-scalajs-inject.js
Last active July 26, 2022 08:18
An example of a bootstrap JS script to inject Scala.js on any page load using browser extensions
// You can inject any Scala.js component into any page using Chrome as follows:
// - This example references an arbitrary Scala.js package called bo-search
// - bo-search contains a top level definition BoSearch.initCit
// - Install CORS Unblock extension
// - Install Custom Style Script or Scripty extension
// - Disable CORS for the page
// - Setup a local web server to host this injection script
// - Use this script to inject the component into the page
var baseURL = "http://127.0.0.1:8080"
var injectUrl = baseURL + "/inject.js" // You can even just inject this URL

Digilent Adept utils on RPI 4 B w/ Ubuntu

  1. To get the djtgcfg tool, use official sources Note: I understand nothing about RPI and the CPU architectures involved, but the "ARM Raspberry Pi" does not work, the ARMHF architecture is expected which is not what RPI4B is. Just use the regular Linux ARM 64 bit .deb for RPI4B w/ Ubuntu
  2. For some reason the /dev/ttyUSB* and /dev/serial/by-id/* devices weren't showing up, I forgot the solution, but it can be fixed, I think I tried some first Google results i.e. some modprobe and echo thing.
  3. When the ttyUSB* works, you have to use the djtgcfg tool with root, but some error regarding permissions appears, can be investigated w/ strace. The fix is some sysctl command
@kshaa
kshaa / streaming_webcam_ogg_with_vlc_over_http.md
Created October 15, 2021 20:58
How to stream WebCam stream in OGG format with VLC over HTTP
@kshaa
kshaa / shell.nix
Last active April 27, 2021 13:53
Experimental nix 3.0 on Ubuntu for flake'd shell usage
# Nix shell info:
# - This shell uses the Nix package manager `https://github.com/NixOS/nix`
# - This shell uses the experimental `nix flake` functionality:
# - See `https://nixos.wiki/wiki/Flakes`
# - See `https://www.tweag.io/blog/2020-05-25-flakes/`
# - This shell usage is described not for NixOS, but for Ubuntu, however NixOS should work too
# - If problems arise while managing nix versions, check state of nix channels:
# - `nix-channel --list`
# - `nix-channel --help`
# - `env | grep nixpkgs`
#!/usr/bin/env bash
function help() {
echo "Usage $0 [TEMPLATE] [RENDER]"
echo "Replaces all instances of '\$TPL_*' in TEMPLATE and write to RENDER"
echo "If RENDER not provided, will print to stdout"
}
template="$1"
if [ -z "$template" ]
#!/usr/bin/env bash
chain_pem="${1}"
if [[ -z "${2}" ]]; then
ssl_flags="x509 -noout -text"
else
ssl_flags="${2}"
fi
echo "SSL Flags: ${ssl_flags}\n"
@kshaa
kshaa / braingames_bulk_lv_rules.md
Last active July 25, 2019 12:33
How to quickly download all game rules from BrainGames site

How to quickly download all game rules from BrainGames site (works on my local @ July 2019)

Go to http://www.brain-games.com/lv/noteikumi/

In the console run this to get a list of all latvian rule download links

var lvhrefs = [];
var lvimgs = document.querySelectorAll("img[src='http://www.brain-games.com/wp-content/uploads/lv.png']")
    .forEach(function(lvimg) {
        lvhrefs.push(lvimg.parentElement.href)
    })
# Source - https://superuser.com/questions/268344/how-do-i-delete-all-but-10-newest-files-in-linux
# Remove all files except the newest 5
preserveCount=5
path="./rotate"
ls -1tr $path | head -n "-$preserveCount" | xargs -I {} -d '\n' rm -f $path/{}
#!/usr/bin/env bash
# Usage:
#
# # Compile main.cpp to merged_main.cpp
# ./merge.sh
#
# # Compile index.cpp to merged_main.cpp
# ./merge.sh index.cpp
#
-- Mergefile
main.cpp
-- main.cpp
#include <iostream>
#include "lib/LinkedList/LinkedList.h"
using namespace std;
int main() {
// Code here
}