Skip to content

Instantly share code, notes, and snippets.

View bartschuller's full-sized avatar

Bart Schuller bartschuller

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bartschuller on github.
  • I am bartschuller (https://keybase.io/bartschuller) on keybase.
  • I have a public key whose fingerprint is AE09 9E16 74C8 DB1E 4DB5 DC97 B984 8FE4 22CA 46BD

To claim this, I am signing this object:

@bartschuller
bartschuller / gist:da1c41722c055a44b61e
Created May 20, 2015 15:28
Upload logstash template settings to elasticsearch for use with fluentd
#!/bin/sh
curl -XPUT localhost:9200/_template/logstash -d '{"template":"logstash-*","settings":{"index.refresh_interval":"5s"},"mappings":{"_default_":{"dynamic_templates":[{"string_fields":{"mapping":{"index":"analyzed","omit_norms":true,"type":"string","fields":{"raw":{"index":"not_analyzed","ignore_above":256,"type":"string"}}},"match_mapping_type":"string","match":"*"}}],"properties":{"geoip":{"dynamic":true,"path":"full","properties":{"location":{"type":"geo_point"}},"type":"object"},"@version":{"index":"not_analyzed","type":"string"}},"_all":{"enabled":true}}},"aliases":{}}'
@bartschuller
bartschuller / evaluator.js
Created January 3, 2011 21:14
Example of how to eval and then eval some more, adding to the scope of the first eval.
var evaluatorString =
'(function(stuff) {'+
' return eval("(function() {"'+
'+stuff+'+
'"return "+evaluatorString+";'+
'})();");'+
'})';
var scope1 = eval(evaluatorString);
var scope2 = scope1('var myVar = 42;');
@bartschuller
bartschuller / proto.coffee
Created January 12, 2011 12:40
Figuring out prototypes
sys = require('sys')
print = sys.print
class A
bar: ->
print "A's bar\n"
this.baz()
baz: ->
@bartschuller
bartschuller / proto.js
Created January 12, 2011 12:41
Figuring out prototypes
var A, B, a, b, print, sys;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
sys = require('sys');
@bartschuller
bartschuller / scala transcript.txt
Created January 17, 2011 22:42
My new Scala Mechanize library is taking shape
scala> val agent = new org.smop.mechanize.Mechanize
agent: org.smop.mechanize.Mechanize = org.smop.mechanize.Mechanize@612e3937
scala> agent.get("http://www.smop.org/")
res0: org.apache.http.HttpResponse = org.apache.http.message.BasicHttpResponse@3ab5b692
scala> agent.isSuccess
res1: Boolean = true
scala> agent.isHtml
val a = List(1,2,3,4)
val b = List("A","B","C","D")
val c = Map() ++ a.zip(b)
@bartschuller
bartschuller / gist:1078610
Created July 12, 2011 18:23
Resolving imports in lesscss files for dependency tracking
import io.Source
import java.io.File
object Stuff {
val Import = """.*@import\s*"(.*?)".*""".r
def allLessFiles(initial: File): Set[File] =
Set(initial) ++ Source.fromFile(initial).getLines().flatMap[File](_ match {
case Import(file) => allLessFiles(new File(initial.getParentFile, file))
case _ => Set.empty
@bartschuller
bartschuller / dyn.scala
Created August 7, 2011 14:09
Example of Scala's Dynamic trait as implemented in Scala 2.9.0 with scalac -Xexperimental
// Compile this with scala 2.9.x and an extra option:
// scalac -Xexperimental dyn.scala
/**
* Example to show off the Dynamic trait.
*
* Create an instance, call methods on it (the methods return this
* so you can chain calls), then call result.
**/
class ListBuilder extends Dynamic {
@(helloForm: Form[(String,Int,Option[String])])
@import helper._
@main(title = "The 'helloworld' application") {
<h1>Configure your 'Hello world':</h1>
@form(action = routes.Application.sayHello, args = 'id -> "helloform") {