## Create a “when I am busy” calendar

September 12th, 2016

Here’s how to create a public calendar on your website that shows when you are busy. For example, mine

\1. To set up sharing go to your calendar on http://calendar.google.com, select Sharing from the drop down on the left side:

\2. Make sure that it’s public but only showing busy:

\3. Then go to “Calendar Details”, copy the <iframe ... HTML tag:

\4. On your website, create a calendar.html page with the following contents (replacing the <iframe ... tag appropriately):

“

<!DOCTYPE html>
<html>
<head>
<title>Alec's Busy</title>
<style>
html {margin: 0;padding 0;}
body { margin: 0;position:fixed; left:0; width:100%; top:0; height:100%; }
iframe { margin: 0;display: block; width:100%; height:100%; }
</style>
</head>
<body>
<iframe src="https://www.google.com/calendar/embed?title=Alec&#39;s%20Busy&showCalendars=0&mode=WEEK&src=alecjacobson%40gmail.com&ctz=local" style=" border-width:0 " width="100%" height="95%" frameborder="0" scrolling="no"></iframe>
</body>
</html>


“

Finally, if you’re logged into your google account and you visit your calendar.html page, you might be freaked out because you see all of your events (instead of busy). But to verify that it’s really hidden, use an “incognito”/private window to see that it just shows “busy”.

## Make Two-Sided Printing the default setting on mac os x

September 7th, 2016
1. In Terminal.app issue: cupsctl WebInterface=yes
2. In a browser visit http://localhost:631/printers
3. Click on the printer’s name
4. On the second drop-down list choose “Set Default Options”
5. Change “2-Sided Printing:” to “Long-Edge (Portrait)”

## (Slightly) Faster way to compute number of unique elements in matlab matrix

August 31st, 2016

The standard way to compute the number of unique entries in a matlab matrix A is:

numel(unique(A))


If our entries are positive integers, we can try to do the same thing using sparse with:

nnz(sparse(A(:),1,1,size(A,1),1))


but actually this is slower.

I don’t see a way to avoid a sort. I came up with this,

sum(diff(sort(F(:)))~=0)+1


As far as I can tell, this will work for matrices that don’t have infs and nans. It’s slightly faster than number(unique(A)). I have a feeling I’m only winning anything here because I’m avoiding overhead within unique

## Eitan Grinspun’s “How to host a visit”

August 25th, 2016

Eitan has prepared a google doc on hosting visitors to the lab that I find very useful. It contains a detailed list (some unique to Columbia) of things you should do to host a visitor and when you should do them.

## Real-time LaTeX in browser

August 23rd, 2016

A long time ago, I made a little web app that allowed you to submit Latex code to a server, the server would run pdflatex and then send back the pdf to be rendered on the page.

Nowadays MathJax can render LaTeX equations in the browser. I found http://www.texrendr.com that let’s you interactively write formulae, but it’s restricted to a single equation. There’s also the LaTeXit standalone app, but you have to keep hitting “typeset”. This isn’t so useful if you’re trying to quickly type math during a Skype call.

So I wrote a little program to run in the browser:

http://www.cs.toronto.edu/~jacobson/latex.html

You can also fork the git gist

## option click on volume menu bar item to change sound devices

August 19th, 2016

I find myself often switching the microphone and speaker devices on my mac. I usually go all the way through System Preferences > Sound, but I stumbled upon a much faster route.

Normally if you click on the volume menu item at the top of the screen you get a little volume slider:

If you hold OPTION while you click you see a device selection menu:

## Energy optimization, calculus of variations, Euler Lagrange equations in Maple

August 16th, 2016

Here’s a simple demonstration of how to solve an energy functional optimization symbolically using Maple.

Suppose we’d like to minimize the 1D Dirichlet energy over the unit line segment:

min  1/2 * f'(t)^2
f
subject to: f(0) = 0, f(1) = 1


we know that the solution is given by solving the differential equation:

f''(t) = 0, f(0) = 0, f(1) = 1


and we know that solution to be

f(t) = t


How do we go about verifying this in Maple:

with(VariationalCalculus):
E := diff(f(t),t)^2:
L := EulerLagrange(E,t,f(t)):


so far this will output:

        L := {-2*diff(diff(x(t),t),t), -diff(x(t),t)^2 = K[2], 2*diff(x(t),t) = K[1]}


Finally solve with the boundary conditions using:

dsolve({L[1],f(0)=0,f(1)=1});


which will output

         t(t) = t


## Are you using libigl?

August 3rd, 2016

I would love to gather up some information about who out there is using libigl. Drop me a line if you or your university/institution/company is.

## Inverse of common ease curves

July 13th, 2016

Awkwardly I ended up needing the inverse of an ease curve (or S-curve) used in tweening animations. For trigonometric ease curves, this is easy. For example, if your ease filter is:

f = 0.5-cos(x*pi)*0.5;


then the inverse is:

x = acos(-2*(f-0.5))/pi


But if you’re using the famous cubic ease curve,

f = 3.*x.^2 - 2.*x.^3


then the relevant inverse is a complex function (involving the i = sqrt(-1)) that produces real values for f in [0,1]:

x = -1./4.*(1-2.*f+2.*(f.^2-f).^(1./2)).^(1./3)-1./4./(1-2.*f+2.*(f.^2-f).^(1./2)).^(1./3)+1./2-1./2.*i.*3.^(1./2).*(1./2.*(1-2.*f+2.*(f.^2-f).^(1./2)).^(1./3)-1./2./(1-2.*f+2.*(f.^2-f).^(1./2)).^(1./3));


I haven’t bothered to see if this can be simplified into something tidy. It’d be great to get rid of the i.

## MAC Address Spoofing on Mac OS X for unlimited free hour passes on xfinitywifi and CableWiFi networks

July 8th, 2016

From what I gather, xfinity charges people to “rent” wifi routers and then uses that hardware to host pay-per-use public wifi networks. These networks are usually named xfinitywifi or CableWiFi. Every 24 hours each MAC Address is granted a “$0.00 Complimentary Free Pass”: 1. CLICK I am not an XFINITY customer 2. CLICK Sign Up 3. CHOOSE$0.00 for a Complimentary Hour Pass
4. CLICK Start Session

To “spoof” a new wifi MAC Address on MAC OS X, one can issue:

ifconfig en0 | grep ether


This will spit out a number like: 70:51:81:c1:3f:6e. Record this number. To set your MAC address to a random yet valid address use:

sudo ifconfig en0 ether openssl rand -hex 6 | sed 's/$$..$$/\1:/g; s/.$//'  Then, later, if you want to return to your old address issue: ifconfig en0 ether 70:51:81:c1:3f:6e  It seems that System Preferences > Network > Advanced > Hardware will reveal your original MAC address in case you forget it. You can also place these commands as aliases in your ~/.profile: alias random_mac="ifconfig en0 ether \openssl rand -hex 6 | sed 's/$$..$$/\1:/g; s/.$//'\"
alias reset_mac="ifconfig en0 ether 70:56:81:c0:3f:6d"
alias sudo='sudo '


This all assumes en0 is your wifi location. It might be en1 on other macs.