This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Replace all instances of first string with second string. Use third arg as file(s) selector. | |
# If no selector is provided, do it to all files. | |
# Usage: | |
# ra artursapek ArturSapek | |
# => Replaces all instances of "artursapek" with "ArturSapek" in all files in this directory and its directories. | |
# Makes backups with names like index.html.1357352744.sedbak | |
# Required for sed to treat all ASCII as ASCII |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Grep for a certain filetype recursively. | |
# Usage: | |
# gr headerBar html | |
# => All instances of "headerBar" in html files in this directory. | |
if [ -z "$2" ] | |
then | |
SELECTOR="*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ants.views import log_event | |
def ant_log(request, eventname, data={}): | |
# Sample wrapper using ants.log_event which always includes logged-in users' name and email, for instance... | |
if not request.user.is_anonymous(): | |
data['user'] = '%s %s (%s)' % (request.user.first_name, request.user.last_name, request.user.email) | |
log_event(request, eventname, 'mysite', data) | |
def my_view(request): | |
# Your code... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preload = (urls) -> | |
for url in urls | |
braces = url.match(/{\d\.\.\d}/g) | |
if braces | |
nums = braces[0].match(/\d/g) | |
expanded = [] | |
for num in [nums[0]..nums[1]] | |
expanded.push url.replace(braces[0], num) | |
preload expanded | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Download a file to your machine | |
download = function(key){ | |
// The CM download API call only requires a key as a parameter. | |
// Here we also include a second options parameter where "filename" tells | |
// the SDK we want to download the file to our local filesystem. | |
cm.download(key, {filename: key}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cm.destroy(key) | |
.on('complete', function(){ | |
$('span[item="' + key + '"]').remove(); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
image = open('e.jpg', 'r') | |
lines = ''.join(image.readlines()) | |
image.close() | |
ran = int(random.random() * len(lines)) | |
for i in range(0, int(str(ran)[:1])/2): | |
ran = int(random.random() * len(lines)) | |
t = lines[ran:ran+ran*6] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(0, 101): | |
d = {} | |
d[i % 3], d[i % 5] = 'Fizz', 'Buzz' | |
if 0 in d: | |
if len(d) == 1: | |
print 'FizzBuzz' | |
else: | |
print d[0] | |
else: | |
print i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
bandscape CSS | |
author: Artur Sapek | |
*/ | |
html, body{ | |
height:100%; | |
margin:0px; | |
overflow:hidden; | |
background:#F5F5F6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DOM objects used in bandscape main view | |
// author: Artur Sapek | |
// bandscape 2011 | |
// pre: nothing | |
// post: returns top-right control on the map, date and city (city doesn't do anything) and injects into DOM | |
function dateControl(){ | |
var me = this; | |
this.dropdownFairGame = true; | |
this.keepopen = false; |