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 / fileopendialog.py
Created Feb 25, 2014
File Open dialog in Python to read in a file path
View fileopendialog.py
import Tkinter
import tkFileDialog
def main():
Tkinter.Tk().withdraw() # Close the root window
in_path = tkFileDialog.askopenfilename()
print in_path
if __name__ == "__main__":
@ashwin
ashwin / build-cuda.cmake
Last active Jun 17, 2019
Sample CMakeLists.txt file to build a CUDA program
View build-cuda.cmake
### 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 / dict_to_namedtuple.py
Created Feb 27, 2017
How to convert Python dict to class object with fields
View dict_to_namedtuple.py
>>> from collections import namedtuple
>>> d = {"name": "joe", "age": 20}
>>> d
{'age': 20, 'name': 'joe'}
>>> d_named = namedtuple("Employee", d.keys())(*d.values())
>>> d_named
Employee(name='joe', age=20)
>>> d_named.name
'joe'
@ashwin
ashwin / latex-letter.tex
Created Jan 2, 2013
Simple letter template for LaTeX
View latex-letter.tex
%-----------------------------------------------------------------------------%
% Letter class
\documentclass[a4paper, 10pt]{letter}
% Name of sender
\name{Joe Fox}
% Signature of sender
\signature{Joe Fox}
@ashwin
ashwin / OpenTKExample.cs
Created Jun 7, 2013
An example C# program that uses OpenTK. Displays a colored triangle.
View OpenTKExample.cs
// C# example program to demonstrate OpenTK
//
// Steps:
// 1. Create an empty C# console application project in Visual Studio
// 2. Place OpenTK.dll in the directory of the C# source file
// 3. Add System.Drawing and OpenTK as References to the project
// 4. Paste this source code into the C# source file
// 5. Run. You should see a colored triangle. Press ESC to quit.
//
// Copyright (c) 2013 Ashwin Nanjappa
@ashwin
ashwin / DisableArrowKeys.vim
Created Feb 7, 2013
Disable arrow keys in Vim
View DisableArrowKeys.vim
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
@ashwin
ashwin / date_time.cpp
Created Jan 13, 2015
Get and print current date and time in C++
View date_time.cpp
// Example output from this code:
// Tue Jan 13 12:09:53 2015 (from ctime)
// 20150113_12_09_53 (from strftime)
// 20150113_12_09_53 (from put_time)
#include <ctime>
#include <chrono>
#include <iomanip>
// Get current time
@ashwin
ashwin / getopt_long_example.cpp
Last active Apr 3, 2019
How to parse options in C++ using getopt_long
View getopt_long_example.cpp
#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 / pocket_bookmarklet.js
Created Sep 17, 2017
Pocket bookmarklet code
View pocket_bookmarklet.js
javascript:(function(){var%20e=function(t,n,r,i,s){var%20o=[3259948,5462209,2047928,6163034,3042905,5012734,5672738,4996252,5003701,2852099];var%20i=i||0,u=0,n=n||[],r=r||0,s=s||0;var%20a={'a':97,'b':98,'c':99,'d':100,'e':101,'f':102,'g':103,'h':104,'i':105,'j':106,'k':107,'l':108,'m':109,'n':110,'o':111,'p':112,'q':113,'r':114,'s':115,'t':116,'u':117,'v':118,'w':119,'x':120,'y':121,'z':122,'A':65,'B':66,'C':67,'D':68,'E':69,'F':70,'G':71,'H':72,'I':73,'J':74,'K':75,'L':76,'M':77,'N':78,'O':79,'P':80,'Q':81,'R':82,'S':83,'T':84,'U':85,'V':86,'W':87,'X':88,'Y':89,'Z':90,'0':48,'1':49,'2':50,'3':51,'4':52,'5':53,'6':54,'7':55,'8':56,'9':57,'\/':47,':':58,'?':63,'=':61,'-':45,'_':95,'&':38,'$':36,'!':33,'.':46};if(!s||s==0){t=o[0]+t}for(var%20f=0;f<t.length;f++){var%20l=function(e,t){return%20a[e[t]]?a[e[t]]:e.charCodeAt(t)}(t,f);if(!l*1)l=3;var%20c=l*(o[i]+l*o[u%o.length]);n[r]=(n[r]?n[r]+c:c)+s+u;var%20p=c%(50*1);if(n[p]){var%20d=n[r];n[r]=n[p];n[p]=d}u+=c;r=r==50?0:r+1;i=i==o.length-1?0:i+1}if(s==126){var%20v
@ashwin
ashwin / tao.cs
Created Jun 18, 2013
C# program that uses Tao framework to call OpenGL, GLU and FreeGLUT functions.
View tao.cs
// C# program that uses Tao framework to call
// OpenGL, GLU and FreeGLUT functions.
//
// Steps:
// 1. Install Tao framework. Its .Net assemblies will be added to GAC.
// 2. Create an empty C# console application project in Visual Studio
// 3. Add references to Tao.OpenGL.dll and Tao.FreeGLUT.dll to the project.
// These files are in C:\Program Files (x86)\TaoFramework\bin
// 4. Paste this source code into the C# source file
// 5. Copy FreeGLUT.dll from C:\Program Files (x86)\TaoFramework\lib to
You can’t perform that action at this time.