Skip to content

Instantly share code, notes, and snippets.

@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())" />