Better HN
topnewbestaskshowjobs
Log inSign up

elclanrs

33 karma · joined May 21, 2012 (14y ago) · 73 submissions

Submissions

comment 10y ago · link · parent

Do you mean like npm's shrinkwrap [1]?

[1] https://docs.npmjs.com/cli/shrinkwrap

comment 11y ago · link · parent

Unfortunately that won't work as expected, you'll need something ugly like:

  Array.apply(null, Array(26)).map((_, index) => String.fromCharCode(65 + index))

comment 11y ago · link · parent

I find it useful to have `unary` and `apply` around:

  [1,2,3].map(unary(User))
  [[1,2],[3,4],[5,6]].map(apply(User))

comment 12y ago · link · parent

In dynamic languages I don't see the need to create a Monad interface. I'd create classes/objects and simply use instances of those objects. As long as they conform to the desired interface, and you can check their relationships, then it should work; and use monkey-patching if necessary, embracing the dynamic nature of the language. I don't think it is possible to fully translate Haskell examples without the types, but you can adapt the ideas to other languages and get very similar functionality, in JavaScript for example:

    class Maybe {
      constructor(value) {
        if (value != null) {
          return new Just(value)
        }
        return new Nothing()
      }
      bind(f) {
        if (this instanceof Just) {
          return f(this.value)
        }
        return new Nothing()
      }
    }

    class Just extends Maybe {
      constructor(value) {
        this.value = value
      }
      toString() {
        return `<Just ${this.value}>`
      }
    }

    class Nothing extends Maybe {
      constructor() {
        this.value = null
      }
      toString() {
        return '<Nothing>'
      }
    }

    var result = Maybe(2).bind(x => {
      return Maybe(3).bind(y => {
        return Maybe(x + y)
      })
    })

    console.log(result.toString()) // <Just 5>

comment 12y ago · link · parent

Function declarations inside blocks are illegal, technically, because of hoisting. See http://kangax.github.io/nfe/#function-declarations-in-blocks

comment 12y ago · link · parent

I was a Photoshop user for a long time, but haven't looked back since I moved to Linux full time a few years back. The challenge was to use libre software for everything and reduce my business' expenses. It's been 4 years since then and I don't miss Photoshop. I realized in the process the I was terribly misusing it. It was my goto tool for everything, from web design, to photo retouch, to vector, icons...

I have a background in 3D & VFX but my work today is mostly web development, and opensource software covers all my needs. MyPaint for free drawing like brainstorming, illustrations, and blueprints. Inkscape for vector graphics like icons, logos, layouts, mockups. Darktable for simple photo editing. GIMP for heavy photo retouch, and well, it's still my goto tool for those quick screenshots, image cropping jobs. And Blender for 3D work of course. I hardly do print, but when I do I use Inkscape, HTML and CSS.

TLDR; Photoshop isn't the best for every task. There are free software alternatives for everything. Using them all together provides me with all that I need, so I no longer miss Photoshop.

comment 12y ago · link · parent

Nice laptop, but unusable website. It takes 3+ seconds to at least see something, and the scrolling effect makes everything seem so slow. There is an obvious memory leak somewhere, the graphs in devtools are INSANE for such a simple site, take a look http://imgur.com/j13Xk6h

comment 12y ago · link · parent

I find this paper [1] very interesting and elaborates on this issue -- "From experience it appears that there are three major semantic hurdles which trip up novice imperative programmers. In order they are: assignment and sequence, recursion/iteration and concurrency".

[1] http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf

comment 12y ago · link · parent

I agree. I think music and sports consciously impact your code as well. Skills with a mix of creativity and endurance are going to affect the way you think about problems, in general.

10.

Building a jQuery-like library(cedricruiz.me ↗)

1 points · by elclanrs · 12y ago · discuss

comment 12y ago · link · parent

Then Windows Update: "Your computer will restart in 10 minutes". Postpone 4 hours. Glad I'm on Ubuntu 99% of the time nowadays.

comment 12y ago · link · parent

Australis looks nice in Ubuntu. The new menu is much better with big icons and can be customized however you like it. It's great IMO. I took a couple screenshots from latest nightly release. http://i.imgur.com/19Iwy7r.png, http://i.imgur.com/6Kouk14.png

comment 12y ago · link · parent

"You might not need jQuery" -- But you have to cope with ugly syntax, browser compatibility hacks, and disconnected pieces of code. By the time you re-factor all of this, make it user friendly and lower the cognitive load, you're already re-inventing the wheel by building your own jQuery replacement, with the parts that you need.

The beauty of jQuery is working with the DOM as collections. I don't see how it's better to have all these helpers like `nextSibling`, `matches`, or `filter` thrown in the global scope or having to remember is this a real array? jQuery already built solutions for these common problems and exposes a nice API.

