Skip to content

Instantly share code, notes, and snippets.

// write literal true
ByteArrayOutputStream bs1 = new ByteArrayOutputStream();
(new ObjectOutputStream(bs1)).writeObject(true);
// write Boolean.TRUE
ByteArrayOutputStream bs2 = new ByteArrayOutputStream();
(new ObjectOutputStream(bs2)).writeObject(Boolean.TRUE);
// did we write same bytes? yes.
System.out.println(Arrays.equals(bs1.toByteArray(), bs2.toByteArray())); // true
@ragnard
ragnard / upstart
Created May 25, 2015 21:20
/etc/logrotate.d/upstart
/var/log/upstart/*.log {
daily
missingok
rotate 7
compress
notifempty
nocreate
}
(require '[clj-kafka.core :refer [with-resource]]
'[clj-kafka.consumer.zk :as kafka.consumer])
(defn deserialize-message
[message]
message)
(defn production-traffic?
[event]
true)
.classpath: project.clj
lein classpath \
| tr ':' '\n' \
| sed '/\.jar/!d' \
> .classpath
repl: .classpath
@java -cp $(shell cat .classpath | tr '\n' ':') clojure.main -i nrepl.clj -r
.PHONY: repl
\d+ clickouts
Table "public.clickouts"
Column | Type | Modifiers | Storage | Stats target | Description
------------+-----------------------------+-----------+----------+--------------+-------------
click_ref | character varying(36) | not null | extended | |
click_date | timestamp without time zone | not null | plain | |
deal_id | character varying(40) | not null | extended | |
raw_data | jsonb | not null | extended | |
user_agent | jsonb | | extended | |
Indexes:
user=> (doc redis/atomically)
-------------------------
redis/atomically
([& body])
Macro
Execute all redis commands in body atomically, ie. sandwiched in a
MULTI/EXEC statement. If an exception is thrown the EXEC command
will be terminated by a DISCARD, no operations will be performed and
the exception will be rethrown.
;;
;; Implementation of exercise 2 found at:
;; http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-1/
;;
;; Part of code sparring evening at the first SCLOJUG meeting,
;; unfinished then, finished now.
;;
;; Horrible specification btw.
;;
;; Setup Mac keys
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
using System.Messaging;
using System.Transactions;
using NHibernate.Criterion;
using NUnit.Framework;
using System.Collections;
namespace NHibernate.Test.NHSpecificTest.NH2238
{
@ragnard
ragnard / ASQ.cs
Created November 29, 2010 20:19
Attribute Scoped Queries made easier.
public class Group
{
[DirectoryAttribute("member")]
public IList<string> Members { get; set; }
}
public class User
{
[DirectoryAttribute("objectGUID")]
public Guid ObjectGUID { get; set; }