Skip to content

Instantly share code, notes, and snippets.

@roberthopman
roberthopman / routes_csv.rake
Created August 28, 2024 13:22 — forked from adamdullenty/routes_csv.rake
Export rails routes to csv
namespace :routes do
desc 'Print out all defined routes in CSV format.'
task :csv => :environment do
class CSVFormatter
def initialize
@buffer = []
end
def result
@roberthopman
roberthopman / system-wide-clipboard.zsh
Created May 5, 2024 15:58 — forked from welldan97/system-wide-clipboard.zsh
Zsh copy & paste system wide for OS X, like in emacs
pb-kill-line () {
zle kill-line
echo -n $CUTBUFFER | pbcopy
}
pb-kill-whole-line () {
zle kill-whole-line
echo -n $CUTBUFFER | pbcopy
}
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros

Step 1: add a migration, assuming usage of ActsAsTaggableOn - though any Tag model would work.

Adding :archived_at as bonus...

# frozen_string_literal: true

class CreateTagSettings < ActiveRecord::Migration[6.1]
  def change
 create_table :tag_settings do |t|
@roberthopman
roberthopman / script.sh
Created June 11, 2023 09:29 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
// optimized for rails
document.addEventListener("turbolinks:load", () => {
$('[data-toggle="tooltip"]').tooltip()
$('[data-toggle="popover"]').popover()
if (document.querySelector('#target-btn')) {
// start of the actual copy paste action
document.querySelector('#target-btn').addEventListener("click", (event) => {
var el = document.getElementById("target-table");
var body = document.body, range, sel;
@roberthopman
roberthopman / Selenium Cheat Sheet.md
Created February 7, 2021 16:42 — forked from kenrett/Selenium Cheat Sheet.md
Selenium Cheat Sheet - Ruby

#Getting Started

##Webpage:

<html>
<head>
    <title>Testing with Ruby and Selenium WebDriver</title>
</head>
 
<body bgcolor="antiquewhite">
@roberthopman
roberthopman / capybara cheat sheet
Created November 4, 2020 10:33 — 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')
require 'csv'
namespace :csv do
desc "generates a migration file from column names from the CSV headers"
task create_migration: :environment do
def headers_from_CSV (filename)
csv_header_array = CSV.read(filename, headers: true).headers
return csv_header_array.map { |col_a| col_a.strip.downcase.gsub(' ', '_').gsub('.', '_') }
end
@roberthopman
roberthopman / wip_graphql_demo.rb
Created October 25, 2018 13:36 — forked from skatkov/wip_graphql_demo.rb
Ruby example of creating a todo and then completing it using wip.chat graphql.
# NOTE: Be sure to set the API key further down in the code!
require "net/http"
require "uri"
require "json"
class WIP
def initialize(api_key:)
@api_key = api_key
end