Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mo-gr on github.
  • I am mogr (https://keybase.io/mogr) on keybase.
  • I have a public key whose fingerprint is 4080 87C4 AAE5 7193 1FC8 CE89 35CE 99DB E2EE 72A7

To claim this, I am signing this object:

module Ugly where
import Data.List (sort)
import Data.Map.Lazy (Map, empty, insertWith, toList)
data FacetValue = FacetValue {
value :: String,
count :: Int
} deriving (Show, Eq)
@mo-gr
mo-gr / Fails in Firefox34.js
Created December 5, 2014 09:54
Try-Catch of doom
try {
var a = func;
function func() {return "a";};
console.log(a());
} catch (e) {
console.log(e);
}
// ReferenceError: func is not defined
@mo-gr
mo-gr / dabblet.css
Created August 1, 2013 15:08
Whitespace doesn't matter in HTML – unless it does
.wrapper {
width: 253px;
background: red;
box-sizing: border-box;
margin: 10px
}
a {
display: inline-block;
width: 50%; /* set to 49% to see the gap */
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.fest.assertions.Assertions.assertThat;
public class Solution {
@mo-gr
mo-gr / neutral.java
Created July 17, 2012 10:01
List getter/setter
private final List<Bla> blas = new ArrayList<Bla>();
// foo.setBlas(foo.getBlas()) is neutral, but every getter invocation creates a new List
public List<Bla> getBlas() { return Collections.unmodifiableList(new ArrayList<Bla>(blas)); }
public void setBlas(List<Bla> blas) {
if (blas != null) {
this.blas.clear();
this.blas.addAll(blas);
}
@mo-gr
mo-gr / _config.yml
Created March 19, 2012 10:31
source/_includes/custom/asides/flattr.html
default_asides: [asides/recent_posts.html, asides/twitter.html, asides/github.html, asides/googleplus.html, custom/asides/flattr.html]
# ... snip ...
# Flattr
flattr_user: mogr
flattr_blog_thing: http://flattr.com/thing/582242/Not-a-blog
@mo-gr
mo-gr / js-bug
Created September 29, 2011 14:47
Can you spot the error?
$("input[type='text']").keyup(function(e) {
if ( e.which == 13 || e.which == 10 ) // on Return/Enter key, blur the input to execute update
$(this).blur();
});
@mo-gr
mo-gr / about.md
Created August 29, 2011 15:22 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer