Skip to content

Instantly share code, notes, and snippets.

View JasonTrue's full-sized avatar
:octocat:
Looking for new project work (or a Real Job™)

Jason Truesdell JasonTrue

:octocat:
Looking for new project work (or a Real Job™)
View GitHub Profile
@JasonTrue
JasonTrue / flatten_hash.rb
Last active September 28, 2015 20:07
Flatten a hash structure
def flatten_hash(hash={}, context="", new_hash={})
hash.each do |key, value|
flattened_key = context.empty? ? key : "#{context}_#{key}"
if value.respond_to? :key
flatten_hash(value, flattened_key, new_hash)
else
new_hash[flattened_key]=value
end
end
new_hash
@JasonTrue
JasonTrue / searchkick_and_elasticsearch_guidance.md
Last active July 17, 2024 10:01
Searchkick and Elastic Search guidance

Resources:

https://github.com/ankane/searchkick

Indexing

By default, simply adding the call 'searchkick' to a model will do an unclever indexing of all fields (but not has_many or belongs_to attributes).

In practice, you'll need to customize what gets indexed. This is done by defining a method on your model called search_data

def search_data

@JasonTrue
JasonTrue / most_recent_notifications_older_than.sql
Created February 28, 2020 03:38
most_recent_notifications_older_than some date
select v.name, max(n.inserted_at)
from variables v
left join notifications n on v.id = n.variable_id
where tenant_id = 2
group by v.name
having max(n.inserted_at) < '2020-02-28 12:25:07.000000'
or max(n.inserted_at) is null --disjunction clause

How to succeed in hiring without really hazing

Tech job interviews suck. Make them suck less to attract better peoople.

You aren't a big fan of the typical tech interview process. Why not?

Mainly because success or failure in the interview is often not well-correlated to success in the actual role. Objective-sounding criteria are often more capricious than they appear at first glance, and can easily filter out excellent engineers, and are often a better indicator of who did the best interview prep than anything else.

Redirecting a Git repository

Let's say you have a project depending on a private git repository that your CI server needs access to, or a third-party developer.

In our case, it's an Elixir dependency in our Mix.exs file that looks like this:

{:my_private_dependency, git: "[email protected]:original-organization/my_private_dependency.git", ref: "46de95907bc4e636acd798ba19c43138f72199de"},