Skip to content

Instantly share code, notes, and snippets.

View scalahub's full-sized avatar

ScalaHub scalahub

View GitHub Profile
@scalahub
scalahub / Bech32.scala
Created May 29, 2022 15:44 — forked from gafiatulin/Bech32.scala
Scala implementation of Bech32 — general checksummed base32 format.
import scala.util.Try
// BIP173
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
case object Bech32 {
type Int5 = Byte
final val CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
final val CHARSET_MAP: Map[Char, Int5] = CHARSET.zipWithIndex.toMap.mapValues(_.toByte)
final val CHARSET_REVERSE_MAP: Map[Int5, Char] = CHARSET_MAP.map(_.swap)
@scalahub
scalahub / RPS.es
Last active August 10, 2020 12:49
Rock-paper-scissors in Ergo
/** RPS game:
Alice creates a RPS game of "playAmount" ergs by creating a Half-game UTXO called the "halfGameOutput" output below.
Another player (Bob) then sends a transaction spending Alice's UTXO and creating two outputs called "fullGameOutputs" ("Full game" UTXOs).
After Alice opens her commitment (see below), the fullGameOutputs can be spent by the winner.
The transactions encode the following protocol.
protocol:
Step 1: Alice commits to secret number a in {0, 1, 2} as follows:
Generate random s and compute h = Hash(s||a)
h is the commitment to a
Alice also selects the "play amount", the amount each player must spend to participate.
@scalahub
scalahub / RPS.sol
Created August 10, 2020 12:32
Rock-paper-scissors in Ethereum
pragma solidity ^0.4.9;
contract RPS {
address public house;
uint public numTokens;
mapping(address => uint) public tokenBalance;
function getContractBalance() returns (uint) {
return (this.balance);
}
function RPS(uint startTokens) {
if (startTokens < 1000 ether) throw;
@scalahub
scalahub / ConsumerExample.scala
Created April 30, 2020 05:33 — forked from fancellu/ConsumerExample.scala
Kafka Producer/Consumer Example in Scala
import java.util
import org.apache.kafka.clients.consumer.KafkaConsumer
import scala.collection.JavaConverters._
object ConsumerExample extends App {
import java.util.Properties
Request body
See description of /wallet/transaction/generate
Examples:
{"requests":[{"address":"4MQyML64GnzMxZgm","value":123456,"assets":[],"registers":{"R4":"0e20f091616c10378d94b04ed7afb6e7e8da3ec8dd2a9be4a343f886dd520f688563","R5":"061913aaf504e4bc1e62173f87a4378c37b49c8ccff196ce3f0ad2","R6":"0e061a2b3c4d5e6f"}},{"address":"7g5LhysK7mxX8xmZdPLtFE42wwxGFjpp8VofStb","value":123456,"assets":[],"registers":{"R4":"0e20f091616c10378d94b04ed7afb6e7e8da3ec8dd2a9be4a343f886dd520f688563","R5":"061913aaf504e4bc1e62173f87a4378c37b49c8ccff196ce3f0ad2","R6":"0e061a2b3c4d5e6f"}}],"fee":1000000,"inputsRaw":[]}
Execute
Clear
Responses
@scalahub
scalahub / create-efi-keys.sh
Created July 18, 2019 18:16 — forked from Era-Dorta/create-efi-keys.sh
Sign kernel modules on Ubuntu, useful for Nvidia drivers in UEFI system
# VERY IMPORTANT! After each kernel update or dkms rebuild the modules must be signed again with the script
# ~/.ssl/sign-all-modules.sh
# Place all files in ~/.ssl folder
mkdir ~/.ssl
cd ~/.ssl
# Generate custom keys with openssl
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -subj "/CN=Owner/"
@scalahub
scalahub / license-badges.md
Created June 8, 2019 05:12 — forked from lukas-h/license-badges.md
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

@scalahub
scalahub / readme.md
Last active May 7, 2019 13:54 — forked from benstr/readme.md
Gist Markdown Cheatsheet

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Paragraph

@scalahub
scalahub / skylake-tuning-linux.md
Created January 30, 2018 18:58 — forked from Brainiarc7/skylake-tuning-linux.md
This gist will show you how to tune your Intel-based Skylake, Kabylake and beyond Integrated Graphics Core for performance and reliability through GuC and HuC firmware usage on Linux.

Tuning Intel Skylake and beyond for optimal performance and feature level support on Linux:

Note that on Skylake, Kabylake (and the now cancelled "Broxton") SKUs, functionality such as power saving, GPU scheduling and HDMI audio have been moved onto binary-only firmware, and as such, the GuC and the HuC blobs must be loaded at run-time to access this functionality.

Enabling GuC and HuC on Skylake and above requires a few extra parameters be passed to the kernel before boot.

Instructions provided for both Fedora and Ubuntu (including Debian):

Note that the firmware for these GPUs is often packaged by your distributor, and as such, you can confirm the firmware blob's availability by running: