Skip to content

Instantly share code, notes, and snippets.

View Florian95's full-sized avatar

Florian LAMACHE Florian95

View GitHub Profile
@benoit-intrw
benoit-intrw / test_analyzer.sh
Created August 23, 2012 10:06
Elasticsearch: test analyser for text like 'R&D' or 'Canal+'
#!/bin/bash
# Script and configuration to test analyser
#
# Check arguments
hostname=$1
indexname=$2
if [ -z "$hostname" ] || [ -z "$indexname" ]
then
@Breefield
Breefield / hexagon.js
Created August 12, 2012 04:12
Drawing a Hexagon with Paper.js
// Create a Paper.js Path to draw a line into it:
var hexagon = new Path();
// Color our path black
hexagon.strokeColor = 'black';
// How many points do we want our object to have
var points = 6;
// How large should it be
var radius = 60;
// 0 to 2PI is a circle, so divide that by the number of points
@karmi
karmi / active_record_associations.rb
Created July 29, 2012 16:57
An example of elasticsearch & Tire setup for ActiveRecord associations
# An example of elasticsearch & Tire setup for ActiveRecord associations.
#
# A `Book has_many :chapters` scenario, with mapping and JSON serialization
# for indexing associated models.
#
# Demonstrates three important caveats as of now:
#
# 1. You you have to use `touch: true` in the `belongs_to` declaration,
# to automatically notify the parent model about the update.
#
@sunny
sunny / application_helper.rb
Created July 25, 2012 17:21
li_nav : Utilitaire pour faire des liens dans des <li> qui appliquent des classe "current" automatiquement
# encoding: UTF-8
module ApplicationHelper
# Utilitaire pour faire un lien dans un li qui applique des classe "current"
# automatiquement.
#
# Arguments :
# - nom : nom du lien
# - url : chemin vers la page
@dz0ny
dz0ny / Capfile.rb
Created May 5, 2012 19:29
FTP Sync for Capistrano
load 'config/deploy'
desc "FTP Sync"
namespace :deploy do
desc "Sync and compile to remote by default"
task :default do
#assets.sprite
#assets.compile
remote.default
@nherment
nherment / backup.sh
Created February 29, 2012 10:42
Backup and restore an Elastic search index (shamelessly copied from http://tech.superhappykittymeow.com/?p=296)
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
@bkutil
bkutil / deploy.rb
Created December 4, 2011 22:22 — forked from andruby/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
@maccman
maccman / juggernaut_heroku.md
Created June 2, 2011 01:26
Juggernaut on Heroku

Clone repo:

git clone git://github.com/maccman/juggernaut.git
cd juggernaut

Create Heroku app:

heroku create myapp --stack cedar
heroku addons:add redistogo:nano

git push heroku master

@codenamev
codenamev / grep search & replace
Created March 4, 2011 12:19
Search and replace a regex in multiple files on UNIX
egrep -lRZ "\.jpg|\.png|\.gif" . \
| xargs -0 -l sed -i -e 's/\.jpg\|\.gif\|\.png/.bmp/g'
#egrep: find matching lines using extended regular expressions
# -l: only list matching filenames
# -R: search recursively through all given directories
# -Z: use \0 as record separator
# "\.jpg|\.png|\.gif": match one of the strings ".jpg", ".gif" or ".png"
# .: start the search in the current directory
#xargs: execute a command with the stdin as argument