Skip to content

Instantly share code, notes, and snippets.

View rajatkhanduja's full-sized avatar

Rajat Khanduja rajatkhanduja

View GitHub Profile
#include "o2/o1.h"
#include <QString>
class EvernoteAuthenticator : public O1{
EvernoteAuthenticator(const QString& host, const QString& customerKey, const QString& customerSecret, QObject *parent = 0){
rajatkhanduja / FizzBuzz.cpp
Last active August 29, 2015 13:58
Solution of the famous FizzBuzz problem ( in C++
using namespace std;
int main(void)
for(int i = 1; i <= 100; ++i)
if (i % 3 == 0)
#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 / 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};
rajatkhanduja / FindStrings.cpp
Created October 26, 2012 13:27
My attempt at solving the find strings question on InterviewStreet (
/* Solution using suffix trees. */
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cassert>
using namespace std;
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)
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 / fdToStream.cpp
Created March 10, 2012 19:49
Converting a file descriptor to an istream or ostream (with g++-4.5) [ non-portable method ]
#include <iostream>
#include <ext/stdio_filebuf.h>
using __gnu_cxx::stdio_filebuf;
using std::istream;
using std::ostream;
inline stdio_filebuf<char> * fileBufFromFD (int fd, std::_Ios_Openmode mode)
return (new stdio_filebuf<char> (fd, mode));
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 @@
diff --git a/client/client b/client/client
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
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