Skip to content

Instantly share code, notes, and snippets.


Vlad Lasky vlasky

View GitHub Profile
vlasky / cron.js
Created May 27, 2020
Meteor demo code for running jobs synchronized across multiple processes. It is based on percolate:synced-cron, but modified to use MySQL. Files must be placed in the Meteor server folder and all required atmosphere & NPM dependencies installed.
View cron.js
// A package for running jobs synchronized across multiple processes
// Based on percolate:synced-cron, but modified to use MySQL
/*You must create a cron_history table in your MySQL database with the following schema:
CREATE TABLE `cron_history` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
vlasky /
Last active Mar 21, 2018
This is a Linux shell (bash) script that gzip-compresses the static assets contained within a production build of a Meteor webapp. It has been tested under CentOS 7. This script is intended to be used when Nginx is running as the web server and the 'gzip_static' configuration option is enabled. When the client supports gzip compression, Nginx wi…
# Files with the following extensions will be compressed with gzip
GZFILETYPES=( "*.html" "*.css" "*.js" "*.ico" "*.xml" "*.json" "*.svg" "*.otf" "*.ttf" "*.eot" )
# The base directory of the Meteor production bundle assets that are served to the client
# Files smaller than this size (in bytes) will NOT be compressed as the gzip overhead usually makes them larger
for currentDir in $DIRECTORIES; do
for f in "${GZFILETYPES[@]}"; do
files="$(find $currentDir -iname "$f")";
vlasky / disable_transparent_huge_pages.service
Created Mar 6, 2018
Systemd startup script to automatically disable Transparent Huge Pages (THP) under Linux. This must be done before launching MySQL with the TokuDB storage engine or before launching MongoDB.
View disable_transparent_huge_pages.service
# Copy this file to /etc/systemd/system/
# Then run:
# systemctl enable disable_transparent_huge_pages.service
# systemctl start disable_transparent_huge_pages.service
Description=Disable transparent huge pages
ExecStart=/bin/sh -c "/usr/bin/echo never | /usr/bin/tee /sys/kernel/mm/transparent_hugepage/enabled"
vlasky / point_in_polygon_using_winding_number.js
Created Jan 10, 2018
JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
View point_in_polygon_using_winding_number.js
//JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//Based on C++ implementation of wn_PnPoly() published on
function pointInPolygon(point, vs) {
var x = parseFloat(point[0]), y = parseFloat(point[1]);
var wn = 0;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = parseFloat(vs[i][0]), yi = parseFloat(vs[i][1]);
vlasky / debugeventemitter.js
Last active May 30, 2020
Debugging code to help track down events that cause EventEmitter memory leaks in Node.js
View debugeventemitter.js
//Is Node.js reporting warning messages like this?:
// "Warning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit"
//The following code will intercept calls to addListener() and on() and print the type of event and generate an Error exception
//With a stack trace to help you find the cause
var EventEmitter = require('events').EventEmitter;
const originalAddListener = EventEmitter.prototype.addListener;
You can’t perform that action at this time.