Skip to content

Instantly share code, notes, and snippets.

View pi3r's full-sized avatar
🐒
💻

Pierre Nespo pi3r

🐒
💻
View GitHub Profile
@pi3r
pi3r / gist:5353199
Last active December 16, 2015 01:09
class Api::V1::BaseController < ActionController::Base
include ActionController::HttpAuthentication::Basic
protect_from_forgery with: :null_session
before_filter :require_current_user
respond_to :json
rescue_from AccessDenied do |exception|
{
"ticket": {
"custom_fields": [
{
"id": "424242424",
"value": "child_of:42"
}
]
}
}
{
"ticket": {
"fields": {
"424242424": "child_of:42"
}
}
}
$('img[src*="http://www.we-are-coders.com"]').each(function(){
$(this).attr('src', $(this).attr("src").replace(/http:\/\/www.we-are-coders.com/g, ''));
});
uniq = []
inject([]) do |memo, e|
uniq_value = block ? block.call(e) : e
uniq.include?(uniq_value) ? memo.push(e) : uniq.push(uniq_value)
memo
end
App::Application.routes.draw do
scope module: 'company', constraints: ValidSubdomain do
root to: "home#index"
match 'login' => 'sessions#new', as: :login
match 'logout' => 'sessions#destroy', as: :logout
end
scope module: 'invalid_subdomain', constraints: InvalidSubdomain do
match '/*path' => 'home#index'
@pi3r
pi3r / gist:4124008
Created November 21, 2012 09:41
Postgres to ES
Establishment has_many Product has_many Period.
I need to scope the search on multiple criteria :
Where:
Establishment: (geo_location/name)
Where:
Product: (name/type)
Where:
Period: (start_date/end_date)
module SeoContentable
extend ActiveSupport::Concern
included do
Basically i had :
class Base
def self.match_attributes(hash, attributes = self::ATTRIBUTES_MAPPING)
#do work on attributes
end
end
class SpecificMapper < Base
ATTRIBUTES_MAPPING = { ... }
@pi3r
pi3r / gist:3187134
Created July 27, 2012 09:42
Error when installing emacs snapshot
-> % sudo apt-get install emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
emacs-snapshot-bin-common emacs-snapshot-common
The following NEW packages will be installed:
emacs-snapshot emacs-snapshot-bin-common emacs-snapshot-common emacs-snapshot-el emacs-snapshot-gtk
0 upgraded, 5 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B/40.4 MB of archives.