If all I need is querying the DOM and I don't have to support IE8 then I may consider using vanilla JavaScript, or building my own simple jQuery-esque library. But you'd start with some structure, and expose your own API. I re-invented the DOM wheel many times, and from my experience, although the code is smaller, I end up going back to jQuery because it covers some edge case or provides something else I need, like AJAX, or nice events, etc.

But building your own DOM library is a good educational challenge. Querying the DOM is all about collections, and if you don't need IE8 then you can use all the ES5 arrays methods, like map and filter. It all boils down to four functions to work with collections: toArray, unique, flatten and query. And four functions to work with the DOM: compose, join, dot, loop. See here for an example http://jsbin.com/EgIkega/1/edit. The article is more about techniques to build your own jQuery-like library; I wouldn't use "el.nextElementSibling || nextElementSibling(el)" when I can use "$(el).next()". C'mon!

Conclusion, you are probably going to use jQuery anyway.

comment 12y ago · link · parent

In LiveScript there's a := operator. From the docs -- "However, unlike CoffeeScript, you must use := to modify variables in upper scopes" -- I find LiveScript overall a better alternative to CoffeeScript. If you're into CS for the sugar, then you'll love LS.

comment 12y ago · link · parent

Looks like a nice library, but I'm not in love with the syntax; I find it a bit confusing TBH... But it packs some nice features, specially the validation and precendece awareness. A simple overloading helper works for my needs though, ie: https://gist.github.com/elclanrs/8515458

comment 12y ago · link · parent

You can use viewport units in modern browsers. See here http://caniuse.com/viewport-units

comment 12y ago · link · parent

I'd use:

  bar = bar != null ? bar : 'default';

comment 12y ago · link · parent

Ubuntu 13.10 on both desktop and laptop. I just love Unity.

19.

"do" monad syntax in JavaScript(jsbin.com ↗)

1 points · by elclanrs · 12y ago · discuss

comment 13y ago · link · parent

I would definitely go with ASUS Zenbook. I have the 13.3 Zenbook (i5, 4gb, 1080p) and I can code very comfortably on it. The IPS screen is great and even better once calibrated. It's very sleek too, solid aluminum build. ASUS is a big brand, Zenbooks are popular for their nice quality/price ratio.

comment 13y ago · link · parent

Well, I downloaded IE11 to replace IE10 on my VM, and all the issues I had with my current WIP are still present. I'm using `calc()` heavily for a quite complex responsive layout, and paddings are missing on some places and CSS transitions don't work properly while everything works just fine in Firefox and Chrome. I haven't been able to find what's causing these issues, but given IE's history, I suspect that a fix could simply be `zoom:1` or `min-height:100%` or whataver hack du jour you have to remember this time around.

So not at all impressed by this release so far. Will have to wait another year for IE12 and hope it can really compete with FF and Chrome, that means, opening IE and having no surprises.

comment 13y ago · link · parent

ASUS Zenbooks are great, very light, solid aluminum build, 1080p IPS matte panel, 6+ hours battery life. I'm quite happy with mine.

comment 13y ago · link · parent

Right, gratis = free, libre = free.

comment 13y ago · link · parent

You can avoid pulling the repo everytime if you create a hook. In Ubuntu real quick, with default LAMP stack:

    git init --bare --shared=group /srv/git/app.git
    mkdir /var/www/app
    chown -R www-data:www-data /srv/git/app.git /var/www/app
    chmod -R g+rw /srv/git/app.git /var/www/app
    vim /srv/git/app.git/hooks/post-receive
      #!/bin/sh
      export GIT_WORK_TREE=/var/www/app
      git checkout -f dev # dev branch
      cd /var/www/app
      # Run composer, npm, etc...
    chmod +x /srv/git/app.git/hooks/post-receive
Whenever you push it'll checkout the dev branch in your public web folder. Now, that's instant deployment!

comment 13y ago · link · parent

I don't think so. Heroku is a PaaS (Platform as a Service). You can connect with SSH but everything is mostly set-up for you already but I don't have Heroku so I'm not sure. A VPS (Virtual Private Server) is just a remote computer typically with a bare Linux installation, and you build up from there and install what you need, Ruby, Node, PHP... Check https://www.digitalocean.com/, they're pretty popular.

comment 13y ago · link · parent

If you want a good challenge, get a private VPS for $5/month and set everything up yourself: SSH, Apache, users, permissions, Git repo, etc...

comment 13y ago · link · parent

I see the potential of these kind of applications, it's a killer product for their target audience. But I can't see how this would fit in my WordPress workflow to be honest.

I tried the demo and the interface looks great but I feel restricted. My process usually begins in Inkscape. I build all the layouts in vector and once I have a good idea of how they should look like I grab my WordPress boilerplate folder and build the theme from scratch; no static first, just dynamic as I go. They're not complete themes though, just what's needed for the given project.

So yeah, great product, looks good, but I won't use it. I had the same thoughts about Adobe Reflow. Tried it, liked it, maybe for a static portfolio site but other than won't be useful.

123