Skip to content

Instantly share code, notes, and snippets.

View ashwin's full-sized avatar

Ashwin Nanjappa ashwin

View GitHub Profile
@ashwin
ashwin / UnorderedSetUsage.cpp
Created June 26, 2012 06:34
Using unordered_set
#include <iostream>
#include <unordered_set>
typedef std::unordered_set< int > IntUSet;
int main()
{
IntUSet iset;
// Insert
@ashwin
ashwin / UnorderedSetHashFunction.cpp
Created June 26, 2012 06:38
Using unordered_set with hash function
#include <iostream>
#include <unordered_set>
struct Point
{
int x, y;
bool operator == ( const Point& p ) const
{
return ( ( x == p.x ) && ( y == p.y ) );
@ashwin
ashwin / LaTeX-Figure.tex
Created June 29, 2012 06:35
Inserting a figure in LaTeX
% At the beginning of the document
\usepackage{graphicx}
% At the place you want a figure
\begin{figure}[h]
\centering
\includegraphics[scale=0.3]{pics/foobar.png}
\caption{This is a caption for the figure.}
\label{foobar-figure}
\end{figure}
@ashwin
ashwin / LaTeX-Algorithm.tex
Created June 29, 2012 06:49
Inserting algorithm in LaTeX
% Add the packages
\usepackage{algorithm}
\usepackage{algpseudocode}
% Insert the algorithm
\begin{algorithm}
\caption{Compute sum of integers in array}
\label{array-sum}
\begin{algorithmic}[1]
\Procedure{ArraySum}{$A$}
@ashwin
ashwin / subfloat.tex
Created July 31, 2012 06:23
Sub-figures using subfloat in LaTeX
% Package for subfloat
\usepackage{subfig}
% Figure with two sub-figures
\begin{figure}
\centering
\subfloat[]
{
\includegraphics[scale=.5]{fig-1.pdf}
\label{fig:foo-1}
@ashwin
ashwin / subfloat-row.tex
Created July 31, 2012 06:41
Sub-figures arranged in rows in LaTeX
\begin{figure}
\centering
\subfloat[]
{
\includegraphics[scale=.6]{fig-1.pdf}
\label{fig:foo-1}
}
\par
\subfloat[]
{
@ashwin
ashwin / gist:3269777
Created August 6, 2012 03:40
Delete pages from DjVu document
# Delete page 170 from foo.djvu
djvm -d foo.djvu 170
# Delete pages 170-174 from foo.djvu
for ( $i = 0; $i -lt 5; $i++ ) { djvm -d foo.djvu 170 }
@ashwin
ashwin / gist:3269858
Created August 6, 2012 03:45
Append one DjVu document to another
# Append back.djvu to front.djvu
djvm -i front.djvu back.djvu
@ashwin
ashwin / latex-letter.tex
Created January 2, 2013 06:31
Simple letter template for LaTeX
%-----------------------------------------------------------------------------%
% Letter class
\documentclass[a4paper, 10pt]{letter}
% Name of sender
\name{Joe Fox}
% Signature of sender
\signature{Joe Fox}
@ashwin
ashwin / CursorLineOnlyInActiveWindow.vim
Last active October 9, 2017 03:56
Show cursorline only in active window of Vim
augroup CursorLineOnlyInActiveWindow
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END