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
export CLICOLOR=1 | |
export LC_CTYPE=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
LSCOLORS=gxfxcxdxbxegedabagacad |
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
"https://github.com/tpope/vim-pathogen | |
execute pathogen#infect() | |
syntax on | |
filetype plugin indent on | |
set hlsearch | |
set number | |
set expandtab | |
set shiftwidth=4 | |
set listchars=tab:>-,trail:- |
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
.directive('validFile', function() { | |
return { | |
require: 'ngModel', | |
link: function(scope, element, attrs, ngModel) { | |
var extentions = /(\.|\/)(gif|jpe?g|png)$/i; | |
var maxSize = 204800; // bytes | |
var setViewValue = function(file) { | |
scope.$apply(function() { | |
ngModel.$setValidity('extention', extentions.test(file.name)); | |
ngModel.$setValidity('size', file.size <= maxSize); |
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
var fd = new FormData(); | |
fd.append('file', $scope.files[0]); | |
$http({url: URL.api + '/upload/', | |
method: 'POST', | |
data: fd, | |
headers: {'Content-Type': undefined}, | |
transformRequest: angular.identity}); |
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
var createPreview = function(file, image, callback) { | |
var canvas = $('<canvas>')[0]; | |
var context = canvas.getContext('2d'); | |
var width = image.width; | |
var height = image.height; | |
if (image.width > previewOptions.maxWidth) { | |
width = previewOptions.maxWidth; | |
height = previewOptions.maxWidth / image.width * image.height; | |
} |
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
var cancel = function(e) { | |
e.stopPropagation(); | |
e.preventDefault(); | |
return false; | |
}; | |
var drop = function(e) { | |
cancel(e); | |
add(event.dataTransfer.files); | |
event.dataTransfer.clearData(); | |
return false; |
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 to_snake_case(string): | |
return re.sub('(.)([A-Z]{1})', r'\1_\2', string).lower() |
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
>>> from itertools import groupby | |
>>> data = [{'foo': 1, 'bar': 1, 'baz': 1}, {'foo': 1, 'bar': 1, 'baz': 2}, {'foo': 1, 'bar': 2, 'baz': 11}, {'foo': 1, 'bar': 2, 'baz': 12}, {'foo': 2, 'bar': 2, 'baz': 31}] | |
>>> for (key, group) in groupby(data, lambda x: [x[k] for k in ['foo', 'bar']]): | |
... print 'keys' | |
... print list(key) | |
... print 'groups' | |
... print list(group) | |
... | |
keys | |
[1, 1] |
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
filters.filter('belowDecimalPoint', [ | |
function() { | |
return function(amount, symbol) { | |
var decimal = ((amount || '').split('.')[1]) || '0'; | |
while (decimal.length < (symbol || 1)) { | |
decimal += '0'; | |
} | |
return decimal; | |
}; | |
}]); |
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
$scope.settings.splice(index, 1); |