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", |
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 fs = require( 'fs' ); | |
var b = require( 'browserify' )(); | |
var outputFile = fs.createWriteStream( './output.js' ); | |
b.add( './index.js' ); | |
b.require( './test.js', {expose: 't'} ); | |
b.bundle().pipe( outputFile ); |
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
""" ArcGIS 10.0 ToolValidator - Import package or module relative to .tbx file | |
Rules for packages: | |
1. You can't import a subpackage (__init__.py) directly for example: | |
# This works: | |
import myPackage | |
myPackage.mySubPackage.doSomething() | |
# This doesn't work |
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
class DictWrap(object): | |
""" Wrap an existing dict, or create a new one, and access with either dot | |
notation or key lookup. | |
The attribute _data is reserved and stores the underlying dictionary. | |
When using the += operator with create=True, the empty nested dict is | |
replaced with the operand, effectively creating a default dictionary | |
of mixed types. | |
args: |
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
#Compact example to get the name of the primary key field of a Django model. | |
loc_fields = self._model._meta.fields | |
loc_pk = next((f.db_column or f.name for f in loc_fields if f.primary_key)) | |
#Get all related model classes for a model class or instance | |
related_models = [f.rel.to for f in loc_record._meta.fields if f.rel] |
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
// Modified excerpt from: | |
// https://developer.mozilla.org/en-US/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript | |
// define the Person Class | |
function Person(name) { | |
//Public property | |
this.name = name; | |
//Private property |
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
class C(object): | |
def __init__(self, x=None): | |
self.x = x | |
@property | |
def x(self): | |
return self._x | |
@x.setter |
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
def DefaultKwargs(**init_kwargs): | |
"""Decorator factory for passing default kwargs to the decorated function. | |
Returns: | |
decorator function | |
""" | |
def decorator(func): | |
"""Recieves a function, then wraps it with wrapper_func |
OlderNewer