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 useDidChange(cb: (previous: any[]) => void, deps: any[]) { | |
| const isMountedRef = React.useRef(false); | |
| const cbRef = React.useRef(cb); | |
| React.useEffect(() => { | |
| cbRef.current = cb; | |
| }, [cb]); | |
| const previousRef = React.useRef(deps); | |
| React.useEffect(() => { | |
| if (isMountedRef.current) { |
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
| interface Listener<T> { | |
| (value: T): void; | |
| } | |
| class Echo<T> implements Disposable { | |
| private listeners = new Set<Listener<T>>(); | |
| listen(listener: (value: T) => void) { | |
| this.listeners.add(listener); | |
| return new Disposable(() => { |
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
| atom.packages.onDidActivateInitialPackages (initialPackages) -> | |
| atom.commands.add 'atom-text-editor', 'akonwi:rename-file', (e) -> | |
| atom.commands.dispatch e.target, 'tree-view:rename' | |
| if gitPlus = atom.packages.getActivePackage('git-plus')?.mainModule.provideService() | |
| gitPlus.registerCommand 'atom-text-editor', 'akonwi:update-last-commit', -> | |
| gitPlus.getRepo() # If there are multiple repos in the project, you will be prompted to select which to use | |
| .then (repo) -> gitPlus.run repo, 'commit --all --amend --no-edit' | |
| gitPlus.registerCommand 'atom-text-editor', 'akonwi:unstage-last-commit', -> |
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
| module.exports = (func) -> | |
| xs = [] | |
| curry = (x) -> | |
| if x | |
| xs.push x | |
| curry | |
| else | |
| xs = [0] if xs.length is 0 | |
| func.apply null, xs |
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
| git.add(repo).then -> GitCommit(repo, andPush: true) |
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
| gitAddAllCommitAndPush = (repo) -> | |
| git.add repo, | |
| exit: -> | |
| new GitCommit(repo, andPush: true) |
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
| git.cmd = (args, options={}) -> | |
| new Promise (resolve, reject) -> | |
| output = '' | |
| try | |
| new BufferedProcess | |
| command: atom.config.get('git-plus.gitPath') ? 'git' | |
| args: args | |
| options: options | |
| stdout: (data) -> output += data.toString() | |
| stderr: (data) -> reject data.toString() |
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
| gitStagedFiles = (repo, stdout) -> | |
| files = [] | |
| gitCmd | |
| args: ['diff-index', '--cached', 'HEAD', '--name-status', '-z'] | |
| cwd: repo.getWorkingDirectory() | |
| stdout: (data) -> | |
| files = _prettify(data) | |
| stderr: (data) -> | |
| # edge case of no HEAD at initial commit | |
| if data.toString().includes "ambiguous argument 'HEAD'" |
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
| # Public: Execute a git command. | |
| # | |
| # options - An {Object} with the following keys: | |
| # :args - The {Array} containing the arguments to pass. | |
| # :cwd - Current working directory as {String}. | |
| # :options - The {Object} with options to pass. | |
| # :stdout - The {Function} to pass the stdout to. | |
| # :exit - The {Function} to pass the exit code to. | |
| # | |
| # Returns nothing. |
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').on('click', e => { | |
| e.preventDefault(); | |
| tableToExcel('table', 'Servers'); | |
| }) | |
| var tableToExcel = (function () { | |
| var uri = 'data:application/vnd.ms-excel;base64,' | |
| , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>' | |
| , base64 = function (s) { return window.btoa(window['unescape'](encodeURIComponent(s))) } | |
| , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) } |
NewerOlder