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
Copyright (c) 2012, Michael A. Jackson | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without modification, | |
are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright notice, this | |
list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright notice, |
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
expire_deltas = { | |
'minutes': frdelta.FWD_MIN, | |
'hours' : frdelta.FWD_HR, | |
'days': frdelta.FWD_DAY, | |
'months': frdelta.FWD_MO, | |
'years': frdelta.FWD_YR, | |
} | |
def GetExpireDate(expire_date='months', now=None): | |
"""Convert expire_date arguments to date |
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
""" Inherit SafeReadOnly for safe access to mutable objects on classes | |
* Deep copy of mutable attributes on accessing uninstantiated class | |
* No assignment to class attributes on uninstantiated class | |
* Deep copy of mutable attributes when class is instantiated | |
""" | |
from collections import Hashable |
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 django.db import models | |
class QuerySetManager(models.Manager): | |
"""Add new QuerySet methods using a Model inner class | |
Reference: | |
http://djangosnippets.org/snippets/734/ | |
""" |
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
var x = [1,2,3] | |
//back to front | |
while(x.length){ | |
var value = x.pop(); | |
console.log(value); | |
} | |
//array is now empty, lets replace it | |
var x = [1,2,3] |
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
""" Interview question | |
Write a method that takes a string, and returns the string in reverse. | |
For instance, if passed abc123 it should return 321cba | |
""" | |
class StringUtil(object): | |
""" Utility for strings |
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
""" Additional collections to augment Python's collections module. | |
""" | |
from collections import namedtuple | |
def defaultnamedtuple( | |
typename, | |
field_names, | |
verbose=False, | |
rename=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
#-- Start pm-ops-utils dev --# | |
# Remove local modules and npm cache | |
alias npmPurge=" | |
rm -rf node_modules | |
npm cache clean | |
" | |
# Ugly, but it is a fail-safe way of generating npm-shrinkwrap.json | |
alias updateShrinkwrap=" |
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
var http = require('http'); | |
function RequestQueue() { | |
this._maxRequests = 3; | |
this._pendingCount = 0; | |
this._queue = []; | |
this.count = 0; | |
this._uriInQueue = {}; | |
} |
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
var gulp = require('gulp'); | |
var lib = require('./lib'); | |
var protractor = require("gulp-protractor").protractor; | |
var jarPath = lib.getProtractorSeleniumJarPath(); | |
gulp.task('default', function(){ | |
gulp.src(["./spec/*.js"]) | |
.pipe(protractor({ | |
configFile: "protractor.config.js", |