News for hackers. Stuff that matters.

elclanrs

Re:Alert: NPM modules hijacked on Wednesday March 23, 2016 @01:53PM (#11346666)
Do you mean like npm's shrinkwrap [1]?

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

Re:Atom Shell is now Electron on Thursday April 23, 2015 @05:27PM (#9429962)
Unfortunately that won't work as expected, you'll need something ugly like:

  Array.apply(null, Array(26)).map((_, index) => String.fromCharCode(65 + index))
Re:New-less JavaScript (2013) on Thursday March 12, 2015 @05:50AM (#9189828)
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))
Re:Monads without pretension (2011) on Friday September 12, 2014 @04:48PM (#8310377)
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>
Re:Firefox 29 over optimized? on Tuesday May 20, 2014 @04:51AM (#7771709)
Function declarations inside blocks are illegal, technically, because of hoisting. See http://kangax.github.io/nfe/#function-declarations-in-blocks
Re:Switch from Photoshop to Gimp: Tips From a Pro on Thursday March 27, 2014 @09:17PM (#7484673)
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.

Re:The New Razer Blade on Thursday March 13, 2014 @01:39AM (#7390200)
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
Re:Learn C, Then Learn Computer Science on Monday February 10, 2014 @03:30AM (#7209799)
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

Re:Why Programming is Difficult on Friday February 07, 2014 @07:22PM (#7199711)
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.
Re:Firefox 27 Released on Wednesday February 05, 2014 @08:31PM (#7188143)
Then Windows Update: "Your computer will restart in 10 minutes". Postpone 4 hours. Glad I'm on Ubuntu 99% of the time nowadays.
Re:Firefox 27 Released on Wednesday February 05, 2014 @08:16PM (#7188077)
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
Re:You might not need jQuery on Thursday January 30, 2014 @06:26PM (#7154108)
"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.

Re:The worst thing about CoffeeScript on Saturday January 25, 2014 @04:53PM (#7122657)
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.
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
Re:PSD to HTML is Dead on Tuesday January 14, 2014 @07:53PM (#7060942)
You can use viewport units in modern browsers. See here http://caniuse.com/viewport-units
Re:Args.js – Optional and Default parameters for JavaScript on Monday January 13, 2014 @12:09PM (#7051840)
I'd use:

  bar = bar != null ? bar : 'default';
Re:Ask HN: What Linux distribution do you use? on Sunday December 29, 2013 @04:02AM (#6978943)
Ubuntu 13.10 on both desktop and laptop. I just love Unity.
Re:Ask HN: Developer laptop under $2000? on Monday November 11, 2013 @04:25AM (#6710746)
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.
Re:IE11 for Windows 7 Globally Available on Thursday November 07, 2013 @05:55PM (#6693049)
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.

Re:Ask HN: what is the best laptop for a web development? on Saturday October 19, 2013 @09:33PM (#6578669)
ASUS Zenbooks are great, very light, solid aluminum build, 1080p IPS matte panel, 6+ hours battery life. I'm quite happy with mine.
Re:Why Free Software Is More Important Now Than Ever Before on Saturday September 28, 2013 @11:30PM (#6463997)
Right, gratis = free, libre = free.
Re:Simple deployment with git on Friday September 20, 2013 @05:53PM (#6420745)
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!
Re:Ask HN: How/where should I host my personal site? on Monday August 12, 2013 @11:55PM (#6203914)
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.
Re:Ask HN: How/where should I host my personal site? on Monday August 12, 2013 @09:19PM (#6203435)
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...
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.

Re:How Much to Charge as a Freelancer on Friday July 26, 2013 @07:43PM (#6111170)
Maintenance is a monthly fee, forgot to mention that. Sometimes clients do call in unfortunate situations, but they pay for that privilege. All additional services are opt-in.
Re:How Much to Charge as a Freelancer on Thursday July 25, 2013 @09:02PM (#6106014)
As a freelancer I think overall, clients prefer fixed prices over hourly rates. I take this approach, if project takes less than 10h I bill per hour otherwise I offer different packages and add-ons. Say client wants a fairly big responsive site with WordPress backend etc:

  ---- Essential ----
  * Basic site (static, up to 5 pages)  
  * 8 extra pages  
  * WordPress + Blog  
  * Mobile/Responsive Layout
  * Social Media Integration
  * Usability, feedback by professionals
  * Basic SEO

  ---- Additional ----
  * Maintenance 24/7
  * Setup server and domain
These packages have a fixed price that has been pre-estimated in hours. Obviously not every project is them same, so sometimes you work more and sometimes less that what was quoted. For out of the ordinary features such as complex grids, user profiles or highly dynamic sites I estimate the extra work in hours as well and add it to the total cost.

Then I divide the project in 3 milestones: Pre-Production, Production and Post-Production. A 25% deposit must be payed after signing the contract, another 25% after Pre-Production and the rest on completion. The contact also clearly states that any major changes in layout, design or content after the Pre-Production phase will be quoted extra.

This has been working for me over the years. Clients seem happy with the process.

Re:Final Term - Terminal Emulator on Monday July 08, 2013 @07:44PM (#6010160)
Same thoughts here. Autocomplete doesn't work for me and the input lag is noticeable. I'm on 13.04. An option to turn it off would be nice, other than that it looks great.

Older »