Share a single X window with someone over VNC

I recently found a need to share an NX session open on my desktop with someone else remotely in Linux.  Sure, I could have setup a VNC sharing my entire X desktop,but I didn't see the need to send 3840x1080 over the WAN for a smaller section of interesting data.

This slick little trick comes compliments of a StackExchange based website, Super User:

 

x11vnc supports sharing a window based on it's id.  Basic steps:

  1. Run xwininfo from a console. It will change your cursor. Click on the window you want to share. xwininfo will print out the window id.
  2. Run x11vnc -id "id from xwininfo" replacing "id from xwininfo" with the appropriate id.

 

Filed under  //  linux   ubuntu   vnc   x11vnc   xdesktop  
Posted

Beer of the night: Convict Hill, Oatmeal Stout

-1382861174

Slightly hoppy flavor with a smooth and clean finish. Willing to drink but only a maybe on a repurchase.

Filed under  //  beer   hoppy   oatmeal   stout  
Posted

Publish syntax colorized code from html

I came across this pretty slick way of getting reasonable syntax highlighting for code copied into PowerPoint, email, etc. by exporting the buffer as HTML directly from Vim.

Now you have no excuses for ugly formatting and lack of syntax highlighting in your presentations!

Filed under  //  html   presentations   vim  
Posted

Quickly tidy XML in vim on Linux

If you find yourself staring at an ugly representation of an XML doc, use the following command to tidy it up using xmllint:

$!xmllint --format --recover - 2>/dev/null

Filed under  //  linux   vim   xml  
Posted

Web vs product design for web apps

Great article on working at mutiple levels in the stack and focusing on strengths within a team.

http://jeffcroft.com/blog/2011/dec/25/2012-web-design-vs-product-design/

Posted

APT Repository Keys behind a HTTP Proxy

We have an HTTP proxy at work that doesn't like hkp style requests; however, there's this little gem to make it work perfectly.

sudo gpg --keyserver yourkeyserver.somewhere.org --keyserver-options http-proxy=http://myworkproxy:port --recv-keys ABCDEF01

 

Posted

Acts As Statistic Rails Gem

I finally got around to putting time into building out a gem for unified statistics gathering. The goal is to build up enough support to mimic something like the Benchmark class but log to an ActiveRecord model in a normalized format. However, unlike Benchmark, it will also support stats of counts and rates.

It was almost a year to the day before I put some effort into it beyond script/generate plugin. I do hope to keep up the development at a significantly faster rate. :-)

https://github.com/nickjones/acts_as_statistic

Filed under  //  foss   gem   rails   ruby  
Posted

Hadoop on LVM2

I had built up a cluster from the remains of past projects and other odds and ends of hardware around the labs so inevitably the nodes were configured with mostly odd sized disks. Most of the time everything runs smoothly; however, the amount of stored data on the cluster has been growing quite a bit. We had plenty of capacity for it but several nodes with smaller disks would fill up while executing, get blacklisted by jobs, and become less useful to the cluster.

Amidst upgrading (i.e. adding additional disks), I decided to give LVM2 a shot.  One large expandable volume freed us from dealing with unique Hadoop config files. LVM2 (using defaults) will get you a single volume to use but the performance of multiple disks is lost.  Nevertheless, LVM2 can be configured to stride across disks (much like a RAID 0) but without the requirement that disks are of the same size.  I recommend at least trying it; it does make system management a whole lot easier.

These are my notes on how I setup the volume; feel free to adjust as you see fit.

  1. fdisk both physical drives with a partition type of 8e (Linux LVM).
  2. Create a new LVM volume group with the physical disk partitions
    # vgcreate hadoopdisks /dev/sda1 /dev/sdc1
    Volume group "hadoopdisks" successfully created
  3. The disks I used were one terabyte in size, but not all of that space is actually usable. This was a pretty easy way to get LVM to tell you the number of extents available.
    # lvcreate -L2T -i2 -nhadoop hadoopdisks /dev/sda1 /dev/sdc1
    Using default stripesize 64.00KiB
    Insufficient free extents (476932) in volume group hadoopdisks: 524288 required
    
    # lvcreate -l 476932 -i2 -nhadoop hadoopdisks /dev/sda1 /dev/sdc1
    Using default stripesize 64.00KiB
    Logical volume "hadoop" created
  4. One last change tells LVM2 it's free to allocate anywhere it can.
    # lvchange --alloc anywhere /dev/hadoopdisks/hadoop

Filed under  //  fdisk   hadoop   hdfs   linux   lvm2   mapreduce   sysadmin  
Posted

Hadoop and bnx2

Awhile back, I setup a hadoop cluster here at the office using some discarded old boards.  They're actually a decent platform to use as Hadoop nodes as I came to find out; however, I kept having random nodes die every so often with the following kernel message:

bnx2: Chip not in correct endian mode

The solution?

...disable the IRQ balancer daemon.

It turns out that when the IRQ balancer reallocates the device's interrupt to another CPU's local APIC, it must first disable it before moving it to the new APIC ID.  However, if the device had reset itself during that time, you'll end up with this endian mode problem.  Running the IRQ balancer on a TaskTracker node after they've been balanced once doesn't really have a benefit anyway since you're likely scaling to the entire machine's size.

Filed under  //  bnx2   hadoop   linux  
Posted

Lone Star Ruby Conference 2011: Day 2 Notes

These are some of my (terse) notes from day two of the LSRC.  It would probably be helpful to read my colleague's notes as well.

