Skip to content

Instantly share code, notes, and snippets.

View guilhermehn's full-sized avatar

Guilherme Nagatomo guilhermehn

  • PagSeguro
  • Brasil, São Paulo
View GitHub Profile

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@guilhermehn
guilhermehn / gist:10417176
Created April 10, 2014 19:56
Binary to Decimal
function binToDecimal (n) {
var i = s = 0, h
while (h = n[i]) {
s += (1 << n.length - ++i) * h
}
return s
}
function getRgba (ctx, x, y) {
var colors = ['r', 'g', 'b', 'a']
, result = {}
, data = ctx.getImageData(x, y, 1, 1)
data.forEach(function (c, i) {
result[colors[i]] = c
})
return result
@guilhermehn
guilhermehn / gist:1992714
Created March 7, 2012 11:56
Javascript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@guilhermehn
guilhermehn / gist:1992731
Created March 7, 2012 12:01
CSS: Image Replacement
.ir {
border:0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@guilhermehn
guilhermehn / gist:1992732
Created March 7, 2012 12:01
HTML: Prompt Chrome Frame
<!-- Prompt IE6 users to install Chrome Frame -->
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
@guilhermehn
guilhermehn / gist:1992760
Created March 7, 2012 12:10 — forked from zetareticoli/gist:934071
CSS: Micro clearfix
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:block;
}
.cf:after {
clear:both;
}
@guilhermehn
guilhermehn / gist:1993257
Created March 7, 2012 13:47
Javascript: Kill hard-coded events
(function(d) {
var tags = d.body.getElementsByTagName('*');
var i = tags.length;
while (i--) {
var attr = tags[i].attributes;
var ii = attr.length;
while (ii--) {
if (attr[ii].name.match(/^on/i)) {
@guilhermehn
guilhermehn / campo-numerico.js
Created September 28, 2012 14:14
JavaScript: Campo numérico (jQuery)
$(".numerico").keypress(function(e){
var charcode = e.keyCode ? e.keyCode : e.which;
if(charcode < 48 || charcode > 57){
e.preventDefault();
return false;
}
});
@guilhermehn
guilhermehn / gist:3800128
Created September 28, 2012 14:15
Javascript: Validar CPF
function valida_cpf(cpf) {
var numeros, digitos, soma, i, resultado, digitos_iguais;
digitos_iguais = 1;
if (cpf.length < 11) return false;
for (i = 0; i < cpf.length - 1; i++)
if (cpf.charAt(i) != cpf.charAt(i + 1)) {
digitos_iguais = 0;
break;