Skip to content

Instantly share code, notes, and snippets.

const groupZipObj = R.curry((keys, values) => {
const obj = R.pipe(R.take(keys.length), R.zipObj(keys))
const remain = R.drop(keys.length)
return R.isEmpty(values) ? [] : R.prepend(obj(values), groupZipObj(keys, remain(values)))
})
groupZipObj(['key', 'value'], ['K1', 'V1', 'K2', 'V2', 'K3', 'V3'])
var fs = require('fs');
var path = require('path');
var jsdom = require('jsdom');
function template (js) {
return (
`<!DOCTYPE html>
<html>
<head>
<script>${fs.readFileSync(require.resolve('raphael'))}</script>
@qur2
qur2 / README.md
Last active August 29, 2015 14:16 — forked from agnoster/README.md

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@qur2
qur2 / findEvents.js
Last active August 29, 2015 14:13
Find event handlers from jQuery (2.1.0)
// Thanks to http://www.aaron-powell.com/posts/2014-03-06-debugging-jquery-events.html
// If your're looking at submit events, check handlers attached to document.
// domEl has to be a native DOM element.
function findEvents(domEl, eventType) {
function targetedBy(el, eventData) {
if (el === domEl) {
return true;
}
if (eventData.selector) {
if ($(el).find(eventData.selector).is(domEl)) {
@qur2
qur2 / article.md
Last active August 29, 2015 14:07
Vertical image responsiveness

For a small project, I wanted to display an author portrait in the bottom right corner of a page. Of course, I wanted the image to be responsive. The only technnique I was sort of familiar with is [Foundation interchange][foundation-interchange], but I wanted to see more. And in particular, I wanted to read about any new (or soon-to-be) HTML5 standard.

After a very quick googling, I stumbled on this [Smashing article][smashing-responsive-image] which very nicely exposes where we stood last year (in July 2013) on this topic. Although many things changed since then, it points out the[ picturefill library][scottjehl-picturefill], which is a polyfill for the fast moving [picture element][living-standard-embedded-content], a new HTML standard.

Aware of this polyfill, I searched for more explanations about how this srcset and sizes attributes work. A very good article explained it all to me, including where the specification comes from and with [a lot of peas][portis-srcset].

Now I get everything that's need

@qur2
qur2 / diacritic.js
Last active August 29, 2015 14:05
Javascript handling of combining diacritic characters
// TODO: complete the mapping
var combiningDiacriticMap = {
// combining grave accent
'\u0300': {
'A': '\u00c0', 'a': '\u00e0',
'E': '\u00c8', 'e': '\u00e8',
'I': '\u00cc', 'i': '\u00ec',
'O': '\u00d2', 'o': '\u00f2',
'U': '\u00d9', 'u': '\u00f9'
},
@qur2
qur2 / xfocus.py
Created June 7, 2013 12:58
Python + AppleScript to bring a window in foreground.
# Using applescript, sets the focus + foreground on a window by its title
# That works on OSX 10.7.5.
# @author Aurelien Scoubeau <aurelien.scoubeau@gmail.com>
import argparse
import subprocess
parser = argparse.ArgumentParser(description='Utility to activate a window by title, for OSX')
parser.add_argument('title', help='Title of the window to activate')
args = vars(parser.parse_args())
@qur2
qur2 / .gitconfig
Last active December 14, 2015 19:09
Aliases for shell awesomeness
[alias]
oldest-ancestor = !bash -c 'diff -u <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | sed -ne \"s/^ //p\" | head -1' -
recently = !bash -c 'git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format=\"%(refname:short)\"'
branchdiff = !bash -c 'git diff `git oldest-ancestor "${1:-master}" "${2:-HEAD}"`..."${2:-HEAD}"' -
branchlog = !bash -c 'git log --oneline `git oldest-ancestor "${1:-master}" "${2:-HEAD}"`..."${2:-HEAD}"' -
thebranch = !bash -c 'git branch | sed -ne \"s/^\\* \\(.*\\)/\\1/p\"'
@qur2
qur2 / bash_prompt.sh
Last active October 6, 2015 02:08 — forked from insin/bash_prompt.sh
Set color bash prompt according to active virtualenv, git branch (including detached head state) and return status of last command. Adapted for git 1.8.5 status output.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository (handles detached head state)
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@qur2
qur2 / jquery.spinner.js
Last active October 4, 2015 02:07
Spinner jQuery plugin
(function($) {
/**
* Helper function to update the spinner display.
* @param {jQuery} display The DOM element to update
* @param {String} val The value to display
*/
function updateDisplay(display, val) {
display.text(val);
}