Skip to content

Instantly share code, notes, and snippets.

@yannvery
yannvery / README.md
Created March 2, 2015 11:39
Untrack files after updating gitignore

To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename

To untrack every file that is now in your .gitignore:

First commit any outstanding code changes, and then, run this command:

git rm -r --cached .

This removes any changed files from the index(staging area), then just run:

@yannvery
yannvery / gists_search.rb
Last active August 29, 2015 14:16
Launch it and search string on your gists
require 'octokit'
require 'open-uri'
class Gist
attr_reader :description, :html_url
def initialize params
@id = params[:id]
@description = params[:description]
@yannvery
yannvery / heroku_reminder.md
Last active August 29, 2015 14:10
Heroku deployment reminer

Requirements

By default heroku uses a pg database.

Don't forget to add in your Gemfile :

group :production do
  # Use postgresql as the database for Active Record
  gem 'pg'
  gem 'rails_12factor', group: :production
end
@yannvery
yannvery / user.rb
Created December 4, 2014 14:14
Fix : Login by username and reset password on Devise
# Devise 3.4.1 and Rails 4.1.7 be carefull if you apply this method to authorize users to log in with username or email : https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address
# Add this method on User model file
def self.find_first_by_auth_conditions(warden_conditions)
# Note to_h method this must be used instead, reset password will failed
# Future pull on devise will fix it : https://github.com/plataformatec/devise/pull/3162
conditions = warden_conditions.dup.to_h
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
@yannvery
yannvery / readme.md
Created November 21, 2014 16:27
Turbolinks and $(document).ready()

Don't forget when you used turbo-links

Coffeescript

ready = ->
  #...your coffeescript goes here...

$(document).ready(ready)
$(document).on('page:load', ready)
# last line listens for page load which is what turbo links will trigger.
@yannvery
yannvery / reminder.md
Last active August 29, 2015 14:09
MongoDB On OSX

MongoDB on OSX

Installation

Update Homebrew

brew update

Install mongodb

brew install mongodb

Start

@yannvery
yannvery / readme.md
Last active August 29, 2015 14:09
Can't specify password with chef solo and chef-user

Issue with chef-user

I use chef with knife solo. I want to create a user so I decided to use this cookbook : https://github.com/fnichol/chef-user.

{
  "id": "deploy",
  "home": "/srv/deploy",
  "system_user": true,
 "create_group": true,
@yannvery
yannvery / readme.md
Last active August 29, 2015 14:08
delayed_jobs - extract jobs with specifics error on celebrities ( B&C)

List all errors about Twitter page does not exist

select * from celebrities where id in
(
  select distinct SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(handler, '\n', 4), '\n', -1), ' ', -1) as celebrity_id 
    from delayed_jobs 
  where last_error like '{Sorry, that page%'
)
@yannvery
yannvery / readme.md
Last active August 29, 2015 14:08
GRLOADER - Readme

GRLOADER

Introduction

Le GRLOADER a pour but d'importer les informations sur les CI dans une CMDB. Il utilise des documents XML en entrée (R12.6) et depuis la 12.7 il est possible de charger des documents spreadsheet ( XLS ) et des fichiers CSV.

Le GRLOADER est utilisable à partir d'une invite de commande ou à l'aide d'un fichier .bat ou .cmd.

Paramètres obligatoires

Tous les utilisations du GRLOADER demandent 3 paramètres obligatoires

@yannvery
yannvery / penalty_compute.rb
Created October 16, 2014 13:07
Compute invoice penalty amount
require 'date'
puts "Enter due date (YYYY/MM/DD) : "
due_date = gets.chomp
puts "Enter amount VAT included: "
amount = gets.chomp.to_f.round(2)
puts "Enter penalty rate : "
penalty_rate = gets.chomp.to_f.round(2)
penalty_amount_by_day = (amount * penalty_rate / 100.00) / 365