Skip to content

Instantly share code, notes, and snippets.

@nikolaybotev
nikolaybotev / remmina-build.sh
Last active December 15, 2015 14:29
Compile Remmina on Windows Using Cygwin
# Note: I had to install a lot of required libraries and dev packages from Cygwin.
# I am not listing these here. The easiest way around this would be to do a
# complete installation of cygwin.
#
# Build libvncserver
#
git clone git://git.code.sf.net/p/libvncserver/code libvncserver-code
cd !$
@nikolaybotev
nikolaybotev / Hello.jasmin
Last active December 17, 2015 07:39
A simple Jasmin file demonstrating the use of the jsr instruction.
.bytecode 49.0
.source Hello.j
.class Hello
.super java/lang/Object
; This example method uses a PrintMe subroutine to invoke the System.out.println() method.
.method static usingSubroutine()V
.limit stack 2
.limit locals 2
#!scala
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Success
import scala.util.Failure
val x: Future[Boolean] = Future.successful(true)
val y: Future[Boolean] = Future.successful(false)
val xMapped: Future[Int] = x.map(_ match { case true => 42 case false => throw new Exception("hey") })
@nikolaybotev
nikolaybotev / build.gradle
Last active March 17, 2020 16:40
Gradle Build with Java 9 Modules and Kotlin Support (root project)
plugins {
id 'idea'
id 'com.zyxist.chainsaw' version '0.3.1' apply false
id "org.jetbrains.kotlin.jvm" version "1.2.31" apply false
}
subprojects {
apply plugin: 'idea'
apply plugin: 'java-library'
apply plugin: 'com.zyxist.chainsaw'
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class TestIncrement {
public static void main(String[] args) throws InterruptedException, BrokenBarrierException {
@nikolaybotev
nikolaybotev / build-hsdis-macos.sh
Created April 30, 2018 07:24
Java 10 HotSpot Disassembly on macOS High Sierra
#!/bin/bash -e
# Download OpenJDK Reference Implementation Sources from
# http://jdk.java.net/java-se-ri/10
curl -O https://download.java.net/openjdk/jdk10/ri/openjdk-10_src.zip
# Navigate to the hsdis sources
unzip openjdk-10_src.zip
cd openjdk/src/utils/hsdis
@nikolaybotev
nikolaybotev / pidiskmark.sh
Last active November 18, 2021 20:36
A CrystalDiskMark equivalent benchmark script for Raspberry Pi OS Linux (requires fio)
#!/bin/sh
crystalread() {
awk -F \; '{ printf("%32s : %8.2f MB/s [%9.1f IOPS]\n", $3, $7*1024/1e6, $8) }'
}
crystalwrite() {
awk -F \; '{ printf("%32s : %8.2f MB/s [%9.1f IOPS]\n", $3, $48*1024/1e6, $49) }'
}
@nikolaybotev
nikolaybotev / sendsms
Last active May 14, 2021 03:36 — forked from artizirk/sendsms.sh
Send SMS using AT commands over the TTY of a Cellular modem. Supports Unicode international characters and emojis.
#!/bin/sh -e
# Usage: sendsms +375555555 "some text i want to send"
TELFNUMB="$1"
SMSTEXT="$2"
MODEM="${3:-/dev/ttyUSB2}"
TIMEOUT="${4:-1}"
# Text encoding
@nikolaybotev
nikolaybotev / spiritual_autolysis.js
Last active March 26, 2021 03:01
Spiritual Autolysis - by Jed McKenna
import { tired, sleep, eat, walk } from “my_body/index.js”;
import { pray } from “my_body/heart.js”;
import { wahtDoIKnow, why } from “my_body/brain.js”;
const knowledge = [];
function write() {
while (!tired()) {
const text = knowledge.shift() || wahtDoIKnow();
text.split(“ “).forEach(word => {
@nikolaybotev
nikolaybotev / iptables-firewall-config.sh
Created June 11, 2021 04:41
Router Firewall Configuration (iptables)
UPSTREAM_IFACE="${1:-eth1}"
# IPv4 and IPv6
for iptables in iptables ip6tables; do
# :INPUT
# - returning traffic
sudo $iptables -A INPUT -i $UPSTREAM_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT
# - ping
sudo $iptables -A INPUT -i $UPSTREAM_IFACE -p icmp -j ACCEPT