Change your baby’s astrological sign with physics!

My summer project this year was a little non-academic web app project.

http://whatsyoursign.baby/

The premise of the site is that the mechanism of astrology is gravitational influence, and that since small nearby things have influence comparable to large things far away, it should be possible to tune your child’s astrological sign by giving birth around specifically arranged person-made objects. As a pop science site, you’ll see that it is a pretty soft sell: not telling anyone that astrology is wrong, instead trying to channel the interest in astrology into relevant subjects of physics.

I haven’t even released the site yet, but as a summer project it’s already a big success. I developed my frontend skills a bunch, and learned how to use astrological ephemeris databases. I also learned that astrology has a big open source community. I learned that there is a .baby and .amazon top-level domain for web addresses. I also learned a bit more about how to teach web programming students, hopefully showing the bones of the Internet a bit and making code a bit less intimidating.


Zeno’s Arrow Keys: Geometric text navigation sequences in vim

I wrote a little script for the world’s best text editor. It solves a very simple problem whose smallness is counterbalanced by its commonness. Here is some text:

I wrote a little script for the world’s best text editor.

I want to get to the word “text.” In Vim you have a few options:

  • type ‘l’ over and over
  • type $ then ‘h’ over and over.
  • 50l and then adjust
  • 10w if you can subitize that high
  • ft;;;;; but it would help a lot if you know how many ‘t’s there were without having to thinking about it
  • /text\\ but that’s a lot for a little.

What I really want is to just think about being there and I’m there. Short of that, I want a command that just goes to the right part of the line. Short of that, I want to solve this problem they way Zeno would: get halfway, then go half of that, and half of that, until I’m there. So with the function I wrote, ZenosArrowKeys(), mapped to C-l for forward and C-h for back, I can go to the halfway mark with C-l, the 3/4 mark with C-ll, the 1/4 mark with C-lh, the 5/8 with C-llh, and so on. It’s a few strokes, but you can type them unconsciously because your eye knows where you want to end up so your brain can form a motor plan at stroke one. The halving resets 2 seconds after you’ve initiated. The fractions are calculated relative to you current cursor position and the beginning or end of the line. It’s my first attempt at Vimscript and I’m pretty happy with the result.

