Skip to content

Instantly share code, notes, and snippets.

View codeboost's full-sized avatar
😎

Florin codeboost

😎
  • Barcelona
View GitHub Profile
@codeboost
codeboost / test.clj
Last active September 8, 2020 23:21
The test
(ns user.dustin.minitest2
(:require
[meander.epsilon :as m]))
(defn error [& args]
(apply println args))
(defn run-tests [formv]
(let [parsed (m/rewrite formv
[] []
@codeboost
codeboost / server.cljs
Created November 10, 2016 10:02
Clojurescript sample node http server
(ns helloserver
(:require [cljs.nodejs :as nodejs]))
(def http (nodejs/require "http"))
(-> (.createServer http (fn [req res]
(doto res
(.writeHead 200 {"Content-Type" "text/plain"})
(.end "Hello from ClojureScript"))))
(.listen 8080 "127.0.0.1"))
All data is contained in one big file, for example:
http://www.boomhub.org/db/results.json
All the nodes are stored in the root of the json, with the url paths as keys.
Each node has a "type" field.
Type can be "section" or "article".
Section node
A section node has a "links" field, which is an array of "link" nodes.
Each link contains a "href" field, a imageURL and a title field.
└─ express@4.13.3
├─ array-flatten@1.1.1
├─ cookie-signature@1.0.6
├─ debug@2.2.0
│ └─ ms@0.7.1
├─ depd@1.0.1
├─ accepts@1.2.12
│ ├─ negotiator@0.5.3
│ └─ mime-types@2.1.4
│ └─ mime-db@1.16.0
;Source map:
{
"key1" {name: "some1" dependencies: ["dep1" "dep2" "dep3"]}
"key2" {name: "some2" dependencies: ["dep4" "dep3"]}
;and so on
}
; I want to get to this
{
"key1" {name: "some1" dependencies: ["mapped dep1" "mapped dep2" "mapped dep3"]}
superSum = (k, n) ->
sum = n
sum = (sum * (n + i)) / (i + 1) for i in [1..k]
sum
console.log 'superSum(1,3)=', superSum(1, 3)
console.log 'superSum(2,3)=', superSum(2, 3)
console.log 'superSum(10,10)=', superSum(10,10)
console.log 'superSum(20,20)=', superSum(20,20)
go and node running on MacOS Lion, i7, 8GB RAM.
ab running on linux in a VirtualBox (on the same machine).
Script source code:
https://gist.github.com/2722169
ab command line:
ab -n 40000 -c 200 -r 192.168.1.104:1337/
Test results:
@codeboost
codeboost / main.go
Created May 17, 2012 23:01
Source code for test scripts
package main
import (
"net/http"
"log"
"fmt"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@codeboost
codeboost / gist:1424465
Created December 2, 2011 19:17
Convert Mongoose obj to JS obj and all ObjectIds to String
toObject = (item) ->
return item unless item.toObject
json = item.toObject()
for key, val of json
if _.isArray val
json[key] = _.map val, (element) -> toObject element
else
@codeboost
codeboost / test-32k.js
Created November 12, 2010 10:15
Sending large buffers through SSL connection causes the other side to stop receiving the data
const
util = require('util'),
net = require('net'),
crypto = require('crypto'),
fs = require('fs'),
Buffer = require('buffer').Buffer,
http = require('http'),
url = require('url');
var privateKey = fs.readFileSync('../cert/privatekey.pem').toString();