Skip to content

Instantly share code, notes, and snippets.

View mjul's full-sized avatar

Martin Jul mjul

View GitHub Profile
@mjul
mjul / Instructions.md
Created August 25, 2012 14:51
How to make pallet-hadoop-example work without #<JSchException com.jcraft.jsch.JSchException: Auth fail>

First, generate a set of SSH keys in the local directory (./ec2key_rsa) to use for the experiment with the ssh-keygen command:

pallet-hadoop-example$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/mjul/.ssh/id_rsa): ./ec2key_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ./ec2key_rsa.
Your public key has been saved in ./ec2key_rsa.pub.
@mjul
mjul / pallet-intro.clj
Created August 24, 2012 23:13
Start and stop an Amazon EC2 server in EU region from Pallet
(defn start [config]
(pallet.core/converge
(pallet.core/group-spec "mygroup"
:count 1
:node-spec (pallet.core/node-spec
:image {:os-family :ubuntu}
:location {:location-id "eu-west-1"})) ;; :location-id is the name of the AWS Region
:compute config))
@mjul
mjul / app.config
Created July 31, 2012 14:42
SpecFlow set default language for features to (example, set it to #language: da)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<specFlow>
<language feature="da-DK" tool="" />
</specFlow>
@mjul
mjul / master.proj
Created March 22, 2012 17:04
MSBuild start and stop WCF service host
<PropertyGroup>
<WcfSvcHost>$(MSBuildProjectDirectory)\Build\WcfServiceHost\wcfsvchost.exe</WcfSvcHost>
<AsyncStartWcfServiceHostCode>
<![CDATA[
Public Shared Function ScriptMain() as String
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.arguments = "/service:App\MyApp.Server.Services\bin\Debug\MyApp.Server.Services.dll /config:App\MyApp.Server.Services\bin\Debug\MyApp.Server.Services.dll.config"
@mjul
mjul / Tree.feature
Created January 27, 2012 12:29
Tip for formatting tree data structures in Cucumber / SpecFlow
# You can use indentation to make tree data more readable in tables
# The step defs use the ids to link up the data, and trims
# the indentation / underscores which is just there to
# visualize the tree structure
Given the following org units
| id | parent | name |
| 1 | | Corporate |
| 11 | 1 | __ Danish Subsidiary |
| 12 | 1 | __ Partner Company |
@mjul
mjul / ResharperUnitTestTemplate
Created January 13, 2012 15:18
C# Unit Test "File Template" for Resharper (mstest)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace $namespace$
{
[TestClass]
public class $class_under_test$
@mjul
mjul / websocket.clj
Created December 6, 2011 16:12
Clojure JVM Kaazing JMS STOMP websocket client
(ns apiclient.websocket
(:import (java.net URL)
(java.util Properties)
(javax.naming Context InitialContext)
(javax.jms BytesMessage Connection ConnectionFactory Destination
ExceptionListener JMSException
Message MessageConsumer MessageListener MessageProducer
Session TextMessage Topic TopicSubscriber)
(com.kaazing.gateway.jms.client.stomp StompInitialContextFactory
GenericBaseMessage GenericBaseMessageImpl
@mjul
mjul / scatter-plot.clj
Created October 24, 2011 14:35
Incanter: Customize scatter-plot to have single-pixel points
;; Customize scatter plot to have single-pixel points
(let [sp (scatter-plot (range 10) (range 10))
r (-> sp .getXYPlot .getRenderer)]
(.setSeriesShape r 0 (java.awt.Rectangle. 0 0 1 1))
(view sp))
@mjul
mjul / incanter-charts.clj
Created October 24, 2011 11:40
Clojure pattern for named parameters with defaults
;; From Incanter Charts - neat way to do named parameters with defaults in Clojure:
([chart & options]
(let [{:keys [width dash series dataset]
:or {width 1.0 dash 1.0 series 0 dataset 0}} (apply hash-map options)
@mjul
mjul / CustomSerializer.clj
Created October 16, 2011 17:42
Custom Serialization from Clojure for Backtype Storm (Joda DateTime example)
(ns storm-tutorial.CustomSerializer
(:import [backtype.storm StormSubmitter LocalCluster]
[backtype.storm.serialization ISerialization]
[java.io DataInputStream DataOutputStream]
[org.joda.time DateTime])
(:use [backtype.storm clojure config]
[clj-time.core :only (date-time now)]
[clj-time.format :only (formatters parse unparse)])
(:gen-class
:implements [backtype.storm.serialization.ISerialization]))