I hereby claim:
- I am BrunoBonacci on github.
- I am brunobonacci (https://keybase.io/brunobonacci) on keybase.
- I have a public key whose fingerprint is F05B 1D2E F3BE D8C8 E12F 44EF 6BEF 76A7 B805 F61B
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(defn crypto-square [s] | |
(->> (re-seq #"\w+" s) | |
(map clojure.string/lower-case) | |
(apply str) | |
(#(let [size (int (Math/ceil (Math/sqrt (count %))))] | |
(partition size size (repeat " ") %))) | |
(apply map vector) | |
(map (partial apply str)) | |
(clojure.string/join "\n"))) |
/* | |
* this benchmark compares the speed of | |
* the reminder operator vs the bitwise | |
* equivalent. | |
*/ | |
public class ReminderBenchmark { | |
final static long d = 8; | |
final static long mask = d-1; | |
final static long REPEAT = 1_000_000L; |
# stopping the server | |
sudo /etc/init.d/mongod stop | |
# now replace local.n files | |
cd /var/lib/mongo/local | |
sudo rm -fr local.* | |
sudo rename 's/new-local/local/g' new-local.* | |
# restarting the server | |
sudo /etc/init.d/mongod start |
cd /var/lib/mongo/local | |
# as root user | |
for i in {0..11} | |
do | |
echo "Initializing new-local.$i" | |
dd if=/dev/zero of=new-local.$i bs=2146435072 count=1 | |
chown mongod:mongod new-local.$i | |
chmod 0600 new-local.$i | |
done |
# generate the key and make it readable only by mongo server | |
sudo openssl rand -base64 753 > /etc/mongodb.key | |
sudo chown mongod:mongod /etc/mongodb.key | |
sudo chmod 0600 /etc/mongodb.key |
# this is the replica set name | |
# every node will need to have the same name | |
replSet = setname | |
# this is the authetication encryption key | |
# this will be required to be same on every node | |
keyFile = /etc/mongodb.key | |
# This is the operational log size | |
# here we assume ~24GB for example |
////////////////////////////////////////////////////////////////////////// cd | |
def cd(def path, String cid) { | |
path = path == "" ? null : path | |
def newPath = virtual2real(path, cid); | |
if (!newPath.exists() || !newPath.isDirectory()) | |
return [status: "ERROR", message: "### ERROR: $path: no such directory!".toString()] | |
// changing directory | |
_connections[cid].curDir = new File(newPath.canonicalPath); |
// Regular expression to verify/extract pathnames from commands | |
PATH_ELEM = "[A-Za-z0-9.-]+" | |
PATH = "(/?$PATH_ELEM(/$PATH_ELEM)*/?|/)" | |
// Commands handler | |
bus.registerHandler("commands") { | |
msg -> | |
def cmd = msg.body.command | |
switch (cmd) { | |
case ~$/cd( $PATH)?/$: |
// general configuration | |
settings = [port: 1234]; | |
// Vert.x server and event-bus | |
def server = vertx.createNetServer() | |
def bus = vertx.eventBus | |
// Connection handler. Here requests are captured, parsed, and executed. | |
server.connectHandler { sock -> | |
// upon a new connection, assigning a new connection id (cid) |