(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // Trim text. | |
| function trimText( jquery_obj_to_trim, trim_length ){ | |
| var currentText = jquery_obj_to_trim.text(); | |
| var newLength = trim_length; | |
| var currentTextTrimmed = currentText.substr(0, newLength); | |
| var endOfCurrentText = /\W?\s?\b\w+\W*?$/.exec( currentTextTrimmed ); | |
| if( endOfCurrentText === null ) return; | |
| var endOfCurrentTextLength = endOfCurrentText[0].length; | |
| currentTextTrimmed = currentText.substr(0, newLength - endOfCurrentTextLength ); |
| <div class="btn-group pull-right" role="group"> | |
| <button class="btn btn-default inline" data-target="#content .panel:not('.in')" data-toggle="collapse" id="info-page-uncollapse-all">Expand All <span class="glyphicon glyphicon-chevron-down"></span></button> | |
| <button class="btn btn-default" data-target="#content .panel.in" data-toggle="collapse" id="info-page-collapse-all">Collapse All <span class="glyphicon glyphicon-chevron-up"></span></button> | |
| </div> |
| // Bookmark help for phones | |
| var isMobile = { | |
| Android: navigator.userAgent.match(/Android/i), | |
| BlackBerry: navigator.userAgent.match(/BlackBerry/i), | |
| iOS: navigator.userAgent.match(/iPhone|iPad|iPod/i), | |
| Opera: navigator.userAgent.match(/Opera Mini/i), | |
| Windows: navigator.userAgent.match(/IEMobile/i), | |
| any: function() { | |
| return isMobile.Android || isMobile.BlackBerry || isMobile.iOS || isMobile.Opera || isMobile.Windows; | |
| } |
| // Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345 | |
| function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) { | |
| var s1_x, s1_y, s2_x, s2_y; | |
| s1_x = p1_x - p0_x; | |
| s1_y = p1_y - p0_y; | |
| s2_x = p3_x - p2_x; | |
| s2_y = p3_y - p2_y; | |
| var s, t; |
| int[][] result; | |
| float t; | |
| void setup() { | |
| setup_(); | |
| result = new int[width*height][3]; | |
| } | |
| void draw() { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // by Dave @ Bees & Bombs >:) | |
| int[][] result; | |
| float time; | |
| void setup() { | |
| setup_(); | |
| result = new int[width*height][3]; | |
| } |
| $.fn.equalheight = function( remove ) { | |
| // Reset heights from the last viewport resize so that values do not get wacky-large. | |
| this.height('auto'); | |
| // if remove is true, just reset the heights and return | |
| if ( remove ) { | |
| return; | |
| } |
| $.fn.equalheight = function( remove ) { | |
| // Reset heights from the last viewport resize so that values do not get wacky-large. | |
| this.height('auto'); | |
| // if remove is true, just reset the heights and return | |
| if ( remove ) { | |
| return; | |
| } |
| $.fn.equalheight = function(){ | |
| var $selection = this; | |
| var $groups = []; | |
| while( $selection.length > 1 ){// If $selection.length is greater than 1, then it must be 2, meaning there are at least 2 equal-height divs left. This will prevent an infinite loop if there is an equal-height div without a partner equal-height div. | |
| // Find an equal-height group. | |
| $groups.push( $selection.eq(0).siblings('.equal-height').addBack() ); | |
| // Reduce selection by the latest equal-height group. | |
| $selection = $selection.not( $groups[ $groups.length - 1 ] ); | |
| // Drop groups that only have 1 element - it doesn't make any sense to have a lone equal-height element. |