Skip to content

Instantly share code, notes, and snippets.

Sokolov Yura funny-falcon

Block or report user

Report or block funny-falcon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@funny-falcon
funny-falcon / rand_test.go
Last active Jan 10, 2017
Use of runtime.Mid and runtime.Fastrand
View rand_test.go
package benchmarks
/*
BenchmarkRandInt63_Global-4 10000000 154 ns/op
BenchmarkRandInt63_Channel-4 10000000 220 ns/op
BenchmarkRandInt63_Pool-4 50000000 28.8 ns/op
BenchmarkSourceInt63_Pool-4 50000000 34.9 ns/op
BenchmarkRandInt63_Source-4 300000000 5.71 ns/op
BenchmarkRandInt63_ShardsGettid-4 50000000 29.2 ns/op
BenchmarkRandInt63_ShardsMid-4 100000000 14.2 ns/op
@funny-falcon
funny-falcon / ciph48.c
Last active Jul 19, 2016
Encrypt 32bit value + 2*32bit seed + 128bit key into 48bit cipher text
View ciph48.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <assert.h>
#include <sys/stat.h>
#include <unistd.h>
#include <inttypes.h>
#include <string.h>
// Minimum recommended values are DOUBLEROUND=3 and MIX=2.
@funny-falcon
funny-falcon / 00_unpacthed
Last active May 4, 2016
Test patched luajit
View 00_unpacthed
# unpatched
$ for i in {1..6} ; do time src/luajit test_str.lua $i ; done
1 1000000 8191
real 0m0.197s
user 0m0.196s
sys 0m0.000s
2 500000 8191
real 0m0.169s
@funny-falcon
funny-falcon / bash.out
Last active Mar 25, 2016
bench pipe vs socket
View bash.out
$ echo $((16*1024*1024)) | sudo tee /proc/sys/fs/pipe-max-size
$ gcc -ggdb3 -DN=256 -O1 bench-unixsocket-pipe.c
yura@falcon-new:~/tmp$ taskset -c 2,3 ./a.out 1000000000 $((16*1024*1024))
pipe lasts: 3.121495 sec, iter/sec: 320359349.183537
sock lasts: 5.402942 sec, iter/sec: 185084353.868363
pipe lasts: 3.287446 sec, iter/sec: 304187536.025462
sock lasts: 5.444722 sec, iter/sec: 183664098.170782
$ gcc -ggdb3 -DN=512 -O1 bench-unixsocket-pipe.c
$ taskset -c 2,3 ./a.out 1000000000 $((16*1024*1024))
pipe lasts: 1.790609 sec, iter/sec: 558469073.197397
@funny-falcon
funny-falcon / mypassw.rb
Last active Nov 18, 2019
Personal password storage :)
View mypassw.rb
#!/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]
View mhash.h
/*
* Copyright (C) 2011, 2012, 2013, 2014 Mail.RU
* Copyright (C) 2011, 2012, 2013, 2014 Yuriy Vostrikov
* Copyright (C) 2014 Yuriy Sokolov aka funny_falcon
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
View deferClosure.go
package main
import "fmt"
func A(x, y int) {
fmt.Println("The deferred A-call", x, y)
}
func B() int {
theAnswer := 42
View 00-test_hash_shift.rb
require 'benchmark'
N = 50000
K = 10000
a = {}
K.times{|i| a[i] = nil}
class Hash
def custom_shift
View build_sumbur_ranges.rb
require 'rational'
ONE = Rational(1)
def draw(arr)
print "N = #{arr.size}\n"
arr.each_with_index do |ar, i|
print "#{i}: (#{ar.size} items)\t#{ar.inspect}\n"
end
flat = arr.flatten
@funny-falcon
funny-falcon / atomic_linked_queue.rb
Last active Dec 16, 2015
Non blocking queue if we have attr_atomic
View atomic_linked_queue.rb
# rewrite of https://gist.github.com/jstorimer/5298581 if ruby has Class.attr_atomic
class AtomicLinkedQueue
class Node
attr_accessor :item, :successor
attr_atomic :successor
def initialize(item, successor)
@item = item
@successor = successor
You can’t perform that action at this time.