Skip to content

Instantly share code, notes, and snippets.

View funny-falcon's full-sized avatar

Sokolov Yura funny-falcon

View GitHub Profile
@funny-falcon
funny-falcon / mypassw.rb
Last active December 29, 2020 10:42
Personal password storage :)
#!/usr/bin/env ruby
require 'digest/sha2'
require 'io/console'
require 'base64'
USAGE = <<EOF
USAGE:
#$0 set domain [file]
- store encoded password for domain
#$0 domain [file]
@funny-falcon
funny-falcon / maglev.go
Created April 22, 2018 17:14
Maglev for redis
package main
const TableSize = uint16(1 << 14)
type Table []uint16
type Shard struct {
Hash uint64
Weight float64
}
require "benchmark"
def fake_cos(x : Float64) : Float64
1.0
end
def taylor_cos(x : Float64) : Float64
x = x.abs
kf, x = x.divmod(Math::PI)
k = kf.to_i
@funny-falcon
funny-falcon / greeter_client.go
Last active February 11, 2019 18:37
Go GRPC benchmark
/*
*
* Copyright 2015 gRPC authors.
*
* 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
*
@funny-falcon
funny-falcon / java.java
Created August 13, 2012 15:12
Consistent hash from Google Guava Core libraries
/**
* Assigns to {@code input} a "bucket" in the range {@code [0, buckets)}, in a uniform
* manner that minimizes the need for remapping as {@code buckets} grows. That is,
* {@code consistentHash(h, n)} equals:
*
* <ul>
* <li>{@code n - 1}, with approximate probability {@code 1/n}
* <li>{@code consistentHash(h, n - 1)}, otherwise (probability {@code 1 - 1/n})
* </ul>
*
@funny-falcon
funny-falcon / promiseme.js
Created December 18, 2017 14:42
Promise proxy
let handlers = {}
handlers.get = function(target, property) {
let v = target[property]
if (typeof(v) == "function") {
return async (...args) => {
return new Promise((resolve, reject) => {
target[property](...args, (err, ...rest) => {
if (err) reject(err)
else resolve(rest.length == 1 ? rest[0] : rest)
[gui]
spellingdictionary = en_US
tabsize = 4
fontui = -family \"DejaVu Sans\" -size 10 -weight normal -slant roman -underline 0 -overstrike 0
fontdiff = -family \"DejaVu Sans Mono\" -size 10 -weight normal -slant roman -underline 0 -overstrike 0
[user]
emal = funny.falcon@gmail.com
email = funny.falcon@gmail.com
name = Sokolov Yura
[http]
@funny-falcon
funny-falcon / prim.txt
Created September 9, 2017 11:34
xorshit64 for 2*32bit state
26-5-1 11 x^64 + x^36 + x^32 + x^30 + x^28 + x^26 + x^24 + x^15 + x^13 + x^4 + 1
2-7-21 11 x^64 + x^35 + x^34 + x^32 + x^19 + x^18 + x^8 + x^4 + x^3 + x^2 + 1
5-27-18 11 x^64 + x^32 + x^26 + x^20 + x^18 + x^12 + x^9 + x^6 + x^5 + x^4 + 1
1-2-11 13 x^64 + x^41 + x^35 + x^33 + x^32 + x^18 + x^11 + x^9 + x^6 + x^3 + x^2 + x + 1
20-7-3 13 x^64 + x^52 + x^44 + x^40 + x^32 + x^24 + x^21 + x^16 + x^14 + x^12 + x^8 + x^4 + 1
23-8-1 15 x^64 + x^47 + x^41 + x^36 + x^32 + x^27 + x^26 + x^23 + x^22 + x^13 + x^11 + x^10 + x^6 + x^4 + 1
5-27-21 15 x^64 + x^33 + x^32 + x^29 + x^27 + x^23 + x^21 + x^15 + x^13 + x^10 + x^7 + x^6 + x^5 + x^3 + 1
10-13-6 17 x^64 + x^42 + x^39 + x^38 + x^37 + x^34 + x^31 + x^29 + x^28 + x^26 + x^24 + x^23 + x^21 + x^16 + x^14 + x^12 + 1
17-1-18 17 x^64 + x^37 + x^35 + x^32 + x^31 + x^27 + x^23 + x^21 + x^19 + x^16 + x^15 + x^13 + x^9 + x^7 + x^3 + x + 1
18-7-16 17 x^64 + x^47 + x^46 + x^41 + x^40 + x^34 + x^31 + x^25 + x^22 + x^20 + x^15 + x^14 + x^12 + x^10 + x^9 + x^8 + 1
@funny-falcon
funny-falcon / performance_and_backport_gc.patch
Created February 18, 2012 12:26
Union of backport GC and performance patches for ruby-1.9.3-p125
diff --git a/Changelog.backport_gc b/Changelog.backport_gc
new file mode 100644
index 0000000..b617fc8
--- /dev/null
+++ b/Changelog.backport_gc
@@ -0,0 +1,128 @@
+Tue Jan 17 12:32:46 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.c (aligned_malloc, aligned_free): covered missing defined
+ operators and fixes for cygwin.
@funny-falcon
funny-falcon / hasher.cr
Last active June 17, 2017 10:18
Hasher Crystal draft
require "secure_random"
require "static_array"
module Hashing
alias Type = UInt32
@@seed = uninitialized StaticArray(UInt32, 6)
struct StdHasher
# lucky777 hash https://github.com/funny-falcon/fanom_hash/blob/master/lucky777.h
struct Impl