Skip to content

Instantly share code, notes, and snippets.

View ashwin's full-sized avatar

Ashwin Nanjappa ashwin

View GitHub Profile
@ashwin
ashwin / roundHalfToEven.cpp
Created August 17, 2018 05:27
Round half to even implementation for float
#include <array>
#include <cmath>
#include <iostream>
float roundHalfToEven(float f)
{
const float r = round(f); // Result is round-half-away-from-zero
const float d = r - f; // Difference
// Result is not half, RHAFZ result same as RHTE
@ashwin
ashwin / type_tree.py
Created December 11, 2017 13:42
Print type hierarchy tree
#!/usr/bin/env python3
"""Print hierarchy of types present in Python."""
import argparse
import sys
def is_builtin(t):
"""Check if type is builtin."""
builtin_s = "__builtin__" if sys.version_info.major <= 2 else "builtins"
@ashwin
ashwin / gpu_topologies.txt
Created November 13, 2017 15:59
GPU topology examples
$ nvidia-smi topo -m
GPU0 CPU Affinity
GPU0 X 0-7
Legend:
X = Self
SOC = Connection traversing PCIe as well as the SMP link between CPU sockets(e.g. QPI)
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe switches (without traversing the PCIe Host Bridge)
@ashwin
ashwin / weekly_view.jira
Created October 26, 2017 00:43
Weekly view of issues in JIRA
# Last week
assignee = currentUser() AND duedate < startOfWeek() AND duedate >= startofWeek("-1w")
# This week
assignee = currentUser() AND duedate < endOfWeek() AND duedate >= startOfWeek()
# Next week
assignee = currentUser() AND duedate >= endOfWeek() AND duedate <= startofWeek("+1w")
@ashwin
ashwin / dot_to_ascii.pl
Created October 21, 2017 01:19
Perl script to convert DOT file to ASCII graph
#!/usr/bin/perl -w
use Graph::Easy::Parser::Graphviz;
my $parser = Graph::Easy::Parser::Graphviz->new();
print $parser->from_file($ARGV[0])->as_ascii();
@ashwin
ashwin / git-rename-remote-branch
Created October 12, 2017 15:11
Git script to rename remote branch
#!/bin/sh
# From: https://github.com/sschuberth/dev-scripts/
if [ $# -ne 3 ]; then
echo "Rationale : Rename a branch on the server without checking it out."
echo "Usage : $(basename $0) <remote> <old name> <new name>"
echo "Example : $(basename $0) origin master release"
exit 1
fi
@ashwin
ashwin / pocket_bookmarklet.js
Created September 17, 2017 09:20
Pocket bookmarklet code
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
FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu16.04
ENV CUDA_ARCH "30 35 52 60"
MAINTAINER Felix Abecassis "fabecassis@nvidia.com"
# Install dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
git \
FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu16.04
MAINTAINER Felix Abecassis "fabecassis@nvidia.com"
ENV CUDA_ARCH_BIN "30 35 50 52 60"
ENV CUDA_ARCH_PTX "60"
# Install dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
@ashwin
ashwin / .Xresources
Created July 27, 2017 13:09
My ~/.Xresources config for xterm
! =============================================================================
! XTerm settings
! =============================================================================
! Use white-on-black colors
XTerm.vt100.reverseVideo: true
UXTerm.vt100.reverseVideo: true
! XTerm already has 256 colors support
! We ask it to set the correct $TERM