""" Zeno-style line navigation for vim.
""" I want a navigation mode that let's me quickly get to certain
""" points in the line. Even though its up to five keystrokes, it
""" probably will never feel like more than two, since your eye knows
""" where you want to end up. Control-left and right takes you half
""" the distance it did previously, for two seconds.
""" Seth Frey
""" Put this in .vimrc
function! ZenosArrowKeys(direction)
""" Find current position
let s:nowpos = getpos(".")
""" Separate timeouts for vertical and horizontal navigation
let s:vtimeout = 0.8
let s:htimeout = 0.8
""" Find previous position
""" This command has to have state because how far you navigate
""" depends on how far you just navigated.
""" The 5 below is the numer of seconds to wait before resetting
""" all the state.
if ( ($ZENONAVLASTTIME != "") && (abs(reltime()[0] - str2nr($ZENONAVLASTTIME)) < s:vtimeout ) ) let s:vcontinuing = 1 else let s:vcontinuing = 0 endif if ( ($ZENONAVLASTTIME != "") && (abs(reltime()[0] - str2nr($ZENONAVLASTTIME)) < s:htimeout ) ) let s:hcontinuing = 1 else let s:hcontinuing = 0 endif """ Calculate future position if (a:direction < 2) " left or right """ whether left or irght, first zeno press takes you to the halfway """ point of the line, measured from the indent "let s:halfway = ( col("$") - col("0") + 0.001) / 2 if ( s:hcontinuing ) let s:diff = abs( str2float($ZENONAVLASTPOSITIONH) ) / 2 if (a:direction == 0) " left let s:nowpos[2] = float2nr( round( s:nowpos[2] - s:diff ) ) else " right let s:nowpos[2] = float2nr( round( s:nowpos[2] + s:diff ) ) endif else let s:indent = indent( line(".") ) let s:halfway = ( col("$") - s:indent + 0.001) / 2 let s:nowpos[2] = float2nr( round( s:indent + s:halfway ) ) let s:diff = s:halfway endif let $ZENONAVLASTPOSITIONH = printf( "%f", s:diff ) """ make up down scrolling normal if (len(s:nowpos) == 4) let s:nowpos = s:nowpos + [s:nowpos[2]] else let s:nowpos[4] = s:nowpos[2] endif else " up or down """ first up and donw zeno action is to the upper or bottom quater, """ since M already give syou the middle fo the screen if ( s:vcontinuing ) let s:diff = abs( str2float($ZENONAVLASTPOSITIONV) ) / 2 else let s:diff = ( line("w$") - line("w0") + 0.001) / 4 endif if (a:direction == 2) "up if ( s:vcontinuing ) let s:nowpos[1] = float2nr( ceil( s:nowpos[1] - s:diff ) ) else let s:nowpos[1] = float2nr( round( line("w0") + s:diff ) ) endif else "down if ( s:vcontinuing ) let s:nowpos[1] = float2nr( floor( s:nowpos[1] + s:diff ) ) else let s:nowpos[1] = float2nr( round( line("w0") + ( 3 * s:diff ) ) ) endif endif let $ZENONAVLASTPOSITIONV = printf( "%f", s:diff ) endif """ Change position and update state for next execution call setpos(".", s:nowpos) if ( s:diff <= 1) """ if the command has topped out and is freezing you, reset "let $ZENONAVLASTTIME = string( reltime()[0] + s:htimeout ) let $ZENONAVLASTTIME = reltime()[0] else let $ZENONAVLASTTIME = reltime()[0] endif endfunction """ crazy mappings with iterm2 in iterm, map to  (aka F13) and
""" proceed a few more times for the other codes. than map the F codes to zeno
""" Map to specially escaped left and right keys
:set =
:map [1;2P :call ZenosArrowKeys(0)
:set =
:map [1;2Q :call ZenosArrowKeys(3)
:set =
:map [1;2R :call ZenosArrowKeys(2)
:set =
:map [1;2S :call ZenosArrowKeys(1)

About

This entry was posted on Wednesday, September 21st, 2016 and is filed under straight-geek.


Some people know how to kill

Certain processes are vital to the computer’s operation and should not be killed. For example, after I took the screenshot of myself being attacked by csh, csh was shot by friendly fire from behind, possibly by tcsh or xv, and my session was abruptly terminated.

Context? This. Turns out I’m only 14 years behind the latest word on Doom as a system administration tool.


Prediction: Tomorrow’s games and new media will be public health hazards.

Every psychology undergraduate learns the same scientific parable of addiction. A rat with a line to its veins is put in a box, a “Skinner Box,” with a rat-friendly lever that releases small amounts of cocaine. The rat quickly learns to associate the lever with a rush, and starts to press it, over and over, in favor of nourishment or sociality, until death, often by stroke or heart failure.

Fortunately, rat self-administration studies, which go back to the 1960’s, offer a mere metaphor for human addiction. A human’s course down the same path is much less literal. People don’t literally jam a “self-stimulate” button until death. Right? Last week, Mr. Hsieh from Taiwan was found dead after playing unnamed “combat computer games” for three days straight. Heart failure. His case follows a handful of others from the past decade, from Asia and the West. Streaks of 12 hours to 29 days, causes of death including strokes, heart failure, and other awful things. One guy foamed at the mouth before dropping dead.

East Asia is leagues ahead of the West in the state of its video game culture. Multiplayer online games are a national pastimes with national heroes and nationally-televised tournaments.(And the South Korean government has taken a public health perspective on the downsides, with a 2011 curfew for online gamers under 18.) Among the young, games play the role that football plays for the rest of the world. With Amazon’s recent purchase of e-sport broadcaster twitch.tv, for $1.1 billion, there is every reason to believe that this is where things are going in the West.

Science and industry are toolkits, and you can use them to take the world virtually anywhere. With infinite possibilities, the one direction you ultimately choose says a lot about you, and your values. The gaming industry values immersion. You can see it in the advance of computer graphics and, more recently, in the ubiquity of social gaming and gamification. You can see it in the positively retro fascination of Silicon Valley with the outmoded 1950’s “behaviorist” school of psychology, with its Skinner boxes, stimuli and responses, classical conditioning, operant conditioning, positive reinforcement, new fangled (1970’s) intermittent reinforcement. Compulsion loops and dopamine traps. Betable.com, another big dreamer, is inpiring us all with its wager that the future of gaming is next to Vegas. Incidentally, behaviorism seems to be the most monetizable of the psychologies.

And VR is the next step in immersion, a big step. Facebook has bet $400 million on it. Virtual reality uses the human visual system — the sensory modality with the highest bandwidth for information — to provide seamless access to human neurophysiology. It works at such a fundamental level that the engineering challenges remaining in VR are no longer technological (real-time graphics rendering can now feed information fast enough to keep up with the amazing human eye). Today’s challenges are more about managing human physiology, specifically, nausea. In VR, the easiest game to engineer is “Vomit Horror Show,” and any other game is hard. Nausea is a sign that your body is struggling to resolve conflicting signals; your body doesn’t know what’s real. Developers are being forced to reimagine basic principles of game and interface design.*** Third-person perspective is uncomfortable, it makes your head swim. Cut scenes are uncomfortable for the lack of control. If your physical body is sitting while your virtual body stands, it’s possible to feel like you’re the wrong height (also uncomfortable). And the door that VR opens can close behind it: It isn’t suited to the forms that we think of when we think of video games: top-down games that makes you a mastermind or a god, “side-scroller” action games, detached and cerebral puzzle games. VR is about first-person perspective, you, and making you forget what’s real.

We use rats in science because their physiology is a good model of human physiology. But I rolled my eyes when my professor made his dramatic pause after telling the rat story. Surely, humans are a few notches up when it comes to self control. We wouldn’t literally jam the happy button to death. We can see what’s going on. Mr. Hsieh’s Skinner Box was gaming, probably first-person gaming, and he self-administered with the left mouse button, which you can use to kill. These stories are newsworthy today because they’re still news, but all the pieces are in place for them to become newsworthy because people are dying. The game industry has always had some blood on its hands. Games can be gory and they can teach and indulge violent fantasizing. But if these people are any indication, that blood is going to become a lot harder to tell from the real thing.

About

This entry was posted on Thursday, January 29th, 2015 and is filed under science, straight-geek.


The scientist as dataset — specifically a high-rez, 4-D facial capture dataset

RigidStabilizationSelfie
I am data for my colleagues at Disney Research. Note lawless dentition and sorry excuse for anger.


Regex crossword puzzle

This showed up at the lab one day. Print it out, give it a try.
regexcrossword
I have no idea who to credit. If you don’t know what this is, that’s OK. In my opinion, ignorance, in this case, is bliss, but this explains the basic idea. And, if you’re interested, here are more puzzles.

About

This entry was posted on Tuesday, August 26th, 2014 and is filed under straight-geek.


Design for magical spherical dice (3D printed)

I designed a die. It’s special because it’s a sphere pretending to have six sides: each roll will end with one to six dots facing up. It’s also special because you can print a copy. The trick is a weight that falls into one of six pockets under each of the numbers. “Spherical dice” sounds better than “spherical die,” so print two.

Some assembly is required: You just have to drop in the weight and jam in the plug. According to the colleague that helped me, Nobuyuki Umetani, fishing stores are the best place to get lead. For the plug, you can use your thumb. Most of the plug will still be sticking out post-jam and you’ll have to snap off the rest. The way many printers print makes them snap clean along the path of the printer head. So score the plug by drawing a knife around it’s diameter where it meets the sphere, steady it (with a vice or on the edge of a table), and give it a good whack.

Notes

  • The roll has satisfying action. Video at bottom.
  • The plug is tapered so as to jam well. It functions as the number one.
  • With this design, the strength of the jam may influence the fairness of the die. Probably not a real concern (since the ball’s mid-air choice of pockets will have a bigger influence on the outcome), but this is an imperfection in the design. Someone will have to do a few thousand or so rolls to make sure.
  • The density of the fill and the weight of the missing dots could also influence a die’s fairness, but if you care that much then you know not to bet six with any dice that didn’t come through a casino.
  • You can fill the dots in if you want them to stand out. Nail polish will do. Just be careful: the plastic doesn’t forgive mistakes because its layers act like capillaries and suck up liquidy paint (or nail polish removered nail polish)
  • You want the diameter of the lead weight to leave some wiggle in the pockets. If your weight is a snug fit into the die, get a smaller weight (or scale up the size of the model).
  • I’ve oriented the model at an angle so that it’ll print correctly (without any support material on the inside) if your printer can handle printing a 45° overhang. It probably can? I don’t know how common that is, but the machine I used can.
  • The original design subtracted an octahedron from the center of the sphere, but it was a little too sensitive, and also harder to make fair, so I redesigned it to subtract three mutually orthogonal boxes.
  • Workflow was 123D (for the orthogonal part) to Meshmixer (to sculpt out the dots) to MakerWare (staging and path planning) to a second generation Replicator.
  • I got the idea from someone who did the same thing in wood. I saw it for sale at a store call Aha.

And, this is how I roll:

About

This entry was posted on Saturday, July 26th, 2014 and is filed under straight-geek, tricks.


Chrome extension: Facebook deconditioner

I used to find myself on Facebook even when I did not want to be there. Now that doesn’t happen any more. Every time I go I have to click through a bunch of popups. The number of popups increases by one each time I return. I can still check the site, it just takes a little work, and a little more work each time.

With the carefully engineered convenience of these sites, you can reach a point where spasms of muscle memory override your own intentions about where you want your mind. If you think a small simple barrier would help you be a more mindful consumer of social media, you can install an extension I made for Chrome.

Even if you check the “do not show popups” box every time, this plugin will still force at least three clicks before every page access. And it will still make it easier to stop than to continue. And it will still keep count.

nerds

Here is the early code (you can ask me for more recent code). And these pages are useful for authoring.

About

This entry was posted on Monday, May 19th, 2014 and is filed under straight-geek, tricks.


One year free my ass: Webfaction trumps AWS/JumpBox

AWS was pretty complicated, and on top of that I couldn’t figure out why my free trial was costing three time what I’m paying with webfaction. Now i’ve got all the control I need, without getting charged each time I write to the harddrive.

About

This entry was posted on Monday, November 18th, 2013 and is filed under straight-geek.


Nerd post: Installing R packages remotely and without priviliges, thereby salvaging xgrid

I’m distributing jobs and had a bit of trouble with my scripts. I don’t want to go to every computer on the cluster one-by-one to get the right scripts on them, and we’ve turned ssh off, and it’ll take going to each one to turn it on. Plus what if a later script needs different libraries? This pretty simple (*nix-/OSX-only) snippet installs the package if you don’t already have it, and it works even if xgrid is chugging without special privileges:
if (!("urpackagehere" %in% installed.packages())) {install.packages("urpackagehere", repos = "http://cran.r-project.org", lib="/tmp/")}

About

This entry was posted on Thursday, February 28th, 2013 and is filed under straight-geek.