Skip to content

Instantly share code, notes, and snippets.

View jramb's full-sized avatar

Jörg Ramb jramb

  • Stockholm
  • 07:48 (UTC +02:00)
View GitHub Profile
@jramb
jramb / nic_validate_se_persnr_mod.js
Created October 27, 2023 06:43
Luhn validation of swedish personal id number
/**
* @NApiVersion 2.1
*
* @Description nic_validate_se_persnr_mod.js
* @Solution Generic module
*
* @Copyright 2023 Noresca IT Consulting AB
* @Author jorg.ramb <jorg.ramb@noresca.se>
*
* # Explanation
@jramb
jramb / keybase.md
Created February 6, 2016 21:38
keybase.md

Keybase proof

I hereby claim:

  • I am jramb on github.
  • I am jramb (https://keybase.io/jramb) on keybase.
  • I have a public key ASDOFoydae_xmR9tVPSYO8rejULQNTtghARbtdhWwhAgdgo

To claim this, I am signing this object:

@jramb
jramb / TryIt
Created June 10, 2015 09:45
Calling a WS from Java using WSsecurity (cleartext PW), building XML manually, no XMLBeans
package xxcust.testClient;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
@jramb
jramb / levenshtein.sql
Last active December 30, 2015 11:39
String distance metric - Levenshtein distance Optimized with some efford, still, performance depends heavily on the length of the input. Example: select xx_tools_pkg.levenshtein_dist('Hejsan', 'hejsan'), xx_tools_pkg.levenshtein_dist('kitten', 'sitting') from dual; Returns distances of 1 and 3. Probably you would want to apply upper/lower on the…
-- Levenshtein is a string distance metric
-- https://en.wikipedia.org/wiki/Levenshtein_distance
function levenshtein_dist(p_s varchar2, p_t varchar2)
return number deterministic
is
type int_t is table of pls_integer index by pls_integer;
type char_t is table of char(2) index by pls_integer;
v0 int_t;
v1 int_t;
t char_t; -- copy of p_t for performance
@jramb
jramb / ebs-logged-in-users.sql
Last active June 15, 2023 20:49
List all users currently logged in on Oracle EBS.This select lists all users currently logged in (only potentially, since they might have ended the session without loggin out).
select last_connect, usr.user_name, resp.responsibility_key, function_type, icx.*
from apps.icx_sessions icx
join apps.fnd_user usr on usr.user_id=icx.user_id
left join apps.fnd_responsibility resp on resp.responsibility_id=icx.responsibility_id
where last_connect>sysdate-nvl(FND_PROFILE.VALUE('ICX_SESSION_TIMEOUT'),30)/60/24
and disabled_flag != 'Y' and pseudo_flag = 'N'
@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)))
@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 / 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 / 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)