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 defaut MyBigClass extends MyParent { | |
| constructor() { | |
| super() | |
| } | |
| method1() { | |
| // ... | |
| } | |
| method2() { |
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 server = require('./server/server') | |
| server.run() |
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
| content = '' | |
| with open('/google-cloud-sdk/platform/google_appengine/google/appengine/dist27/socket.py', 'rb') as fd: | |
| content = fd.read() | |
| content = content.replace('from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE', | |
| '''from _ssl import \\ | |
| RAND_add, \\ | |
| RAND_status, \\ | |
| SSL_ERROR_ZERO_RETURN, \\ | |
| SSL_ERROR_WANT_READ, \\ | |
| SSL_ERROR_WANT_WRITE, \\ |
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() | |
| { | |
| 'use strict'; | |
| angular | |
| .module('Controllers') | |
| .controller('MyController', MyController); | |
| /* @ngInject */ | |
| function MyController($scope, MyService) |
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 re | |
| s = "string to replace with KEY1 and KEY2, but also KEY3. But KEY5 is not defined in the replacements dict." | |
| pattern = re.compile(r'\b(' + '|'.join(replacements.keys()) + r')\b') | |
| replacements = { | |
| 'KEY': 'VALUE', | |
| 'KEY2': 'VALUE2', | |
| 'KEY3': 'VALUE3', | |
| 'KEY4': 'VALUE4' |
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 server.api.drive import Drive | |
| from server.libs.docx import Document | |
| from cStringIO import StringIO | |
| driveFile = Drive.getFile('DRIVE_ID') | |
| doc = Document(StringIO(Drive.downloadFile(driveFile['downloadUrl']))) | |
| doc_to_copy = Document(StringIO(Drive.downloadFile(Drive.getFile('DRIVE_ID_TO_COPY')['downloadUrl']))) | |
| for element in doc_to_copy._body._element: | |
| doc._body._element.append(element) |
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 xlrd | |
| from openpyxl.workbook import Workbook as openpyxlWorkbook | |
| # content is a string containing the file. For example the result of an http.request(url). | |
| # You can also use a filepath by calling "xlrd.open_workbook(filepath)". | |
| xlsBook = xlrd.open_workbook(file_contents=content) | |
| workbook = openpyxlWorkbook() | |
| for i in xrange(0, xlsBook.nsheets): |
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 copyArray(src, dest) | |
| { | |
| // (performance: http://jsperf.com/empty-javascript-array & http://jsperf.com/array-extending-push-vs-concat) | |
| while(dest.length > 0) | |
| { | |
| dest.pop(); | |
| } | |
| if (src) | |
| { | |
| for (var i = 0; i < src.length; ++i) |
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 promptGit() | |
| { | |
| if [[ -d ./.git ]]; then | |
| local change_waiting_commit=`if git status | grep -q "nothing to commit (working directory clean)"; then echo ""; else echo ">"; fi` | |
| local current_branch=`git rev-parse --symbolic-full-name --abbrev-ref HEAD` | |
| local commits_behind=`git rev-list --left-right $current_branch...origin/master | grep -c "^>"` | |
| local commits_ahead=`git rev-list --left-right $current_branch...origin/master | grep -c "^<"` | |
| echo " [$change_waiting_commit$current_branch|-$commits_behind|+$commits_ahead]" | |
| fi | |
| } |
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
| [alias] | |
| lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
| eu = "!f() { git diff --name-status --diff-filter=U | cut -f2 ; }; subl `f`" | |
| au = "!f() { git diff --name-status --diff-filter=U | cut -f2 ; }; git add `f`" | |
| pop = !sh -c 'git stash pop' | |
| ro = "!git stash; git rebase origin/$1; git pop" | |
| reb = "!git fetch; git ro $1" | |
| mp = "!git stash; git checkout $1; git merge @{-1}; git push origin $1; git checkout @{-1}; git pop" | |
| rmp = "!git reb $1; git mp $1" |
NewerOlder