Skip to content

Instantly share code, notes, and snippets.

@xeago
xeago / curl
Created October 23, 2016 20:04
> GET /api/rtm.start?token=snip HTTP/1.1
> User-Agent: curl/7.35.0
> Host: slack.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Access-Control-Allow-Origin: *
commit c251b8fb2c30d767f3eac253c645e2325c941473
Author: Twan Wolthof <xeago@spotify.com>
Date: Thu May 19 09:05:20 2016 +0000
wip
diff --git a/build.gradle b/build.gradle
index d718c40..2285d50 100644
--- a/build.gradle
+++ b/build.gradle
@xeago
xeago / retire.rb
Last active December 28, 2015 19:49 — forked from anonymous/retire.rb
terms = []
terms += { term: { category_id: params[:category_id] } } if params[:category_id].present?
# etc
filter :and, terms if not terms.empty?
@xeago
xeago / phi.rb
Created July 20, 2013 19:05
Usage: 10.phi #=> 4
class Integer
def phi
fractions = self.prime_division
primes = fractions.map { |b,e| b }
rationals = primes.map {|p| Rational(p-1,p) }
return (rationals.reduce { |a,b| a*b } * self).to_i
end
end
@xeago
xeago / gist:4657407
Last active December 11, 2015 20:48
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"test" : {
"properties" : {
"field" : {
"index" : "not_analyzed",
"type" : "string"
}
}
We will first describe the infrastructure in use at VideofyMe and introduce new
components. After this we will discuss the changes to the infrastructure and
provide test results of this new infrastructure. We will also discuss how the
software is built up of easy to extend components.
{
"query": {
"filtered": {
"query": { "match_all" },
"filter": {
"and": [
{ "type": { "value": "vets" } },
{ "geo_polygon": {
"geoLocation": {
"points": [
@xeago
xeago / gist:4625779
Created January 24, 2013 17:57
Elasticsearch directory layout
.
|-- bin
| `-- *
|-- config
| `-- *
|-- homebrew.mxcl.elasticsearch.plist
|-- lib
| `-- *
|-- libexec
| `-- *
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"number_of_shards" : 1
}
}
'
curl -XPUT 'http://127.0.0.1:9200/test/foo/1?pretty=1' -d '
{
"bar" : 5,
# [Tue Jun 21 12:05:39 2011] Protocol: http, Server: 192.168.5.103:9200
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"contact" : {
"properties" : {
"twitter" : {
"type" : "object",
"properties" : {
"profile" : {