Skip to content

Instantly share code, notes, and snippets.

@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 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
// длинный вариант
function getValue(id, cache, retrieveValue) {
return new Promise(function(ful, rej) {
if(cache.has(id)) {
ful(cache.get(id))
} else {
rej(false);
}
}).catch(function() {
function getValue(id, cache, retrieveValue) {
if(cache.has(id)) {
return cache.get(id);
} else {
return new Promise(function(ful, rej) {
retrieveValue(id, ful, rej);
});
}
}
@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);
}
}
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 / 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
fs = require('fs')
Flightplan = require("./.node_modules/flightplan") # we need to install flightplane to .node_modules for meteor to ignore it
path = require('path')
plan = new Flightplan()
releaseFile = "release.tar.tgz" # name of the bundle generated by meteor
workPath = '/home/user/path' # path to the project folder
releaseFolder = 'rel' + Date.now()
do fn # if not returning value or I don't care
fn() # if returning value
fn 1
fn fn2()
fn(fn2(), 1)
fn fn2(1, 2, 3) # 4, 5 ...
@Termina1
Termina1 / gist:3928508
Created October 21, 2012 21:04
meteor deploy cake task
exec = require('child_process').exec
ssh = require 'NodeSSH'
scp = require 'scp'
deploy = (host, name, pass, path, start = true, port=3001) ->
client = new ssh host, name, pass
console.log 'connecting to server'
client.connect ->
client.once 'data', ->
console.log 'cleaning old code'
client.write "cd #{path}\r\n"