Skip to content

Instantly share code, notes, and snippets.

@vermaslal
vermaslal / The Technical Interview Cheat Sheet.md
Created April 29, 2016 05:07 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@vermaslal
vermaslal / README
Created March 10, 2016 10:28 — forked from kalebdf/LICENSE
Export Table Data to CSV using Javascript
Example code for exporting data in a table to a csv file.
- Added IE support & check (@kalebdf, 8/19/2015)
http://bl.ocks.org/kalebdf/ee7a5e7f44416b2116c0
var child_process = require('child_process'),
http = require('http');
url = require('url'),
ffmpeg = null;
var livestream = function (req, resp) {
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var input = 'udp://225.1.1.1:8208';
@vermaslal
vermaslal / serialize.js
Last active February 1, 2016 09:27
Serialization on node js
function insertCollection(collection, callback) {
var coll = collection.slice(0); // clone collection
(function insertOne() {
var record = coll.splice(0, 1)[0]; // get the first record of coll and reduce coll by one
db.insert(record, function(err) {
if (err) { callback(err); return }
if (coll.length == 0) {
callback();
} else {
insertOne();
@vermaslal
vermaslal / file0.txt
Created January 23, 2016 11:40 — forked from giwa/file0.txt
Install g++/gcc 4.8.2 in CentOS 6.6 ref: http://qiita.com/giwa/items/28c754d8fc2936c0f6d2
$ wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
$ yum install devtoolset-2-gcc devtoolset-2-binutils
$ yum install devtoolset-2-gcc-c++ devtoolset-2-gcc-gfortran
@vermaslal
vermaslal / queryStringParam.js
Created December 14, 2015 09:36
jQuery Get Query String Parameters as object
$.extend({
getUrlVars: function () {
var vars = {}, hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
}
return vars;
},
@vermaslal
vermaslal / streamMiddle.js
Last active December 8, 2015 10:09
To update stream on middle using node js
'use strict';
//Reference: https://www.safaribooksonline.com/blog/2013/05/01/using-streams-in-node-js/
var fs = require('fs');
var stream = require('stream');
//var Transform = require('stream').Transform;
var mx = {};
mx.bind_helo = '--------sham-----';
var source = fs.createReadStream('/home/sarv/node_modules/smail/s.txt');
@vermaslal
vermaslal / replace_href_anchor.js
Created November 25, 2015 11:32
Replace href from anchor tag html using node js
var source = '<a href="double-quote test">double-quote test</a>\n' +
'<a href=\'single-quote test\'>single-quote test</a>\n' +
'<a href=\'single-quote test\'>single-quote test</a>\n' +
'<a class="foo" href="leading prop test">\n' +
'<a href="trailing prop test" class="foo">\n' +
'<a style="bar" link="baz" ' +
'name="quux" ' +
'href="multiple prop test" class="foo">\n' +
'<a class="foo"\n href="inline newline test"\n style="bar"\n >inline newline test</a>' +
'<a href=3D"with 3d data double quote"\n style="bar"\n >with 3d data double quote</a>' +
@vermaslal
vermaslal / node_cluster.js
Last active October 31, 2015 12:09
Improve node.js app performance using Clustering
var cluster = require('cluster');
var numCPUs = require('os').cpus().length;
var express = require("express");
var app = express();
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
@vermaslal
vermaslal / ksort.js
Created October 30, 2015 12:39 — forked from stiekel/ksort.js
JavaScript ksort
function ksort(obj){
var keys = Object.keys(obj).sort()
, sortedObj = {};
for(var i in keys) {
sortedObj[keys[i]] = obj[keys[i]];
}
return sortedObj;
}