Skip to content

Instantly share code, notes, and snippets.

View olov's full-sized avatar

Olov Lassus olov

  • Linköping, Sweden
View GitHub Profile
@olov
olov / lossy_dropbox.txt
Created January 5, 2014 19:19
Dropbox, you're handling >260 long paths wrong on Windows
Hello there,
I'm supporting DELETED and DELETED with IT. Both of them are paying customers of yours. I was pretty shocked when I learned today that when you encounter a path longer than 260 characters (on a Windows system), you do no sync it, and you do not inform the end user about it. In a shared folder setup, this is pretty disastrous.
I can think of two sensible ways to handle the limitation of 260 character long paths in Windows.
1. Detect them, and inform the user prominently that he/she has files that will not be synced.
2. Detect and sync as usual (this is certainly possible from a technical standpoint).
Your current way of handling this causes lots of frustration to end-users and at the end of the day, may cause them to lose data quite easily.
@olov
olov / smallsort.c
Last active December 30, 2015 05:58
sorting algorithms for small arrays
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <sys/time.h>
long long gettime_ms(void)
{
@olov
olov / alternate.js
Last active December 22, 2015 08:18
funny little ES6 for (let;;) example
// according to my guesses of what is to come in future ES6 specs:
// the loop should execute five times so the program should print five numbers at the end
// the fresh-per-iteration x is captured in a closure (that will increment it by 3),
// then executed (for side-effects only) in the cond-expr and post-expr.
// it will never ever modify the outer x thus five loop iterations
(function() {
let arr = [];
let fn = null;
let cnt = 0;
for (let x = 0; (fn && fn()), x < 5; (fn && fn()), x++) {
@olov
olov / gist:6443290
Created September 4, 2013 21:45
es6 loop variable bindings
// will this example
let arr = [];
for (let x = 0; x < 5; x++) {
x++;
arr.push(function() { return x; });
}
// ..be semantically equivalent to this?
let arr = [];
Lot's of good stuff from Ariya as always and expected! :) I wanted to chime in with a couple of comments regarding ES6 block scope, const in particular. It's kind of a pet-peeve of mine (I'm the author of the defs transpiler).
The article describes Mozilla-JS const, not ES6 const. Mozilla-JS const is not block scoped and is silent on reassignment. ES6 const is block scoped and reassignment is a static error found at parse time (see https://gist.github.com/olov/6255863) before program execution. Do note that you have to opt-in to using ES6 const in v8/node via strict mode, otherwise you'll get Mozilla-const semantics. Prepend a "use strict"; to the example and re-run it - *boom* you're now in the beautiful world of ES6 const. :)
Also, while not an error, my humble opinion is that we're missing out big time by teaching that "the major use case for const is to safeguard important constants". While that may have been true in a Mozilla-JS const world, in ES6 const means that the variable binding won't change - a
@olov
olov / ES6 consts
Last active December 21, 2015 05:18
[:~/projects/js] % cat const.js
"use strict"; // required to opt-in ES6 block scope in V8 for now
console.log("const assignment error is caught at parse-time so this doesn't get printed");
const limit = 100;
limit = 200;
console.log(limit);
[:~/projects/js] % node --harmony const.js
/Users/olov/projects/js/const.js:4
limit = 200;
@olov
olov / nan.js
Created June 14, 2013 13:43
Which arithmetic operators in JS can yield a NaN given non-NaN (numeric) operands:
"use strict";
const vals = [
0,(-0),1,-1,Infinity,-Infinity,
];
const binops = [
"&", "|", "^", ">>", "<<", ">>>",
"+", "-", "*", "/", "%",
"&&", "||"
Would you be OK with your internet bank saying "our position is
that we recommend a private connection over HTTPS but you can
always scrap that and send your private login credentials in
clear text directly in the URL instead. Over HTTP of course, if
you find that convenient. Choice is good and we want to make you
happy"?
I wouldn't, because it would tell me that they are clueless about
security or that they don't care about their user's money and/or
privacy.
@olov
olov / gist:2731048
Created May 19, 2012 14:36
the Bash mp3 links
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20Cashkeeper.mp3
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20Come%20on.mp3
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20Join%20the%20bash.mp3
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20Tears%20and%20smiles%20%28edit%29.mp3
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20To%20it%20%28now%29.mp3
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20Una%20mas%20%28edit%29.mp3
http://dl.dropbox.com/u/283098/the%20Bash/the%20Bash%20-%20Where%27s%20your%20mind.mp3
@olov
olov / gist:1320163
Created October 27, 2011 17:10
Pygments DartLexer for syntax highlighting. Example and installation instructions: <http://blog.lassus.se/2011/10/dart-syntax-highlighting.html>
class DartLexer(RegexLexer):
"""
For `Dart <http://dartlang.org/>`_ source code.
"""
name = 'Dart'
aliases = ['dart']
filenames = ['*.dart']
mimetypes = ['text/x-dart']