Simple EventMachine tail server
Stream tail -f over tcp/http using EventMachine.
Stream tail -f over tcp/http using EventMachine.
I recently found time to explore creating separate OS X Terminal styles for day and night. Here is my solution, please let me know if you have a better setup.
First, I created two different themes in iTerm2 or Terminal.
Then I created two AppleScripts called "Dayterm" and "Nightterm" below:
The AppleScripts write to both Terminal or iTerm2 OS X defaults properties. Then, I saved the AppleScripts as Applications and now I can do spotlight "Dayterm" or spotlight "Nightterm" to use one or the other. Setting the defaults shown means that opening new tabs or windows from within the opened terminal app will use the same Dayterm or Nightterm style as the one that was opened. Exporting the "SHELL_VIBE" variable allows reading the current Terminal style from other places like .vimrc for instance to further customize the terminal experience for Day or Night.
Doing all of my work in Tmux also allows me to detach my Tmux client and switch Terminal styles and re-attach to the same Tmux session in the new Terminal style.
Comments [1]
I'm using this simple cross-browser script to send tracking information back to the server when users leave a page.
I've tested it across Safari4.0.5/MobileSafari4.0.0+/Chrome5.0.375/Firefox3.6.3 and IE 6/7/8.
Comments [0]
I thought this was cool because it made writing a quick test for my simple UDP server really clean and easy. What I needed to do was spawn another process to run alongside my script. In this case it was this subprocess that I wanted to test. Python subprocess made this really easy.
The script starts the udps server in a child process using subprocess.Popen and then sends a UDP datagram to the udps server, which gets written to the server log file. The test verification is the printed content of the udps.log file created by the udps server subprocess, and then subprocess.Popen.kill is a nice simple way to end the udps process.
Comments [0]
I've been using and liking this simple UDP server setup to receive and log stats data from iPhone apps. I'm running this simple UDP server (udps), and using the following code to send UDP datagrams from iPhone apps:
The benefits of this setup are no waiting client side, and low overhead server side (just write to a log file to process later). UDP is unreliable so I could be missing a few datagrams, but I'm just sending stats that are nice to have but not necessary. I process the entire log every once in a while, and stream it back over http to analyze the incoming results in real-time.
Comments [0]
This has come up a few times now as a way to avoid server side coding and use Javascript more dynamically based on the CGI parameters passed in the src attribute of the <script> tag. This script has been cross-browser tested in Chrome5+/Safari4+/FF3.6+/IE6+.
The way this script works is:
Being setup this way also allows the script to be included in the DOM multiple times specifying different CGI parameters to determine different functionality for the script.
A simple demo can be found here using the cgi.js file here.
If you have a better way of doing this please do share.
Comments [0]
Comments [0]