This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# results: | |
# doing 100000000 records | |
# set: 24.3293866 -- ( 4110255 per second) | |
# `ps -p #{Process.pid} -o rss` # => " RSS\n9547028\n" | |
# 99999999 | |
# get: 0.4833987 -- ( 206868574 per second ) | |
a = {} of Int32 => String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
based on: | |
https://blog.myhro.info/2017/01/how-fast-are-unix-domain-sockets | |
get about 28K per second on crystal vs 20K on python. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install git | |
# for apt-add-repository | |
apt-get install -y software-properties-common | |
sudo apt-add-repository -y ppa:git-core/ppa | |
apt-get update | |
apt-get install -y git | |
#---------------- [ ruby ] ---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://askubuntu.com/questions/193072/how-to-use-the-new-adobe-source-code-pro-font | |
mkdir /tmp/adodefont | |
cd /tmp/adodefont | |
wget https://github.com/adobe-fonts/source-code-pro/archive/1.017R.zip | |
unzip 1.017R.zip | |
mkdir -p ~/.fonts | |
cp source-code-pro-1.017R/OTF/*.otf ~/.fonts/ | |
fc-cache -f -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FizzBuzz do | |
def fizzbuzz(n) when rem(n, 15) == 0, do: "FizzBuzz" | |
def fizzbuzz(n) when rem(n, 5) == 0, do: "Buzz" | |
def fizzbuzz(n) when rem(n, 3) == 0, do: "Fizz" | |
def fizzbuzz(n), do: n | |
end | |
Enum.map(1..100, &FizzBuzz.fizzbuzz/1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://twitter.com/sadserver/status/610520237755142144 | |
# "..developers and their shitty code.." | |
# he muttered before returning to work on the | |
# home-grown deployment system written in Csh | |
#apt-get update | |
apt-get -y install autoconf bison build-essential libssl-dev libyaml-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev libreadline-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncnet, asyncdispatch, strutils, threadpool | |
proc fib(n: int): int = | |
if n < 2: | |
result = n | |
else: | |
result = fib(n-1) + fib(n-2) | |
proc processClient(client: AsyncSocket) {.async.} = | |
while true: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
net = require "net" | |
HOST = "127.0.0.1" | |
createServer = (port) -> | |
net.createServer((sock) -> | |
sock.write("welcome! on port #{port}\r\n") | |
console.log("CONNECTED: #{sock.remoteAddress}:#{sock.remotePort}") | |
while true # this is the work queue, what ports to send to... | |
sock.write "hello\r\n" | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HOST, createServer, g, net; | |
net = require("net"); | |
HOST = "127.0.0.1"; | |
createServer = function(port) { | |
net.createServer(function(sock) { | |
sock.write("welcome! on port " + port + "\r\n"); | |
console.log("CONNECTED: " + sock.remoteAddress + ":" + sock.remotePort); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, db_mysql, asynchttpserver, httpclient, parseurl, asyncdispatch, strtabs, strutils | |
var server = newAsyncHttpServer() | |
var db: TDbConn | |
db = open(connection="localhost", user="root", password="", | |
database="") | |
let aheaders = {"Content-Type": "text/html"}.newStringTable | |
proc onRequest(req: TRequest) {.async.} = |
NewerOlder