Skip to content

Instantly share code, notes, and snippets.

@rbresearch
rbresearch / server.R
Created March 4, 2013 12:20
Shiny with Performance Analytics Example
library(shiny)
library(PerformanceAnalytics)
data(managers)
# Define server logic required to plot relative performance
shinyServer(function(input, output) {
# Use charts.PerformanceSummary from Performance Analytics package
# to generate a performance summary plot
@a2ndrade
a2ndrade / gist:5235019
Last active December 15, 2015 08:59
Datomic: constructor-like transaction function
; See http://stackoverflow.com/questions/15595540/datomic-insert-blocks
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
(d/transact conn [{:db.install/_attribute :db.part/db
:db/id #db/id[:db.part/db]
:db/ident :car/model
@dustingetz
dustingetz / gist:5250571
Last active December 15, 2015 11:09
Datomic entity navigation, for my blog post
(ns artscentre.orm.scratch
(:use [datomic.api :only [db q] :as d]
[datomico.core :only [build-schema]]
[artscentre.datomic-util]))
(def Skill (build-schema :Skill [[:name :string :unique]
[:description :string]]))
@a2ndrade
a2ndrade / gist:5651419
Last active December 23, 2020 16:11
Datomic: data model for a simple blog
;; see http://stackoverflow.com/questions/14724991/modelling-multiple-many-to-many-relationships-in-datomic
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
(d/transact conn [ ;; User
{:db/id #db/id [:db.part/db]
:db/ident :user/username
@a2ndrade
a2ndrade / gist:5654999
Last active April 11, 2020 23:13
Datomic: database functions and foreign-key constraints
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
(d/transact conn [{:db/id #db/id [:db.part/db]
:db/ident :enum/ns
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "Enum's namespace. Help enforce fk constraints on :db.type/ref enum references"
@willurd
willurd / web-servers.md
Last active August 5, 2025 00:46
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@wvdlaan
wvdlaan / core.clj
Last active March 16, 2018 06:53
Datomic multiple attribute key example
(ns myupsert.core
(require [datomic.api :as d]))
(def schema
[
{:db/id #db/id [:db.part/db]
:db/ident :product/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}
@a2ndrade
a2ndrade / gist:5820364
Created June 20, 2013 04:44
Datomic: nested component entities
;; see http://stackoverflow.com/questions/16242750/nesting-structures-with-datomic
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
;; sample attributes
(d/transact conn [{:db/id #db/id[:db.part/db]
:db/ident :some/ref-value
:db/valueType :db.type/ref
@sebastianseilund
sebastianseilund / merged_array.js
Last active December 20, 2015 07:58
An implementation of a merged array in Ember.js that combines items from multiple source arrays so you can easily list them together in your Handlebars templates. Read the blog post at the [Billy's Billing Developer Blog](http://dev.billysbilling.com/blog/How-to-merge-multiple-data-sources-into-one-array-in-Ember-js)
/**
* `Ember.MergedArray` is an array that observes multiple other arrays (called source arrays) for changes and includes
* all items from all source arrays in an efficient way.
*
* Usage:
*
* ```javascript
* var obj = Ember.Object.create({
* people: [
* {
@alexspeller
alexspeller / base64encode.js.coffee
Last active December 21, 2015 04:38
Ember Table Extensions
# So, this is pretty horrible. If we just encode using btoa, any UTF-8 chars cause an error.
# If we use either of the workarounds on MDN[1], the £ sign is encoded wrong. I suspect
# Excel totally sucking at encodings is the reason why. So, the workaround is, to use
# the MDN workaround on chars with values > 255, and allow chars 0-255 to be encoded
# as is with btoa. Note that if you use either of the workarounds on MDN, chars
# 128-255 will be encoded as UTF-8, which includeds the £ sign. This will cause excel
# to choke on these chars. Excel will still choke on chars > 255, but at least the £
# sign works now...
# [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding