Skip to content

Instantly share code, notes, and snippets.

View malko's full-sized avatar

Jonathan Gotti malko

View GitHub Profile
@malko
malko / basic-compat.js
Created November 26, 2012 18:34
touch events support
/**
* minimal jquery/zepto compatibility layer
* be aware that won't mimic jquery/zepto at all but offer a similar api for basic stuffs as querySelectorAll and addEventListener ...
* @author jgotti at modedemploi dot fr for agence-modedemploi.com
* @licence Dual licence LGPL / MIT
* @changelog
* - 2012-11-28 - more jquery like syntax and some events related stuffs
*/
(function($){
"use strict";
@malko
malko / stepl-test.html
Created December 10, 2012 15:57
minimalistic template system
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jsonFilter test suite</title>
<link type="text/css" rel="stylesheet" href="qunit-1.10.0.css" media="all" />
</head>
<body>
<div id="qunit"></div>
@malko
malko / lcdBrightness.sh
Created February 9, 2013 00:49
Shell script for screen brightness setting of ASUS UX32 series under ubuntu 12.10 You can pass a step value as parameter, and should pass negative values to decrease brightness.
#!/bin/sh
# get user step on command line or default to 1
USERSTEP=${1:-1}
# get max and current values of brightness
MAX=`/usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-max-brightness`
CUR=`/usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness`
# define step and min to apply regarding the max value to have approximatively ten levels of settings
STEP=$(($MAX/10))
MIN=$((STEP/2))
# calc new user wanted value
@malko
malko / pager.sh
Last active December 14, 2015 23:49
simple shell program to launch pager (most for now) only if input datas won't fit into screen
#!/bin/bash
pgr="most"
tmpFile="/tmp/pager_$(uuidgen)"
cat - /dev/stdin > $tmpFile;
nblines=$(wc -l $tmpFile |awk '{print($1)}');
if [ "$nblines" -gt "$(tput lines)" ]; then
$pgr $tmpFile
else
cat $tmpFile && echo ""
@malko
malko / pre-commit
Last active December 15, 2015 14:52 — forked from mebibou/pre-commit
JSHint and JSCS pre-commit hook
#!/bin/sh
# pre-commit git hook.
files=$(git diff --cached --name-only --diff-filter=ACMR -- \*.js **/*.js)
pass=true
errorJscs=0
errorJshint=0
if [ "$files" != "" ]; then
@malko
malko / getSelector.js
Last active December 20, 2015 06:39
return a querySelector for given DOMElement
/**
* return a selector to use with document.querySelector to retrieve given node
* @param {DOMElement} node
* @returns {string}
*/
function getSelector(node){
// check for node.id avoiding autogenerated ids by ignoring any ids containing numeric values
// and checking that the id is unique in the document.
if (node.id && node.id.match(/^\D+$/) && document.querySelectorAll(node.id).length === 1) {
return '#' + node.id;
@malko
malko / 0_reuse_code.js
Created October 7, 2013 11:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@malko
malko / report
Created December 5, 2013 00:33
still failing test
60 failing
1) 2.3.3: Otherwise, if `x` is an object or function, 2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise` 2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)` `y` is a thenable for a thenable `y` is a thenable that tries to fulfill twice for an asynchronously-fulfilled custom thenable `then` calls `resolvePromise` synchronously via return from a fulfilled promise:
Error: timeout of 200ms exceeded
at null.<anonymous> (/tmp/D.js/node_modules/promises-aplus-tests/node_modules/mocha/lib/runnable.js:165:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
2) 2.3.3: Otherwise, if `x` is an object or function, 2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise` 2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)` `y` is a thenable for a then
@malko
malko / gist:ea530a66b5927ea03d5c
Created February 23, 2015 13:37
Confluence fancybox enhance navigation
// ==UserScript==
// @name Confluence fancybox enhance navigation
// @version 0.0.1
// @description add navigation through image previews
// @author Jonathan Gotti
// @match http://*/*
// @match https://*/*
// ==/UserScript==
// update match rules for your domain
(function(){
/**
* source: http://stackoverflow.com/a/37511463/646056
*/
function removeDiacritics(s) {
return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}