Blow up Your Views

  • Instance variables in views suck
    • Real interface between C/V
      (github: voxdolo/decent_exposure)
    • Added "exposes(:foo)" in the controller and the view starts using just "foo" instead of "@foo"
  • Kill helpers
    • Example of timestamps
      • Should be writing helpers to format timestamps
      • Usually helpers are for specific objects (e.g. formats the timestamp on a particular kind of object)
    • We write helpers like print_name(user) instead of user.print_name but we want the later.
  • View Objects Implemented
    • Create an /app/decorators folder
    • Implement an attr_accessible approach to the view: Limit what it is allowed to call.
    • Github: jcasimir/draper
  • Should be splitting up responsibilities
    • Always render the same thing from the controller (define an API)
    • The view should deal with drawing the display for the client
    • Send them a JS template, assets, etc.
  • Render Engines
    • Plain HTML with jQuery Replacement
    • Mustache
    • Handlebars (SproutCore)
    • ICanHazJS

ZeroMQ

  • ZeroMQ is a messaging bus
  • Zero stands for 'zero brokers'
  • Scalability
    • Serve requests faster
    • Deals with complexity scalability
  • Uses an actor model
    • stateless
    • self-contained pieces
  • What ZeroMQ isn't
    • ZeroMQ isn't designed to write an HTTP server
      • It doesn't care what you send in messages but it cares how it sends it
      • ZeroMQ sockets only talk to other ZeroMQ sockets
    • Could write a layer that interprets HTTP and sends it into ZeroMQ (Mongrel2)
  • How to use it
    • Ruby: gem install zmq
    • Based in C and supported in every language
    • Threadsafe but can't share a socket between threads
  • Example: Request/Reply Sockets
    • Can start a client and it starts trying to communicate but will block until the server responds
    • If the server crashes in the middle and restarts but it wont automatically work.
  • Publish/Subscribe model
    • Uses option "SUBSCRIBE"
    • If the publisher goes down, the subscriber is durable
  • Push/Pull sockets
    • Multiple pull sockets can bind to a single push socket
    • Spawn more workers if the queue is backing up
  • Durable Sockets
    • Set a socket identity: give it a name
    • Setup spooling to disk for unreceived messages

JavaScript for people who didn't learn JavaScript (@jwo)

  • Prototype Inheritance
    • Only one prototype per function (but can be switched out when needed)
    • Like Ruby modules but you only get one.
    • Calling super
      • JavaScript doesn't provide a method to call super
      • var Note = Backbone.Model.extend({
          set: function(...) { } <-- override behavior and call Backbone.Model.set.call(...)
  • Using 'new'
    • Don't just use new because you think you have to
    • Use 'new' if you need the prototype of the object
    • Don't use it if your just creating a new Array, etc.
    • Object.create is useful but some browser dependencies
    • "Don't write new Array()"
      • Arrays in JS don't have limits
    • "Don't write new Function()" - just use the funciton() literal
  • Invocation
    • Functions get declared-parameters, this, and arguments
    • Creating a new object with Object.create(HelloWorld) and calling hi.speak() you get the prototype
    • Using just HelloWorld.speak doesn't provide scope so 'this' isn't bound to the object
    • JavaScript allows you to pass in the object that you want 'this' to reference (so function() in the method can actually operate on whatever object you provide)
  • JavaScript puts semicolons in where you "forgot them"
    • return
      {
        javascript: "foo"
      }; // This will fail because return gets a magic ';' on the end.

Testing JavaScript with Jasimine

  • Jasmine has rspec like syntax
  • Jasmine with jQuery
    • jasmine-jquery adds more matchers
    • Lettering.js
      • Allows you to throw spans in between chars in a particular HTML DOM element
    • SpecRunner.html
      • Added jquery and lettering js files
  • Jasmine with Rails
    • Add 'jasmine' to Gemfile
    • rake jasmine / rake jasmine:ci
  • Easier way with Evergreen "gem install evergreen"
    • Create public folder (with js in it)
    • Create spec folder with specs in it
    • evergreen run
    • Evergreen follows the name_spec.js file naming convention
    • Install coffee-script and works with Jasmine (make .coffee file)
  • Headless running
    • Install capybara-webkit
    • Switched from selenium to webkit and runs faster
  • Rosie gives you factory_girl for JS
    • github: bkeepers/rosie
  • jasminerice - jasmine + coffee script + rails 3.1

The Ballad of Goliath, EventMachine, and MongoDB

These notes are bit short since a lot of the talk was random aspects of MongoDB towards the end.
  • Goliath
    • Event Driven (Built upon EventMachine)
    • Web and app server
    • Uses fibers in Ruby 1.9
    • Matches a rackup app somewhat
      • Inherits from Goliath::API
    • Get an array of command line options
      • -u for actually specifying the user
    • By default it doesn't log at all
  • EventMachine: Watch peepcode screencode
  • MongoDB
    • Just doing Mongo::ReplSetConnection.new(host), only R/W to primary
    • Use Mongo::ReplSetConnection.new(host, :read_secondary => true) to get better read performance

Polygot Parallelism

This talk started off with a brief intro to Erlang and continued a discussion into how Rackspace was able to successfully solve a massively parallel data gathering problem.
  • Erlang
    • Immutable Data Structures
    • Single assignment => everything is immutable
  • Webmachine
    • Similar to Sinatra or Goliath
    • Basically developing a custom web server for your application's behavior.
    • http://webmachine.basho.com
    • Leaves sensible defaults for the whole HTTP life cycle and can override at any step.

Filed under  //  javascript   lsrc   rails   ruby   zeromq  
Posted