Skip to content

Instantly share code, notes, and snippets.

# usage: `python ~/Desktop/contours.py 1994-654-12_v02.tif`
# output is to a squareless.txt file and the directory "out"
# Working well with thumbnails with 400px as their longest side - untested with other dimensions
# for i in $(ls -1 | grep tif); do python /Users/artsyinc/Documents/resistance/experiments/artwork_image_cropping/contours.py $i; done
import cv2
import numpy as np
from matplotlib import pyplot as plt
import sys
@adhithyan15
adhithyan15 / while.go
Created May 10, 2015 23:52
While loop in Go
package main
import "fmt"
func main(){
counter := 1
for{
if counter > 10{
break;
}
@adhithyan15
adhithyan15 / mat2latex.m
Created July 22, 2012 20:33
matlab2octave(path_to_m_file) example
function output = mat2latex(varargin)
%This function produces Latex code for any matlab matrix of any dimension.
%It requires the package amsmath in latex for successful operation. This
%code utilizes bmatrix environment.This code produces square brackets to
%enclose the elements of the matrix.This function has to be run as an
%argument for the builtin fprintf() function to work properly. For example
%this fprintf(mat2latex(A)).Decimal numbers are left as decimal numbers by default.
%If you want the decimal numbers to be formatted as rational numbers, pass
%in a second parameter 'ratio' with your matrix. For example,fprintf(mat2latex(A,'ratio'))
@adhithyan15
adhithyan15 / mat2latexOctave.m
Created July 22, 2012 20:50
Converted mat2latex.m file
function output = mat2latexOctave(varargin)
%This function produces Latex code for any matlab matrix of any dimension.
%It requires the package amsmath in latex for successful operation. This
%code utilizes bmatrix environment.This code produces square brackets to
%enclose the elements of the matrix.This function has to be run as an
%argument for the builtin fprintf() function to work properly. For example
%this fprintf(mat2latex(A)).Decimal numbers are left as decimal numbers by default.
%If you want the decimal numbers to be formatted as rational numbers, pass
%in a second parameter 'ratio' with your matrix. For example,fprintf(mat2latex(A,'ratio'))
@adhithyan15
adhithyan15 / mat2DetLatex.m
Created July 22, 2012 23:29
matlab2octave(path_to_m_files_folder) example
function output = mat2DetLatex(varargin)
%This function produces Latex code for any octave/matlab matrix of any dimension as a determinant.
%It requires the package amsmath in latex for successful operation. This
%code utilizes vmatrix environment.This code produces absolute value brackets to
%enclose the elements of the matrix.This function has to be run as an
%argument for the builtin fprintf() function to work properly. For example
%this fprintf(mat2DetLatex(A)).Decimal numbers are left as decimal numbers by default.
%If you want the decimal numbers to be formatted as rational numbers, pass
%in a second parameter 'ratio' with your matrix. For example,fprintf(mat2DetLatex(A,'ratio'))
@adhithyan15
adhithyan15 / mat2latex.m
Created July 23, 2012 00:28
Converted Matlab Code and Saved in a different directory
function output = mat2latex(varargin)
%This function produces Latex code for any matlab matrix of any dimension.
%It requires the package amsmath in latex for successful operation. This
%code utilizes bmatrix environment.This code produces square brackets to
%enclose the elements of the matrix.This function has to be run as an
%argument for the builtin fprintf() function to work properly. For example
%this fprintf(mat2latex(A)).Decimal numbers are left as decimal numbers by default.
%If you want the decimal numbers to be formatted as rational numbers, pass
%in a second parameter 'ratio' with your matrix. For example,fprintf(mat2latex(A,'ratio'))
@adhithyan15
adhithyan15 / mat2DetLatex.m
Created July 23, 2012 00:33
fourth version output
function output = mat2DetLatex(varargin)
%This function produces Latex code for any octave/matlab matrix of any dimension as a determinant.
%It requires the package amsmath in latex for successful operation. This
%code utilizes vmatrix environment.This code produces absolute value brackets to
%enclose the elements of the matrix.This function has to be run as an
%argument for the builtin fprintf() function to work properly. For example
%this fprintf(mat2DetLatex(A)).Decimal numbers are left as decimal numbers by default.
%If you want the decimal numbers to be formatted as rational numbers, pass
%in a second parameter 'ratio' with your matrix. For example,fprintf(mat2DetLatex(A,'ratio'))
@adhithyan15
adhithyan15 / mat2DetLatexOctave.m
Created July 23, 2012 00:38
third version output
function output = mat2DetLatexOctave(varargin)
%This function produces Latex code for any octave/matlab matrix of any dimension as a determinant.
%It requires the package amsmath in latex for successful operation. This
%code utilizes vmatrix environment.This code produces absolute value brackets to
%enclose the elements of the matrix.This function has to be run as an
%argument for the builtin fprintf() function to work properly. For example
%this fprintf(mat2DetLatex(A)).Decimal numbers are left as decimal numbers by default.
%If you want the decimal numbers to be formatted as rational numbers, pass
%in a second parameter 'ratio' with your matrix. For example,fprintf(mat2DetLatex(A,'ratio'))
@adhithyan15
adhithyan15 / generate_random_number_with_n_digits.rb
Created July 27, 2012 18:34
A ruby method to generate a random number with given number of digits
def generate_random_number_with_n_digits(input_n_digit)
smallest_number_of_nplus1_digits = 10**input_n_digit
smallest_number_of_n_digits = 10**(input_n_digit-1)
random_n_digit_number = Random.rand(smallest_number_of_nplus1_digits-smallest_number_of_n_digits)+smallest_number_of_n_digits
return random_n_digit_number
@adhithyan15
adhithyan15 / Test.tex
Last active October 7, 2015 15:57
Latex Highlight Text Without Color
\documentclass{article}
\usepackage[margin = 0.8in]{geometry}
\usepackage{soul}
\begin{document}
\hl{This is a wonderful highlight}