Skip to content

Instantly share code, notes, and snippets.

View dr-dimitru's full-sized avatar
👨‍💻
get 💩 done

dr.dimitru dr-dimitru

👨‍💻
get 💩 done
View GitHub Profile
@dr-dimitru
dr-dimitru / mongodb-collections-sizes.js
Last active January 26, 2021 19:21
Show each collection size in MongoDB
var getReadableFileSizeString = function(fileSizeInBytes) {
var i = -1;
var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
do {
fileSizeInBytes = fileSizeInBytes / 1024;
i++;
} while (fileSizeInBytes > 1024);
return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
};
@dr-dimitru
dr-dimitru / deploy.sh
Last active November 4, 2019 08:08
Deploy Meteor + Phusion Passenger + nginx
#!/bin/bash
rsync -auhiP -e 'ssh -p {sshPort}' /path/to/app/myApp.tar.gz user@host:/home/meteoruser/
dv1 dv2 of1 of2 of3
3.95E+000 1.63E+000 0.44242 0.0055127 0.0666262
7.11E+000 3.44E+000 0.860229 0.00615626 0.174343
6.90E+000 1.78E+000 0.782869 0.0089705 0.122455
7.79E+000 3.82E+000 0.960738 0.00650422 0.203037
1.25E+000 3.28E+000 0.158067 0.00373114 0.031634
5.63E+000 2.11E+000 0.643855 0.00648422 0.107407
6.64E+000 2.33E+000 0.762737 0.00699037 0.132135
3.96E+000 1.41E+000 0.444265 0.00597551 0.0638318
6.38E+000 4.89E+000 0.864868 0.00535356 0.201884
@dr-dimitru
dr-dimitru / readme.md
Created March 16, 2016 23:00
Speed-test of trimming float number

Test trim-float

var x = 5.0364342423;
parseFloat(x.toFixed(2));
//VS
Math.round(x*100)/100; // 97% faster
@dr-dimitru
dr-dimitru / server.coffee
Created October 31, 2015 15:55
instagram example
# @var {Object} bound - Meteor.bindEnvironment aka Fiber wrapper
bound = Meteor.bindEnvironment (callback) -> return callback()
ServiceConfiguration.configurations.remove service: "instagram"
ServiceConfiguration.configurations.insert
service: "instagram"
clientId: "clientId"
requestPermissions: ['basic', 'likes', 'relationships', 'comments']
scope: ['basic', 'likes', 'relationships', 'comments']
@dr-dimitru
dr-dimitru / like_all_on_page.js
Last active August 25, 2017 12:07
Like all posts on page at vk.com
// Better to execute this in Google Chrome
// 0. Go to vk.com on page where you would like to like all posts
// 1. Right click on any place of page
// 2. Inspect Element
// 3. In opened panel - choose "console" tab
// 4. Copy-paste code you se below and hit "Enter" key
(function(){
var newscript = document.createElement('script');
newscript.type = 'text/javascript';
newscript.async = true;
@dr-dimitru
dr-dimitru / etc_nginx_nginx.conf
Last active August 29, 2015 14:16
PHP5-FMP Configuration example with cache for laravel or drupal
user www-data;
worker_processes 2; #THIS VALUE SHOULD BE EQUAL TO PROCESS CORES QTY
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
}
http {
@dr-dimitru
dr-dimitru / readme.md
Last active August 29, 2015 14:10
Fastest If Callback
@dr-dimitru
dr-dimitru / readme.md
Last active August 29, 2015 14:10
In function scope: this vs. object name reference
@dr-dimitru
dr-dimitru / readme.md
Last active August 29, 2015 14:10
jQuery Selectors comparison