Skip to content

Instantly share code, notes, and snippets.

View olivere's full-sized avatar

Oliver Eilhard olivere

  • Alt F4
  • Munich, Germany
View GitHub Profile
@olivere
olivere / gist:730591
Created December 6, 2010 17:17
Problem with STI and scopes
# Let's start off with a company and a buyer model
class Company < ActiveRecord::Base
has_many :users
end
class Buyer < Company
# Makes sure that +user+ only gets the buyers she may see.
# If +user+ is nil we assume anonymous.
def self.for(user)
@olivere
olivere / jQuery keyboard events
Created February 22, 2011 13:46
A test for keyboard events
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Keypress Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(function() {
$(document).keypress(function(e) {
console.dir(e);
@olivere
olivere / gist:877805
Created March 19, 2011 21:10
em-http-request with capturing and passing cookies on redirects
# Gemfile
source "http://rubygems.org"
gem 'eventmachine', '~>1.0.0.beta.3'
gem 'em-synchrony', '~>0.3.0.beta.1'
gem 'em-http-request', '~>1.0.0.beta3'
gem 'addressable', :require => 'addressable/uri'
# Capturing and passing cookies on redirects
require "rubygems"

Keybase proof

I hereby claim:

  • I am olivere on github.
  • I am olivere (https://keybase.io/olivere) on keybase.
  • I have a public key whose fingerprint is 673A C913 DD38 B088 A1DD 5376 BDDC E308 FF6D 71E5

To claim this, I am signing this object:

@olivere
olivere / connect.go
Last active August 29, 2015 14:18
Connecting to Elasticsearch via Elastic (the infinite loop edition)
package main
import (
"fmt"
"time"
"runtime"
"github.com/olivere/elastic"
)
@olivere
olivere / elastic-issue-107.go
Created July 27, 2015 09:45
Elastic: Sharing a client
package main
import (
"log"
"sync"
elastic "gopkg.in/olivere/elastic.v2"
)
var (
@olivere
olivere / elastic-issue-107-2.go
Created July 28, 2015 08:50
elastic-issue-107-2.go
package main
import (
"fmt"
"log"
"sync"
elastic "gopkg.in/olivere/elastic.v2"
)
@olivere
olivere / pool.go
Created November 26, 2015 08:50
Very simple bulk pool for elastic/Elasticsearch.
package bulk
import (
"errors"
"sync"
"time"
"gopkg.in/olivere/elastic.v3"
)
@olivere
olivere / bulk_processor_example1.go
Created January 16, 2016 11:17
Example #1 of bulk processor usage
// This is an example of using elastic's BulkProcessor with Elasticsearch.
//
// See https://github.com/olivere/elastic and
// and https://github.com/olivere/elastic/wiki/BulkProcessor
// for more details.
/*
* This example illustrates a simple process that performs bulk processing
* with Elasticsearch using the BulkProcessor in elastic.
*
@olivere
olivere / elastic_v3_getting_started.go
Created June 4, 2016 11:44
Getting started with elastic.v3
package main
import (
"encoding/json"
"fmt"
"reflect"
elastic "gopkg.in/olivere/elastic.v3"
)