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))
<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?
@retro
retro / canjs_firebase_chat_demo.html
Created April 13, 2012 12:44
Implementation of Firebase chat demo with CanJS. Uses observable and live binding
<html>
<head>
<title>CanJS Firebase chat demo</title>
<script type='text/javascript' src='http://static.firebase.com/demo/firebase.js'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script type="text/javascript" src="http://retro.github.com/javascripts/can.jquery.js"></script>
<link rel='stylesheet' type='text/css' href='http://www.firebase.com/css/example.css'>
</head>
<body>
<div id='messagesDiv'></div>