Skip to content

Instantly share code, notes, and snippets.

View k4rtik's full-sized avatar

Kartik Singhal k4rtik

View GitHub Profile
@k4rtik
k4rtik / distance.cpp
Created December 10, 2011 02:44
Some object oriented code that was asked in the practical in first year - November 10, 2009
#include <iostream>
using namespace std;
class DB;
class DM
{
int metres;
int cms;
public:
@k4rtik
k4rtik / temp.sh
Created April 28, 2012 13:10
Simple script to let me know the temperatures of my laptop, hddtemp requires sudo making this script more than 3 lines.
#!/bin/bash
sensors
aticonfig --odgt
answer="N"
if [ "$(whoami)" != "root" ]; then
echo -ne "\n\nDo you want to know hard disk temperature (requires sudo)? (y/N) "
read answer
if [ "$answer" == "y" ]; then
@k4rtik
k4rtik / .vimrc
Last active October 4, 2015 15:58
My custom vimrc
" URL: http://vim.wikia.com/wiki/Example_vimrc
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
" Description: A minimal, but feature rich, example .vimrc. If you are a
" newbie, basing your first .vimrc on this file is a good choice.
" If you're a more advanced user, building your own .vimrc based
" on this file is still a good idea.
"------------------------------------------------------------
" Features {{{1
"
@k4rtik
k4rtik / scanning-maxsum.c
Created October 1, 2012 13:38
Linear time program to find the max sum in a subsequence in an array of numbers.
// Program to find the max sum in a subsequence in an array of numbers.
//
// Adapted from the linear time scanning algorithm described by Jon Bentley in
// his famouos collection of programming columns - Programming Pearls.
//
// Author: Kartik Singhal
// Date: October 1, 2012
#include <stdio.h>
@k4rtik
k4rtik / subquadratic-maxsum.c
Created October 1, 2012 13:51
O(n lg n) program to find the max sum in a subsequence in an array of numbers.
// Program to find the max sum in a subsequence in an array of numbers.
//
// Adapted from the O(n lg n) algorithm described by Jon Bentley in his famouos
// collection of programming columns - Programming Pearls.
//
// Author: Kartik Singhal
// Date: October 1, 2012
#include <stdio.h>
@k4rtik
k4rtik / lift-scheduler.py
Created October 2, 2012 06:02
A simple lift scheduler program using nearest car approach
#!/usr/bin/python
# Assume there is a 50 storey building and it has 4 lifts. You have to write a
# scheduler program for the lifts. All the 4 lifts will be controlled by
# single program and Waiting time for peoples waiting for lift should be
# minimum.
#
# Using the Nearest Car approach described at http://www.quora.com/Is-there-any-public-elevator-scheduling-algorithm-standard
#
# Some assumptions include direction of lift at top floor will always be down,
# and on ground floor it will be up. More assumptions obvious from the code.
@k4rtik
k4rtik / kvm-check.sh
Created October 23, 2012 12:59
Simple utility to check whether KVM is installed, loaded and running, wrote for Fedora 17 platform for IBM Virtual Tux contest.
#!/bin/bash
echo Checking if required packages are installed...
rpm -q qemu-kvm python-virtinst libvirt | grep not
echo Done.
echo
echo Loaded kvm kernel modules:
lsmod | grep kvm_intel
@k4rtik
k4rtik / vmstats.py
Created October 23, 2012 13:04
Simple utility to display stats of all active (running) KVM virtual machines, wrote for Fedora 17 platform for IBM Virtual Tux contest.
#!/usr/bin/env python
import os
import sys
import commands
status, domains = commands.getstatusoutput("virsh list | grep running | cut -f7 -d' '")
domains = domains.rsplit('\n')
@k4rtik
k4rtik / Delete mass Drupal content
Created June 14, 2013 06:13
iMacros script for deleting a lot of spam content on a Drupal website.
VERSION BUILD=6011206 RECORDER=CR
URL GOTO=http://a.drupal.website/admin/content/node
'REFRESH
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:node-admin-content ATTR=* CONTENT=YES
TAG POS=1 TYPE=SELECT FORM=ID:node-admin-content ATTR=ID:edit-operation CONTENT=%delete
SET !TIMEOUT 2
SET !ERRORIGNORE YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:node-admin-content ATTR=ID:edit-submit-1
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:node-admin-content ATTR=ID:edit-submit
@k4rtik
k4rtik / keybase.md
Created January 9, 2015 17:51
KeybaseIO proof

Keybase proof

I hereby claim:

  • I am k4rtik on github.
  • I am k4rtik (https://keybase.io/k4rtik) on keybase.
  • I have a public key whose fingerprint is E53F 7004 EAA7 3D1F 33CF 35AB 8868 ADA4 B129 C858

To claim this, I am signing this object: