Skip to content

Instantly share code, notes, and snippets.

@ruflin
ruflin / Xodoa_Helper::toUrl
Created April 29, 2011 15:53
Convert string to url string
/**
* Transforms a string to a valid url parameter
*
* @param string $string String to transform to valid url
* @param int $limit Max length of return string. Default is 255, because url shouldn't be longer
* @return string
*/
public static function toUrl($string, $limit = 255) {
$string = self::toAscii($string, true);
$string = str_replace('.', '-', $string);
@ruflin
ruflin / gist:1146118
Created August 15, 2011 12:16
Set invalid settings
curl -XDELETE 'http://localhost:9200/test/test/1'
curl -XPUT 'http://localhost:9200/test/test/1' -d '{}'
curl -XPUT 'localhost:9200/test/_settings' -d '{"index":{"merge.policy.expunge_deletes_allowed":25}}'
curl -XPOST 'localhost:9200/test/_close'
curl -XPUT 'localhost:9200/test/_settings' -d '{"index":{"merge.policy.hello_world":15}}'
curl -XPOST 'localhost:9200/test/_open'
curl -XGET 'localhost:9200/test/_settings?pretty=true'
@ruflin
ruflin / gist:1253270
Created September 30, 2011 09:40
Get has source
curl -XDELETE 'http://localhost:9200/test/'
curl -XPUT 'http://localhost:9200/test/'
curl -XPUT 'http://localhost:9200/test/test/_mapping' -d '
{"test":{"properties":{"firstname":{"type":"string","store":"yes"},"lastname":{"type":"string", "store":"no"}},"_source":{"enabled":false}}}'
curl -XPUT 'http://localhost:9200/test/test/1' -d '
{"firstname":"Nicolas","lastname":"Ruflin"}'
@ruflin
ruflin / Elastica_Log general
Created November 20, 2011 19:56
Write to general PHP log system in Elastica_Log
$client = new Elastica_Client(array('log' => true));
$log = new Elastica_Log($client);
$log->log('hello world');
@ruflin
ruflin / backup.sh
Created March 11, 2012 11:57
Backup mit Duplicity auf S3
#!/bin/bash
# Set ENV variables
export AWS_ACCESS_KEY_ID=YOUR_AWS_ID
export AWS_SECRET_ACCESS_KEY=YOUR_AWS_KEY
export PASSPHRASE="yourpassphrase"
# DEST and PARMS setup
DEST=s3+http://your.bucket.com/possible-sub-folder
PARAMS="--s3-european-buckets --s3-use-new-style --full-if-older-than 2W"
@ruflin
ruflin / 0_reuse_code.js
Created June 12, 2014 05:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/*
Beat provides the basic environment for each beat.
Each beat implementation has to implement the beater interface.
# Start / Stop / Exit a Beat
A beat is start by calling the Run(name string, version string, bt Beater) function an passing the beater object.
@ruflin
ruflin / dynamic-fields.json
Last active March 17, 2016 15:27
Dynamic mapping for name nested docs
{
"fs": {
"disk1": {
"size": 175,
"name": "dis1"
},
"disk2": {
"size": 1785,
"name": "dis2"
}

Keybase proof

I hereby claim:

  • I am ruflin on github.
  • I am ruflin (https://keybase.io/ruflin) on keybase.
  • I have a public key whose fingerprint is C861 8985 6895 237F 839A 0B3A F119 702A 2CAE 354A

To claim this, I am signing this object:

DELETE ecs
PUT ecs
POST ecs/_mapping/_doc
{
"properties": {
"host.name": {
"type": "keyword"
}