Skip to content

Instantly share code, notes, and snippets.

Jan Lehnardt janl

Block or report user

Report or block janl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View checkStorage.js
module.exports.checkStorage = function () {
try {
global.mozSimpleStorage = require('sdk/simple-storage');
} catch() {
global.mozSimpleStorage = false;
}
if (chrome.storage) { // We're running inside the Chrome/Web Extension context
return 'chromeOrWebExt';
} else if (window.localStorage) { // We're running inside a normal webpage
View gist:7290789
Title:
Service Orientated Architecture to scale to infinity and beyond
or
Service Orientated Architecture for robust and scalable systems
Proposal:
Software Architecture is hard. And when your business grow, its getting even harder because scaling doesn’t come out the box and it’s not only the software which grows it’s also the team. So you have to find a way how to scale your software in a way that it stays easy maintainable for growing teams and scalable. I’d like to talk about Service Orientated Architecture in general and also share some experience and give some examples where SOA would save your ass and maybe places where SOA isn’t the best idea to implement.
View hu.md

Title: Service Orientated Architecture to scale to infinity and beyond or Service Orientated Architecture for robust and scalable systems

Proposal: Software Architecture is hard. And when your business grow, its getting even harder because scaling doesn’t come out the box and it’s not only the software which grows it’s also the team. So you have to find a way how to scale your software in a way that it stays easy maintainable for growing teams and scalable. I’d like to talk about Service Orientated Architecture in general and also share some experience and give some examples where SOA would save your ass and maybe places where SOA isn’t the best idea to implement.

View gist:4742336
# list by how many inhabitants all in all
select district, sum(quantity) from inhabitants group by district order by sum(quantity);
# list by how many women per district
select district, sum(quantity) from inhabitants where gender = 'f' group by district order by sum(quantity);
# list by how many children per district pre-school (0-5)
select district, sum(quantity) from inhabitants where age_low = '0' group by district order by sum(quantity);
# is indeed Prenzlauer Berg the district with the most children implying as many parents as well?
View maintenance.html
<h1>Maintenance Releases of Apache CouchDB 1.0.4, 1.1.2, and 1.2.1</h1>
<p>The Apache CouchDB project is pleased to announce a set of maintenance releases</p>
<h2>CouchDB 1.0.4</h2>
<ul>
<li>Fix file descriptor leak in _log.</li>
<li>Fix missing revisions in _changes?style=all_docs.</li>
<li>Fix validation of attachment names.</li>
View gist:4271866
var cradle = require('cradle');
var usersdb = new(cradle.Connection)().database('users');
var documentsdb = new(cradle.Connection)().database('documents');
/*
* GET users listing.
*/
exports.user = getUser;
View gist:4271837
var cradle = require('cradle');
var usersdb = new(cradle.Connection)().database('users');
var documentsdb = new(cradle.Connection)().database('documents');
/*
* GET users listing.
*/
exports.user = getUser;
@janl
janl / rss-subscribers.sh
Created Sep 25, 2012 — forked from marcoarment/rss-subscribers.sh
Bash script to parse Apache log for a count of RSS subscribers and email it to you
View rss-subscribers.sh
#!/bin/sh -e
# sh for portability, -e for halt on errors
# Schedule this to run once a day with cron. Doesn't matter what time since it parses yesterday's hits (by default).
# I only tested this on the Marco.org server, which runs CentOS (RHEL). No idea how it'll work on other distributions, but it's pretty basic.
# Required variables:
RSS_URI="/rss"
MAIL_TO="your@email.com"
LOG_FILE="/var/log/httpd/access_log"
View gist:552288

Using CouchDB with node.js

First, get yourself a CouchDB! You can get a free hosted CouchDB in seconds or download a binary from the Couchio downloads page.

Next, install npm because all awesome node packages are in npm :)

Node has better support for HTTP than any language I've ever worked with and coincidentally CouchDB's interface is solely accessible via HTTP. First, let's just talk to CouchDB using an HTTP library and later we'll look at some higher level abstractions.

Talking to CouchDB using request

View mustache3.js
> rake
(in /Users/jan/Work/mustache.js)
..FFFFFFFFFFFF....FFF.F.FFFFFFFFFF.F.FFFFFFFFFFFFFFFFFFF
1)
'mustache array_of_strings should generate the correct html' FAILED
expected: "hello world \n",
got: "\n hello world \n" (using ==)
./test/mustache_spec.rb:71:
You can’t perform that action at this time.