Skip to content

Instantly share code, notes, and snippets.

(ns kata-lights-out.core
(:require [reagent.core :as reagent :refer [atom]]))
;; -------------------------
;; Views
(def lights (atom [[1 1 1][1 1 1][1 1 1]]))
(defn neighbors [[x0 y0]]
(for [x (range 3)
@mankind
mankind / rails-jsonb-queries
Last active May 3, 2025 05:37
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")
@miguelmota
miguelmota / auth.go
Created February 11, 2019 21:26
Golang AWS Cognito Validate JWT token
package auth
import (
"crypto/rsa"
"encoding/base64"
"encoding/binary"
"encoding/json"
"fmt"
"io/ioutil"
"log"
due_date = Date.parse('2019-03-31')
instalments = Installment.delinquent.
where(due_date: due_date).
joins(:loan => :merchant).
where('DATE(loans.delinquent_at) = ?',due_date).
merge(Merchant.active)
instalments.find_each do |installment|
begin
if installment.payment_method&.debit?