This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example.cache-util | |
(:require [clojure.core.cache :refer [lru-cache-factory ttl-cache-factory]] | |
[clojure.core.cache.wrapped :refer [lookup-or-miss]] | |
)) | |
(defmacro defn-lru-ttl-cached-by-key | |
"Defines function name, which will cache using the return value of key-fn which is passed args. | |
If cache miss, will run the value-forms which will have args in scope." | |
[name doc | |
max-qty ttl-ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Example running HTTPKit REST JSON service | |
;; http://localhost:9843/api/example?q=12344 | |
;; http://localhost:9843/ | |
;; Add these to your project.clj | |
;; [ring "1.9.6"] | |
;; [ring/ring-defaults "0.3.4"] | |
;; [compojure "1.7.0"] | |
;; [http-kit "2.6.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateHttpLogsTable < ActiveRecord::Migration | |
def change | |
create_table :http_request_logs do |t| | |
t.datetime :created_at | |
t.string :request_method | |
t.text :path | |
t.jsonb :params | |
t.integer :http_status | |
t.integer :bytes_sent | |
t.integer :bytes_received |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
import Ember from 'ember'; | |
import ENV from 'my-app/config/environment'; | |
Ember.ENV.DEBUG = true; | |
const {get} = Ember; | |
const ElasticSearchAdapter = DS.JSONAPIAdapter.extend({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest' | |
class Api::V2::FileStorageController < ApplicationController | |
skip_before_filter :authorize, :only => [:save, :serve] | |
before_filter :authorize_admin_api_token, :only => [:save] | |
def save | |
if params[:contents].is_a?(ActionDispatch::Http::UploadedFile) | |
params[:contents].close(false) # close and don't delete so we can import it | |
tmp_file = params[:contents] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PouchDB from 'pouchdb'; | |
import { Adapter } from 'ember-pouch'; | |
var db = new PouchDB('app-database'); | |
export default Adapter.extend({ | |
db: db, | |
// Generates something like: 9f6kf-xz6by | |
// Much nicer than a full uuid |