Skip to content

Instantly share code, notes, and snippets.

View Leonidas-from-XIV's full-sized avatar

Marek Kubica Leonidas-from-XIV

View GitHub Profile
module Main where
import System.Environment (getArgs)
multiplesOf :: Int -> [Int]
multiplesOf n = [n,2*n..]
getBiggerThan x n = case dropWhile (< x) (multiplesOf n) of
[] -> 0
(x:xs) -> x
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<xsl:apply-templates />
</html>
</xsl:template>
<xsl:template match="conference">
@Leonidas-from-XIV
Leonidas-from-XIV / data.s
Last active December 30, 2015 19:39
ARM assembly, #immediates do not work with large numbers, so store them in memory and load from there.
.data
.balign 4
count:
.word 100000
.text
.global main
.func main
@Leonidas-from-XIV
Leonidas-from-XIV / .mailfilter
Created November 21, 2013 13:23
Maildrop filter rules to avoid SpamAssassin trashing the server.
# put it through spamassassin
# but only if it is smaller than 5MB, otherwise SA uses excessive RAM
if ($SIZE < 5242880)
xfilter "/usr/bin/spamassassin"
// app
angular.module("phonecatServices", ["ngResource"]).
factory("Namespace", function($resource) {
$resource("clojure_core/:namespace", {}, {get: {method: "GET"}, params: {namespace: "namespace"}, isArray: true});
});
// controller
function namespace_list($scope, $routeParams, Namespace) {
$scope.functions = Namespace.get({namespace: $routeParams.namespace});
}
@Leonidas-from-XIV
Leonidas-from-XIV / cljdocs.cljs
Last active December 23, 2015 10:39
This is quite a thing.
(ns cljdocs.cljdocs)
(.write js/document "Hello, ClojureScript!")
@Leonidas-from-XIV
Leonidas-from-XIV / cz_job_audit
Last active December 23, 2015 08:49
Data imported via kitchen tool
123873 | 12635 | TM_CZ | Kettle - create_clinical_data | GSE5 | Done | 0 | 0 | 2013-09-18 17:17:24.671701 | 0
123875 | 12635 | GSE4382_raw_data.txt | Kettle - create_clinical_data | Input rows | Done | 167 | 1 | 2013-09-18 17:17:33.190891 | 8.51919
123876 | 12635 | GSE4382_raw_data.txt | Kettle - create_clinical_data | Data columns per row | Done | 11 | 2 | 2013-09-18 17:17:33.198807 | 0.007916
123877 | 12635 | GSE4382_raw_data.txt | Kettle - create_clinical_data | Aggregate input records | Done | 0 | 3 | 2013-09-18 17:17:33.199815 | 0.001008
123878 | 12635 | GSE4382_raw_data.txt | Kettle - create_clinical_data | Aggregate output records | Done | 0 | 4 | 2013-09-18 17:17:33.201473
@Leonidas-from-XIV
Leonidas-from-XIV / detailedlog.txt
Created September 18, 2013 14:01
Spoon import log
2013/09/18 15:58:39 - Spoon - Starting job...
2013/09/18 15:58:39 - create_clinical_data - Start of job execution
2013/09/18 15:58:39 - create_clinical_data - exec(0, 0, START.0)
2013/09/18 15:58:39 - START - Starting job entry
2013/09/18 15:58:39 - create_clinical_data - Starting entry [Validate parameters]
2013/09/18 15:58:39 - create_clinical_data - exec(1, 0, Validate parameters.0)
2013/09/18 15:58:39 - Validate parameters - Starting job entry
2013/09/18 15:58:39 - Validate parameters - Opening transformation: [file:///home/transmart/tranSMART-ETL/Postgres/GPL 1.0/Kettle/Kettle-ETL/validate_clinical_data_params.ktr]
2013/09/18 15:58:39 - Validate parameters - Loading transformation from XML file [file:///home/transmart/tranSMART-ETL/Postgres/GPL 1.0/Kettle/Kettle-ETL/validate_clinical_data_params.ktr]
2013/09/18 15:58:39 - Validate parameters - Starting transformation...(file=${Internal.Job.Filename.Directory}/validate_clinical_data_params.ktr, name=Validate parameters, repinfo=null)
(let [iden (fn [x] x)]
(defmacro nested [x] `(iden ~x)))
(macroexpand-1 '(nested 42))
;;=> (user/iden 42)
(nested 42)
;;=> CompilerException java.lang.RuntimeException: No such var: user/iden
@Leonidas-from-XIV
Leonidas-from-XIV / memoize-recursive.clj
Last active December 22, 2015 20:39
Memoizing recursive function macro. Saves recursive calls in a cache.
;; memorizing recursive macro
;; replace your recursive defn by defmemo and recursive calls get memorized
(defmacro defmemo [name args & body]
`(defn ~name ~args
; the call cache which stores results
(let [cache# (ref {})]
; yes, this shadows the outer ~name definition, but it's fine
(letfn [(~name ~args
(if-let [[k# v#] (find @cache# ~args)] v#
(let [res# ~@body]