Skip to content

Instantly share code, notes, and snippets.

@Termina1
Termina1 / gist:8c9da9857b3a08f163db
Created November 19, 2014 15:17
paper php-fpm ab
Server Software: nginx/1.4.6
Server Hostname: paperpaper.ru
Server Port: 80
Document Path: /
Document Length: 37679 bytes
Concurrency Level: 1
Time taken for tests: 711.723 seconds
Server Software: nginx/1.4.6
Server Hostname: paperpaper.ru
Server Port: 80
Document Path: /
Document Length: 34971 bytes
Concurrency Level: 1
Time taken for tests: 413.202 seconds
Complete requests: 1000
@Termina1
Termina1 / sync-example.js
Last active August 29, 2015 14:17
latency-effect-1
function getValue(id, cache, retrieveValue) {
if(cache.has(id)) {
return cache.get(id);
} else {
// синхронный запрос к удаленному источнику
return retrieveValue(id);
}
}
function getValue(id, cache, retrieveValue) {
if(cache.has(id)) {
return cache.get(id);
} else {
return new Promise(function(ful, rej) {
retrieveValue(id, ful, rej);
});
}
}
// длинный вариант
function getValue(id, cache, retrieveValue) {
return new Promise(function(ful, rej) {
if(cache.has(id)) {
ful(cache.get(id))
} else {
rej(false);
}
}).catch(function() {
module Main
import Data.Vect
import Data.Vect.Views
data Total : {a : Type} -> (a -> a -> Type) -> (x : a) -> (y : a) -> Type where
LR : x `order` y -> Total order x y
RL : y `order` x -> Total order x y
interface TotalOrder a (order : a -> a -> Type) | order where
@Termina1
Termina1 / idris-hex.idr
Created December 9, 2016 19:14
Idris Fin 16 to Hex Char convertion
finToHex : Fin 16 -> Char
finToHex FZ = '0'
finToHex (FS FZ) = '1'
finToHex (FS (FS FZ)) = '2'
finToHex (FS (FS (FS FZ))) = '3'
finToHex (FS (FS (FS (FS FZ)))) = '4'
finToHex (FS (FS (FS (FS (FS FZ))))) = '5'
finToHex (FS (FS (FS (FS (FS (FS FZ)))))) = '6'
finToHex (FS (FS (FS (FS (FS (FS (FS FZ))))))) = '7'
finToHex (FS (FS (FS (FS (FS (FS (FS (FS FZ)))))))) = '8'
module crc32
import Data.Bits
g0 : Bits 32
g0 = intToBits 0xEDB88320
g1 : Bits 32
g1 = shiftRightLogical g0 (intToBits 1)
@Termina1
Termina1 / bitsToHex.idr
Last active December 12, 2016 13:34
Conversion from Bits 32 to hex String
bitsToBytes : Bits 32 -> Vect 4 (Bits 8)
bitsToBytes x = bitsToBytes' 4 x
where
bitsToBytes' : (n : Nat) -> Bits 32 -> Vect n (Bits 8)
bitsToBytes' Z x = []
bitsToBytes' (S k) bits = let prevBits = bitsToBytes' k bits in
let shifted = shiftRightLogical bits (MkBits $ natToBits {n = nextBytes 32} k * 8) in
let nextByte = truncate {m = 24} {n = 8} shifted in
nextByte :: prevBits
### Keybase proof
I hereby claim:
* I am termina1 on github.
* I am thought_sync (https://keybase.io/thought_sync) on keybase.
* I have a public key whose fingerprint is 2AD6 D5B3 EFF4 288E 61F3 57CE C2C1 B06C 79D7 CD3B
To claim this, I am signing this object: