Blast from the Past... Daily WTF edition.
What is Truth?
Classic WTF - What is Truth?
Saturday, July 23, 2016
Saturday, July 2, 2016
Some Interesting Go Videos
Using Go at The New York Times
Twelve Go Best Practices - Francesc Campoy
Google I/O 2013 - Fireside Chat with the Go Team
Origins of Go Concurrency style by Rob Pike
Google I/O 2012 - Go Concurrency Patterns
Rob Pike - 'Concurrency Is Not Parallelism'
Google I/O 2013 - Advanced Go Concurrency Patterns
Go for Pythonistas
Go Proverbs - Rob Pike - Gopherfest - November 18, 2015
Building Services in Go
Let's Go Further: Build Concurrent Software using the Go Programming Language
The Go Programming Language - Rob Pike
A Tour of the Go Programming Language with Russ Cox
blogodex = {"toc" : "golang", "idx" : "videos"};
Sunday, June 26, 2016
Interesting Python One-Liners
You can do some amazing things with lambda and itertools.
Python one-lines for Project Euler
Half of linear algebra in 10 Python one-liners
KNN classifier in one line of Python
blogodex = {"toc" : "one-liners", "idx" : "Python"};
Python one-lines for Project Euler
Half of linear algebra in 10 Python one-liners
KNN classifier in one line of Python
blogodex = {"toc" : "one-liners", "idx" : "Python"};
Thursday, June 23, 2016
GitHub based dotfiles
Not much new here, this is just my take on StreakyCobra's excellent work, with these differences:
- I made two repos, one for dotfiles, one for scripts that go into $HOME/bin.
- I made two commands dotf and binf that correspond to StreakyCobra's config.
- incorporated github repos dotf and binf as noted.
# create github repo "dotf"
git init --bare $HOME/.dotf
alias dotf='/usr/bin/git --git-dir=$HOME/.dotf/ --work-tree=$HOME'
dotf config status.showUntrackedFiles no
dotf add .bash_profile
dotf commit -m "first import"
dotf remote add origin git@github.com:YOURNAME/dotf.git
dotf push -u origin master
# create github repo "binf"
git init --bare $HOME/.binf
alias binf='/usr/bin/git --git-dir=$HOME/.binf --work-tree=$HOME/bin'
# binf config status.showUntrackedFiles no ## want to track unused files
cd $HOME/bin
dotf add some-file
dotf commit -m "first import"
binf remote add origin git@github.com:YOURNAME/binf.git
binf push -u origin master
git init --bare $HOME/.dotf
alias dotf='/usr/bin/git --git-dir=$HOME/.dotf/ --work-tree=$HOME'
dotf config status.showUntrackedFiles no
dotf add .bash_profile
dotf commit -m "first import"
dotf remote add origin git@github.com:YOURNAME/dotf.git
dotf push -u origin master
# create github repo "binf"
git init --bare $HOME/.binf
alias binf='/usr/bin/git --git-dir=$HOME/.binf --work-tree=$HOME/bin'
# binf config status.showUntrackedFiles no ## want to track unused files
cd $HOME/bin
dotf add some-file
dotf commit -m "first import"
binf remote add origin git@github.com:YOURNAME/binf.git
binf push -u origin master
Wednesday, June 15, 2016
Do you have a restless urge to program?
I finally found a scan advertising the Famous Programmers' School which originally appeared in the April 1982 of BYTE, page 384.
"Top down programming for the masses."
"Top down programming for the masses."
Friday, May 13, 2016
Adding a git commit template
So I find myself constantly forgetting to add the jira ticket number to commits that need them.
echo JIRA >~/txt/git-commit-template.txt
And one of these commands
git config commit.template ~/txt/git-commit-template.txt
Don't forget to manage your git commit template in git!
echo JIRA >~/txt/git-commit-template.txt
And one of these commands
git config commit.template ~/txt/git-commit-template.txt
git config --global commit.template ~/txt/git-commit-template.txt
or put in in .git/config (per repo) or $HOME/.gitconfig (global):
[commit]
template = /Users/mh/txt/git-commit-template.txt
blogodex = {"toc" : "git", "idx" : "commit template"};
Friday, April 29, 2016
Python: virtualenv quickstart
Installation
pip install virtualenv
Usage
mkdir myproject
cd myproject
pip install virtualenv
Usage
mkdir myproject
cd myproject
virtualenv foo
source foo/bin/activate
pip install hjson # install packages...
./foo/bin/python
import hjson
./foo/bin/python
import hjson
Getting pip if necessary
curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
python get-pip
yum install openssl openssl-devel
or
apt-get install openssl openssl-devel
References
https://pip.pypa.io/en/stable/installing/
http://docs.python-guide.org/en/latest/dev/virtualenvs/
Getting ssl if necessary in order to get pip on your linux box
symptom: ImportError: cannot import name HTTPSHandler
or
apt-get install openssl openssl-devel
References
https://pip.pypa.io/en/stable/installing/
http://docs.python-guide.org/en/latest/dev/virtualenvs/
Wednesday, April 27, 2016
Encrypting UDP Game Traffic
not only encryption protects your players from classical attacks, it also protects your games against cheaters too.
As a side bonus, with proper encryption you can be sure that network errors which corrupt your packets are not going undetected (and with unencrypted UDP those 16-bit UDP checksums can detect only one out of 60’000 in-transit corruptions, which means that with all those millions of packets you’re sending out each second, some corruptions WILL go undetected, causing all kinds of trouble).
http://ithare.com/udp-for-games-security-encryption-and-ddos-protection/
Tuesday, April 19, 2016
Classic Programmer Paintings!
http://classicprogrammerpaintings.tumblr.com
My Favorite:
Hieronymus Bosch “A visual guide to the Scala language” oil on oak panels, 1490-1510.
The left panel shows the functional features, the main one describes the type system, and the right the object oriented parts.
My Favorite:
Hieronymus Bosch “A visual guide to the Scala language” oil on oak panels, 1490-1510.
The left panel shows the functional features, the main one describes the type system, and the right the object oriented parts.
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
+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
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
[mysqld]
log-bin=mysql-bin
binlog_format=row
server-id=1235
mysql> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 143 |
| mysql-bin.000002 | 120 |
+------------------+-----------+
[mysqld]
log-bin=mysql-bin
binlog_format=row
server-id=1235
binlog status
Restart mysql and you can see the logs and current position.
+------------------+-----------+
| 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/*!*/;
BEGIN
/*!*/;
# 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
BINLOG '
qkvsVhPTBAAAKgAAAI0FAAAAAEYAAAAAAAEAAm1oAAF0AAEDAAE1sgKz
qkvsVh7TBAAAKAAAALUFAAAAAEYAAAAAAAEAAgAB//5jAAAAE1CeTQ==
'/*!*/;
### INSERT INTO `mh`.`t`
### SET
### @1=99
# at 1461
#160318 11:40:42 server id 1235 end_log_pos 1492 CRC32 0x94dcc720 Xid = 73
COMMIT/*!*/;
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!
Setup:
- brew tap homebrew/services
Usage:
- 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:
cube(10,true);
Now, let's animate a 360 degree turntable view of the cube:
rotate([0,0,$t*360])
cube(10,true);
$t is filled in when the animation is in process. You can see it in action like this:
rotate([0,0,$t*360]) {
echo($t);
cube(10,true);
}
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"]};
Monday, February 29, 2016
Some Raft References
https://ramcloud.stanford.edu/~ongaro/userstudy/
Raft is a consensus algorithm designed to be easier to understand than Paxos. To measure Raft's understandability, we conducted an experimental study using CS students at two universities. We recorded a video lecture of Raft and another of Paxos, and created corresponding quizzes. This page makes our materials available for anyone interested. We think these are valuable resources for anyone learning consensus (whether Raft or Paxos or both).
Raft is a consensus algorithm for managing a replicated log. It produces a result equivalent to (multi-)Paxos, and it is as efficient as Paxos, but its structure is different from Paxos; this makes Raft more understandable than Paxos and also provides a better foundation for build- ing practical systems. In order to enhance understandabil- ity, Raft separates the key elements of consensus, such as leader election, log replication, and safety, and it enforces a stronger degree of coherency to reduce the number of states that must be considered. Results from a user study demonstrate that Raft is easier for students to learn than Paxos. Raft also includes a new mechanism for changing the cluster membership, which uses overlapping majori- ties to guarantee safety.Lectures
Raft lecture (Raft user study) - YouTube
Tech Talk - Raft, In Search of an Understandable Consensus Algorithm
Raft Consensus Algorithm
Consul is a new product by HashiCorp which aims to solve the core issues of service discovery and configuration. As part of that it needs to maintain a strongly consistent catalog shared between multiple servers for availability. Raft was used as the consensus protocol for Consul because it was the most readily understandable and simple algorithm available.Raft - secret lives of data
The simplicity of Raft reduced our time to market, and now Consul powers HashiCorp, a number of customers using our on-premise product, and hopefully soon many thousands of other clients through our open source efforts.
We've open sourced our Raft library as well, allowing others to use it independently of Consul. The library fully implements the protocol as described, following the paper as closely as possible.
blogodex = {"toc" : "Raft"};
Saturday, February 6, 2016
jq -- lightweight flexible JSON processor
"jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text."https://stedolan.github.io/jq
brew install jq
blogodex: jq / json
Friday, February 5, 2016
Installing Consolas font on Mac
Courtesy of ikato blog:
brew install cabextract
cd ~/Downloads
mkdir consolas
cd consolas
curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
cabextract PowerPointViewer.exe
cabextract ppviewer.cab
open CONSOLA*.TTF
blogodex: / fonts, consolas, mac
brew install cabextract
cd ~/Downloads
mkdir consolas
cd consolas
curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
cabextract PowerPointViewer.exe
cabextract ppviewer.cab
open CONSOLA*.TTF
blogodex: / fonts, consolas, mac
Friday, January 22, 2016
Three options for a new blogodex
The current blogodex is fine, except it's a bit tedious to type. I'm OK with it, but it may bother other people. In addition, it depends on a certain amount of care to not introduce syntax errors.
Thinking about it, three alternatives going forward:
Thinking about it, three alternatives going forward:
- stick with current blogodex. pros and cons as per above.
- switch blogodex to YAML. I really liked this idea, until I saw that blogger would put extra formatting cruft in a multi-line block. Additionally, blogger labels aren't multi-line friendly.
- Make a new blogodex format, a bit more forgiving typing-wise.
Ideas for new blogodex to try:
- maintain backwards compatibility. lines that begin with "blogodex =" are 1.0, lines that begin with "blogodex:" are 2.0
- format something like this: blogodex: optional-TOC / optional-Index Entries
- B: my toc topic
- B: toc topic / index topic 1, index topic 2
- B: toc topic (no index)
- B: / index topic (no toc)
- what delimiters are best?
blogodex: blogodex / blogodex 2.0
TechCrunch: The Stack Fallacy
A coworker pointed me to this article which meshes well with my experience:
http://techcrunch.com/2016/01/18/why-big-companies-keep-failing-the-stack-fallacy
my takeaways:
blogodex = {"idx" : ["Stack Fallacy", "building software"];
http://techcrunch.com/2016/01/18/why-big-companies-keep-failing-the-stack-fallacy
my takeaways:
- It's easier to build pieces below your level in the stack than above, because you are your own customer and know what you want.
- "Product management is the art of knowing what to build."
- "the what is 100 times more important than the how."
related:
Friday, January 8, 2016
Subscribe to:
Posts (Atom)
-
A while back I answered a question on Stack Overflow asking about the relative popularity of The Art of Computer Programming . I replied wit...
-
Here's a quick example of duckdb's new ASOF JOIN. Problem: we have a time-based price table; if you have a sale time that falls in t...
-
Covering: Introducing Kafka: history, Kafka at LinkedIn, Kafka adoption in the industry, why Kafka Kafka core concepts: topics, partiti...



