Giter Site home page Giter Site logo

munificent / journal Goto Github PK

View Code? Open in Web Editor NEW
93.0 93.0 16.0 37.95 MB

My blog, in all its statically-generated glory.

Home Page: http://journal.stuffwithstuff.com/

Ruby 0.01% Python 0.01% JavaScript 8.74% CSS 0.40% HTML 83.50% SCSS 0.43% Makefile 0.03% Dart 6.82% C 0.01% C++ 0.01% C# 0.04% Go 0.01% Java 0.01% NewLisp 0.01% OCaml 0.02% Smalltalk 0.01%
blog

journal's People

Contributors

jrheard avatar munificent avatar tkharaishvili avatar tosh avatar zellyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

journal's Issues

re: what-is-open-recursion.md

Using decorator pattern instead of super feels more js. :)

R = require 'ramda'
log = console.log

# ## orignal impl
makeCounter = ( count = 0 ) ->
    get = -> count
    inc = -> count = count + 1
    set = (x) -> count = x
    {get, inc, set}

# # decorate pattern
#
# Wrap a function inside another to allow you to
# make adjustments to the parameters,
# or do other processing either before the internal function
# is called or with its results.
logIt = (msg, f) ->
    R.wrap f, (func, arg) ->
        log msg
        func(arg)

# ## V1
makeLoggingCounter = ( count = 0 ) ->
    set = logIt 'set!', (x) -> count = x
    get = logIt 'get!', -> count
    inc = logIt 'inc!', -> count = count + 1
    {get, inc, set}


# ## V2
mkLoggedCounter = () ->
    c = makeCounter()
    get = logIt 'get!', c.get
    inc = logIt 'inc!', c.inc
    set = logIt 'set!'. c.set
    {get, inc, set}

re: what-color-is-your-function

original function

  function makeSundaeOriginal(callback) {
    scoopIceCream(function (iceCream) {
      warmUpCaramel(function (caramel) {
        callback(pourOnIceCream(iceCream, caramel));
      });
    });
  }

with a biased assumption

scoopIceCream and warmUpCaramel are used only for side-effect?

pourOnIceCream is used though.

let me assume the intention is this

      function makeSundae(callback) {
        return function (iceCream) {
          return function (caramel) {
            return callback(pourOnIceCream(iceCream, caramel));
          };
        };
      }

      // try to simplify that


      var _ = require('ramda'),
        add = _.curry(function (a, b) { return a + b }),
        pourOnIceCream = add
        log = console.log;


      //step 1

      var makeSundaeSimpl  = function (callback) {
        return _.compose(callback, pourOnIceCream)
      };

      // step 2

      var makeSundaeSimpl = function (callback, pourOnIceCream) {
        _.compose(callback, pourOnIceCream)
      };

      // step 3

      var makeSundaeSimpl = _.compose;

      makeSundaeSimpl(log, add)(1, 2)

YES! makeSundae is the good old compose.
Or composeP if callback and pourOnIceCream are promises.
http://ramdajs.com/0.15/docs/#composeP
We don't need to defined it ourselves.
But we need to pass in the argument iceCream and caramel together.

      // get fancy?

      var g = _.curry(function (cb, f, a, b) {
        cb(f(a,b))
      });

      g(log, add)(1, 2)
      g(log, add)(1)(2)
      g(log)(add)(1, 2)
      g(log)(add)(1)(2)
      // =>  all log 3 to screen

without assumptions

callbcak, warmUpCaramel and scoopIceCream will be called in the order of the orignal function. They can be promise functions or regular functions. pipeP can handle both. Use async.seq if you like.

    var R = require('ramda'),
        v1,
        add,
        warmUpCaramel,
        scoopIceCream,
        log = console.log;

    v1 = R.curry(function (callback, iceCream, caramel) {
        var f = function () {
            return callback(iceCream, caramel);
        };
        R.pipeP(f, warmUpCaramel, scoopIceCream)();
    });

    add = function (a, b) {
        log('add', a + b);
        return a + b;
    };

    warmUpCaramel = function (x) {
        log('warmUpCaramel', x);
        return x;
    };

    scoopIceCream = function (x) {
        log('warmUpCaramel', x);
        return x;
    };

    v1(add, 1,2)
    v1(add)(1,2)
    v1(add)(1)(2)

    // all log to console
    // add 3
    // warmUpCaramel 3
    // warmUpCaramel 3

but the code is longer!

That's because in the original funciton, all helper functions are defined somewhere else. Taking that approch, the function most likely mimic the orignal one would be:

    var R = require('ramda'),
        v1;
    v1 = R.curry(function (callback, iceCream, caramel) {
            var f = function () {
                return callback(iceCream, caramel);
            };
            R.pipeP(f, warmUpCaramel, scoopIceCream)();
        });

wrong date in README

Hey

looks like your README file says 2008-2011. I know it must be so glorious at Google that you forget time entirely, but pls update. ๐Ÿ˜„

Build requirements

I've been playing with the idea of starting a blog and yours was one of the templates I tried out. I had some problems building your blog with Jekyll. Jekyll was producing empty HTML files. I tracked the error to here.

I discovered that to build your blog, I had to have the following versions of software due to incompatibility with pygments:

  • Ruby 2.0.0
  • Python 2.7.6
  • Pygments 0.5.0

I had to uninstall Python 3 and install 2.7.6, and uninstall Pygments 0.5.4 and install 0.5.0. It also complained about missing the magpie lexer. These problems can of course be fixed by deleting the posts that contain code. I was starting from scratch so deleting all posts makes sense for me. Nevertheless, I thought I'd just create an issue in case some other chap tries to build the blog.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.