## Rail-Fence Cipher

### March 31, 2009

The obvious solution uses arithmetic to extract characters at the various positions of the text in the desired order. But the details are tricky and hard to get right. Matthias Felleisen, a Professor in the Computer Science department at Northeastern University in Boston and one of the authors of The Little Schemer proposes instead the following solution:

`(define X '_) ; a unique tag for padding the data structure`

`Waves` splits a text into pieces of length equal to the key; alternate pieces are reversed and have their first and last characters padded. For instance, `(waves (string->list "PROGRAMMING PRAXIS") 4)` evaluates to `((#\P #\R #\O #\G) (_ #\A #\R _) (#\M #\M #\I #\N) (_ #\space #\G _) (#\P #\R #\A #\X) (_ #\S #\I _)).`

``` (define (waves str h)   (define (down str)     (if (>= h (length str))         (list (fill h str))         (cons (take h str) (up (drop h str)))))   (define (up str)     (if (>= (- h 2) (length str))         (list (pad (fill (- h 2) str)))         (cons (pad (take (- h 2) str)) (down (drop (- h 2) str)))))   (define (pad str) (append (list X) (reverse str) (list X)))   (define (fill h str) (append str (make-list (- h (length str)) X)))   (down str)) Fence uses waves to produce a list of the positions from which the transposed characters will be taken. For instance, (fence (range (string-length "PROGRAMMING PRAXIS")) 4) produces the list (0 6 12 1 5 7 11 13 17 2 4 8 10 14 16 3 9 15). Fence uses waves to perform the transposition: (define (fence lox h)   (define a (apply append (transpose (waves lox h))))   (filter (lambda (e) (not (eq? X e))) a)) Encipherment is done by calling fence: (define (encipher str h)   (list->string (fence (string->list str) h))) Decipherment is somewhat more difficult. Fence builds a list of the positions of the transposed characters; for our running example, e will be (0 6 12 1 5 7 11 13 17 2 4 8 10 14 16 3 9 15). Those positions are melded with the cipher-text in x, the position/character pairs are sorted into order in y, and the characters extracted in z: (define (decipher str h)   (define e (fence (range (string-length str)) h))   (define x (map list e (string->list str)))   (define y (sort (lambda (i j) (<= (car i) (car j))) x))   (define z (map cadr y))   (list->string z)) Felleisen's program is simple and clear, a fine example of beautiful code by a master of the craft. Running the rail-fence cipher looks like this: > (encipher "PROGRAMMING PRAXIS" 4) "PMPRAM RSORIGAIGNX" > (decipher "PMPRAM RSORIGAIGNX" 4) "PROGRAMMING PRAXIS" We can test the functions using assert; remember that, with the assert macro, no news is good news: (do ((i 2 (+ i 1))) ((< 18 i))   (assert (decipher (encipher "PROGRAMMING PRAXIS" i) i)           "PROGRAMMING PRAXIS")) We use take, drop, range, filter, make-list, sort and assert from the Standard Prelude. We also use the utility function (transpose m), which transposes the rows and columns of a list of lists: (define (transpose m)   (if (null? (car m)) '()     (cons (map car m) (transpose (map cdr m))))) You can run this program at http://programmingpraxis.codepad.org/9abH1QKb. .wordads-ad-wrapper { display:none; font: normal 11px Arial, sans-serif; letter-spacing: 1px; text-decoration: none; width: 100%; margin: 25px auto; padding: 0; } .wordads-ad-title { margin-bottom: 5px; } .wordads-ad-controls { margin-top: 5px; text-align: right; } .wordads-ad-controls span { cursor: pointer; } .wordads-ad { width: fit-content; margin: 0 auto; } Advertisement sas.cmd.push(function() { sas.render("sas_110354"); }); window._stq = window._stq || []; window._stq.push( [ 'extra', { x_wordads_smart: 'render_sas_110354', }, ] ); Share this:TwitterFacebookLike this:Like Loading... Related Pages: 1 2 ```
``` Posted by programmingpraxis Filed in Exercises 9 Comments » ```
``` 9 Responses to “Rail-Fence Cipher” FalconNL said March 31, 2009 at 3:06 PM In Haskell: import Data.List main = do print \$ rail 4 "PROGRAMMING PRAXIS" print . derail 4 \$ rail 4 "PROGRAMMING PRAXIS" rail :: Int -> String -> String rail n s = map (s !!) \$ waves n s derail :: Int -> String -> String derail n s = map snd . sort \$ zip (waves n s) s waves :: Int -> String -> [Int] waves n = map snd . sort . zip (cycle \$ [1..n] ++ [n-1,n-2..2]) . zipWith const [0..] matthias said April 1, 2009 at 2:31 PM FalconNL, your design turns the solution into “Fortran”, using indexes into lists (of chars) where a generative-recursion design (for freshmen) exposes the waves as they come about. Then again, you demonstrate how temporary laziness in ‘waves’ is a useful tool. Let me show you how temporary, invisible assignments accomplish the exact same purpose. ;; [Listof X] Nat -> [Listof X] ;; 1 5 9 ;; 1 2 3 4 5 6 7 8 9 10 11 ==> 2 4 6 8 10 ==> 1 5 9 2 4 6 8 10 3 7 11 ;; 3 7 11 (check-expect (fence ‘(1 2 3 4 5 6) 3) ‘(1 5 2 4 6 3)) (check-expect (fence ‘(1 2 3 4 5 6 7 8 9 10 11) 3) ‘(1 5 9 2 4 6 8 10 3 7 11)) (define (fence s n) (define is (shared ((x (append (range 1 n) (range (- n 1) 2) x))) x)) (define wv (for/list ((c s)) (begin0 (list c (car is)) (set! is (cdr is))))) (map first (sort2 wv))) matthias said April 1, 2009 at 3:37 PM Oops, fence is a two-liner in PLT Scheme, too: (define (fence s n) (define is (shared ((x (append (range 1 n) (range (- n 1) 2) x))) x)) (map first (sort2 (for/list ((c s) (i (in-list is))) (list c i))))) FalconNL said April 2, 2009 at 9:40 AM Updated version that I believe should run in O(n log n) for both rail and derail (rail was O(n^2) in the previous version): import Data.List import GHC.Exts main = do print \$ rail 4 "PROGRAMMING PRAXIS" print . derail 4 \$ rail 4 "PROGRAMMING PRAXIS" rail :: Int -> [a] -> [a] rail n = zipSort (cycle \$ [1..n] ++ [n-1,n-2..2]) derail :: Ord a => Int -> [a] -> [a] derail n s = zipSort (rail n \$ zipWith const [0..] s) s zipSort :: Ord a => [a] -> [b] -> [b] zipSort ks = map snd . sortWith fst . zip ks Luis Sergio Oliveira said May 17, 2009 at 5:03 PM Hi, my solution in Common Lisp, including some tests is here: http://lisp.pastebin.com/f27e23d44. Notice that I haven’t followed the algorithm proposed in your solution which is indeed very interesting… Thanks for the problem, Luis programmingpraxis said May 22, 2009 at 4:50 AM Posted on behalf of Matthias Felleisen: “I have finally found some time to write up my version of the story which only starts with the post here as a way to explain the idea in a first-semester FP course — with design principles. In contrast to the Haskell solution, mine is linear. If a linear purely FP solution exists, I’d like to know.” Programming Praxis – Double Transposition Cipher « Bonsai Code said May 30, 2009 at 3:49 PM […] up we have zipSort, which I also used in the Rail-Fence Cipher […] Jan Van lent said July 6, 2009 at 11:08 PM Common Lisp solution at http://paste.lisp.org/display/83135. ftt said February 27, 2014 at 10:46 PM https://github.com/ftt/programming-praxis/blob/master/20090331-rail-fence-cipher/rail-fence-cipher.py Leave a Reply Enter your comment here... Fill in your details below or click an icon to log in: Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. ( Log Out /  Change ) You are commenting using your Twitter account. ( Log Out /  Change ) You are commenting using your Facebook account. ( Log Out /  Change ) Cancel Connecting to %s var highlander_expando_javascript = function () { function hide( sel ) { var el = document.querySelector( sel ); if ( el ) { el.style.setProperty( 'display', 'none' ); } } function show( sel ) { var el = document.querySelector( sel ); if ( el ) { el.style.removeProperty( 'display' ); } } var input = document.createElement( 'input' ); var comment = document.querySelector( '#comment' ); if ( input && comment && 'placeholder' in input ) { var label = document.querySelector( '.comment-textarea label' ); if ( label ) { var text = label.textContent; label.parentNode.removeChild( label ); comment.setAttribute( 'placeholder', text ); } } // Expando Mode: start small, then auto-resize on first click + text length hide( '#comment-form-identity' ); hide( '#comment-form-subscribe' ); hide( '#commentform .form-submit' ); if ( comment ) { comment.style.height = '10px'; var handler = function () { comment.style.height = HighlanderComments.initialHeight + 'px'; show( '#comment-form-identity' ); show( '#comment-form-subscribe' ); show( '#commentform .form-submit' ); HighlanderComments.resizeCallback(); comment.removeEventListener( 'focus', handler ); }; comment.addEventListener( 'focus', handler ); } } if ( document.readyState !== 'loading' ) { highlander_expando_javascript(); } else { document.addEventListener( 'DOMContentLoaded', highlander_expando_javascript ); } Notify me of new comments via email. Notify me of new posts via email. Δdocument.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); ```
``` Categories Administrivia Exercises Archives December 2021 November 2021 October 2021 September 2021 June 2021 May 2021 April 2021 March 2021 February 2021 January 2021 December 2020 November 2020 October 2020 September 2020 August 2020 July 2020 June 2020 May 2020 April 2020 March 2020 February 2020 January 2020 December 2019 November 2019 October 2019 September 2019 August 2019 July 2019 June 2019 May 2019 April 2019 March 2019 February 2019 January 2019 November 2018 October 2018 September 2018 August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 March 2009 S M T W T F S 1234567 891011121314 15161718192021 22232425262728 293031   « Feb   Apr » Archives December 2021 November 2021 October 2021 September 2021 June 2021 May 2021 April 2021 March 2021 February 2021 January 2021 December 2020 November 2020 October 2020 September 2020 August 2020 July 2020 June 2020 May 2020 April 2020 March 2020 February 2020 January 2020 December 2019 November 2019 October 2019 September 2019 August 2019 July 2019 June 2019 May 2019 April 2019 March 2019 February 2019 January 2019 November 2018 October 2018 September 2018 August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 Blogroll WordPress.com WordPress.org ```
``` Blog at WordPress.com. var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1\$s: You are commenting using your %2\$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"https:\/\/programmingpraxis.wordpress.com\/public.api\/connect\/?action=request&domain=programmingpraxis.com","logoutURL":"https:\/\/programmingpraxis.wordpress.com\/wp-login.php?action=logout&_wpnonce=f85a78ccf4","homeURL":"https:\/\/programmingpraxis.com\/","postID":"350","gravDefault":"blank","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"","userIsLoggedIn":"","isJetpack":"","text_direction":"ltr"}; ( function () { var setupPrivacy = function() { // Minimal Mozilla Cookie library // https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework var cookieLib = window.cookieLib = {getItem:function(e){return e&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\\$&")+"\\s*\\=\\s*([^;]*).*\$)|^.*\$"),"\$1"))||null},setItem:function(e,o,n,t,r,i){if(!e||/^(?:expires|max\-age|path|domain|secure)\$/i.test(e))return!1;var c="";if(n)switch(n.constructor){case Number:c=n===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n;break;case String:c="; expires="+n;break;case Date:c="; expires="+n.toUTCString()}return"rootDomain"!==r&&".rootDomain"!==r||(r=(".rootDomain"===r?".":"")+document.location.hostname.split(".").slice(-2).join(".")),document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(o)+c+(r?"; domain="+r:"")+(t?"; path="+t:"")+(i?"; secure":""),!0}}; // Implement IAB USP API. window.__uspapi = function( command, version, callback ) { // Validate callback. if ( typeof callback !== 'function' ) { return; } // Validate the given command. if ( command !== 'getUSPData' || version !== 1 ) { callback( null, false ); return; } // Check for GPC. If set, override any stored cookie. if ( navigator.globalPrivacyControl ) { callback( { version: 1, uspString: '1YYN' }, true ); return; } // Check for cookie. var consent = cookieLib.getItem( 'usprivacy' ); // Invalid cookie. if ( null === consent ) { callback( null, false ); return; } // Everything checks out. Fire the provided callback with the consent data. callback( { version: 1, uspString: consent }, true ); }; // Initialization. document.addEventListener( 'DOMContentLoaded', function() { // Internal functions. var setDefaultOptInCookie = function() { var value = '1YNN'; var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'usprivacy', value, 365 * 24 * 60 * 60, '/', domain ); }; var setDefaultOptOutCookie = function() { var value = '1YYN'; var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'usprivacy', value, 24 * 60 * 60, '/', domain ); }; var setDefaultNotApplicableCookie = function() { var value = '1---'; var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'usprivacy', value, 24 * 60 * 60, '/', domain ); }; var setCcpaAppliesCookie = function( applies ) { var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'ccpa_applies', applies, 24 * 60 * 60, '/', domain ); } var maybeCallDoNotSellCallback = function() { if ( 'function' === typeof window.doNotSellCallback ) { return window.doNotSellCallback(); } return false; } // Look for usprivacy cookie first. var usprivacyCookie = cookieLib.getItem( 'usprivacy' ); // Found a usprivacy cookie. if ( null !== usprivacyCookie ) { // If the cookie indicates that CCPA does not apply, then bail. if ( '1---' === usprivacyCookie ) { return; } // CCPA applies, so call our callback to add Do Not Sell link to the page. maybeCallDoNotSellCallback(); // We're all done, no more processing needed. return; } // We don't have a usprivacy cookie, so check to see if we have a CCPA applies cookie. var ccpaCookie = cookieLib.getItem( 'ccpa_applies' ); // No CCPA applies cookie found, so we'll need to geolocate if this visitor is from California. // This needs to happen client side because we do not have region geo data in our \$SERVER headers, // only country data -- therefore we can't vary cache on the region. if ( null === ccpaCookie ) { var request = new XMLHttpRequest(); request.open( 'GET', 'https://public-api.wordpress.com/geo/', true ); request.onreadystatechange = function () { if ( 4 === this.readyState ) { if ( 200 === this.status ) { // Got a geo response. Parse out the region data. var data = JSON.parse( this.response ); var region = data.region ? data.region.toLowerCase() : ''; var ccpa_applies = ['california', 'colorado', 'connecticut', 'utah', 'virginia'].indexOf( region ) > -1; // Set CCPA applies cookie. This keeps us from having to make a geo request too frequently. setCcpaAppliesCookie( ccpa_applies ); // Check if CCPA applies to set the proper usprivacy cookie. if ( ccpa_applies ) { if ( maybeCallDoNotSellCallback() ) { // Do Not Sell link added, so set default opt-in. setDefaultOptInCookie(); } else { // Failed showing Do Not Sell link as required, so default to opt-OUT just to be safe. setDefaultOptOutCookie(); } } else { // CCPA does not apply. setDefaultNotApplicableCookie(); } } else { // Could not geo, so let's assume for now that CCPA applies to be safe. setCcpaAppliesCookie( true ); if ( maybeCallDoNotSellCallback() ) { // Do Not Sell link added, so set default opt-in. setDefaultOptInCookie(); } else { // Failed showing Do Not Sell link as required, so default to opt-OUT just to be safe. setDefaultOptOutCookie(); } } } }; // Send the geo request. request.send(); } else { // We found a CCPA applies cookie. if ( ccpaCookie === 'true' ) { if ( maybeCallDoNotSellCallback() ) { // Do Not Sell link added, so set default opt-in. setDefaultOptInCookie(); } else { // Failed showing Do Not Sell link as required, so default to opt-OUT just to be safe. setDefaultOptOutCookie(); } } else { // CCPA does not apply. setDefaultNotApplicableCookie(); } } } ); }; // Kickoff initialization. if ( window.defQueue && defQueue.isLOHP && defQueue.isLOHP === 2020 ) { defQueue.items.push( setupPrivacy ); } else { setupPrivacy(); } } )(); Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy ( function() { function init() { document.body.addEventListener( 'is.post-load', function() { if ( typeof __ATA.insertInlineAds === 'function' ) { __ATA.insertInlineAds(); } } ); } if ( document.readyState !== 'loading' ) { init(); } else { document.addEventListener( 'DOMContentLoaded', init ); } } )(); Follow Following Programming Praxis Join 824 other followers Already have a WordPress.com account? Log in now. Programming Praxis Customize Follow Following Sign up Log in Copy shortlink Report this content View post in Reader Manage subscriptions Collapse this bar window.addEventListener( "load", function( event ) { var link = document.createElement( "link" ); link.href = "https://s0.wp.com/wp-content/mu-plugins/actionbar/actionbar.css?v=20210915"; link.type = "text/css"; link.rel = "stylesheet"; document.head.appendChild( link ); var script = document.createElement( "script" ); script.src = "https://s0.wp.com/wp-content/mu-plugins/actionbar/actionbar.js?v=20220329"; script.defer = true; document.body.appendChild( script ); } ); window.WPCOM_sharing_counts = {"https:\/\/programmingpraxis.com\/2009\/03\/31\/rail-fence-cipher\/":350}; (function(){ var corecss = document.createElement('link'); var themecss = document.createElement('link'); var corecssurl = "https://s1.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/styles/shCore.css?ver=3.0.9b"; if ( corecss.setAttribute ) { corecss.setAttribute( "rel", "stylesheet" ); corecss.setAttribute( "type", "text/css" ); corecss.setAttribute( "href", corecssurl ); } else { corecss.rel = "stylesheet"; corecss.href = corecssurl; } document.head.appendChild( corecss ); var themecssurl = "https://s2.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/styles/shThemeDefault.css?m=1363304414h&amp;ver=3.0.9b"; if ( themecss.setAttribute ) { themecss.setAttribute( "rel", "stylesheet" ); themecss.setAttribute( "type", "text/css" ); themecss.setAttribute( "href", themecssurl ); } else { themecss.rel = "stylesheet"; themecss.href = themecssurl; } document.head.appendChild( themecss ); })(); SyntaxHighlighter.config.strings.expandSource = '+ expand source'; SyntaxHighlighter.config.strings.help = '?'; SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n'; SyntaxHighlighter.config.strings.noBrush = 'Can\'t find brush for: '; SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Brush wasn\'t configured for html-script option: '; SyntaxHighlighter.defaults['pad-line-numbers'] = false; SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); // Infinite scroll support if ( typeof( jQuery ) !== 'undefined' ) { jQuery( function( \$ ) { \$( document.body ).on( 'post-load', function() { SyntaxHighlighter.highlight(); } ); } ); } var sharing_js_options = {"lang":"en","counts":"1","is_stats_active":"1"}; var windowOpen; ( function () { function matches( el, sel ) { return !! ( el.matches && el.matches( sel ) || el.msMatchesSelector && el.msMatchesSelector( sel ) ); } document.body.addEventListener( 'click', function ( event ) { if ( ! event.target ) { return; } var el; if ( matches( event.target, 'a.share-twitter' ) ) { el = event.target; } else if ( event.target.parentNode && matches( event.target.parentNode, 'a.share-twitter' ) ) { el = event.target.parentNode; } if ( el ) { event.preventDefault(); // If there's another sharing window open, close it. if ( typeof windowOpen !== 'undefined' ) { windowOpen.close(); } windowOpen = window.open( el.getAttribute( 'href' ), 'wpcomtwitter', 'menubar=1,resizable=1,width=600,height=350' ); return false; } } ); } )(); var windowOpen; ( function () { function matches( el, sel ) { return !! ( el.matches && el.matches( sel ) || el.msMatchesSelector && el.msMatchesSelector( sel ) ); } document.body.addEventListener( 'click', function ( event ) { if ( ! event.target ) { return; } var el; if ( matches( event.target, 'a.share-facebook' ) ) { el = event.target; } else if ( event.target.parentNode && matches( event.target.parentNode, 'a.share-facebook' ) ) { el = event.target.parentNode; } if ( el ) { event.preventDefault(); // If there's another sharing window open, close it. if ( typeof windowOpen !== 'undefined' ) { windowOpen.close(); } windowOpen = window.open( el.getAttribute( 'href' ), 'wpcomfacebook', 'menubar=1,resizable=1,width=600,height=400' ); return false; } } ); } )(); // <![CDATA[ (function() { try{ if ( window.external &&'msIsSiteMode' in window.external) { if (window.external.msIsSiteMode()) { var jl = document.createElement('script'); jl.type='text/javascript'; jl.async=true; jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jl, s); } } }catch(e){} })(); // ]]> %d bloggers like this: _tkq = window._tkq || []; _stq = window._stq || []; _tkq.push(['storeContext', {'blog_id':'6649073','blog_tz':'0','user_lang':'en','blog_lang':'en','user_id':'0'}]); _stq.push(['view', {'blog':'6649073','v':'wpcom','tz':'0','user_id':'0','post':'350','subd':'programmingpraxis'}]); _stq.push(['extra', {'crypt':'UE5XaGUuOTlwaD85flAmcm1mcmZsaDhkV11YdWtpP0NsWnVkPS9sL0ViLndld3BuVT01Uj14Ti1yYTBnR1N+UVJ+VkxET2R3R0Y/YTloT0RYa2kuUFZSTmFVV1p+K2s4QVNIMlBNPTV8LC5QdEQmPWUmdmljRlIsVzlUOVpdNS9wUVAuMW1JaEF8bzV3NyZoUkNmSTN3eGQ3YXJRLVVqamJ6YSUyTUJKSVU9WFAxUndWbSsxQ1M2cHF5UDFSMXVCfEZXJXVJWjJwLkNQcSxRViV1ay9iOWdwLUwyfHk9OGpTalA5dCVEdGJXWVhYPXovRHJYSkFXMnRpdC9YNmt2WFMtSWtyfkljb05+dVVtUm1Sb0JrejFVT1pPQ004cTZ0SFRreEhNLTdMQ1ssbTgmXzhjTmh2TEFHeG9fby8xZDNIP1lLLFg/WUlycXMwRWM4JkZwMVtjX0pLdmVlRDRzLz1PJSU5azhaWElV'}]); _stq.push([ 'clickTrackerInit', '6649073', '350' ]); if ( 'object' === typeof wpcom_mobile_user_agent_info ) { wpcom_mobile_user_agent_info.init(); var mobileStatsQueryString = ""; if( false !== wpcom_mobile_user_agent_info.matchedPlatformName ) mobileStatsQueryString += "&x_" + 'mobile_platforms' + '=' + wpcom_mobile_user_agent_info.matchedPlatformName; if( false !== wpcom_mobile_user_agent_info.matchedUserAgentName ) mobileStatsQueryString += "&x_" + 'mobile_devices' + '=' + wpcom_mobile_user_agent_info.matchedUserAgentName; if( wpcom_mobile_user_agent_info.isIPad() ) mobileStatsQueryString += "&x_" + 'ipad_views' + '=' + 'views'; if( "" != mobileStatsQueryString ) { new Image().src = document.location.protocol + '//pixel.wp.com/g.gif?v=wpcom-no-pv' + mobileStatsQueryString + '&baba=' + Math.random(); } } ```