- Resources are programatic data constructs that can optionally have actual data associated with them
- Actions are operation that are performed programmatically
- A Role has association with zero or more resources and their corresponding actions
- A User is associated with zero or more roles
- All actions are applicable on all resources
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
from collections import OrderedDict | |
from time import time | |
import enum | |
class CacheStrategy(enum.Enum): | |
TTL = "TTL" | |
LRU = "LRU" | |
LFU = "LFU" |
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 React from "react"; | |
import * as Flux from "./Flux"; | |
export default class App extends Flux.Component { | |
getState(data) { | |
return { name: data.name }; | |
} | |
componentWillMount() { | |
setTimeout(() => Flux.Component.__update_context__({ name: "World" }), 2000); // Async response |
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
// Elm lang supports creating functions which can be used like an infix operator | |
// Ex: 1 + 2 |> (\n -> n == 3) -- "|>" is the infix operator and the code returns True | |
// If we look at the type of this operator, it would look like: | |
// |> : a -> (a -> b) -> b | |
// Now, let's try to do this in JavaScript. | |
// Firstly, we need a piper which would take any data and return a pipe-able data-type | |
// Next, every function call - when piping - should return a pipe-able data type | |
// A pipe-able data type is capable of executing a specific function |
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
#[macro_use] | |
extern crate serde_json; | |
#[macro_use] | |
extern crate serde_derive; | |
extern crate serde; | |
use serde::{ | |
de::{Error, MapAccess, Unexpected, Visitor}, | |
Deserialize, Deserializer, | |
}; |
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
module Loop exposing (forEach) | |
loop : List a -> List b -> (a -> Int -> b) -> List b | |
loop a b fn = | |
case a of | |
[] -> | |
b | |
x::xs -> | |
loop xs (b ++ [(fn x (List.length b))]) fn |
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 * as React from 'react' | |
import { StyledComponent } from './StyledComponent' | |
function Spinner(props) { | |
return ( | |
<div className={'w--spinner ' + props.customClass}> | |
<div className="bounce1" /> | |
<div className="bounce2" /> | |
<div className="bounce3" /> | |
</div> |
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
function curry(callable) { | |
return function(...args) { | |
if (callable.length <= args.length) { | |
return callable.apply(null, args) | |
} else { | |
return curry(callable).bind(null, ...args) | |
} | |
} | |
} |
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
function thresholder(callback, holdMillis, resetOnEachCall) { | |
let timer = null | |
let args | |
return function() { | |
args = arguments | |
if (timer && resetOnEachCall) { | |
clearTimeout(timer) | |
timer = null |
NewerOlder