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 subprocess import Popen, PIPE | |
import sys | |
import re | |
import os | |
APP_DIR = '/Users/artur/Work/Codecademy-dev/Codecademy/app/' | |
VIEWS = ['erb', 'mustache', 'haml'] | |
def search(query, filetypes=[]): | |
args = ['grep', '-r', '-I', '--exclude=".git"'] |
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
# POSTs your confirmation key, first name, and last name | |
# to Southwest.com check-in endpoint over and over | |
# until it doesn't see the 24-hour error. | |
# In testing I never got rate-limited or blocked | |
# but I didn't let it run for very long at a time | |
# so use at your own risk. :) | |
# Six-character SW confirmation token here | |
CONF=AB1234 |
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
. $HOME/.bash_profile | |
cd $HOME/Codecademy/app | |
check_usage () { | |
while read data | |
do | |
PARTIAL_NAME=$(echo $data | sed 's/views\///g' | sed 's/\/\_/\//g' | sed 's/\..*//g') | |
PARTIAL_LOCAL_NAME=$(echo $PARTIAL_NAME | sed 's/.*\///g') |
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 own ind, char of as | |
# Iterate over the characters in a-split | |
if matching | |
# So far we have only found matching chars... | |
if bs[ind] == char | |
# If they're still matching then great | |
continue | |
else | |
# Uh-oh! We've found the first mistmatch! | |
matching = false |
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 | |
# Remove all .sedbak files (sed backup files) | |
find . -name "*.sedbak" -print0 | xargs -0 rm |
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
(function($){ | |
// Bind to an input field. Provide chars, a string of characters. | |
// Now only those characters can be typed in. | |
$.fn.whitelist = function(chars){ | |
var $this = $(this), chars = chars.split(''); | |
$this.keypress(function(e){ | |
if (chars.indexOf(String.fromCharCode(e.which)) == -1){ return false; }}); | |
return $this; | |
}; | |
}(jQuery)); |
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 |