Skip to content

Instantly share code, notes, and snippets.

@lukaskleinschmidt
lukaskleinschmidt / app.scss
Last active September 11, 2023 14:50
Utility class generator like tailwindcss but in pure Sass.
@use 'sass:map';
@use 'variants' as * with (
$breakpoints: (
'small': 640px,
'medium': 768px,
'large': 1024px,
'wide': 1280px,
)
);
@ta1kt0me
ta1kt0me / add_frozen_string_literal_comment.rb
Last active May 29, 2022 13:33
Add frozen string literal comment into generated files in rails v5.1.0
module AddFrozenStringLiteralComment
def add_frozen_string_literal_comment(dist)
if File.exist?(dist) && File.extname(dist) == '.rb'
File.open(dist, 'r') do |f|
body = f.read
File.open(dist, 'w') do |new_f|
new_f.write("# frozen_string_literal: true\n" + body)
end
end
@dkniffin
dkniffin / capybara cheat sheet
Last active August 9, 2016 21:31 — 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_on('Link Text') # Click either a link or a button
click_on('Button Value')
@lbspen
lbspen / gist:5674563
Created May 29, 2013 23:11
Select date and time for capybara-rspec from rails forms
def select_date(date, options = {})
field = options[:from]
base_id = find(:xpath, ".//label[contains(.,'#{field}')]")[:for]
year, month, day = date.split(',')
select year, :from => "#{base_id}_1i"
select month, :from => "#{base_id}_2i"
select day, :from => "#{base_id}_3i"
end
def select_time(hour, minute, options = {})
@MarcoPolo
MarcoPolo / css-colors
Created December 6, 2012 21:03
Convert hex color values to rgb clojure
(defn css-color [color]
(let [ colors (rest (clojure.string/split color #""))
red (take 2 colors)
green (take 2 (drop 2 colors))
blue (take 2 (drop 4 colors))]
(map #(-> (conj % "0x") (clojure.string/join) (read-string)) [red green blue])))
@nuxlli
nuxlli / console.rb
Created July 10, 2012 17:43
To access url helpers (url_for, etc) from Rails console (Rails 3)
# Example from: http://snipplr.com/view/37063/
include Rails.application.routes.url_helpers
# set host in default_url_options:
default_url_options[:host] = "localhost"
# can then use:
url_for()
@bartoszmajsak
bartoszmajsak / prepare-commit-msg.sh
Last active March 20, 2024 08:12
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"