Skip to content

Instantly share code, notes, and snippets.

@seb
seb / gist:6507677
Created September 10, 2013 10:39
Bootstrap Gemfile
source 'http://rubygems.org'
## Rails
gem 'rails', '3.2.13'
gem 'mysql2'
## Views
gem 'jquery-rails'
gem "haml"
@seb
seb / sample.conf
Last active December 12, 2017 09:01
Nginx + Puma + Rails + Cache Configuration File Replace example.com.
upstream example.com {
server unix:///var/www/example.com/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name *.example.com;
return 301 http://example.com$request_uri;
}
layouts = [
[[500,250][500,250]],
[[250,250],[250,250],[250,250],[250,250]]
]
- @posts.each_with_index do |post,i|
row = layouts[i%layouts.length] # On récupere ici une ligne de layout
- row.each do |elm|
= content_tag :div, :style => "width:#{elm.first}px;height:#{elm.last}px;float:left"
next row.length
def self.calculate_delay(now = Time.now.to_date)
next_payment = Date.new((now+1.month).year, (now+1.month).month, -1)
# Affiche la date passée en argument, a priori date de commande, puis la date du prochain prélèvement et le délais entre les 2 en jours
[now.strftime('%d/%m/%Y'),next_payment.strftime('%d/%m/%Y'),(next_payment-now).to_i]
end
create db/migrate/20111006135013_create_posts.rb
create app/models/post.rb
invoke rspec
create spec/models/post_spec.rb
route resources :posts
invoke scaffold_controller
create app/controllers/posts_controller.rb
invoke haml
create app/views/posts
create app/views/posts/index.html.haml
<script type="text/javascript" charset="utf-8">
var currentPage = 5;
function nearBottomOfPage() {
return scrollDistanceFromBottom() < 150;
}
function scrollDistanceFromBottom(argument) {
return $(document).height()-$(window).scrollTop()-$(window).height();
@seb
seb / gist:1199991
Created September 7, 2011 07:48
Cleaning file
f = File.new("clean.csv", 'a')
File.open('members_Pyramyd_NTCV_Sep_6_2011.csv').each do |line|
f.puts line.split(",")[0..2].join(',')
end
def index
@magazine = Magazine.published.first
@published_magazines = Magazine.published
if @magazine
@summaries = @magazine.pages.summaries
@description = @magazine.metadescription
redirect_to magazine_url(@magazine)
else
redirect_to new_magazine_path
When "filling a new todo task" do
Then "should see its newly added task" do
visit '/'
fill_in "task_message", :with => "I have to read some BDD books"
click_button "Todo!"
within("#nav_badge") do
page.should have_content(3)
end
within("#todo_badge") do
page.should have_content(3)
@font-face {
font-family: "NeuzeitTextbookRegular";
src: url(/fonts/neuzeittextbook_regular-webfont.eot?1300874573);
src: local("☺"), url(/fonts/neuzeittextbook_regular-webfont.woff?1300874573) format("woff"), url(/fonts/neuzeittextbook_regular-webfont.ttf?1300874573) format("truetype"), url("/fonts/neuzeittextbook_regular-webfont.svg#webfontJ6Q9a4kP") format("svg");
font-weight: normal;
font-style: normal; }