Skip to content

Instantly share code, notes, and snippets.

@saidinesh5
saidinesh5 / nestedjson.cpp
Last active December 9, 2023 02:43
Get/Set values in nested QJsonObjects using "/path/to/key" syntax
#include <QJsonDocument>
#include <QJsonObject>
#include <QDebug>
static QString const &data = R"(
{
"persistentData": {
"module": {
"name": "fancy module",
"options": {}
@saidinesh5
saidinesh5 / act-login
Created November 4, 2017 21:36
The script I use to automatically login to my Act Fibernet
#!/bin/sh
LOGIN_USERNAME="<your mail id>%40<your mail provider>.com"
LOGIN_PASSWORD="<your password>"
LOGIN_SERVER_ADDRESS="http://portal.actcorp.in"
LOGIN_PAGE="/tmp/loginPage"
CONNECTIVITY_CHECK_PING_TIMEOUT=3
CONNECTIVITY_CHECK_PING_HOST=www.google.com
@saidinesh5
saidinesh5 / internet_watchdog.sh
Last active September 28, 2016 23:47
A silly little watchdog script to monitor my wifi connection and reset it
#!/bin/sh
#Host to ping to check pingability, by default it is the default gateway
PING_HOST=$(ip route show default | awk '/default/ {print $3}')
PING_INTERVAL=10
PING_TIMEOUT=5
#Number of consecutive ping successes to note that the server is up
SUCCESS_ALERT_COUNT=1
######################################################################
# Automatically generated by qmake (3.0) Sat Jan 24 06:11:57 2015
######################################################################
TEMPLATE = app
TARGET = benchmark
INCLUDEPATH += .
CONFIG += c++11
QT += testlib
QT -= gui quick qml
/*
* Perfect Hash implementation as described in:
* http://www.drdobbs.com/architecture-and-design/generating-perfect-hash-functions/184404506
*
* Copyright 2015-2020 Dinesh Manajipet <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
@saidinesh5
saidinesh5 / Complex.js
Created March 6, 2014 05:02
Rewrote the code from https://gist.github.com/dsamarin/1258353 such that the arithematic operatioins wont modify the Original object. Trading off performance for cleaner code.
.pragma library
//
// Originally taken from:
// https://gist.github.com/dsamarin/1258353
//
var Complex = function(real, imag) {
if (!(this instanceof Complex)) {
return new Complex (real, imag);
@saidinesh5
saidinesh5 / minesweeper.c
Created November 9, 2012 23:13
One of the very first programs I have written... Here for purely its nostalgic value :D The clearmine(int rx,int ry) function is what taught me the basics of recurssion!
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
int main_array[10][10],disp_array[10][10],i,j,x,y,marked=0,correct=0;
//left over items :
//Game menu.
void new_random_board()
{
@saidinesh5
saidinesh5 / audioclass.h
Created September 10, 2012 18:29
A simple test app to test Phonon's Audio data out: To Compile: qmake && make , To Run: ./audiodataout /path/to/audiofile
#include <QtGui>
#include <phonon/audiodataoutput.h>
class AudioClass: public QWidget{
Q_OBJECT
QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > m_audiodata;
public slots:
void dataReceived(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> >& data){
//qDebug()<<"Hii"<<data[Phonon::AudioDataOutput::LeftChannel][512];
@saidinesh5
saidinesh5 / Makefile
Created May 18, 2012 21:35
A nice Makefile for my Node.js projects.
#
# My Fancy Node.js project
#
PROJECT = "My Fancy Node.js project"
all: install test server
debug: ;@echo "Debugging ${PROJECT}.....http://0.0.0.0:8080/debug?port=5858 to start debugging"; \
@saidinesh5
saidinesh5 / node-mongoskin-benchmark.coffee
Created February 19, 2012 23:29
A simple benchmark for node-mongoskin
mongoskin = require 'mongoskin'
server = 'localhost'
db = 'foobar'
timeElapsed = 0
timeLimit = 10 #total time the benchmark should run in seconds
docsRetrieved = { 0 : 0 }
ids = []