Skip to content

Instantly share code, notes, and snippets.

@yannvery
yannvery / full_background_image.css
Created February 6, 2014 09:36
Perfect Full Page Background Image
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@yannvery
yannvery / 0_app_admin_celebrities.rb
Last active August 29, 2015 13:56
Update Global News Rating with an Admin user
action_item :only => :show do
link_to 'Update Global Rating News', admin_update_global_rating_news_path(:id => celebrity.id), :confirm => "Etes vous sur ?"
end
@yannvery
yannvery / readme.md
Last active August 29, 2015 13:59
Applying .gitignore file on existing repository

After editing .gitignore to match the ignored files, to see the files that are included in the exclude lists, you can do :

git ls-files -ci --exclude-standard

After that to remove them from the repository (without deleting them from disk), you can then do

git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
@yannvery
yannvery / trim_text_with.css
Created May 6, 2014 08:29
Trim text with css
.trim-info {
max-width: 50px;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 15px;
position: relative;
}
@yannvery
yannvery / datepickerEuDirective.js
Created May 6, 2014 10:45
Angular Directive that accept to enter a EU date on angular-ui Datepicker
app.directive('dateEu', [ 'datepickerPopupConfig', function( datepickerPopupConfig) {
// return the directive link function. (compile function not needed)
return {
restrict: 'EA',
require: 'ngModel', // get a hold of NgModelController
link: function(scope, element, attrs, ngModel) {
var format = attrs.datepickerPopup;
var maxDate = scope[attrs.max];
@yannvery
yannvery / public_activity.md
Last active August 29, 2015 14:01
How to configure public_activity ( https://github.com/pokonski/public_activity ) with another table name

Use Public Activity Gem with another table name

##1. Generate migration We assume that your application already has an "activities" table, you need to generate a migration for public activity with a specific name ( public_activity )

rails g public_activity:migration public_activities

You need to open the generated file and modify it like this (replace activities with public_activities) :

Migration responsible for creating a table with activities

@yannvery
yannvery / elegant.rb
Created June 24, 2014 20:45
How to create BigDecimal with comma ? The problem is that BigDecimal ignores everything to the right of the first comma.
#Another elegant solution source : http://chris.finne.us/2011/07/22/ruby-rails-initialize-bigdecimal-with-commas-in-the-string/
class BigDecimal
class << self
def new_with_commas(*args)
if args.first.is_a?(String) && args.first=~/,/
args.first.gsub!(',','')
end
new_without_commas(*args)
end
alias_method_chain :new, :commas
@yannvery
yannvery / GitReminder.md
Last active August 29, 2015 14:03
Git reminder

GitReminder

Just a reminder about git commands, enjoy!

Undo 'git add' before commit
git reset
Mark file as removed
@yannvery
yannvery / get_follower.rb
Created July 8, 2014 13:52
Get twitter followers with twitter gem and deal with rate limit
# Source : https://github.com/sferik/twitter/issues/517
def tw_follower_ids
$client.follower_ids.to_a
rescue Twitter::Error::TooManyRequests => error
p error
p 'tw_follower_ids sleep ' + error.rate_limit.reset_in.to_s
sleep error.rate_limit.reset_in
retry
end
@yannvery
yannvery / fetch_all_friends.rb
Created July 8, 2014 13:55
Fetch all twitter friends of a user
require 'csv'
require 'twitter'
def twitter_client
@twitter_client ||= Twitter::REST::Client.new do |config|
config.consumer_key = 'XXXXXX'
config.consumer_secret = 'XXXXXX'
config.access_token = 'XXXXXX'
config.access_token_secret = 'XXXXXX'
end