-
Embedding GitHub Gists in Tumblr Posts
Tumblr’s utter lack of Gist support was pretty much a show-stopper for me, which is why this is my first post. In trying to figure out how to hack it myself, I ran across Jarred Grippe’s post describing how he hacked it. I refactored his solution a bit to add some error checking and a couple of features:
Most of the magic comes from the call to embedNextGist inside the document.write overrides. Typically when scripts are being added to the page programatically, you have to be careful not to execute code that depends on the script before the script is loaded. For example, if I had instead just put embedNextGist in a loop, all of the document.write overrides and appending of script tags would have happened long before the first appended script even loaded. The calls to the overridden document.write do not occur until the script has loaded, which would mean that all of the appended scripts would use whichever version of document.write was provided in the last iteration of the loop. That is, each Gist would, in turn, write itself into the last p.gist.
But in this case, all of that trouble is circumvented by calling embedNextGist from document.write which is called by the appended script (a call which, naturally, cannot happen until the script is loaded).
Two other small notes:
- Jarred’s version writes the stylesheet link for every Gist that it handles. My version never writes the stylesheet link because I have that link as part of my Tumblr template.
- My version caches document.write before processing Gists and restores it upon completion.
Here is an uncommented version and a 412 byte minified version.
-
Prince of Persia Source Code, Open Sourced! →
Before Prince of Persia was a best-selling video game franchise and a Jerry Bruckheimer movie, it was an Apple II computer game created and programmed by one person, Jordan Mechner.
Not only is Prince of Persia now available as a paperback and ebook, but the source is now on GitHub!
The original Prince of Persia source code recently “just turned up” after being lost for 22 years. Jordan Mechner and two stalwart companions dedicated most of a day and night extracting the source and posting it on github. His friend Jamie — who knows the term “source code” primarily as the title of the movie Jake Gyllenhaal did after Prince of Persia — looking as confused as before, asked “Why?!?”
Why the source code?
Why spend a whole day trying to recover data from some ancient floppy disks?
“Because if we didn’t, it might have disappeared forever.”
Video game source code is a bit like the sheet music to a piano sonata that’s already been performed and recorded. One might reasonably ask: If you have the recording, what do you need the sheet music for?
You don’t, if all you want is to listen and enjoy the music. But to a pianist performing the piece, or a composer who wants to study it or arrange it for different instruments, the original score is valuable.
It’s possible, up to a point, to reverse-engineer new source code from a published video game, much as a capable musician can transcribe a musical score from listening to a performance. But in both cases, there’s no substitute for the original document as a direct line to the creator’s intentions and work process. As such, it has both practical and historical value, to the small subset of the game-playing/music-listening community that cares.
Source on GitHub - Blog Post - Image by Jason “Textfiles” Scott
-
Vimdown - Create great looking READMEs from your .vimrc using Markdown →
On Episode 0.7.3 we extolled the virtues of rolling your own dotfiles, especially for your Vim setup. If you’re sharing those dotfiles on GitHub, Jeff Buttars has created Vimdown, a Python-based command line tool that will process Markdown in your
.vimrccomments and output a Markdown file with your Vim settings in code fences. The following snippet from Jeff’s.vimrc:" Call infect to get the bundle handling started. call pathogen#infect() " infect our locally tracked pkgs call pathogen#infect('~/.vim/pkgs') " " Brief help on Bundle commands " :BundleList - list configured bundles " :BundleInstall(!) - install(update) bundles " :BundleSearch(!) foo - search(or refresh cache first) for foo " :BundleClean(!) - confirm(or auto-approve) removal of unused " " see :h vundle for more details or wiki for FAQ " *NOTE*: comments after Bundle command are not allowed.. " " [Vundle](https://github.com/gmarik/vundle) Configuration " Add vundle to our runtime path (rtp) and start vundle set rtp+=~/.vim/bundle/vundle/ call vundle#rc()… becomes:
Call infect to get the bundle handling started. ```vim call pathogen#infect() ``` Brief help on Bundle commands :BundleList - list configured bundles :BundleInstall(!) - install(update) bundles :BundleSearch(!) foo - search(or refresh cache first) for foo :BundleClean(!) - confirm(or auto-approve) removal of unused see :h vundle for more details or wiki for FAQ *NOTE*: comments after Bundle command are not allowed.. [Vundle](https://github.com/gmarik/vundle) Configuration Add vundle to our runtime path (rtp) and start vundle ```vim set rtp+=~/.vim/bundle/vundle/ call vundle#rc() ```Vimdown source is on GitHub, along with his own example Vim setup, complete with Vimdown-based README.
-
Capistrano Push Alerts
While reading over a few articles I came across a rather nice peice of code by Pivotial Labs’ Jason Noble that did a article on Verifying hosts are active in the load balancer pool with capistrano. This got me to thinking what if I can go one step further and have it pushed to my android device. Plus do it all in pure ruby [plus a gem or to].
So for my weekend hack I wrote up this little bit of code plus started work on creating a gem that supports jabber, android, and iPhone.
Related articles
deploy.rb
require 'httparty' require 'ruby-notify-my-android' set :application, "example" set :repository, "" set :scm, :none role :web, "localhost" role :web, "example.tld" role :app, "example.tld" role :db, "db.example.tld", :primary => true def push_notify(hostname) NMA.notify do |n| n.apikey = YAML.load_file('nmaapi.yml')['apikey'] n.application = application n.event = "Check Load Balencer Status" n.description = message end end desc "Retrieves the check.txt file to see if the host is in the load balancer" task :check_load_balancer do roles[:web].map(&:host).each do |hostname| url = "http://#{hostname}/check.txt" response = HTTParty.get url message = "Retrieving #{url}: #{response.message}" puts message push_notify message end end #-- # (C)2012 Dwight Spencer # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. #++nmaapi.yaml
--- apikey: SECRET_KEY_FROM_NOTIFY_MY_ANDROID.COM
Related resources
-
Enabling SELinux on Amazon ec2
Reciently while working on a Develnet EC2 node I had to deal with a headache beyond all belief, turning on SELinux for Amazon AMI.
How Do I Enable SELinux under Redhat / Fedora, CentOS, and AMI Linux Systems?
What is SELinux
SELinux is a kernel security extension, which can be used to guard against misconfigured or compromised programs. It comes with Mandatory Access Control (MAC) system that improves the traditional UNIX/Linux DAC (Discretionary Access Control) model.
Installing SELinux
sudo yum install -Y sel*
Turning on SELinux
~% sudo $EDITOR /etc/selinux/configSELINUX=permissive SELINUXTYPE=targted~% sudo $EDITOR /etc/sysconfig/configSetting Policies
sudo touch /.autorelabel
sudo restorecon -Rv -n /home
sudo genhomedircon
Reboot
sudo shutdown -r now “Enabling SELinux policies “
Troubleshooting
egrep -i ‘selinux=0|enforcing=0’ /boot/grub/*




