Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / dynamic-paging-url.xsl
Created September 17, 2011 21:12
For SymphonyCMS, provides dynamic pagination-url to Nick Dunn pagination template. It holds the current URL and params while updating the page.
<xsl:call-template name="pagination">
<xsl:with-param name="pagination" select="pagination" />
<!-- build an url that holds every get params, except the page -->
<xsl:with-param name="pagination-url">
<xsl:value-of select="/data/params/root" />
<xsl:value-of select="/data/params/parent-path" />
<xsl:text>?</xsl:text>
<xsl:for-each select="/data/params/*[contains(name(), 'url-')]">
<xsl:if test="not(name(.) = 'url-page')">
<xsl:value-of select="concat(substring-after(name(), 'url-'), '=', text())" />
@qur2
qur2 / FileUpload.php
Created November 5, 2011 20:58
Simple PHP class encapsulating file upload related functions.
<?php
/**
* Simple PHP class encapsulating file upload related functions.
* @author qur2
*/
class FileUpload {
private $name;
public $messages = array(
1 => 'Entry size exceeds upload_max_filesize limit : %s',
2 => 'Entry size exceeds max_file_size limit : %s',
@qur2
qur2 / shuffle.py
Created January 5, 2012 21:34
SublimeText shuffle selection command
import sublime, sublime_plugin, random
class ShuffleCommand(sublime_plugin.TextCommand):
def run(self, edit):
regions = self.view.sel()
selections = [self.view.substr(s) for s in regions]
selections = [shuffle_string(s) for s in selections]
for i in range(len(selections)):
self.view.replace(edit, regions[i], selections[i])
@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);
}
@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 / .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\"'