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 sublime, sublime_plugin | |
class MoveTabCommand(sublime_plugin.WindowCommand): | |
def run(self, mod): | |
view = self.window.active_view() | |
group_index, tab_index = self.window.get_view_index(view) | |
self.window.set_view_index(view, group_index, | |
(tab_index + int(mod)) % len ( | |
self.window.views_in_group(group_index)) ) | |
self.window.focus_view(view) |
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
/* will return null::json on empty resultset */ | |
SELECT array_to_json(array_agg(row_to_json(t))) FROM t; | |
/* | |
will return '[]' on empty resultset, | |
null::json seems to be managed the same way than sql NULL by COALESCE() | |
*/ | |
SELECT COALESCE(array_to_json(array_agg(row_to_json(t))), '[]') FROM t; | |
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
# GET /project_uploads/1/download | |
def download | |
authorize! :download, ProjectUpload | |
@project_upload = ProjectUpload.find(params[:id]) | |
redirect_to(@project_upload.attachment.expiring_url(10)) | |
end |
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
[core] | |
editor = subl -n -w | |
excludesfile = ~/.gitignore_global | |
[color] | |
branch = auto | |
diff = auto | |
status = auto | |
[color "branch"] | |
current = yellow reverse | |
local = yellow |
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
# Turn on git state in command prompt | |
GIT_PS1_SHOWDIRTYSTATE=true | |
# Command prompt with "username path (git state) | " | |
export PS1='\[\033[1;37m\]\u \[\033[0m\]\w$(__git_ps1)\[\033[1;37m\] | \[\033[0m\]' |
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
['aaawhu', 'aaaajkssh', 'aaahwv', 'aaa'].join().match(/^(\w*)\w*(?:,\1\w*)*$/).pop(); |
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 logicGates = { | |
nand (a, b) { return !(a && b); }, | |
not (a) { return this.nand (a, a); }, | |
and (a, b) { return this.not (this.nand (a, b)); }, | |
or (a, b) { return this.nand (this.not (a), this.not(b)); }, | |
nor (a, b) { return this.not (this.or (a, b)); }, | |
xor (a, b) { return this.and (this.nand (a, b), this.or(a, b)); }, | |
xnor (a, b) { return this.not (this.xor (a, b)); } | |
}; |
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 guid = function fn (n) { | |
return n ? | |
(n ^ Math.random() * 16 >> n/4).toString(16) : | |
('10000000-1000-4000-8000-100000000000'.replace(/[018]/g, fn)); | |
}; |
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() { | |
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; | |
} |
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
[0, ['a', 'b', 'c'], 2, 'd', 4, 5, 'f', 7, ['g', 'h'], 9].reduce(function rec (prev, curr) { | |
if (/array/i.test(curr.constructor)) { | |
return curr.reduce(rec, prev); | |
} else if (/string/i.test(curr.constructor)) { | |
prev.push(curr); | |
} | |
return prev; | |
}, []); |
OlderNewer