Friday, March 18, 2016

brewing mysql / binlog reader

Here's what I did to set up MySQL 5.6 on my Mac in binlog row mode, prepping to talk to Aurora.
+1 for brew services!

Install and Test

brew install mysql56
brew tap homebrew/services
brew services start mysql56

mysqladmin -uroot create mh
mysql -uroot

Find my.cnf

/usr/local/bin/mysqld --verbose --help 2>/dev/null | grep -A 1 "Default options" 
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

Configuring binary logging

$ cat /usr/local/etc/my.cnf 

binlog status

Restart mysql and you can see the logs and current position.

mysql> show binary logs;
| Log_name         | File_size |
| mysql-bin.000001 |       143 |
| mysql-bin.000002 |       120 |

mysql> show master status;
| File           | Position | 
+----------------+----------+- . . . 
| mysql-bin.000002 |     1309 


Tailing the binlog

mysqlbinlog --read-from-remote-server --host=localhost  mysql-bin.000001 -uroot -v --stop-never

Insert some data like this

mysql> insert into t values(99);

and you'll see it come out like this

# at 1309
#160318 11:40:42 server id 1235 end_log_pos 1379 CRC32 0xaf303ba0 Query thread_id=7 exec_time=0 error_code=0
SET TIMESTAMP=1458326442/*!*/;
# at 1379
#160318 11:40:42 server id 1235 end_log_pos 1421 CRC32 0xb302b235 Table_map: `mh`.`t` mapped to number 70
# at 1421
#160318 11:40:42 server id 1235 end_log_pos 1461 CRC32 0x4d9e5013 Write_rows: table id 70 flags: STMT_END_F

### INSERT INTO `mh`.`t`
### SET
###   @1=99
# at 1461
#160318 11:40:42 server id 1235  end_log_pos 1492 CRC32 0x94dcc720 Xid = 73

blogodex = {"toc" : "MySQL binlog", "idx" : ["MySQL","binlog","configuration"]};

Thursday, March 17, 2016

brew services

You can use brew to interface with launchservices.  It's great!


  • brew tap homebrew/services

  • brew services list
  • brew services start etcd
  • brew services restart etcd
  • brew services stop etcd
Lots of details over at thoughtbot!

blogodex = {"toc" : "brew", "idx" : ["services", "launchd"]};

Tuesday, March 8, 2016

Animating an OpenSCAD Figure

First, let's draw a cube:


Now, let's animate a 360 degree turntable view of the cube:


$t is filled in when the animation is in process.  You can see it in action like this:

    rotate([0,0,$t*360]) {

To enable the animation:

  • View/Animate to fill in the animation parameters
  • fill in FPS and Steps.  Good values are 24 and 240
  • don't fill in Time.  It is derived from the other parameters.  This is the value of $t in the code.
  • To grab the frames, click the Dump Pictures box.  This will create files frameXXXXX.png in the same directory as your SCAD file.  Note that this implies you've saved your file.

Once you've got the files, you can string them together into an animation.  There's a ton of ways of doing that; I use QuickTime Player 7 on my Mac:

  • File / New Player
  • File / Open Image Sequence - navigate to your folder, and select the first generated file (frame00000.png).  QuickTime will figure out the list of frames from there.
  • Frame Rate: 24
  • You should have a quicktime movie of your animation.  Save it out and you're good to go!

blogodex = {"toc" : "OpenSCAD", "idx" : ["animation", "turntable"]};