Skip to content

Instantly share code, notes, and snippets.

@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:

Verifying that +srinivas is my Bitcoin username. You can send me #bitcoin here: https://onename.io/srinivas
@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
@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 / 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 / gist:c36ce3e8063a155b7732
Last active August 29, 2015 14:09
Quickly check if you have internet access
ping -t 1 -q google.com | grep "0.0% packet loss" | wc -l

returns 1 for internet, 0 for no internet

@sg-s
sg-s / cron-see-path
Created December 11, 2014 00:35
How to get cron to see the $PATH you see
echo PATH=$PATH > tmp.cron
echo >> tmp.cron
crontab -l >> tmp.cron
crontab tmp.cron

Keybase proof

I hereby claim:

  • I am sg-s on github.
  • I am srinivas (https://keybase.io/srinivas) on keybase.
  • I have a public key whose fingerprint is 88C6 D016 6B09 8880 6BF8 F253 8C9C B698 D193 4604

To claim this, I am signing this object:

@sg-s
sg-s / frozen-random.md
Last active August 29, 2015 14:25
One line frozen noise generator in MATLAB
RandStream.setGlobalStream(RandStream('mt19937ar','Seed',1984)); 

sets the randsom stream to a particular state. (1984 because this is the most True state). Make sure you run this before every invocation of rand:

>> RandStream.setGlobalStream(RandStream('mt19937ar','Seed',1984)); 
>> rand(3)
ans =
@sg-s
sg-s / the-bash-guide.md
Last active December 21, 2015 17:54
A collection of various bash tips and tricks collected from various sources.

The Bash Guide

A collection of various bash tips and tricks collected from various sources. I'm writing this as I learn new stuff, so this is in no way authoritative or even corrent. In fact, you shouldn't read this.

Basics

Version, updates and installation

Check your version: