Skip to content

Instantly share code, notes, and snippets.

View laczoka's full-sized avatar

Laszlo (@laczoka on Twitter) laczoka

View GitHub Profile
@laczoka
laczoka / csv.clje
Last active May 19, 2020 10:26
A straight port of a cljs csv library to clojure@beam
;;
;; Straight port of https://raw.githubusercontent.com/testdouble/clojurescript.csv/master/src/testdouble/cljs/csv.cljs
;; by LT
(ns clojure.data.csv
(:require [clojure.string :as str]))
(defn- escape-quotes [s]
(str/replace s "\"" "\"\""))
(defn- wrap-in-quotes [s]
$.getJSON("https://url", function(data){
console.log(data);
$("#div1").html(data);
});
@laczoka
laczoka / broken.clj
Created June 12, 2016 17:58
Possible bug: c.spec/fn-specs doesn't always work on aliased symbols
;; using clojure 1.9.0-alpha5
(ns aaa (:require [clojure.spec :as sp]))
(in-ns 'aaa)
(defn plus [a b] (+ a b))
(sp/fdef plus :args (sp/cat :a number? :b number?))
(assert (not (nil? (:args (sp/fn-specs 'plus)))))
deis-builder.service - deis-builder
Loaded: loaded (/run/fleet/units/deis-builder.service; linked-runtime)
Active: active (running) since Wed 2014-10-29 00:02:19 UTC; 8h ago
Process: 5643 ExecStopPost=/usr/bin/docker rm -f deis-builder (code=exited, status=0/SUCCESS)
Process: 6047 ExecStartPost=/bin/bash -c nsenter --pid --uts --mount --ipc --net --target $(docker inspect --format='{{ .State.Pid }}' deis-builder) /usr/local/bin/push-images (code=exited, status=0/SUCCESS)
Process: 5728 ExecStartPost=/bin/sh -c echo 'Waiting for builder on 2223/tcp...' && until echo 'dummy-value' | ncat $COREOS_PRIVATE_IPV4 2223 >/dev/null 2>&1; do sleep 1; done (code=exited, status=0/SUCCESS)
Process: 5717 ExecStartPre=/bin/sh -c docker inspect deis-builder >/dev/null && docker rm -f deis-builder || true (code=exited, status=0/SUCCESS)
Process: 5692 ExecStartPre=/bin/sh -c IMAGE=`/run/deis/bin/get_image /deis/builder` && docker history $IMAGE >/dev/null || docker pull $IMAGE (code=exited, status=0/SUCCESS)
Pr
(ns blocking.core
(:require [org.httpkit.server :refer [run-server] :as http]))
(def c (atom 0))
(defn app-blocking [req]
(println "Serving blocking connect " (swap! c inc))
(Thread/sleep 3000)
{:status 200
:headers {"Content-Type" "text/plain"}
@laczoka
laczoka / jqasync.js
Last active December 22, 2015 21:09
Mini library that fell out as a by product while experimenting with $.Deferred and underscorejs.
/**
* Extend underscore.js with support for asynchronous computation using jQuery's Deferred implementation
* License:
The MIT License (MIT)
Copyright (c) 2013 Laszlo Török
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
brew install php53
==> Downloading http://www.php.net/get/php-5.3.23.tar.bz2/from/this/mirror
Already downloaded: /Library/Caches/Homebrew/php53-5.3.23
==> Downloading patches
######################################################################## 100.0%
==> Patching
patching file Makefile.global
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 18 (offset -2 lines).
Warning: Backing up all known pear.conf and .pearrc files
@laczoka
laczoka / testCORS.js
Created March 1, 2013 15:12
Show how to implement proper CORS support in Stardog (stardog.com) using a Node.js example
/* ISSUE: Stardog (up to v1.1.3) does not properly support CORS[1] interaction.
The issue is two-fold:
1) Stardog tries to authenticated the OPTIONS "pre-flight" request.
2) Stardog doesn't return CORS headers, hence can only be accessed
by browser web apps running in a different domain via a proxy.
Effected browsers: Firefox and IE*. Safari and Chrome work due to a bug in webkit (see [2]).
Expected behavior: Stardog MUST NOT try to authenticate the pre-flight request, it SHOULD rather return
proper CORS headers. [4]
@laczoka
laczoka / how_to_import_data_to_stardog
Created February 20, 2013 15:15
How to load triples into Stardog Convenience script for running SPARQL queries against Stardog
+You should almost always import data when you create a new database.
+I could load 40k triples/sec, 10M triples under 4 minutes
+
+Follow the quickstart guide at http://stardog.com/docs/quick-start/.
+
+If you have triples in multiple files (.rdf,.n3,.nt, etc.) just use
+
+zip alltriples.zip file1 file2 ....
+
+to compress it, it will speedup the load.
@laczoka
laczoka / dydra-load-triples.sh
Created February 14, 2013 09:47
Troubleshooting Dydra.com by using Stardog as reference. (Stardog 1.1 Community Edition) After loading the data into dydra, export doesn't work as expected. It results in 20+ triples whereas exporting from Stardog works just fine. There seems to be a difference in the total number of loaded triples as well: 5595 (Dydra) vs. 5572 (Stardog) See ht…
#!/bin/bash
DB=test2
# drop database
dydra drop test2
# seed data
array=(blurayplayer.n3 blurayplayer_example.n3 mobilephone.n3 mobilephone_example.n3 tablet.n3 tablet_example.n3 digitalcamera.owl digitalcamera_example.owl)
# create db and load seed data
dydra create test2