Skip to content

Instantly share code, notes, and snippets.

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; }
@ragnard
ragnard / Client usage
Created September 24, 2011 07:29
StatsD Example
// Create a client for sending metrics to "localhost:8125", prefixing all keys with "foo.bar"
using(var client = new StatsClient("localhost", 8125, "foo.bar"))
{
// Increment a counter
client.Incremenet("counter1"); // sends 'foo.bar.counter1:1|c'
// Increment a counter by 42
client.Incremenet("counter2", 42); // sends 'foo.bar.counter2:1|c'
// Decrement a counter by 5, sampled every 1/10th time
@ragnard
ragnard / irb
Created January 12, 2012 10:18
:class locator issue
1.9.2p290 :001 > require 'watir-webdriver'
=> true
1.9.2p290 :002 > browser = Watir::Browser.new :firefox
=> #<Watir::Browser:0x27fd323015c1b386 url="about:blank" title="">
1.9.2p290 :003 > browser.goto "file:///page.html"
=> "file:///Users/ragge/tmp/page.html"
1.9.2p290 :006 > browser.element(:class => "b").text
=> "Blahonga"
1.9.2p290 :008 > browser.div(:class => "b").text
Watir::Exception::UnknownObjectException: unable to locate element, using {:class=>"b", :tag_name=>"div"}
qnet.ModelCollection.prototype.contains = function(obj, identityFn) {
var objIdentity = identityFn(obj)
return goog.array.find(this.models, function(model) {
var modelIdentity = identityFn(model);
if(modelIdentity == objIdentity) {
return true;
} else {
return false;
@ragnard
ragnard / mapping.txt
Created May 29, 2012 08:14
URL mapping
Typ såhär menar jag:
/users -> UserResourse.QueryUsers
/users/{userId} -> UserResource.GetUser(userId)
/users/{userId}/computers -> ComputerResource.GetComputers(userId)
/users/{userId}/computers/{computerId} -> ComputerResource.GetComputer(userId, computerId)
@ragnard
ragnard / gist:3787321
Created September 26, 2012 10:56
Gurka
<head>
<script src="[path to closure library root]/closure/goog/base.js"></script>
<script>
goog.require('goog.dom');
</script>
</head>
...
<script>