Skip to content

Instantly share code, notes, and snippets.

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?
@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"
@mankind
mankind / rails-jsonb-queries
Last active January 29, 2024 05:38
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")
(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)
@siers
siers / collect-times
Last active December 16, 2015 12:15
Vim startup time profiler
#!/bin/bash
while sleep 0.5; do vim --startuptime "$@" >(./startup-info) +qall; done
# usage: ./collect-times
# Running this will collect startup times in `times' directory.
# It will run it multiple times so that the averages start converging.
# Whenever you remove a plugin, it gets stored as a different version,
# which will be shown at 'watch ./watcher'.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@jhchabran
jhchabran / 1_google_map.cljs
Last active February 13, 2019 12:00
Google Map component, with reagent and reframe. Questions asked on Clojurians #re-frame's channel.
; Following code is WRONG, see comments for details.
(defn google-map []
(let [pos (subscribe [:current-position])]
(reagent/create-class
{:reagent-render
(fn []
[:div
[:h4 "Map"]
[:div#map-canvas {:style {:height "400px"}}]])

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@visualjeff
visualjeff / dockerfile
Created August 7, 2014 20:42
Dockerfile for ember-cli
# Docker version 1.1.2, build d84a070
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y \
git \
software-properties-common \
python-software-properties \
make\
gcc \
g++ \
@john2x
john2x / 00_destructuring.md
Last active March 15, 2024 14:24
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences