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
/** | |
* > if foo: | |
* > | <= The cursor is here and hit delCharOrIndent command, it willbe | |
* > | <= here | |
* | |
* This command will delete at most 4 spaces before, if text before charactor is all spaces. | |
* If not on the case, this command will delete charactor as usual. | |
*/ | |
(function(mod) { |
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 ChoicesEnum(Enum): | |
def __str__(self): | |
return self.value | |
@classmethod | |
def choices(cls): | |
return tuple( | |
(item.value, item.name.replace('_', ' ').title()) for item in cls | |
) |
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
reserved_names = { | |
'about', | |
'abuse', | |
'account', | |
'accounts', | |
'activity', | |
'admin', | |
'administrator', | |
'administrators', | |
'admins', |
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 functools import wraps | |
class MemGen: | |
def __init__(self, generator): | |
self.generator = generator | |
self.mem = [] | |
self.__doc__ = generator.__doc__ | |
def __iter__(self): |
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
const EXEC_HEADER_LEN = 8; | |
const EXEC_HEADER_STREAM_LEN = 4; | |
const EXEC_HEADER_SIZE_LEN = 4; | |
function excludeDockerExecHeader(buffer) { | |
if (buffer.length <= EXEC_HEADER_LEN) { | |
return ""; | |
} | |
let bodyLength = buffer.readUInt32BE(EXEC_HEADER_STREAM_LEN, EXEC_HEADER_SIZE_LEN); |
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
module.exports = function(Vue) { | |
Vue.directive('auto-bottom', { | |
update: function() { | |
this.el.scrollTop = this.el.scrollHeight; | |
} | |
}) | |
}; |
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
container.exec({Cmd: ['/bin/sh', '-c', 'cat > /path/to/test.txt], AttachStdin: true}, (err, exec) => { | |
exec.start({hijack: true, stdin: true}, function(err, stream) { | |
stream.write("Hi there.\n") | |
}); | |
}); |
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
import docker | |
class WSFixedClient(docker.Client): | |
def _create_websocket_connection(self, url): | |
sslopt = {} | |
if self.cert: | |
sslopt["certfile"] = self.cert[0] | |
sslopt["keyfile"] = self.cert[1] | |
return websocket.create_connection( |
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
import cachetools | |
import requests | |
class ForceCacheSession(requests.Session): | |
""" Force caching requests.Session | |
* Apply `cachetools.Cache` by `mount_cache()` methoud | |
* It will cache if the method was GET and status code was 200 | |
* It will apply `res.from_cache` bool value |
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 moment = require('moment') | |
undefined | |
> null < moment('1970-01-01') | |
false | |
> null < moment('1970-01-02') | |
true | |
> |