Skip to content

Instantly share code, notes, and snippets.

WITH "cte-133417" AS MATERIALIZED (
SELECT
"film"."film_id" AS "film-id",
"film"."title" AS "title"
FROM
"film" AS "film"
ORDER BY
"film"."title" FETCH NEXT 5 ROWS ONLY
)
SELECT
(ns app-name.middleware.cors
"Ring middleware for Cross-Origin Resource Sharing."
(:require [clojure.set :as set]
[clojure.string :as str]
[macchiato.util.response :as r :refer [get-header]]))
(defn origin
"Returns the Origin request header."
[request] (get-header request "origin"))
;; Pipelines are a new way to write controller action handlers for Keechma.
;; They are a part of the (soon-to-be-released) Keechma Toolbox - https://github.com/keechma/keechma-toolbox
;;
;; In this case we implemented a live Movie Search (it's hitting http://www.omdbapi.com/) where the pipeline is called on every
;; keypress, and makes request after a 500ms timeout. This pipeline is exclusive so if a pipeline is running when the next
;; keypress happens, it will be cancelled (along with the AJAX request) and another pipeline will be started.
;;
;; https://github.com/keechma/keechma-toolbox/tree/master/src/cljs/keechma/toolbox/pipeline
(def search-controller
-- Function: clone_schema(text, text)
DROP FUNCTION clone_schema(text, text);
CREATE OR REPLACE FUNCTION clone_schema(source_schema text, dest_schema text)
RETURNS void AS
$BODY$
DECLARE
seq RECORD;

Why Keechma?

Here are some of my thoughts related to Keechma and why you should try it out…

Unlike the “Keechma Design Decisions” post, this one is purely subjective, and appealing to your emotions.

Globals

Globals are bad.

(deftest trying-to-click-non-existing-element []
(syn-run!
(<! (s/click! ".non-existing-element")) ;; Waits for the element to appear on the page up to 6 seconds
(is false "This should never run"))) ;; will never run, and test will cleanly exit
(deftest typing []
(let [[container cleanup] (container!)
bootstrap #(el! "input" container)]
(.setTimeout js/window bootstrap 2000) ;; Add the element to page after two seconds
(syn-run!
;; If it's for the user stored in the `:current-user` named slot
(def schema {:users {:id :id}})
(def current-user-favorite-color [app-db]
(reaction
(let [db @app-db
current-user (edb/get-named-item schema app-db :users :current)]
(:favorite-color current-user))

Keybase proof

I hereby claim:

  • I am retro on github.
  • I am retro (https://keybase.io/retro) on keybase.
  • I have a public key whose fingerprint is 30F9 39EA 1BAC 3D1E 755B 27FF ABCB 01C8 06D4 3752

To claim this, I am signing this object:

<html>
<head>
<title>Tabs Demo!</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.container {
margin-top: 20px;
}
</style>
</head>
@retro
retro / app.rb
Created August 30, 2012 10:18
Map classes to sinatra routes
require 'rubygems'
require 'sinatra'
class Handler
attr_reader :context
def initialize(context)
@context = context
end
def render
unless context.params[:username].nil?