This file contains hidden or 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
| """ | |
| Exports Issues from a specified repository to a CSV file | |
| Uses basic authentication (Github username + password) to retrieve Issues | |
| from a repository that username has access to. Supports Github API v3. | |
| """ | |
| import csv | |
| import requests |
This file contains hidden or 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 ajaxSubmit(formContext, invokeCustomFunc) { | |
| var form = formContext, | |
| groupErrors = $(formContext).hasClass('group-errors'); | |
| $('.error-message', form).html('').hide(); | |
| $('.error', form).removeClass('error'); | |
| // TODO: show a loader img, to avoid double clicking | |
This file contains hidden or 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 gzip | |
| from collections import namedtuple | |
| PREG_COLS = [ | |
| ('caseid', 1, 12, int), | |
| ('nbrnaliv', 22, 22, int), | |
| ('babysex', 56, 56, int), | |
| ('birthwgt_lb', 57, 58, int), | |
| ('birthwgt_oz', 59, 60, int), |
This file contains hidden or 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
| def ensure_no_duped_migrations(): | |
| migration_dirs = local('find %s -type d -iname migrations' % ROOT_DIR, | |
| True).split('\n') | |
| for migration_dir in migration_dirs: | |
| full_migration_dir = path.join(ROOT_DIR, migration_dir) | |
| # FIXME: for GNU find, need regextype=posix-extended | |
| dupe_checker = ("find -E %s -iregex '.*/[0-9]{4,}[^/]*\.py' -exec basename {} ';'| cut -d_ -f1 | sort | uniq -d" % | |
| full_migration_dir) | |
| any_match = local(dupe_checker, True) |
This file contains hidden or 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
| --http://stackoverflow.com/questions/193780/how-to-find-all-the-tables-in-mysql-with-specific-column-names-in-them | |
| SELECT DISTINCT TABLE_NAME | |
| FROM INFORMATION_SCHEMA.COLUMNS | |
| WHERE COLUMN_NAME IN ('columnA','ColumnB') | |
| AND TABLE_SCHEMA='YourDatabase'; |
This file contains hidden or 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
| #!/usr/bin/env python | |
| """ irssi desktop notifications. | |
| Connects to a remote irssi log file, looks for your nick, | |
| and displays a desktop notification. | |
| Credit: Graham King | |
| """ | |
| import subprocess | |
| import os |
This file contains hidden or 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
| """ | |
| Inserting many items into a django-mptt table can be problematic. | |
| (Importing a large data set for example) | |
| The preorder values (left/right) have to be recalculated with | |
| each insertion so as the size of the table grows INSERTs take | |
| progressively longer each time. | |
| This code snippet demonstrates a case of determining the preorder | |
| values for the hierarchy of directories starting with a root dir. |
This file contains hidden or 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 | |
| #alternative version using Preston Holmes' (ptone) fork of pip with support for | |
| #special "cache" keyword to the --find-links option | |
| #now pip can use the download cache and does not have to contact the index | |
| mkenv(){ | |
| virtualenv --no-site-packages $1; | |
| source $1/bin/activate; | |
| pip install git+https://github.com/ptone/pip.git@cache-as-findlinks#egg=pip-with-cache; | |
| pip install --no-index --find-links=cache -r common.pip; |
This file contains hidden or 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
| #Dump | |
| mysqldump db | gzip -c > db.sql.gz | |
| pg_dump db | gzip -c > db.sql.gz | |
| #use gzip --fast | |
| #Restore | |
| gunzip < db.sql.gz | mysql db | |
| bunzip2 < db.sql.bz2 | mysql db |
This file contains hidden or 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
| #run last command as root | |
| sudo !! | |
| #change to previous dir | |
| cd - | |
| #save current file when you forgot to open with sudo | |
| :w !sudo tee % | |
| #show size of subdirs |