Skip to content

Instantly share code, notes, and snippets.

View chids's full-sized avatar
👻
Not my 🎪, not my 🐒's.

Mårten Gustafson chids

👻
Not my 🎪, not my 🐒's.
View GitHub Profile
@chids
chids / telia-homerun-amaranten-2010-10-27
Created October 27, 2010 17:47
Försöker logga in på Telia homerun på Hotell Amaranten i Stockholm
$ curl -v http://login.homerun.telia.com
* About to connect() to login.homerun.telia.com port 80 (#0)
* Trying 10.0.0.6... connected
* Connected to login.homerun.telia.com (10.0.0.6) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: login.homerun.telia.com
> Accept: */*
>
< HTTP/1.1 302 Found
@chids
chids / RandomRange.java
Created February 13, 2011 13:19
Random number within range
class RandomRange
{
private final int max;
private final int min;
public RandomRange(final int min, final int max)
{
this.min = min;
this.max = max;
}
@chids
chids / SubEthaSMTP.java
Created February 15, 2011 11:37
SubEthaSMTP usage outline
final SMTPServer server = new SMTPServer(new SimpleMessageListenerAdapter(new SimpleMessageListener()
{
@Override
public void deliver(final String from, final String recipient, final InputStream data) throws TooMuchDataException, IOException
{
System.err.println(from + " -> " + recipient);
}
@Override
public boolean accept(final String from, final String recipient)
@chids
chids / mochiweb-make-app-wrong-rebar.conf
Created March 11, 2011 13:43
mochiweb make app generates invalid rebar.config?
When trying to make a project created with Mochiweb "make app" I got:
Pulling mochiweb from {git,"git://github.com/mochi/mochiweb.git",[]}
Cloning into mochiweb...
error: pathspec 'origin/' did not match any file(s) known to git.
ERROR: git checkout -q origin/ failed with error: 1
make: *** [all] Error 1
The mochiweb dependency in rebar.conf looked like this:
{git, "git://github.com/mochi/mochiweb.git", ""}}]}.
@chids
chids / confluence-whats-my-space
Created March 15, 2011 09:57
Confluence Wiki: Get the space key of the space that this page is being rendered in
##
## Atlassian Confluence Wiki User Macro
##
## Example of how to get the space key of the space that this page is being rendered in
## ie, not necessarily the same space as the page belongs to
##
#set($space=$renderContext.getOriginalContext().getSpaceKey())
## This will allow you to do magic based on the space
@chids
chids / neo4j-spatial-test-pom.xml
Created March 16, 2011 13:44
Test POM for playing with Neo4J Spatial
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>neo4j-spatial</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
@chids
chids / nginx-file-extension-to-accept-header.txt
Created March 17, 2011 11:54
How to set the HTTP accept header based on the file extension in Nginx
# Copy the accept header to a variable
set $acceptHeader $http_accept;
# Does the request end in xml or json?
if ($uri ~ ^(.*)\.(xml|json)$) {
# Create a new accept header...
set $acceptHeader "application/$2";
# ...and remove the extension from the path
rewrite ^(.*)\.(xml|json)$ $1 last;
}
-module(a).
-export([tgif/0]).
-define(MUSIC_ASSOCIATIONS, [{ellnestam, "Love Gun"}, {jockeholm, "Family Affair"}, {mahnve, "My name is (Slim Shady)"}]).
tgif() -> tgif(?MUSIC_ASSOCIATIONS).
tgif([{Person, Track}|Others]) ->
io:format("@~w plays '~s'~n", [Person, Track]),
tgif(Others);
tgif([]) -> "Hey! It's friday, have a beer!".
@chids
chids / Macro
Created May 30, 2011 20:23
Confluence Macro - Render XML response from HTTP service
#set($path=$param0.replace("::", "="))
#set($space=$renderContext.getOriginalContext().getSpaceKey())
#if($space.equals("PRIVATE"))
#set($domain="http://your.internal.url")
#else
#set($domain="http://your.public.url")
#end
#set($url="${domain}${path}")
@chids
chids / init.pp
Created June 21, 2011 17:51
Puppet Riak Manifest
class riak {
$configbase = "/etc/riaksearch"
$riak_dir = "/var/lib/riaksearch"
$username = "riak"
package { "riak-search": ensure => latest, }
user { $username:
shell => '/bin/bash',
comment => 'Basho Riak',