Skip to content

Instantly share code, notes, and snippets.

@yannvery
yannvery / 0_Paginate_without_reload_all_page_with_kaminari.md
Last active November 3, 2022 11:11
How to paginate on an ajax way ( with jquery and kaminari )

Paginate with Kaminari without reload all data

Use :remote => true option on link_to and paginate Region index page

@yannvery
yannvery / 0_reuse_code.js
Created November 20, 2013 14:55
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
VERSION=0.20.6
sudo apt-get update
sudo apt-get install openjdk-6-jdk
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.deb
sudo dpkg -i elasticsearch-$VERSION.deb
# be sure you add "action.disable_delete_all_indices" : true to the config!!
@yannvery
yannvery / 0_Index_model_2_times_with_Sunspot_Readme.md
Last active December 30, 2015 14:08
How to use a different searchable solr configuration on an object with sunspot : In this case speaker model does not inherit from celebrity model, all validations and relations can't be used on speaker model. !! Speaker and Celebrity model are used the same table be careful when you save a Speaker item!

#How to apply 2 solr search index on same object (Celebrity)

It's apparently impossible to index twice same object with sunspot solr and 2 searchable block.

##1st idea Create another model (Speaker) that inherits the searchable's model, and apply on Speaker's model another searchable block. This configuration doesn't work because Speaker's searchable block doesn't totally override Celebrity's model block, it's possible to add index on fields that don't be indexed yet but it's impossible to delete indexed fields

##2nd Idea Create a second model (Speaker) that uses the table's first model ( Celebrity ). We can add a searchable block on Speaker and create new indexes .

@yannvery
yannvery / 0_install.sh
Last active December 31, 2015 05:49
How to install and configure consular on OSX 10.9 ( Mavericks ). Use : rvm - ruby 2 - zsh - sublime text
# Install command line developer tools if necessary ( like if consular-item gem can't be installed )
xcode-select --install
gem install consular
gem install consular-iterm
consular init
# Open the newly created ~/.consularc file and add a require statement for your core to the top.
# The project page for each core will have this snippet. For iTerm it’s require 'consular/iterm'.
@yannvery
yannvery / 0_login.rb
Last active July 7, 2023 23:49
Savon Client for SDM webservices - Request examples
require 'savon'
# Get wsdl
client = Savon.client(wsdl: "http://localhost:8080/axis/services/USD_R11_WebService?wsdl")
#login
response = client.call(:login, message: {username: "servicedesk", password: ""})
sid = response.body[:login_response][:login_return]
@yannvery
yannvery / downcase.rb
Created December 29, 2013 18:43
How to downcase accented chars with ruby
# Downcase accented chars
"Île de France".mb_chars.downcase.to_s
# => "île de france"
# Downcase and remove accented chars
I18n.transliterate("Île de france").downcase
# => "ile de france"
@yannvery
yannvery / circular.css
Created January 10, 2014 15:23
how to make an img-circle like bootstrap
.circular {
width: 300px;
height: 300px;
border-radius: 150px;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
background: url(http://link-to-your/image.jpg) no-repeat;
box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
@yannvery
yannvery / remove_accented_char.pl
Created January 15, 2014 09:31
Remove accented char in perl, it can be useful when you use SOAP::Lite that use a Base64 encoding for data
use strict;
use warnings;
use utf8;
use Unicode::Normalize;
my $test = "Vous avez aimé l'épée offerte par les elfes à Frodon";
my $decomposed = NFKD( $test );
$decomposed =~ s/\p{NonspacingMark}//g;
@yannvery
yannvery / utf8-debug.pl
Last active January 3, 2016 08:09
When perl fails to encode utf8 on windows env http://www.i18nqa.com/debug/utf8-debug.html
use strict;
use warnings;
use Encode qw( encode decode );
my $code_points = decode('UTF-8', 'é'); # This is a 'é' char
my $cp1252 = encode('cp1252', $code_points);
print $cp1252;