Skip to content

Instantly share code, notes, and snippets.

View algesten's full-sized avatar
😀
barcelona!

Martin Algesten algesten

😀
barcelona!
View GitHub Profile
@algesten
algesten / Procfile
Created January 31, 2012 13:52
heroku static hosting with node.js
web: node web.js
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("")
base = alphabet.length
exports.encode = (i) ->
return alphabet[0] if i is 0
s = ""
while i > 0
s += alphabet[i % base]
i = parseInt(i / base, 10)
@algesten
algesten / gist:5874476
Created June 27, 2013 06:55
Similarity that disregards the length of the field.
private final static Similarity NO_LENGTH_SIMILARITY = new DefaultSimilarity() {
// we are interested in length norm for the street number field.
// it's good if 10 is sorted before 10a and 10b.
//
// the "country" field is very important it has no document boost since that means
// simply turning Query.setCountry() on will make a different score. This is because
// a document boost will add to every field and country is matched in a MUST.
@Override
public float computeNorm(String field, FieldInvertState state) {
@algesten
algesten / gist:5974504
Created July 11, 2013 10:55
tomcat startup-fel för pbwebapp.
2:48:22,567 INFO [context.ContextLoader] Root WebApplicationContext: initialization completed in 6169 ms
Jul 11, 2013 12:48:22 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter ofp-basic-auth
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
set = (v) -> (f) -> f(v)
get = (f) -> f (v) -> v
t = set(42)
get(t) // 42
@algesten
algesten / gist:60e532d938111e8d4eec
Last active August 29, 2015 14:14
install logstash with lusis/chef-logstash 0.11.2

install logstash with lusis/chef-logstash 0.11.2

My json config file

Notice that java, elasticsearch and rabbitmq are already set up in my system.

{
    "name": "logstash-server",
@algesten
algesten / body_html5-spec.md
Last active September 11, 2015 13:39
body_html5-spec

body_html5 spec 1.2

This is a "loose" spec for the body_html5 part of [ttninjs][ttninjs].

Revision history

  • 1.3 Clarify html-doc structure
  • 1.2 alt-attribute in ``, div.byline before `figcaption` (to be html5-valid)
module.exports = class Bundlr
FORMAT_TTNITF: 'ttnitf'
FORMAT_PICTURE: 'bild' # deliberate to match OFP
FORMAT_TTNINJS: 'ttninjs'
FORMAT_INDESIGN: 'indesign'
FORMAT_CUTPASTE: 'cutpaste' # txt-format in media-moj
FORMAT_TTNITFXML: 'ttnitfxml'
# ofp spec is "ttninf", "ttnintf+bild", "ttinjs" etc
@algesten
algesten / tt_newsml-spec.md
Last active April 11, 2016 17:00
tt_newsml-spec.md

TT NewsML spec

TT:s main content format is ttninjs. The XML variant is a IPTC NewsML G2 2.20 compliant translation of ttninjs where each field somehow relates back to the original ttninjs.

Revision history

1970-01-01 behandlas som null
versioncreated = datum dokumentet skapas. (sdl fotodatum med tidsdel 00:00)
versionstored = indexeringsdatum. om vi är master, eget annars ta källan (sdl typ)
date = datum dokumentet gäller (t.ex. framtid för planering
eller framtid grafik, men fotodatum för sdl)
if tidsdel för date finns
datetime = samma logik som date men med tidsdel. annars null.