Skip to content

Instantly share code, notes, and snippets.

View sdhull's full-sized avatar
🏃
Gettin it

Steve Hull sdhull

🏃
Gettin it
View GitHub Profile
@timm-oh
timm-oh / application_record.rb
Last active May 19, 2024 11:08
Rails 5.2.3: Monkey patch update_all and update_columns to always include updated_at
# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
# Didn't change #update_column because it uses #update_columns under the hood.
def update_columns(attrs)
new_attrs = attrs.symbolize_keys
new_attrs[:updated_at] ||= Time.current if self.class.column_names.include?('updated_at')
super(new_attrs)
end
@gre
gre / scrollparent.js
Created August 3, 2016 11:27
get first parent scrollable container of a dom element
// more minimal version of https://github.com/olahol/scrollparent.js/blob/master/scrollparent.js
const regex = /(auto|scroll)/;
const style = (node, prop) =>
getComputedStyle(node, null).getPropertyValue(prop);
const scroll = (node) =>
regex.test(
style(node, "overflow") +
style(node, "overflow-y") +
@robertpainsi
robertpainsi / README.md
Last active March 21, 2024 10:45
How to reopen a pull-request after a force-push?

How to reopen a pull-request after a force-push?

Precodinitions

  • You need the rights to reopen pull requests on the repository.
  • The pull request hasn't been merged, just closed.

Instructions

  1. Write down the current commit hash of your PR-branch git log --oneline -1 <PR-BRANCH>
  2. Write down the latest commit hash on github before the PR has been closed.
  3. git push -f origin :
@nickmccurdy
nickmccurdy / config.yml.erb
Created April 21, 2015 14:43
Using ERB with a YAML config file in Ruby
:uri: http://example.com/?host=<%= hostname %>
@brianr
brianr / gist:d7e61965fca488636da8
Last active August 29, 2015 14:18
RQL queries for deploys
-- select all deploys
select * from deploy;
-- select main columns for all deploys of a specific revision
select id, timestamp, environment, comment from deploy
where revision = 'some git sha here'
-- deploys of 'production' by revision, and when they were first and last deployed
@chsh
chsh / pg_pub_sub.rb
Last active May 2, 2024 08:13
PostgreSQL LISTEN/NOTIFY example for ruby
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
@subfuzion
subfuzion / global-gitignore.md
Last active May 5, 2024 19:34
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file:

  • Create a file called .gitignore in your home directory and add any filepath patterns you want to ignore.
  • Tell git where your global gitignore file is.

Note: The specific name and path you choose aren't important as long as you configure git to find it, as shown below. You could substitute .config/git/ignore for .gitignore in your home directory, if you prefer.

# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.