Skip to content

Instantly share code, notes, and snippets.

View ashwin's full-sized avatar

Ashwin Nanjappa ashwin

View GitHub Profile
@ashwin
ashwin / build-cuda.cmake
Last active April 20, 2024 04:20
Sample CMakeLists.txt file to build a CUDA program
### CMakeLists.txt for CUDA
cmake_minimum_required(VERSION 2.8)
find_package(CUDA QUIET REQUIRED)
# Pass options to NVCC
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_22,code=sm_22
@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 / OpenTKExample.py
Created June 7, 2013 07:16
An example IronPython program that uses OpenTK. Draws a colored triangle.
# IronPython example program to demonstrate OpenTK
#
# Steps:
# 1. Create an empty IronPython project in Visual Studio
# 2. Place OpenTK.dll in the directory of the Python source file
# 3. Paste this source code into the Python source file
# 4. Run. You should see a colored triangle. Press ESC to quit.
#
# Copyright (c) 2013 Ashwin Nanjappa
# Released under the MIT License
@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-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 / Doxyfile_cpp_cuda
Last active October 19, 2023 07:18
Doxyfile I use for C++ and CUDA code
# Doxyfile 1.8.6
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a double hash (##) is considered a comment and is placed in
# front of the TAG it is preceding.
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
@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 / getopt_long_example.cpp
Last active April 5, 2023 21:42
How to parse options in C++ using getopt_long
#include <getopt.h>
#include <iostream>
int num = -1;
bool is_beep = false;
float sigma = 2.034;
std::string write_file = "default_file.txt";
void PrintHelp()
{
@ashwin
ashwin / async_example.cpp
Last active March 3, 2023 23:18
How to use async threads in C++
#include <future>
float DoWork(int idx)
{
// Do some hard computation using idx
// and internal read-only data structures
// Return the float result
}
void DoAsync()
@ashwin
ashwin / ThrustRandom.cu
Created October 31, 2013 06:20
How to generate random numbers using Thrust
#include <thrust/device_vector.h>
#include <thrust/random.h>
struct GenRand
{
__device__
float operator () (int idx)
{
thrust::default_random_engine randEng;
thrust::uniform_real_distribution<float> uniDist;