Skip to content

Instantly share code, notes, and snippets.

@jots
jots / hashtest.cr
Last active January 21, 2017 00:03
# 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
@jots
jots / notes.txt
Last active January 10, 2017 01:36
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.
# 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 ] ----------
#!/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
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)
#!/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
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:
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
@jots
jots / cs.js
Created January 23, 2015 20:49
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);
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.} =