Skip to content

Instantly share code, notes, and snippets.

// This is your Prisma schema file,
// learn more about it in the docs
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("PG_URL")
@ldayan
ldayan / gist:e9b3f1d0a8a1e42479b90b811b80c95a
Created July 15, 2016 03:03 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
-- clean up database from previous test
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
-- create EAV tables
CREATE TABLE entity (
id SERIAL PRIMARY KEY,
name TEXT,
description TEXT
);
@ldayan
ldayan / simple-clojure-scala-interop.scala
Created June 23, 2016 17:40 — forked from matlux/simple-clojure-scala-interop.scala
Clojure and Scala are both amazing functional languages that have a lot in common. For example their immutable data structures. Both have some amazing libraries. Why not being able to call one from the other? This is a simple Clojure in Scala interop. This is an example showing how to call Clojure function within Scala using standard Scala data …
sealed trait EdnExpr {
def value : Expr
def mdata : Map[Expr,Expr]
override def equals(other : Any) = other match {
case that : EdnExpr => this.value == that.value
case _ => false
}
}
type Expr = Any

A state machine is defined as follows:

  • Input - a set of inputs
  • Output - a set of outputs
  • State - a set of states
  • S0 ∈ S - an initial state
  • T : Input * State -> Output * State - a transition function

If you model your services (aggregates, projections, process managers, sagas, whatever) as state machines, one issue to address is management of State. There must be a mechanism to provide State to the state machine, and to persist resulting State for subsequent retrieval. One way to address this is by storing State is a key-value store. Another way is to use a SQL database. Yet another way is event sourcing. The benefit of even sourcing is that you never need to store State itself. Instead, you rely on the Output of a service to reconstitute state. In order to do that, the state machine transition function needs to be factored into two functions as follows:

import { Dispatcher } from 'flux'
function isPromise(obj) {
return obj && (typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function'
}
const inject = Math.random().toString(16).substr(2, 7)
class Alt {
curl -sS https://getcomposer.org/installer | php
composer global require drush/drush:dev-master
drush qd --core=drupal-8.0.x
# Note the password created for admin will be different from the examples. Either change example or in your Drupal install.
cd quick-drupal
drush en rest hal basic_auth -y
# Create a new page node
curl --include \
--request POST \
--user admin:password \
@ldayan
ldayan / introrx.md
Last active August 29, 2015 14:19 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@ldayan
ldayan / zend2-nginx
Last active August 29, 2015 14:16 — forked from pderoubaix/zend2-nginx
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /home/example/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name dev.apigility.com;
<?php
/* We'll assume that all of the above classes are defined.
*
* We'll assume that Api\V1\Rpc\Query\QueryController will handle an RPC service
* call to /search?s=thing. It needs to be configured such that it responds to
* GET requests, and Content Negotiation is set to HalJson.
*
* This is what it will look like:
*/