Skip to content

Instantly share code, notes, and snippets.

View soypat's full-sized avatar
🎴

Patricio Whittingslow soypat

🎴
View GitHub Profile
@soypat
soypat / main.go
Last active April 12, 2019 21:47
.dat NASTRAN reader for CHEXA20 elements. Returns nodes.txt and elements.txt files. Programmed in golang
package main
import (
"fmt"
"os"
"bufio"
"strings"
"strconv"
"math"
"regexp"
@soypat
soypat / writerDefer.go
Created February 10, 2019 00:03
Convenient little function for writer handling.
d, err := os.Create("nodos.txt")
writer := bufio.NewWriter(d)
defer func() {
if err := writer.Flush(); err!=nil {
fmt.Println(err)
enterContinue("Se encontro un error en escritura! Verifique integridad de nodos.txt!")
}
err = d.Sync()
check(err)
err = d.Close()
@soypat
soypat / latex_wordcloud.m
Last active June 22, 2023 06:44
Generates wordcloud of LaTeX commands in a .tex file (Matlab 2017b)
function [] = latex_wordcloud(filename)
%Crea un wordcloud de las funciones de un archivo latex
%Ejemplo: latex_wordcloud('latextext.txt')
% latex_wordcloud('mi_TP_de_fisica_4.tex')
%Version R2017b y adelante
%Patricio Whittingslow 2018 Creative Commons 4.0
fileID=fopen(filename);
doubleskip=false;
unpermitted={'\','{',"}",'^',' ','%','_',')','(','$','&','=',',','.','[',']','<','>','?','/',"'"};
if fileID==-1
@soypat
soypat / goBuild.bat
Last active July 30, 2019 22:26
Deploy go code for multiple architectures
@ECHO OFF
ECHO.
ECHO Start building...
ECHO.
:: Comment: -ldflags reduces the binary file size by omitting symbol tables and debug information. Useful when deploying.
:: All caps on keywords not necessary.
SET GOOS=linux
SET GOARCH=amd64
go build -ldflags="-s -w" -i -o "main_linux" main.go
@soypat
soypat / alarma.ino
Last active May 5, 2019 16:51
Arduino alarm system for home. Intended to work with Hall Effect door sensor. Works with IR remote.
// IR Setup
#include <IRremote.h>
const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
// Rest of setup
const int doorPin = 12; // Analog input pin that the potentiometer is attached to
//const int resetPin = 4; % Legacy Button reset
const int alarmPin = 8;
@soypat
soypat / min.m
Last active May 26, 2019 18:08
Min/Max index finder for matrix
%% Find minimum amplitud
mini=min(min(M));
index=find(M==mini);
i = ceil(index/Nb);
index=find(M'==mini);
j = ceil(index/Nh);
@soypat
soypat / forceVectorGraphics.m
Last active January 19, 2022 12:17
Force matlab to save .eps without rasterizing vector graphics
plot3(X,Y,Z) %Plot your awesome plot
set(gcf,'renderer','Painters') % 1) Change the renderer of the figure before you draw your figure or before you export. You can use the following command>>
% Change the renderer used by the PRINT command. By default it uses the same renderer that the figure uses, so you would have to type the following command to over-ride this:
print -depsc -tiff -r300 -painters <filename>.eps % modify <filename> to your hearts desire
% modular filename way:
print('-depsc','-tiff','-r300', '-painters',[filename,'.eps'])
%% Obtained from: https://www.mathworks.com/matlabcentral/answers/92521-why-does-matlab-not-export-eps-files-properly
@soypat
soypat / getMyPackages
Created July 30, 2019 21:54
Run in command from a directory of your project to download all go-gettable dependencies
go get -d ./...
@soypat
soypat / bandplot2D3D.m
Last active October 5, 2019 04:39
Finite-element-analysis node-variable bandplot for non-shell elements.
function bandplot2D3D(elementos,nodos,variable,graphArg)
% BANDPLOT2D3D Graficador de variables. CC-BY-NC-SA Patricio Whittingslow
% 2019.
% BANDPLOT2D3D(elementos,nodos,variable,graphArg)
%
% Típica numeración de los nodos de los elementos:
% 4---7---3
% | |
% 8 9 6
@soypat
soypat / ext_footnotes.tex
Last active August 29, 2020 01:16
Symbol footnotes for LaTeX with no counter limit.
% Requires amsymb and amsmath
\usepackage{amsymb}
\makeatletter
\newcommand*{\myfnsymbolsingle}[1]{%
\ensuremath{%
\ifcase#1% 0
\or % 1
*%
\or % 2
\dagger