devops: per-process swap usage

Uncategorized
awk '/Name/{name=$2}; /VmSwap/{printf "%20st%s %sn",name,$2,$3}END{ print ""}' /proc/*/status inspired from: adnans Output:      chromium-browse 19664 kB      chromium-browse 6128 kB         avahi-daemon 320 kB         avahi-daemon 220 kB               colord 644 kB                 smbd 840 kB
Read More

console.log macro in Sublime Text

Uncategorized
Here's how to make a selection macro in Sublime Text.  Type the word "beer", select it, then press a key to turn it into a console.log statement! Here's how to do it: 1. Create the console.log template: Click Tools > Developer > New Snippet... Paste the following: <![CDATA[ console.log("$SELECTION"); ]]> log Save the above as log.sublime-snippet 2. Create a keybinding to the snippet: Click Sublime Text > Preferences > Key Bindings Paste this bit into the middle of the keymap:  {   "keys": ["ctrl+shift+l"],    "command": "insert_snippet",    "args": { "name": "Packages/User/log.sublime-snippet" } }, Save it. To use, type beer in your program. Double-click to select it, then hit your "log this message" keyboard command ctrl+shift+l. Boom! console.log("beer");
Read More

Linux is awsome

Uncategorized
At work we process many millions of emails a day, so we get a lot of bounces. The following code helps me make the system smarter. It translates to "for the most recent five users who's received a bounce message, find all of their bounces in the last 24 hours and show me the Subject lines, with user and date information." find `ls -1t | head -5` -type f -mtime -1 -print0 | xargs -0 egrep Subject /dev/null | less
Read More

tiny "Hello World" webserver

Uncategorized
I'm writing a Nginx configuration that will wrap password protection on top of a bunch of dependent web servers. For testing, I want a few "hello world" type web servers, each of one gives a different message, but is really tiny. The following is what I came up with -- great for testing. # USAGE: # python ./hello.py free beer  import SimpleHTTPServer import StringIO import SocketServer import sys PORT = 8000 class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):     MESSAGE = ' '.join(sys.argv[1:])          def send_head(self):         self.send_response(200)         self.send_header("Content-type", 'text/plain')         self.end_headers()         return StringIO.StringIO(self.MESSAGE)      httpd = SocketServer.TCPServer(("", PORT), MyHandler) print "serving at port", PORT httpd.serve_forever()
Read More

Norris Numbers: adding code is great, until…

Uncategorized
Programmers get stuck at a certain amount of complexity. Newbies can write brute-force programs up to 2,000 lines or so, but beyond that it's too hard to manage. You can't keep everything in your brain. Experienced programmers have other tools -- abstraction -- to get up to 20,000 lines in a single project. There are other complexity walls: at 200K, then 2M. There might be a hard limit of any project at 3M lines: "the growth rate seems to slow down significantly no matter how many people (hundreds) or years are involved (decades). " Norris Numbers The author also clearly highlights the problem of Every Line is a Potential Bug -- go read!
Read More

Using multiple worktrees with git

Uncategorized
Modern development with Git is great. It's really easy to work on a feature branch, make changes, undo changes (oops), and share work with colleagues. However, there are challenges. If I'm running tests on my local "beer" branch, I can't easily switch over to the "gin" branch to edit code. The local environment only has one feature branch checked out at a time. I can run tests, or add code, or switch branches, but I can't do two things on two different branches at once... But now I can! Thanks to Manoj Mahalingam S, I know understand the "git worktrees" feature which lets you easily use multiple branches at the same time. Thanks, Manoj! Using multiple worktrees with git
Read More