Skip to content

Instantly share code, notes, and snippets.

View Florian95's full-sized avatar

Florian LAMACHE Florian95

View GitHub Profile
@Florian95
Florian95 / Dockerfile
Created September 14, 2016 09:23
Rails Web application on Docker Debian
FROM debian:8.5
## Image metadata ##
MAINTAINER Stuart Ellis, stuart@stuartellis.eu
LABEL description="Rails Web application on Debian"
## Application user account ##
ENV APP_USER app
@Florian95
Florian95 / README.markdown
Last active August 29, 2015 14:01
ngSortable by Florian95
@Florian95
Florian95 / simple_search.rb
Created April 24, 2012 11:34 — forked from jimworm/simple_search.rb
Simple search for all Rails 3.2 ActiveRecord models on any string column(s)
class ActiveRecord::Base
class << self
def has_simple_search(*attrs)
raise 'has_simple_search expects at least one attribute' if attrs.empty?
instance_eval do # because this is ActiveRecord::Base, the class inherits this
class_attribute :simple_search_fields
self.simple_search_fields = attrs.flatten
def simple_search(search_string)
return find(:all) if search_string.nil? || search_string.blank?
attrs = self.simple_search_fields
# Delete unnecessary files
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/images/rails.png"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
# Copy database.yml for distribution use
require 'rubygems'
require 'mechanize'
user = 'xxxx'
pass = 'xxxx'
fini = false
a = WWW::Mechanize.new
page_post = a.post("http://#{user}.labrute.fr/login", 'pass' => pass)
@search = Ultrasphinx::Search.new(:query => get_query_by_subject(@subject.id),
:sort_mode => 'descending',
:sort_by => 'created_at',
:weights => {'titre' => 6.0, 'content' => 2.0},
:page => params[:page] || 1)