Skip to content

Instantly share code, notes, and snippets.

View jramb's full-sized avatar

Jörg Ramb jramb

  • Stockholm
  • 23:28 (UTC +02:00)
View GitHub Profile
-- Oracle Applications (aka EBS)
-- Trailing blanks problem in Oracle Workflow
-- check:
select case when display_name!=trim(display_name) then '>'||display_name||'<' end xx_disp
,case when description!=trim(description) then '>'||description||'<' end xx_desc
, w.*
from wf_activities_tl w -- wf_item_types_tl, wf_activities_tl, wf_messages_tl
where display_name!=trim(display_name)
or description!=trim(description);
@jramb
jramb / excel_core.clj
Created June 13, 2011 14:24
Creating and updating Excel files with Clojure/poi.apache.org
((ns excel.core
(:import [org.apache.poi.hssf.usermodel HSSFWorkbook HSSFSheet HSSFRow
HSSFRichTextString HSSFFont HSSFDataFormat
HSSFCellStyle HSSFCell])
(:import [java.io FileOutputStream FileInputStream IOException])
#_(:import [org.apache.poi.ss.util CellRangeAdrress]))
(defn make-excel [file-name]
(let [wb (HSSFWorkbook.)
@jramb
jramb / demo.clj
Created September 12, 2011 15:03 — forked from cgrand/demo.clj
;; this file is a walkthrough of Moustache features, a web framework for Clojure
;; http://github.com/cgrand/moustache/tree/master
;; Moustache allows to declare routes, apply middlewares and dispatch on http methods.
;; Moustache is compatible with all frameworks built on Ring, including Compojure
(ns demo
(:use net.cgrand.moustache)
(:use [ring.adapter.jetty :only [run-jetty]])) ;; hmmm Ring without servlets
@jramb
jramb / kormatest.clj
Created December 26, 2011 14:07
Playing with Clojure Korma SQL
(ns kormatest.core
(:require [korma.core :as sql])
(:require [korma.db :as db])
(:require [clojure.contrib.sql :as jdbc]))
(def play-con
(db/mysql {:db "playground"
;; :host "localhost" ;; optional?
:port "3406" ;; normal: 3306
:user "root"
@jramb
jramb / install-coffee-script.txt
Created February 2, 2012 19:56
Installing Coffee-script on Ubuntu
# install (old) nodejs package and npm
$ sudo apt-get install nodejs npm
# install coffee-script (globally)
$ sudo npm install -g coffee-script
@jramb
jramb / core.clj
Created February 14, 2012 20:01
Comparison of Aleph and Ring performance
(ns alephtest.core
(:require [lamina.core :as l])
(:require [aleph.http :as a])
(:require [ring.adapter.jetty :as jetty]))
;; https://github.com/ztellman/aleph
(def counter (atom 0))
(defn say-hello []
(let [n (swap! counter inc)]
@jramb
jramb / hash-password.clj
Created March 5, 2012 13:50
Password hashing in Clojure
(defn hash-password [password salt]
(assert (> (count salt) 10)) ;would like to have >64 bit of salt
(assert (> (count password) 6)) ;come on, how low can we go?
(let [md (java.security.MessageDigest/getInstance "SHA-512")
encoder (sun.misc.BASE64Encoder.)]
(.update md (.getBytes salt "UTF-8")) ;assume text salt
(.encode encoder
(loop [mangle (.getBytes password "UTF-8")
passes 1e5] ; paranoid, but are we paranoid enough?
(if (= 0 passes)
@jramb
jramb / Makefile
Last active October 3, 2015 04:48
Mandelbrot in different languages
all: mandelrs playc playmandel mandel.js
mandelrs: mandelrs.rs
playc: playc.c
%: %.c
gcc $^ -O2 -o $@
playmandel: playmandel.hs
@jramb
jramb / wsclj-core.clj
Last active December 11, 2015 04:49
Web Services in Clojure, simple example. Both server and client.
(ns wsclj.core
(:gen-class)
(:import [javax.jws WebService])
(:import [javax.xml.ws Endpoint]))
;; Based on a blog-comment by Jonathan Seltzer
(defprotocol Calculator
(hello [this yourname])
(add [this a b])
@jramb
jramb / luhn.clj
Created January 29, 2013 08:04
Luhn in Clojure
(defn- digits [n]
(map read-string (re-seq #"[0-9]" (str n))))
(defn luhn? [n]
(zero? (mod
(reduce +
(digits (reduce str
(map * (cycle [1 2]) (reverse (digits n))))))
10)))