Skip to content

Instantly share code, notes, and snippets.

View shrikrishnaholla's full-sized avatar

Shrikrishna Holla shrikrishnaholla

View GitHub Profile
@konklone
konklone / problem-solving.md
Last active March 16, 2016 08:18
Problem solving high memory usage with node.js, websockets, socket.io, and redis.

Problem: My Node.js processes (drones on Nodejitsu) are repeatedly growing in memory until they crash and get restarted. They are multiple processes responding to websockets connections over socket.io, using socket.io's Redis store to broker messages across connections and broadcast messages.

Conclusion: that socket.io's Redis store's memory usage likely either grows indefinitely, or is just way too high. We also isolated semi-frequent reconnects to the redis client on the part of each node.js process, though this looks unrelated to the overall memory problem.

Possibly related: socketio/socket.io#1040 socketio/socket.io#463

=== edited chat log of #nodejitsu on 25/11/2012 follows ==

@gurudeb
gurudeb / bootstrap-3-right-offset.css
Created August 11, 2016 18:35
Bootstrap 3 offset on right
.col-xs-offset-right-12 {
margin-right: 100%;
}
.col-xs-offset-right-11 {
margin-right: 91.66666667%;
}
.col-xs-offset-right-10 {
margin-right: 83.33333333%;
}
.col-xs-offset-right-9 {
var DIR = '/tmp/test',
FILE_PATTERN = /test/,
fs = require('q-io/fs');
fs.list(DIR)
.then(function (files) {
var matched = files.filter(function (item) {
return item.match(FILE_PATTERN);
});
if (matched.length !== 1) {
@tanaikech
tanaikech / submit.md
Last active July 26, 2020 02:27
Benchmark: Loop for Array Processing using Google Apps Script with V8

Benchmark: Loop for Array Processing using Google Apps Script with V8

- February 9, 2020 - Published. - March 15, 2020 - Results of "for of" and "for of with iterator" were added.
# you can make a text file of request times (in ms, one number per line) and import it here, or you can use a probability distribution to simulate request times (see below where setting req_durations_in_ms)
# rq = read.table("~/Downloads/request_times.txt", header=FALSE)$V1
# argument notes:
# parallel_router_count is only relevant if router_mode is set to "intelligent"
# choice_of_two, power_of_two, and unicorn_workers_per_dyno are only relevant if router_mode is set to "naive"
# you can only select one of choice_of_two, power_of_two, and unicorn_workers_per_dyno
run_simulation = function(router_mode = "naive",
reqs_per_minute = 9000,
@Vovan-VE
Vovan-VE / fix-lists.js
Created June 20, 2019 00:09
Quill Lists Fix (redux ready)
/*
* Quill 1.* cannot next block elements inside <li> including nested <ul>,<ol>.
* To achieve nested lists it uses flat linear lists with CSS class `ql-indent-\d+` on <li>.
* Nesting <ul> inside <ol> or vice-versa cause topmost list to break in two adjacent lists.
*
* There is the only solution: fix bad HTML after getting it from Quill and break it back before
* passing to Quill again for editing.
*/
const mkNode = (tagName = 'div') => document.createElement(tagName);
@aquilax
aquilax / gist:1333830
Created November 2, 2011 14:55
Naive Bayes classifier in PostgreSQL
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.1.1
-- Dumped by pg_dump version 9.1.1
-- Started on 2011-11-02 16:53:36 EET
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
@philfreo
philfreo / gist:7257723
Created October 31, 2013 21:44
Facebook Perl source code from 2005. When browsing around thefacebook.com in 2005 the server spit out some server-side source code rather than running it. I believe this was for their old graph feature that let you visualize the graph between all your friends. The filename is `mygraph.svgz` and contains some gems such as a commented out "zuck" d…
#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
@m-ou-se
m-ou-se / replace-debian-with-arch.txt
Last active October 22, 2023 12:16
Instructions to replace a live Debian installation with Arch
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/
wget 'ftp://ftp.nluug.nl/pub/os/Linux/distr/archlinux/iso/latest/archlinux-bootstrap-*-x86_64.tar.gz'
# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged
# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1
@sent-hil
sent-hil / pictures.markdown
Created August 24, 2012 02:18
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature