Skip to content

Instantly share code, notes, and snippets.

View dideler's full-sized avatar

Dennis Ideler dideler

View GitHub Profile
@dhh
dhh / test_induced_design_damage.rb
Last active June 22, 2023 06:18
This is an extraction from Jim Weirich's "Decoupling from Rails" talk, which explained how to apply the hexagonal design pattern to make every layer of your application easily unit testable (without touching the database etc). It only seeks to extract a single method, the EmployeesController#create method, to illustrate the design damage that's …
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end
@dideler
dideler / screenshots.js
Last active September 30, 2022 16:33 — forked from nhoizey/screenshots.js
Quick way to take screenshots of webpages at different sizes. Not very efficient, but can make it fast later.
#!/usr/bin/env casperjs
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js example.com
*/
@dideler
dideler / coursera.html
Last active March 18, 2024 09:53 — forked from kevingessner/gist:9509148
Responsive emails that work
<div id=":vz" class="ii gt m145ad5537035869c adP adO"><div id=":vy" class="a3s" style="overflow: hidden;"><div><div class="adM">
</div><div bgcolor="#fafafa"><div class="adM">
</div><table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#fafafa"><tbody><tr><td align="left" valign="middle" height="40" bgcolor="#e4eff7" style="color:#787878;font-family:Arial;padding:5px 30px 5px 30px">
<div style="font-size:14px;letter-spacing:1px;font-weight:bold;color:#787878"><a href="https://eventing.coursera.org/redirect/K94Ky5AdlhxW-FQnYSZZtJPNSf_mKt0SlLY3BJoPtzGpi9uZUEt5y2t4OE_LPJ_BCElO-LwczCh98rRU3vjkFA.KYet1zUYKuWJE3yZ5nv7dQ.ew5zeZYivcmzO41tPxqLBchVIzZJsUl86CrpCEZL-BqfouGmyTiOsoHV6zgPWIft-5F1i2Ug42EeeOJS1yfZ-yZdoMF_Oc5dO2aP7vtdCqLHEQLkq4-vHwBL8nGe-T7Lypqw5CtuKyoVwWGNHb0s-n1mM3r5RfTIVyrGJYV4m8NKQI-m4K18qD0fszw5u0_OxR_24DUqzkXqfMfOD9_MwhEkfow89tPO2CYoYdWths3E9TQ3gK_KdRjJRm8AfgKVyacIGbanQ3tUENlDUy_E7E9YMuAmYCXUHe02U2p5FlEQW7LnDqTtG3MYC3uVCOW46Bs3_oIFzlryBTrariC7y1s3KXDtwE83vBW9t65D62
@elidickinson
elidickinson / html_email_buttons_1.html
Last active November 27, 2023 14:55
HTML email buttons that work
<div>
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://www.EXAMPLE.com/" style="height:40px;v-text-anchor:middle;width:300px;" arcsize="10%" stroke="f" fillcolor="#d62828">
<w:anchorlock/>
<center style="color:#ffffff;font-family:sans-serif;font-size:16px;font-weight:bold;">
Button Text Here!
</center>
</v:roundrect>
<![endif]-->
<![if !mso]>
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
ConfirmedGrouperEmails.new(@grouper).deliver
AssignBarForGrouper.enqueue(@grouper.id)
redirect_to home_path
else
#!/usr/bin/env python
# init post for jekyll
import os
import re
import datetime
text_tmpl = """---
layout: post
title: %(title)s
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, french_stem;
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english );
ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, english_stem;
CREATE TEXT SEARCH CONFIGURATION de ( COPY = german );
ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING
@namuol
namuol / INSTALL.md
Last active July 24, 2023 11:53
rage-quit support for bash

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@knicklabs
knicklabs / getting-started-with-tdd.md
Last active August 29, 2015 13:56
A brief tutorial on getting started with test-driven development

Getting Started with TDD

Project Setup

Generate a new Rails project. Skip unit tests and bundle install.

rails new -T -B tdd
" Virtualenv
python << EOF
import sys, vim, os
ve_dir = vim.eval('$VIRTUAL_ENV')
ve_dir in sys.path or sys.path.insert(0, ve_dir)
activate_this = os.path.join(ve_dir, 'bin', 'activate_this.py')
if os.path.exists(activate_this):
execfile(activate_this, dict(__file__=activate_this))