Skip to content

Instantly share code, notes, and snippets.

@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())
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 / .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);
}
@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 / 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 / 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 / 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