Skip to content

Instantly share code, notes, and snippets.

View knutwalker's full-sized avatar
🦀

Paul Horn knutwalker

🦀
View GitHub Profile
@knutwalker
knutwalker / GLAT-1.py
Created May 9, 2012 21:42
Python: Solve GLAT question 1
#!/usr/bin/env python
"""
A brute-force approach to solve the first quesiton of GLAT
More about GLAT: http://googleblog.blogspot.de/2004/09/pencils-down-people.html
The question is as follows:
1. Solve this cryptic equation, realizing of course that values for M and E
could be interchanged. No leading zeros are allowed.
@knutwalker
knutwalker / GLAT17.py
Created May 9, 2012 22:06
Python: Solve GLAT question 17
#!/usr/bin/env python
"""
A brute-force approach to solve the seventeenth quesiton of GLAT
More about GLAT: http://googleblog.blogspot.de/2004/09/pencils-down-people.html
The questoin is as follows:
17. Consider a function which, for a given whole number n,
returns the number of ones required when writing out all numbers
@knutwalker
knutwalker / imdb_to_trakt.py
Created October 14, 2012 03:29
Migrate movies from a public watchlist from IMDb into your private watchlist on trakt.
#!/usr/bin/env python
import csv
import collections
import re
import json
import requests
@knutwalker
knutwalker / gist:3905668
Created October 17, 2012 14:04
Simplest ES creation
# start...
$ bin/elasticsearch
# ... with nothing
$ curl -XDELETE localhost:9200
{"ok":true,"acknowledged":true}
# index document
$ curl -XPUT http://localhost:9200/index1/type1/id1 -d '{"title": "foo", "tags": ["bar", "baz"]}'
{"ok":true,"_index":"index1","_type":"type1","_id":"id1","_version":1}
@knutwalker
knutwalker / AbstractResource.java
Last active November 8, 2016 21:06
Jersey2 + Swagger with Resource inheritance
package com.example;
import com.wordnik.swagger.annotations.ApiParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
package stackoverflow;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
@knutwalker
knutwalker / ga.js
Last active May 11, 2016 02:47
Variation of the Universal Analytics tracking Code (Google Analytics). It can only be safely included once since it overwrites itself. The original script does check against that. Also, document.scripts is not available in Firefox < 9
(function(G,O,o,g,l,e){G.GoogleAnalyticsObject=O;G[O]=function(){G[O].q.push(arguments)},G[O].q=[],G[O].l=+new Date;e=o.createElement('script'),l=o.scripts[0];e.src=g;l.parentNode.insertBefore(e,l)}(this,'ga',document,'//www.google-analytics.com/analytics.js'));
// ===>
ga('create', 'UA-XXXXXXX-Y');
ga('send', 'pageview');
@knutwalker
knutwalker / repl.txt
Created April 10, 2014 08:18
so_22953741
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import spray.json._
import spray.json._
scala> import DefaultJsonProtocol._
package org.example;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LongField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@knutwalker
knutwalker / README.md
Last active April 19, 2023 16:17
Git commit graph to Neo4j

Installation

  • requires python 2.7 (maybe python 3.3+ will work too, didn't tested it)

Put git2neo.py somewhere in your $PATH and chmod +x it.

Usage