Skip to content

Instantly share code, notes, and snippets.

View karimmtarek's full-sized avatar

Karim Tarek karimmtarek

View GitHub Profile
@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@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')
@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 ..."
@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

@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>
@hofmannsven
hofmannsven / README.md
Last active June 4, 2024 04:25
Git CLI Cheatsheet
@hauleth
hauleth / .rubocop.yml
Last active January 27, 2016 10:22
Hauleth's template
AllCops:
Exclude:
- bin/*
- config/**/*
- coverage/**/*
- db/**/*
- doc/**/*
- log/**/*
- public/**/*
- script/**/*
@joshteng
joshteng / dokku_setup.md
Last active May 12, 2022 14:38
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)
@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"
@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], "");
}