Skip to content

Instantly share code, notes, and snippets.

View victorbstan's full-sized avatar

Victor Stan victorbstan

  • Toronto & Remote
View GitHub Profile
@victorbstan
victorbstan / flotr2_defaults.js
Created April 26, 2012 15:57
Flotr2 Defaults
(/**
* Flotr Defaults
*/
Flotr.defaultOptions = {
colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.
ieBackgroundColor: '#FFFFFF', // Background color for excanvas clipping
title: null, // => The graph's title
subtitle: null, // => The graph's subtitle
shadowSize: 4, // => size of the 'fake' shadow
defaultType: null, // => default series type
@victorbstan
victorbstan / created_at_yesterday.rb
Created March 20, 2012 19:27
Get items created yesterday from a Rails app using AR
FieldUpdate.where("created_at < ?", Date.today)
@victorbstan
victorbstan / your_application.rb
Created October 28, 2011 12:31 — forked from nicholasjhenry/your_application.rb
PayRoll application, embedded in Rails, borrowing from Use Case Driven Architecture and DCI
## PayRoll Application Gem
# lib/pay_roll/pay_day_service.rb
# Consider this Use Case as the Context in DCI
#
class PayRoll::PayDayService
def initialize(date=Date.today)
@date = date
# Employee could be any data source from the host,
@victorbstan
victorbstan / slug.rb
Created October 9, 2011 23:34
A Rails model example for generating slugs for a "slug" parameter/column
before_validation :slug_to_slug
protected
def slug_to_slug
self.slug = self.to_slug
end
def to_slug(param=self.slug)
# strip the string
@victorbstan
victorbstan / gist:1256414
Created October 1, 2011 17:57 — forked from Amitesh/gist:1160428
Paperclip file name cleanup or rename
#http://blog.wyeworks.com/2009/7/13/paperclip-file-rename
Paperclip.interpolates :default_image_type do |attachment, style|
attachment.instance.get_user_default_profile_image
end
Paperclip.interpolates :normalized_avatar_file_name do |attachment, style|
attachment.instance.normalized_avatar_file_name
end
@victorbstan
victorbstan / .vimrc
Created September 22, 2011 17:01
My .vimrc setup
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
@victorbstan
victorbstan / count_days_between_dates.rb
Created July 7, 2011 19:21
count days between two dates
# definition
# provide an optional day name (in English)
# as the last parameter to get the number of times that day occurs
# between the two provided dates
#
# dates (t1 and t2) should be valid Time object dates
def list_days_between(t1, t2, day_name=nil)
days = []
(t2.to_i..t1.to_i).step(86400) do |t|
@victorbstan
victorbstan / neat_notification_rounded_shaddow.sass
Created June 5, 2011 21:53
Neat Notification SASS mixin for rouded corners and soft drop-shaddows
$default_rounded_amount: 5px
// Round corner at position by amount.
@mixin round-corner($position, $amount: $default_rounded_amount)
border-#{$position}-radius: $amount
-webkit-border-#{$position}-radius: $amount
@mixin round-corner-mozilla($position, $amount: $default_rounded_amount)
-moz-border-radius-#{$position}: $amount
// Round left corners by amount
@victorbstan
victorbstan / padrino_flash_message_view.haml
Created June 5, 2011 21:40
Flash message generator for Padrino views
.flash=[:error, :warning, :notice].map { |type| flash_tag(type, :id => "flash_#{type}") }.join
@victorbstan
victorbstan / neat_notification_style.css
Created June 5, 2011 21:37
Neat Notification CSS style
#flash_notice, #flash_alert, #flash_error {
z-index: 999;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
position: absolute;
right: 20px;