Skip to content

Instantly share code, notes, and snippets.

View gretch's full-sized avatar

Gretch Gapol gretch

  • Sydney, Australia
View GitHub Profile
@gretch
gretch / rails-jsonb-queries
Created October 8, 2025 23:13 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@gretch
gretch / gist-unlocking-the-secrets-of-rails-secrets-and-credentials.md A comprehensive examination of Rails Secrets, Credentials, and Secret Key Base

Unlocking the Secrets of Rails Secrets and Credentials

Interurban Tunnel at Blackhand Gorge- Brian J Bayer


If you are like many (most?) of us, you have encountered Rails Credentials/Secrets and secret_key_base and may have been left a bit (or more) confused.

This post is an attempt to remove some of that confusion by

<% Category.order(:name).each do |category| %>
<ul>
<li><%= category.name %></li>
<ul>
<% category.sub_categories.each do |sub_category| %>
<li><%= sub_category.name %></li>
<% end %>
</ul>
</ul>
<% end %>
Feature: Items in scheduled
As an singed up user
I want to manage my todos or projects which placed in scheduled
Background:
Given I am a confirmed user and signed in as "[email protected]" with password "iamtom"
Scenario: Move a new todo to Scheduled
When I create a todo "To meet David" on "" about "About trip planning"
And I drag todo "To meet David" to place Scheduled
@gretch
gretch / gist:878957
Created March 21, 2011 03:14
resque - monit
#from defunkt
check process resque_worker_QUEUE
with pidfile /data/APP_NAME/current/tmp/pids/resque_worker_QUEUE.pid
start program = "/bin/sh -c 'cd /data/APP_NAME/current; nohup rake environment resque:work RAILS_ENV=production QUEUE=queue_name VERBOSE=1 PIDFILE=tmp/pids/resque_worker_QUEUE.pid & > log/resque_worker_QUEUE.log" as uid deploy and gid deploy
stop program = "/bin/sh -c 'cd /data/APP_NAME/current && kill -s QUIT `cat tmp/pids/resque_worker_QUEUE.pid` && rm -f tmp/pids/resque_worker_QUEUE.pid; exit 0;'"
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
group resque_workers