Skip to content

Instantly share code, notes, and snippets.

/+dub.sdl:+/
// Siarhei Siamashka - Programming Challange from Erann Gat:
// http://www.flownet.com/ron/papers/lisp-java/
// This work is marked with CC0 1.0. To view a copy of this license, visit
// http://creativecommons.org/publicdomain/zero/1.0
@safe:
import std.stdio, std.file, std.conv, std.ascii, std.algorithm, std.string;
import core.bitop, std.bigint;
// Can be changed to 'long' for more speed, but will overflow in extreme cases
/+dub.sdl:+/
// Siarhei Siamashka - Programming Challange from Erann Gat:
// http://www.flownet.com/ron/papers/lisp-java/
// This work is marked with CC0 1.0. To view a copy of this license, visit
// http://creativecommons.org/publicdomain/zero/1.0
@safe:
import std.stdio, std.file, std.conv, std.ascii, std.algorithm, std.string;
import core.bitop;
immutable letter2digit = (){
/+dub.sdl:+/
// Siarhei Siamashka - Programming Challange from Erann Gat:
// http://www.flownet.com/ron/papers/lisp-java/
// This work is marked with CC0 1.0. To view a copy of this license, visit
// http://creativecommons.org/publicdomain/zero/1.0
@safe:
import std.stdio, std.file, std.conv, std.ascii, std.algorithm, std.string;
immutable letter2digit = (){
char[256] tmp;
@ssvb
ssvb / dlangchecker.d
Created September 14, 2022 03:46
D compiler configuration test for competitive programming online judge platforms.
import std.stdio, std.range, std.algorithm, std.compiler, core.bitop;
// Optimizing compilers should do tail call optimization here, so
// 0xBADF00D magic constant won't be found in stack if optimizations
// are enabled. Is there a cleaner way to detect optimizations?
bool detect_opt() {
int[100] filler;
bool detect_tail_call_opt(int depth, int magic) {
if (depth > 100) {
int x; foreach (i ; 20 .. 80) if (*(&x + i) == magic) return false;
#!/usr/bin/env ruby
$data = {}
$func_name = nil
# binutils confuses the sizes of the first and the second arguments
# this function contains a fixup workaround
def fixup_vshll(l)
if l =~ /(.*vshll.u16\s+)d(\d+),\s*q(\d+)(.*)/
reg1 = $2.to_i
@ssvb
ssvb / bench_ahash.cr
Created February 20, 2022 17:47
Benchmark AHash vs. FxHash vs. FunnyHash in Crystal language (can be run at https://atcoder.jp/contests/practice/custom_test for example)
require "benchmark"
# Access two 64-bit random seed values
struct Crystal::Hasher
def self.get_seed
@@seed
end
end
# Implementation of FunnyHash from
@ssvb
ssvb / bin2elf.sh
Last active February 19, 2022 15:32 — forked from tangrs/bin2elf.sh
Convert a memory dump/raw binary image into an ELF file
#!/bin/sh
# Convert a raw binary image into an ELF file suitable for loading into a disassembler
#
# Usage: bin2elf input_binary_file output_elf_file base_address
cat > raw$$.ld <<EOF
SECTIONS
{
EOF
@ssvb
ssvb / codeforces_ratings.md
Created December 2, 2021 22:42
codeforces ratings

The real starting rating is 1400 (but displayed as 0). Your rating delta after your first contest was -110 and your real rating changed to 1290 (displayed as 390). Your rating delta after your second contest was -43 and your real rating changed to 1247 (displayed as 697).

The following Python code can be used to convert your display rating to your real rating and the other way around:

def get_display_rating(real_rating, number_of_contests):
  if number_of_contests >= 6:
    return real_rating
  display_delta = [1400, 900, 550, 300, 150, 50]
 return real_rating - display_delta[number_of_contests]
@ssvb
ssvb / xorg.conf
Last active September 6, 2020 20:18
Dual monitor support on Allwinner A10
# This is a minimal sample config file, which can be copied to
# /etc/X11/xorg.conf in order to make the Xorg server pick up
# and load xf86-video-fbturbo driver installed in the system.
#
# When troubleshooting, check /var/log/Xorg.0.log for the debugging
# output and error messages.
#
# Run "man fbturbo" to get additional information about the extra
# configuration options for tuning the driver.

Deactivated jsimd_h2v1_downsample_dspr2 and jsimd_h2v2_downsample_dspr2

Running tests...
Test project /tmp/libjpeg-turbo.bigendian/build
        Start   1: tjunittest-static
  1/151 Test   #1: tjunittest-static .................................***Failed   73.19 sec
        Start   2: tjunittest-static-alloc
  2/151 Test   #2: tjunittest-static-alloc ...........................***Failed   72.38 sec
        Start   3: tjunittest-static-yuv