Skip to content

Instantly share code, notes, and snippets.

View samudary's full-sized avatar

Robyn-Dale Samuda samudary

View GitHub Profile
@samudary
samudary / drip_responsive_template.html
Created February 13, 2017 20:04 — forked from iantance/drip_responsive_template.html
Drip Responsive Template (Beta)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<style type="text/css">
/**
* RESETS
*/
/* Based on The MailChimp Reset INLINE: Yes. */
@samudary
samudary / .block
Created April 1, 2017 00:08
fresh block
license: mit
@samudary
samudary / capybara cheat sheet
Created July 10, 2017 11:15 — forked from zhengjia/capybara cheat sheet
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')
@samudary
samudary / friendly_urls.markdown
Created September 24, 2017 21:02 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

#!/usr/bin/env bash
#
# drip_ssh_proxy.sh
#
# Attempts to pull private ip address from hostname pattern.
# assumes ruby is present on the system.
HOST_PORT="$1"
if [[ -z "$HOST_PORT" ]]; then
>&2 echo "host:port is required"
@samudary
samudary / presenters.md
Created May 10, 2018 18:16 — forked from somebox/presenters.md
Thoughts About Rails Presenters

Thoughts about Rails Presenters

This is a collection of links, examples and rants about Presenters/Decorators in Rails.


The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.

Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html

@samudary
samudary / git_rebase.md
Created June 19, 2020 18:35 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@samudary
samudary / sign_in.rb
Created June 22, 2020 21:48 — forked from americodls/sign_in.rb
Interface proposal for ServiceObject/Interactor/UseCase on rails
class SessionsController < ApplicationController
def create
ToDoList::SignIn.new(sign_in_params).call({
success: ->(message) { redirect_to dashboard_user_path, notice: t(message) },
failure: ->(message) { render :new, error: t(message) }
})
end
end
module ToDoList
@samudary
samudary / helper.rb
Created January 1, 2021 15:05 — forked from swanson/helper.rb
# Formats a +number+ into an abbreviated string suitable for
# displaying social media type metrics
#
# ==== Options
# * start_at - The first number to start abbreviating, defaults
# to 10_000. Certain metrics may want to start at e.g. 1000.
#
# ==== Examples
# number_to_social(123) # => 123
# number_to_social(1457) # => 1457
@samudary
samudary / gist:533fae9e2d4a58538414f52a47cfdffe
Created May 25, 2021 13:34 — forked from jwebcat/gist:5122366
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1