Skip to content

Instantly share code, notes, and snippets.

Ashwin Nanjappa ashwin

Block or report user

Report or block ashwin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ashwin
ashwin / printargv.py
Created Feb 25, 2014
Print command-line arguments in Python
View printargv.py
import sys
def main():
for arg in sys.argv:
print arg
if "__main__" == __name__:
main()
@ashwin
ashwin / morton2d.cpp
Last active Aug 29, 2015
Demo of Morton index in 2D
View morton2d.cpp
#include <stdint.h>
#include <cstdio>
uint32_t make_morton(uint32_t x, uint32_t y)
{
uint32_t m = 0;
for (int bit = 31; bit >= 0; --bit)
{
uint32_t mask = 1 << bit;
uint32_t xbit = (x & mask) >> bit;
@ashwin
ashwin / fraction.tex
Created May 28, 2014
How to display fraction in LaTeX
View fraction.tex
% Fraction in LaTeX
% The default method
$\frac{1}{x}$
% Smaller fraction that occupies lesser vertical space
\usepackage{amsmath}
$\tfrac{1}{x}
@ashwin
ashwin / equation.tex
Created May 28, 2014
How to display equation in LaTeX
View equation.tex
% How to display equation in LaTeX
% Simple equation with no numbering
\begin{equation*}
x = y + z
\end{equation*}
% Equation with numbering
\begin{equation}
x = y + z
@ashwin
ashwin / index.tex
Created Jul 3, 2014
How to create index in LaTeX
View index.tex
% In the preamble
\usepackage{makeidx}
\makeindex
% Whenever a key term is defined or used
\index{normal distribution}
\index{poisson distribution}
% At end of document
\printindex
@ashwin
ashwin / wxCMakeLists.txt
Created Jul 21, 2014
CMakeLists.txt for building wxWidgets program
View wxCMakeLists.txt
project(helloapp)
cmake_minimum_required(VERSION 2.8)
find_package(wxWidgets COMPONENTS core base REQUIRED)
include( "${wxWidgets_USE_FILE}" )
add_executable(
${PROJECT_NAME}
@ashwin
ashwin / 0_reuse_code.js
Created Aug 13, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ashwin
ashwin / google-cpp-style-guide.cpp
Created Aug 13, 2014
Code demonstrating Google C++ Style Guide
View google-cpp-style-guide.cpp
// Code demonstrating the Google C++ Style Guide:
// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
// Global variable
int g_widget_num = 0;
// Constant
const int kCameraMax = 890;
// Type
@ashwin
ashwin / boost_dfs_example.cpp
Created Jul 26, 2008
Example of boost DFS on an undirected graph
View boost_dfs_example.cpp
// Boost DFS example on an undirected graph.
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <iostream>
using namespace std;
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS> MyGraph;
typedef boost::graph_traits<MyGraph>::vertex_descriptor MyVertex;
@ashwin
ashwin / randgen.cpp
Created Aug 27, 2014
Random number generation in C++11
View randgen.cpp
#include <iostream>
#include <limits>
#include <random>
int main()
{
std::default_random_engine eng((std::random_device())());
std::uniform_int_distribution<int8_t> idis(0, std::numeric_limits<int8_t>::max());
for (int i = 0; i < 10; ++i)
You can’t perform that action at this time.