Skip to content

Instantly share code, notes, and snippets.

@sg-s
sg-s / publish_version_control.md
Last active August 29, 2015 14:05
Handy hashing for PDFs made by MATLAB code

Automatic Version control for publish()

MATLAB's publish takes a script and makes a PDF from it. Here, we want to add some basic info about the file that created the PDF to the PDF, programatically.

Add the name of the file that created the PDF to the PDF

add this snippet of code to the bottom of the script that you will publish with MATLAB's publish() function (or my MakePDF.m wrapper)

@sg-s
sg-s / parent_func.md
Last active August 29, 2015 14:05
Determine if this MATLAB function is being called by another function, and if so, what is it? The power of dbstack

How to find out if your MATLAB function is being called by another function or not

calling_func = dbstack;

if calling_func is non-empty, it is being called by some other function (as opposed to being called directly by the user from the command prompt)

How to find out the name of the function calling the current function

@sg-s
sg-s / share.md
Last active August 29, 2015 14:05
How to make your own file sharing service

How to make your own file sharing service

What you want to do

Create a small utility that takes a folder you want to share, and creates a not-obvious URL that you can send to other humans.

What you need:

  • A server you can SSH into
  • a *nix machine
Verifying that +srinivas is my Bitcoin username. You can send me #bitcoin here: https://onename.io/srinivas
@sg-s
sg-s / MATLAB publish tweaks.md
Last active August 29, 2015 14:05
This contains some workarounds for annoying bugs in MATLAB's publish function

Some workaround to common problems with MATLAB's publish()

Slow scatter

Problem: Horrible slowdowns when using scatter() in a script that you want to publish Solution: Don't use scatter. Use plot(x,y,'.') instead.

Combinatorial Figure mess

Problem: Horrible slowdown when publishing a document that has many figures in it. Symptom: You will see MATLAB cycling through all open figures. This means that it does something like this:

@sg-s
sg-s / bash history autocomplete
Last active August 1, 2023 04:04
Autocomplete commands in bash by using arrow keys
# supports history search using up and down arrows
# add this to your ~/.bashrc
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\eOA": history-search-backward'
bind '"\eOB": history-search-forward'