Skip to content

Instantly share code, notes, and snippets.

View kmansoft's full-sized avatar

Kostya Vasilyev kmansoft

View GitHub Profile
@kmansoft
kmansoft / connection.go
Last active July 30, 2016 15:03
go-tarantool with debug tracing
package tarantool
import (
"bufio"
"bytes"
"errors"
"io"
"log"
"net"
"sync"
@kmansoft
kmansoft / build.gradle
Created August 11, 2016 22:28
Build.gradle for dnsjava
apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6
compileJava {
source = fileTree(dir: 'org', includes: ['xbill/DNS/*.java', 'xbill/DNS/utils/*.java'] )
}
jar {
@kmansoft
kmansoft / CollateTrie.java
Last active January 17, 2019 23:30
A simple Java trie for collated (hex-encoded) strings
package org.kman.Compat.util;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
/**
* Created by kman on 8/30/16.
*
* Works only with collated strings (hex encoded)
@kmansoft
kmansoft / AppLocaleManager.java
Created September 16, 2016 14:35
Change Android application locale
package org.kman.Compat.util;
import java.util.Locale;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
@kmansoft
kmansoft / build.gradle
Created December 9, 2018 19:51
Failing exoplayer dependencies
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@kmansoft
kmansoft / parse_jwk.go
Created July 18, 2019 12:05
Parse JWK in GO (Golang)
package auth
import (
"crypto/rsa"
"encoding/base64"
"encoding/json"
"fmt"
"math/big"
)
function makeDebounce(real, interval) {
var timerValue;
return function() {
if (timerValue) {
clearTimer(timerValue)
}
timerValue = setTimer(real, interval)
}
}
@kmansoft
kmansoft / LongToMultiLongArray.kt
Created June 9, 2020 07:53
A multi-map of long's in Kotlin
class LongToMultiLongArray {
fun put(key: Long, value: Long) {
var i = ContainerHelpers.binarySearch(mKeys, mSize, key)
if (i >= 0) {
val index = mIndices[i]
val offset = ((index shr 32) and 0x7FFF).toInt()
val cap = ((index shr 16) and 0x7FFF).toInt()
val len = ((index) and 0x7FFF).toInt()
#!/usr/bin/env python3
import sys
import argparse
import secrets
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-'
if __name__ == "__main__":
@kmansoft
kmansoft / simple-2.yaml
Last active May 10, 2022 23:58
An attempt at two network interfaces per EC2 node - results in an error
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Test - simple 2 network interfaces'
Parameters:
KeyName:
Description: 'Key Pair name'
Type: 'AWS::EC2::KeyPair::KeyName'
Default: kman
Resources:
VPC:
Type: 'AWS::EC2::VPC'