Skip to content

Instantly share code, notes, and snippets.

View nikolaifedorov's full-sized avatar

Nikolai Fedorov nikolaifedorov

View GitHub Profile
@nikolaifedorov
nikolaifedorov / file_managers.js.coffee
Created August 7, 2013 13:31 — forked from giosakti/file_managers.js.coffee
Adding Custom Context Menu for elFinder
# ======================================================================
# admin/file_managers.js.coffee
#
# Description:
# contains snippets & functions for handling file-manager-related operation.
# ======================================================================
root = exports ? this
$ ->
@nikolaifedorov
nikolaifedorov / ruby_ftp_example.rb
Last active December 21, 2015 19:19 — forked from 3dd13/ruby_ftp_example.rb
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files with parsing for unix-like ftp, check directory existence, upload files
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) }
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;
}
r(function() {
Backtrace = {};
Backtrace.Router = (function() {
Router.prototype.optionalParam = /\((.*?)\)/g;
Router.prototype.namedParam = /:\w+/g;
// 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