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 /
Created Feb 25, 2014
Print command-line arguments in Python
import sys
def main():
for arg in sys.argv:
print arg
if "__main__" == __name__:
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 / fraction.tex
Created May 28, 2014
How to display fraction in LaTeX
View fraction.tex
% Fraction in LaTeX
% The default method
% Smaller fraction that occupies lesser vertical space
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
x = y + z
% Equation with numbering
x = y + z
ashwin / index.tex
Created Jul 3, 2014
How to create index in LaTeX
View index.tex
% In the preamble
% Whenever a key term is defined or used
\index{normal distribution}
\index{poisson distribution}
% At end of document
ashwin / wxCMakeLists.txt
Created Jul 21, 2014
CMakeLists.txt for building wxWidgets program
View wxCMakeLists.txt
cmake_minimum_required(VERSION 2.8)
find_package(wxWidgets COMPONENTS core base REQUIRED)
include( "${wxWidgets_USE_FILE}" )
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 / 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:
// Global variable
int g_widget_num = 0;
// Constant
const int kCameraMax = 890;
// Type
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 / 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.