Skip to content

Instantly share code, notes, and snippets.

@yannvery
yannvery / readme.md
Created January 22, 2016 14:32
[Ruby On Rails 4] How to add a validation on a textfield which is datefield with mongoid

[Ruby On Rails 4] How to validate a date field named with the format dd/mm/yyyy with Mongoid

In Ruby On Rails 4 it seems impossible to add a validation on a datefield with a text format.

Example in rails 3:

Class Task
...

validates :start, presence: true, format: /\d{2}\/\d{2}\/\d{4}/
@yannvery
yannvery / Proc_and_lambda.md
Created January 20, 2016 15:53
Proc and lambda ( in french )

Proc & Lambdas

1 - Proc

Creation

Un objet proc permet de stocker du code et peut être associé à une variable.

my_proc = Proc.new { puts "Hello" }
@yannvery
yannvery / How_to_maintain_fork_sync.md
Created January 20, 2016 09:52
How to maintain fork sync

How to maintain fork sync

Configuring a remote for a fork

To sync changes you make in a fork with the original repository, you must configure a remote that points to the upstream repository in Git.

  • Open a Terminal
  • List current configured remote repository for your fork
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
@yannvery
yannvery / ubuntu_cleanup_packages.md
Last active May 19, 2022 09:44
Ubuntu - Purge old kernels and unused modules

Ubuntu - Purge old kernels and unused modules

Purge old kernels

Open terminal and check your current kernel:

uname -r

DO NOT REMOVE THIS KERNEL!

@yannvery
yannvery / cleanup_ubuntu_mailbox.md
Created January 6, 2016 08:44
Cleanup Ubuntu mailbox

All mails received by a user are stored into: /var/mail/username

Open mailbox without initial display: mail -N
Then delete all mails: d *

@yannvery
yannvery / grant_user_mysql.md
Created December 15, 2015 10:20
Create user and grant it on database

Create a user and add privileges to access database remotly :

CREATE USER 'application'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON application_database.* TO 'application'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
@yannvery
yannvery / pry.md
Created October 12, 2015 07:21
PRY

PRY

gem install pry

Additionals gems

  • pry-rescue
  • pry-stack_explorer
  • pry-clipboard
@yannvery
yannvery / free_disk_place.md
Created August 17, 2015 15:11
Free disk place on linux server

To delete downloaded packages (.deb) already installed (and no longer needed)
sudo apt-get clean

To remove all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repository or that have a newer version in the repository).
sudo apt-get autoclean

To remove unnecessary packages (After uninstalling an app there could be packages you don't need anymore)
sudo apt-get autoremove

To delete old kernel versions

@yannvery
yannvery / 0_Readme.md
Last active August 29, 2015 14:25
Implement Faye with Rails 4

Faye & Rails 4

This gist describes how to implement faye with a rails 4 application.

What I want ?

A user receives a live notification when another user login.

Requirements

A rails 4 application with devise for user management

2 gems:

@yannvery
yannvery / keybase.md
Created July 1, 2015 15:19
keybase.md

Keybase proof

I hereby claim:

  • I am yannvery on github.
  • I am yannvery (https://keybase.io/yannvery) on keybase.
  • I have a public key whose fingerprint is F4D7 921F AC4D 9945 A033 E9F8 A580 3E32 716F 0BBE

To claim this, I am signing this object: