Skip to content

Instantly share code, notes, and snippets.

View cseeger's full-sized avatar

Chad Seeger cseeger

  • San Francisco, CA
View GitHub Profile
@cseeger
cseeger / gist:91b14f1007784f0d7879f0776336b0d9
Created October 28, 2023 18:35
Postgres with OpenSSL 1.1
Homebrew install of OpenSSL 1.1 gave `error: library 'crypto' is required for OpenSSL`
```
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
```
Then install with:
```
@cseeger
cseeger / commit-msg
Last active February 22, 2019 20:21
Git Hook to automate inclusion of JIRA (`[ABC-123]`) formatted ticket ids in your commit message
#!/usr/bin/env ruby
#
# Install via:
# `curl GIST_URL > .git/hooks/commit-msg && chmod u+x .git/hooks/commit-msg`
COMMIT_MESSAGE = File.read(ARGV[0])
def check_commit_message
message_regex = /\[[A-Z]+-[0-9]+\]/
@cseeger
cseeger / storybook_spec.js
Last active February 12, 2019 19:01 — forked from xogeny/storybook_spec.js
Cypress testing of Storybook
describe('Storybook', () => {
beforeEach(() => {
cy.visit('http://airbnb.io/react-dates/')
})
context('DateRangePicker', () => {
it('should visit the default story in this collection', () => {
cy.get('a[data-name="default"]').click()
// Get the iframe for the components and make assertions on that.
@cseeger
cseeger / enumerator.rb
Created March 6, 2018 18:32
Fun with Ruby's Enumerator
class Whatever
def run
fetch_paginated_data('Whatever...').each do |item|
puts item
end
end
def fetch_paginated_data(obj)
Enumerator.new do |yielder|
loop do
@cseeger
cseeger / string.rb
Created March 8, 2017 01:20 — forked from romansklenar/string.rb
Ruby string to boolean type casting
class String
def to_bool
case
when self == true || self =~ /^(true|t|yes|y|1)$/i
true
when self == false || self.blank? || self =~ /^(false|f|no|n|0)$/i
false
else
raise ArgumentError.new "invalid value for Boolean: '#{self}'"
@cseeger
cseeger / triangle.cr
Created September 8, 2016 04:57
Example C-lib binding in Crystal
module Radians
class Triangle
lib C
# In C: double cos(double x)
fun cos(value : Float64) : Float64
end
def cos(value : Float64)
C.cos(value)
end
module NestedMassAssignment
extend ActiveSupport::Concern
included do
include ActiveAttr::BasicModel
include ActiveAttr::BlockInitialization
include ActiveAttr::Logger
# include ActiveAttr::MassAssignment
include ActiveAttr::AttributeDefaults
include ActiveAttr::QueryAttributes
@cseeger
cseeger / decode_session_cookie.rb
Last active March 31, 2016 23:52 — forked from pdfrod/decode_session_cookie.rb
A simple script to decode Rails 4 session cookies
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<p> Something is broken. Check the following: </p>
<ul>
<%= for {attr, message} <- f.errors do %>
<li>
<%= humanize(attr) %>
&nbsp;
<%= message %>
</li>
@cseeger
cseeger / e-commerce.md
Created November 26, 2012 03:44 — forked from hjr3/e-commerce.md
Examples of RESTful API calls for E-commerce platforms

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links