Skip to content

Instantly share code, notes, and snippets.

Fayi Femi-Balogun fayimora

View GitHub Profile
View arda-d3.js
// Define the size of the canvas above so we can re-use it later to generate co-ordinates
var width = 1000;
var height = 1000;
// create our canvas
var canvas = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
// Helper function to help generate coords.
View spring-redis.conf
spring.redis.cluster.max-redirects= # Maximum number of redirects to follow when executing commands across the cluster.
spring.redis.cluster.nodes= # Comma-separated list of "host:port" pairs to bootstrap from.
spring.redis.database=0 # Database index used by the connection factory.
spring.redis.url= # Connection URL, will override host, port and password (user will be ignored), e.g. redis://user:password@example.com:6379
spring.redis.host=localhost # Redis server host.
spring.redis.password= # Login password of the redis server.
spring.redis.ssl=false # Enable SSL support.
spring.redis.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the
View Serialization.scala
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream}
object Serialization extends App {
def serialise(value: Any): Array[Byte] = {
val stream: ByteArrayOutputStream = new ByteArrayOutputStream()
val oos = new ObjectOutputStream(stream)
oos.writeObject(value)
oos.close
stream.toByteArray
View .spacemacs.el
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
View wat.scala
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
val x = 5
val y = 6
def makeFuture(text: String) = Future { println(text) }
for {
foo <- makeFuture("hi") if x == 5
bar <- makeFuture("yo") if y == 4
View .spacemacs.el
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@fayimora
fayimora / components.hider-component.js
Last active Apr 18, 2017 — forked from courajs/components.hider-component.js
Conditionally rendered components
View components.hider-component.js
import Ember from 'ember';
import through from '../indirect';
// Inlined, since no addons in twiddles. Really use this:
// import through from 'ember-computed-indirect/utils/indirect';
export default Ember.Component.extend({
user: Ember.inject.service('user-permissions'),
flagName: '', // specify in extending component
flagPath: Ember.computed('flagName', function() {
return 'user.permissions.' + this.get('flagName');
View CourseForm.js
import React, { PropTypes } from 'react';
import TextInput from '../common/TextInput';
import SelectInput from '../common/SelectInput';
const CourseForm = ({course, allAuthors, onSave, onChange, loading, errors}) => {
return (
<form>
<h1>Manage Course</h1>
<TextInput
name="title"
View main.go
package main
import (
"fmt"
"github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
)
func main() {
View explanation-functor-monad.md

I think the better approach is to know what is a Functor before asking about Monads.

A Functor is a Higher Kinded Type/Type Constructor/Function at the type level that has a certain shape (that is, it implements a map function). A Functor is also what's known as a typeclass. A Monad is also a typeclass

Typeclasses are a form of ad-hoc polymorphism that let you add functionality to existing code that you may or may not have written.

Here's is the basic definition of a Functor

trait Functor[F[_]] {
    def map[A, B](fa: F[A])(f: A => B): F[B]
You can’t perform that action at this time.