Skip to content

Instantly share code, notes, and snippets.

@prasoon2211
prasoon2211 / chatapp_1.md
Last active August 29, 2015 14:04
Chat application in Node.js: Part 1

Making a chat application in nodejs : Part 1

Nodejs is a new development platform that focusses on developing realtime applications. In this tutorial, we'll be learning how to create a full-fledged chatting application, complete with support for multiple users and multiple chat rooms. We will start slow at first and slowly build up to our goal. This is the first of a multipart turotial series.

What exactly is Node.js?

Before we start, let us first clarify what node.js is, exactly. Is it a language? No. In fact, node.js is a runtime environment that can run JavaScript code. Also, it is build on top of Google's V8 JavaScript engine. Simply put, this means that Node.js is fast. Fast enough that you can write a web server in it and be confident that it'll handle loads just as well as a server written in C.

Node.js is good for writing application that require constant, or almost constant communication with the server. The thing that separated node f

@prasoon2211
prasoon2211 / ctags-gen.sh
Created January 18, 2015 13:48
PHP vim ctags
#!/bin/bash
cd /path/to/framework/library
exec ctags-exuberant -f ~/.vim/mytags/framework \
-h \".php\" -R \
--exclude=\"\.svn\" \
--totals=yes \
--tag-relative=yes \
--PHP-kinds=+cf \
--regex-PHP='/abstract class ([^ ]*)/\1/c/' \
--regex-PHP='/interface ([^ ]*)/\1/c/' \
@prasoon2211
prasoon2211 / dev_apache
Created February 6, 2015 14:01
Developing with apache
If your server documents are in /home/$USER/public_html directory you need to run
sudo chown -R www-data:www-data /home/$USER/public_html
to give ownership of the DocumentRoot folder to the user www-data and group www-data.
Then you can add yourself to the group www-data
sudo adduser $USER www-data
@prasoon2211
prasoon2211 / application.md
Last active August 29, 2015 14:17
Metrics and Graphs support for Buildbot: GSoC 2015 application

Metrics and Graphs for Buildbot

Personal Details

Project Description

@prasoon2211
prasoon2211 / gist:ccfa6e6314f9637f9cd8
Created July 17, 2015 17:58
challenges/bfsshortreach
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
class Graph {
@prasoon2211
prasoon2211 / string_chaining.cpp
Created October 29, 2015 16:21
String chaning
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#define PR cout << 11 << endl;
using namespace std;
string arr[50010];
@prasoon2211
prasoon2211 / suffix_array.py
Last active November 12, 2019 08:15
Python suffix array
def sort_bucket(s, bucket, order):
d = defaultdict(list)
for i in bucket:
key = s[i:i+order]
d[key].append(i)
result = []
for k,v in sorted(d.iteritems()):
if len(v) > 1:
result += sort_bucket(s, v, order*2)
else:
@prasoon2211
prasoon2211 / z_algo.py
Created November 14, 2015 18:13
Z algorithm in Python
def z_arr(s):
"""An advanced computation of Z-values of a string."""
# From https://ivanyu.me/blog/2013/10/15/z-algorithm/
Z = [0] * len(s)
Z[0] = len(s)
rt = 0
lt = 0
@prasoon2211
prasoon2211 / Contributions.md
Created December 7, 2016 20:12
Open source contributions