Skip to content

Instantly share code, notes, and snippets.

@BenHall
BenHall / if_eql.js
Created September 6, 2015 17:47
hbs if_eql
hbs.registerHelper('if_eql', function(v1, v2, context) {
if(v1 === v2) {
return context.fn(this);
}
return context.inverse(this);
});
@BenHall
BenHall / app.cs
Created September 5, 2015 18:53
Example of loading a file into Scrapbook's editor
public class Hello1
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
> ping 172.17.5.108
PING 172.17.5.108 (172.17.5.108) 56(84) bytes of data.
64 bytes from 172.17.5.108: icmp_seq=1 ttl=64 time=0.094 ms
64 bytes from 172.17.5.108: icmp_seq=2 ttl=64 time=0.063 ms
64 bytes from 172.17.5.108: icmp_seq=3 ttl=64 time=0.063 ms
^C
--- 172.17.5.108 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.063/0.073/0.094/0.016 ms
@BenHall
BenHall / gist:bab721dfba3b32c36f88
Created May 28, 2015 13:45
Adding in JavaScript
> var total = 0
undefined
> total += 4.4
4.4
> total += 4.4
8.8
> total += 4.4
13.200000000000001
var total = 0.0
undefined
@BenHall
BenHall / gist:e353806d304fd28ddd52
Created October 12, 2014 22:32
One more reason for docker - Java
TheNewPretty:elasticsearch-1.3.4 ben$ ./bin/elasticsearch
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
@BenHall
BenHall / docker.sh
Created October 7, 2014 16:55
Start a redis docker instance
$ docker run -d --name redis -p 6379 redis
d55a755b91c1ce040625c3843cb71a5f3f037ee456954af716df0e1f1005b232
$ docker port redis 6379
0.0.0.0:49154
@BenHall
BenHall / Space.sh
Created September 9, 2014 07:56
Find largest folders on ubuntu - useful for Docker
du --max-depth=7 /* | sort -n
@BenHall
BenHall / cmd.sh
Last active August 29, 2015 14:05
ElasticSearch bug with dots in document type?
curl -XPUT 'http://localhost:9200/twitter/twee.t/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}'
curl -X GET 'http://localhost:9200/twitter/_search?q=user:kimchy'
curl -X GET 'http://localhost:9200/twitter/twee.t/_search?q=user:kimchy'
curl -X GET 'http://localhost:9200/twitter/tw*/_search?q=user:kimchy'
var prediction Prediction
get_resp := elasticsearch.Get(index, key)
if(get_resp == nil) {
prediction = Prediction {EventId: eventId, UserId: userid}
} else {
json.Unmarshal(*get_resp.Source, &prediction)
}
//cannot convert nil to type elasticsearch.ElasticGetResponse
@BenHall
BenHall / get.go
Last active August 29, 2015 14:05
func Get(id string, inter interface{}) {
baseUrl := "http://localhost:9200"
index := "fixtures"
url := fmt.Sprintf("%v/grandslam/%v/%v", baseUrl, index, id)
response, err := http.Get(url)
if err != nil {
fmt.Printf("Error: %s", err)
}