Skip to content

Instantly share code, notes, and snippets.

View karimmtarek's full-sized avatar

Karim Tarek karimmtarek

View GitHub Profile
@Patru
Patru / Make a Cuba Template.md
Last active March 16, 2017 18:02
How I got to my Cuba template

Since I did not want to constantly re-invent the wheel I will write down my choices for putting together my Cuba template.

  1. Choose your favorite version of ruby and install it using rbenv (I happened to use MRI 2.2.3 at this point).
  2. create your template directory and CD into it.
  3. fix your ruby version using rbenv local 2.2.3 or somesuch
  4. create a github repository and follow the instructions for the README.md and the first commit.
  5. get a Gemfile from a running project and edit away the stuff I considered project specific
  6. run bundle install, takes a while, but looks nice, remember to add Gemfile.lock to git too
  7. create routes and config directories, want to put stuff in there
  8. create an initial Cuba route in routes/default.rb
@tyteen4a03
tyteen4a03 / gist:3420a9e121d13b091343
Last active November 13, 2022 14:35
Shopify handleize function in JavaScript
// from https://github.com/Shopify/liquid/blob/63eb1aac69a31d97e343822b973b3a51941c8ac2/performance/shopify/shop_filter.rb#L100
Shopify.handleize = function (str) {
str = str.toLowerCase();
var toReplace = ['"', "'", "\\", "(", ")", "[", "]"];
// For the old browsers
for (var i = 0; i < toReplace.length; ++i) {
str = str.replace(toReplace[i], "");
}
@Patru
Patru / Cuba Setup.md
Last active March 16, 2017 18:02
Setting up Cuba with Sequel, Fortitude, Capybara and Minitest

Setup for Cuba in a sample app

I recently read up quite some articles on microframworks and I liked the idea to try out Cuba instead of the regular Sinatra for a change. Here is what I ended up with.

First of all my Gemfile:

source "https://rubygems.org"
ruby "2.0.0"
@joshteng
joshteng / dokku_setup.md
Last active August 27, 2024 04:03
Using Dokku to deploy a Rails Application

#Goal Deploy your Rails App super easily with Dokku on Digital Ocean cheap cheap!

##Notes

  • Follow 12 factor design (include the rails_12factor gem)
  • Don't forget your Procfile with the command to start up your application server
  • I prefer using external hosted logging services like Logentries (not in this guide)
  • Set up performance monitoring AppSignal or New Relic (not in this guide)
@hauleth
hauleth / .rubocop.yml
Last active January 27, 2016 10:22
Hauleth's template
AllCops:
Exclude:
- bin/*
- config/**/*
- coverage/**/*
- db/**/*
- doc/**/*
- log/**/*
- public/**/*
- script/**/*
@hofmannsven
hofmannsven / README.md
Last active December 19, 2024 10:47
Git CLI Cheatsheet
@ls-lukebowerman
ls-lukebowerman / sitemap.xml.erb
Created August 7, 2012 17:59
Sitemap (sitemaps.org) generator for Middleman
<% pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/) } %>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% pages.each do |p| %>
<url>
<loc>http://youdomain.com/<%=p.destination_path.gsub('/index.html','')%></loc>
<priority>0.7</priority>
</url>
<% end %>
</urlset>
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@aliang
aliang / application.rb
Created June 12, 2011 08:12
monkeypatch Rails::Application.load_console to load app-specific .irbrc
# taken from http://railsbros.de/2010/11/29/a-custom-irbrc-for-rails-3.html
# config/application.rb that is
module MyApp
class Application < Rails::Application
# config stuff comes here
def load_console(sandbox=false)
super
if File.exists?(project_specific_irbrc = File.join(Rails.root, ".irbrc"))
puts "Loading project specific .irbrc ..."
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')