This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UUID uuid = UUID.randomUUID() | |
String partone = ""+ Long.toString(uuid.getMostSignificantBits(), 36) | |
String parttow = ""+ Long.toString(uuid.getLeastSignificantBits(), 36) | |
String k = "PREFIX$partone$parttow".replace("-", "") | |
String l = k.length() | |
println "UUID short version ($l) : $k" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.text.SimpleDateFormat dataformat = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'"); | |
dataformat.setTimeZone(TimeZone.getTimeZone("Europe/Copenhagen")); // locale time | |
println dataformat.format(new Date()) | |
dataformat.setTimeZone(TimeZone.getTimeZone("UTC")); // zulu time | |
println dataformat.format(new Date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* create token for accessing service */ | |
format = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") | |
timestamp = format.format(new Date(System.currentTimeMillis())) | |
sks = new javax.crypto.spec.SecretKeySpec("OuH5pmYeLIkqiirwiyvY+w==".getBytes(), "AES") | |
cip = javax.crypto.Cipher.getInstance("AES") | |
cip.init(javax.crypto.Cipher.ENCRYPT_MODE, sks, cip.getParameters()); | |
raw = cip.doFinal( timestamp.getBytes() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $HOME/.gitconfig | |
[user] | |
name = Frank Vilhelmsen | |
email = fv at frankvilhelmsen.com | |
[github] | |
user = frankvilhelmsen | |
token = token | |
[color] | |
ui = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0x00c0: 3834 3831 3337 333d 3d3d 0d0a 436f 6e74 8481373===..Cont | |
0x00d0: 656e 742d 4469 7370 6f73 6974 696f 6e3a ent-Disposition: | |
0x00e0: 2066 6f72 6d2d 6461 7461 3b20 6e61 6d65 .form-data;.name | |
0x00f0: 3d22 7061 7373 776f 7264 220d 0a43 6f6e ="password"..Con | |
0x0100: 7465 6e74 2d54 7970 653a 2074 6578 742f tent-Type:.text/ | |
0x0110: 706c 6169 6e3b 2063 6861 7273 6574 3d49 plain;.charset=I | |
0x0120: 534f 2d38 3835 392d 310d 0a0d 0a76 6572 SO-8859-1....ver | |
0x0130: 6131 3233 0d0a 2d2d 3d3d 3d31 3336 3438 a123..--===13648 | |
0x0140: 3938 3438 3133 3733 3d3d 3d0d 0a43 6f6e 98481373===..Con |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns package.classname | |
(:require [clojure.xml :as xml] | |
[clojure.java.jdbc :as jdbc])) | |
(:import java.sql.Types) | |
(def db {:classname "oracle.jdbc.driver.OracleDriver" | |
: .... | |
:password (System/getenv "password")}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.* | |
import static java.util.concurrent.TimeUnit.* | |
long now = System.currentTimeMillis() | |
// process | |
NORMAL = 1000; LONG = 2000; LIMIT = 1000 | |
def MAX = 100 | |
def LOW = (MAX * 0.05) // < 5% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns package.classnamere) | |
(:import java.sql.Types) | |
(def db {:classname "oracle.jdbc.driver.OracleDriver" | |
:.... | |
:password (System/getenv "password")}) | |
(defn prepared-statement " on oracle stored procedure " [] | |
(jdbc/with-connection db | |
(with-open [stmt (.prepareCall (jdbc/connection) "{ call PACKAGE.PROCEDURE(?, ?) }")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog.sms | |
(use blog.common) | |
(:require [clojure.data.json :as json] | |
[clj-http.client :as client])) | |
(defn post "the data to sms gateway over http" [body] | |
(client/post "http://api/rpc/bulk/" { | |
:debug true | |
:multipart [ | |
{:name "username" :content "******"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This utility class provides an abstraction layer for sending multipart HTTP | |
* POST requests to a web server. | |
* @author www.codejava.net | |
* | |
*/ | |
public class MultipartUtility { | |
private final String boundary; | |
private static final String LINE_FEED = "\r\n"; | |
private HttpURLConnection httpConn; |
NewerOlder