Skip to content

Instantly share code, notes, and snippets.

View rajatkhanduja's full-sized avatar

Rajat Khanduja rajatkhanduja

View GitHub Profile
@rajatkhanduja
rajatkhanduja / FizzBuzz.cpp
Last active August 29, 2015 13:58
Solution of the famous FizzBuzz problem (http://blog.codinghorror.com/why-cant-programmers-program/) in C++
#include<iostream>
using namespace std;
int main(void)
{
for(int i = 1; i <= 100; ++i)
{
if (i % 3 == 0)
{
@rajatkhanduja
rajatkhanduja / about.md
Created August 10, 2011 10:22 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@rajatkhanduja
rajatkhanduja / SOPAStrike
Created January 17, 2012 16:03
SOPA Strike Javascript
<script>
var a=new Date;if(18==a.getDate()&&0==a.getMonth()&&2012==a.getFullYear())window.location="http://sopastrike.com/strike";
</script>
@rajatkhanduja
rajatkhanduja / Makefile
Created January 30, 2012 08:55
Example of a Makefile to make use of a general rule
SRC = src
OBJ = obj
BIN = bin
CC = gcc
DEFINES =
CFLAGS = -Iinclude/
OBJECTS = ${OBJ}/fsm.o ${OBJ}/set.o ${OBJ}/regex_parser.o ${OBJ}/regex_to_fsm.o ${OBJ}/main.o
all: ${OBJECTS}
${CC} $^ -g -o ${BIN}/lexical_analyzer.out
@rajatkhanduja
rajatkhanduja / mutli-UDP-gitignore.patch
Created March 8, 2012 06:58
Patch for multithreaded UDP client-server to add .gitignore and remove obj/executable files.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..42f2eb97deb421f3acfbb2653524767da65d2300
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+client/client
+server/server
diff --git a/client/client b/client/client
Ideas :
1. Detect the person entering the room and automatically open the door, lock the door when a person leaves - P0
2. Automatically wake up "a computer" and open some programs on it (configurable)
3. Play music according to time of day and recent music preferences
4. Automatically toggle lights and curtains based on ambient light in the room.(using motors and such, but the hardware comes later, if we can just generate the right signals, that would be a huge step)
5. Have 2-3 "profiles" for the room which can be toggled by voice commands.
6. Integrate all this with mobile (Optional)
7. Identification and authentication of all people entering the room, if face not present in database, say unknown person.
8. RFID tag all "movable" items in room and detect when sth is taken out.
@rajatkhanduja
rajatkhanduja / PGM to matrix
Created October 21, 2012 06:14
Reading directory of files into a matrix of row vectors of pixels. Here, the code needs to be executed when orl_faces is a sub-directory of "current working directory".
library (pixmap)
# List the train files
trainFiles = dir("orl_faces", pattern="*[1-9].pgm", full.names=T, recursive=T)
# List the test files
testFiles = dir("orl_faces", pattern="*10.pgm", full.names=T, recursive=T)
# Separate the training set and test set corresponding to each folder
trainSet = numeric(9)
@rajatkhanduja
rajatkhanduja / FindStrings.cpp
Created October 26, 2012 13:27
My attempt at solving the find strings question on InterviewStreet (https://www.interviewstreet.com/challenges/dashboard/#problem/4efa210eb70ac)
/* Solution using suffix trees. */
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cassert>
using namespace std;
#define ALPHABETSIZE 26
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
void sccSetInsertions (set<int>& indexSet, set<int>& valSet, const int& i, const int& val)
@rajatkhanduja
rajatkhanduja / KingdomConnectivity.cpp
Created October 29, 2012 22:29
Attempt at solving Kingdom Connectivity problem on InterviewStreet
#include <cstdio>
#include <list>
#include <vector>
#define MOD 1000000000
using namespace std;
typedef vector<list<int> > Graph;
enum {WHITE = 0, GREY};