Skip to content

Instantly share code, notes, and snippets.

@yannvery
yannvery / Upload.cs
Last active January 4, 2016 05:59
Upload file web method with c#
public bool UploadFile(string FileName, byte[] buffer, long Offset)
{
bool retVal = false;
try
{
// setting the file location to be saved in the server.
// reading from the web.config file
string FilePath =
//Path.Combine(ConfigurationManager.AppSettings["upload_path"], FileName);
//WebConfigurationManager.AppSettings["PFUserName"].ToString()
@yannvery
yannvery / 0_orbit.html
Created January 27, 2014 08:27
Foundation : Text and buttons over image in Orbit
<ul id="featured" data-orbit>
<li id="slide1">
<img src="http://placehold.it/1200x300&text=Slide1" />
<p>Text goes here!</p>
</li>
<li id="slide2">
<img src="http://placehold.it/1200x300&text=Slide1" />
<p>Text goes here!</p>
</li>
</ul>
@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 / log_level.rb
Created June 25, 2014 07:54
Manage log level in a Rails console
#To turn it off
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
#To turn it back on
ActiveRecord::Base.logger = old_logger