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
| # ====================================================================== | |
| # admin/file_managers.js.coffee | |
| # | |
| # Description: | |
| # contains snippets & functions for handling file-manager-related operation. | |
| # ====================================================================== | |
| root = exports ? this | |
| $ -> |
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
| require 'net/ftp' | |
| CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk" | |
| CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login" | |
| CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password" | |
| # LOGIN and LIST available files at default home directory | |
| Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp| | |
| files = ftp.list.map{ |obj| parse_ls_unix_like_format(obj) } |
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 adler32(data) { | |
| var MOD_ADLER = 65521; | |
| var a = 1, b = 0; | |
| var index; | |
| // Process each byte of the data in order | |
| for (index = 0; index < data.length; ++index) { | |
| a = (a + data.charCodeAt(index)) % MOD_ADLER; | |
| b = (b + a) % MOD_ADLER; | |
| } |
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
| r(function() { | |
| Backtrace = {}; | |
| Backtrace.Router = (function() { | |
| Router.prototype.optionalParam = /\((.*?)\)/g; | |
| Router.prototype.namedParam = /:\w+/g; |
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
| // kills long running ops in MongoDB (taking seconds as an arg to define "long") | |
| // attempts to be a bit safer than killing all by excluding replication related operations | |
| // and only targeting queries as opposed to commands etc. | |
| killLongRunningOps = function(maxSecsRunning) { | |
| currOp = db.currentOp(); | |
| for (oper in currOp.inprog) { | |
| op = currOp.inprog[oper-0]; | |
| if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) { | |
| print("Killing opId: " + op.opid |
OlderNewer