Skip to content

Instantly share code, notes, and snippets.

Avatar
🕶️
riding my bicycle

Giles gilesbradshaw

🕶️
riding my bicycle
  • SiGyl
  • Devon
View GitHub Profile
View map.js
// map with selectMany
function map(func) {
return this::selectMany(x => [func(x)]);
}
View selectMany.js
function selectMany(func) {
return this.reduce(
(acc, val) => [
...acc,
...func(val),
],
[],
);
}
View roller.js
it('observes a tree', marbles((m) => {
const a = {
children: [
{
children: [
{
name: 'esau',
},
{
name: 'jacob',
View gist:e037116a923e98cc7b2e04c3dbb09f13
import merge from 'lodash/merge';
/* eslint-env mocha */
describe('new test', () => {
it('works', () => {
const getIt = (x = {}) => {
const {
a = null,
b: {
@gilesbradshaw
gilesbradshaw / Dockerfile.slack
Created Mar 2, 2017 — forked from alexellis/Dockerfile.slack
Slack Dockerfile for 2.1.0
View Dockerfile.slack
FROM debian:stretch
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gconf2 \
@gilesbradshaw
gilesbradshaw / tag dependency
Last active Feb 25, 2016
Setting one opc tag fom another
View tag dependency
/* configuration..
<config updateRate="1000">
<ua endpoint="opc.tcp://localhost:49320/" />
<da endpoint="localhost" server="Kepware.KEPServerEX.V5" />
<dependencies>
<dependency name="dep1">
<from node="OPC.Tag1"/>
<to node ="OPC.Tag2"/>
</dependency>
View responsive hiding
.if-xs, .if-not-sm, .if-not-md, .if-not-lg {
display:inherit;
}
.if-not-xs, .if-sm, .if-md, .if-lg {
display:none;
}
@media (min-width: 48em) {
.if-xs, .if-not-sm {
display:none;
View poor mans concurrency
module Lab5 where
import Control.Monad
data Concurrent a = Concurrent ((a -> Action) -> Action)
instance Functor Concurrent where
fmap = liftM
instance Applicative Concurrent where
View The Sieve of Aristophenes
primes :: [Int]
primes = sieve [2..]
sieve :: [Int] -> [Int]
sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /=0]
@gilesbradshaw
gilesbradshaw / arithmetic parser
Last active Nov 28, 2015
arithmetic parse (and other stuff) eval "(1+2)*3+4"
View arithmetic parser
-- from hutton
import Control.Applicative -- Otherwise you can't do the Applicative instance.
import Control.Monad (liftM, ap)
import Data.Char
newtype Parser a = P(String -> [(a, String)])
You can’t perform that action at this time.