How to fix blogger homepage blurry thumbs?

Question: I just start learning programing few month ago, I customized my blogger template to look the way I want, I'm succeded fixing some errors and bug, but I'm stuck now on thumbs resolution and resize, here some codes from my template:
$(document).ready(function(){$(".header-search > .fa-search").click(function(){$("#search-bar .search-form").slideDown("",function(){}),$(".header-search > .fa-search").toggleClass("active"),$(".header-search > .fa-times").toggleClass("active")}),$(".header-search > .fa-times").click(function(){$("#search-bar .search-form").slideUp("",function(){}),$(".header-search > .fa-search").toggleClass("active"),$(".header-search > .fa-times").toggleClass("active")}),$("#menu .widget").attr("style","display:block!important;"),$("#menu a.mega-link").map(function(){var e=$(this),t=e.attr("href");if(t=t.toLowerCase(),e.hasClass("mega-link")){var a=e.text();$.ajax({url:"/feeds/posts/default/-/"+a+"?alt=json-in-script&max-results=4",type:"get",dataType:"jsonp",success:function(t){e.closest("li").addClass("isMega hasSubmenu");for(var n=0;n<t.feed.link.length;n++){var s=t.feed.link[n],r=s.rel,i=s.type;if("alternate"==r&&"text/html"==i){var l=s.href+"?&max-results="+perPage;e.attr("href",l)}}var d=t.feed.openSearch$totalResults.$t,o=t.feed.openSearch$startIndex.$t,c=t.feed.openSearch$itemsPerPage.$t;if(d>4);else;var f=Math.ceil(d/c);if(t.feed.entry){var m="

';for(n=0;n<t.feed.entry.length;n++){var u=t.feed.entry[n];if(u.media$thumbnail)-1!==(p=u.media$thumbnail.url).indexOf("/s72-c")&&(p=p.replace("/s72-c","/s1600")),-1!==p.indexOf("img.youtube.com")&&(p=p.replace("/default.jpg","/maxresdefault.jpg"));else var p="https://4.bp.blogspot.com/-wPwjv7-YYGY/Wc98wlDT8qI/AAAAAAAAAEE/mH8YkPl8qJAH9FMuFKcShQvXXYMmVyrIgCLcBGAs/s1600/notfound.png";for(var h=u.title.$t,g=0;g<u.link.length;g++)if("alternate"==u.link[g].rel)var b=u.link[g].href;m=m+'

'+h+"

"}m+="

",e.after(function(){$(this).after(m);var e=$(this).closest(".isMega");e.find(".mega-prev").click(function(){var e=$(this).closest("ul");e.find(".pixel-mega-loading").fadeIn(0);var t=e.attr("data-label"),a=Number(e.attr("data-start")),n=Number(e.attr("data-cstage")),s=(Number(e.attr("data-stages")),Number(e.attr("data-itemnums")));if(a-=s,n-1<=1?$(this).addClass("disable"):$(this).removeClass("disable"),e.find(".mega-next").removeClass("disable"),n>1){var r="",i="/feeds/posts/default/-/"+t+"?alt=json-in-script&start-index="+a+"&max-results="+s;$.ajax({url:i,type:"get",dataType:"jsonp",success:function(t){if(e.attr("data-start",a),e.attr("data-cstage",n-1),t.feed.entry){for(var s=0;s<t.feed.entry.length;s++){var i=t.feed.entry[s];if(i.media$thumbnail)-1!==(l=i.media$thumbnail.url).indexOf("/s72-c")&&(l=l.replace("/s72-c","/s1600")),-1!==l.indexOf("img.youtube.com")&&(l=l.replace("/default.jpg","/maxresdefault.jpg"));else var l="https://4.bp.blogspot.com/-wPwjv7-YYGY/Wc98wlDT8qI/AAAAAAAAAEE/mH8YkPl8qJAH9FMuFKcShQvXXYMmVyrIgCLcBGAs/s1600/notfound.png";for(var d=i.title.$t,o=0;o<i.link.length;o++)if("alternate"==i.link[o].rel)var c=i.link[o].href;r=r+'

'+d+"

"}e.find(".mega-inner").html(r),setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}},error:function(t){setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}})}}),e.find(".mega-next").click(function(){var e=$(this).closest("ul");e.find(".pixel-mega-loading").fadeIn(0);var t=e.attr("data-label"),a=Number(e.attr("data-start")),n=Number(e.attr("data-cstage")),s=Number(e.attr("data-stages")),r=Number(e.attr("data-itemnums"));if(a+=r,n+1==s?$(this).addClass("disable"):$(this).removeClass("disable"),n>=1?e.find(".mega-prev").removeClass("disable"):e.find(".mega-prev").addClass("disable"),s>n){var i="",l="/feeds/posts/default/-/"+t+"?alt=json-in-script&start-index="+a+"&max-results="+r;$.ajax({url:l,type:"get",dataType:"jsonp",success:function(t){if(e.attr("data-start",a),e.attr("data-cstage",n+1),t.feed.entry){for(var s=0;s<t.feed.entry.length;s++){var r=t.feed.entry[s];if(r.media$thumbnail)-1!==(l=r.media$thumbnail.url).indexOf("/s72-c")&&(l=l.replace("/s72-c","/s1600")),-1!==l.indexOf("img.youtube.com")&&(l=l.replace("/default.jpg","/maxresdefault.jpg"));else var l="https://4.bp.blogspot.com/-wPwjv7-YYGY/Wc98wlDT8qI/AAAAAAAAAEE/mH8YkPl8qJAH9FMuFKcShQvXXYMmVyrIgCLcBGAs/s1600/notfound.png";for(var d=r.title.$t,o=0;o<r.link.length;o++)if("alternate"==r.link[o].rel)var c=r.link[o].href;i=i+'

'+d+"

"}e.find(".mega-inner").html(i),setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}},error:function(t){setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}})}})})}},error:function(e){}})}})}),$(document).ready(function(){$(".zune-ran-zunebt span").each(function(){$.ajax({url:"/feeds/posts/default?alt=json-in-script",type:"get",dataType:"jsonp",success:function(e){e=e.feed.entry.length-3,0==(e=Math.floor(Math.random()*(e-0+1))+0)&&(e=Math.floor(Math.random()*(e-0+1))+1),$.ajax({url:"/feeds/posts/default?alt=json-in-script&start-index="+e+"&max-results=1",type:"get",dataType:"jsonp",success:function(e){for(var t="",a="",n=0;n<e.feed.entry.length;n++){for(var s=0;s<e.feed.entry[n].link.length;s++)if("alternate"==e.feed.entry[n].link[s].rel){t=e.feed.entry[n].link[s].href;break}a+=''}$(".zune-ran-zunebt span").html(a)}})}})})}),$(".ticker .HTML .widget-content").each(function(){var e=$(this).find("span").attr("data-no")||"",t=$(this).find("span").attr("data-label")||"",a=$(this).find("span").attr("data-type")||"";null!=a&&a.match("zune-")?$.ajax({url:"/feeds/posts/default?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(e){for(var t="",a="
",n=0;n<e.feed.entry.length;n++){for(var s=0;s<e.feed.entry[n].link.length;s++)if("alternate"==e.feed.entry[n].link[s].rel){t=e.feed.entry[n].link[s].href;break}var r=e.feed.entry[n].title.$t,i=e.feed.entry[n].category[0].term,l=e.feed.entry[n].content.$t,d=$("
").html(l);if(l.indexOf("//www.youtube.com/embed/")>-1)var o=e.feed.entry[n].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(l.indexOf("-1)o=d.find("img:first").attr("src").replace("s72-c","s1600");else o=no_image;a+='

'+i+'
'+r+"

"}a+="
",$(".ticker .widget-content").each(function(){$(this).html(a),$(this).prev("h2").prepend(''),$(this).find("ul").webTicker()})}}):a.match("label")&&$.ajax({url:"/feeds/posts/default/-/"+t+"?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(e){for(var t="",a="
",n=0;n<e.feed.entry.length;n++){for(var s=0;s<e.feed.entry[n].link.length;s++)if("alternate"==e.feed.entry[n].link[s].rel){t=e.feed.entry[n].link[s].href;break}var r=e.feed.entry[n].title.$t,i=e.feed.entry[n].category[0].term,l=e.feed.entry[n].content.$t,d=$("
").html(l);if(l.indexOf("//www.youtube.com/embed/")>-1)var o=e.feed.entry[n].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(l.indexOf("-1)o=d.find("img:first").attr("src").replace("s72-c","s1600");else o=no_image;a+='

'+i+'
'+r+"

"}a+="
",$(".ticker .HTML .widget-content").each(function(){$(this).html(a),$(this).prev("h2").prepend(''),$(this).find("ul").webTicker()})}})}),$(".featured .HTML .widget-content").each(function(){var e=$(this).find("span").attr("data-label"),t=($(this).find("span").attr("data-no"),$(this).prev("h2").text(),$(this).parent().attr("id"));$(this).find("span").attr("data-type").match("blsm")&&$.ajax({url:"/feeds/posts/default/-/"+e+"?alt=json-in-script&max-results=3",type:"get",dataType:"jsonp",success:function(e){var a="",n='
';if(e.feed.entry){for(var s=0;s<e.feed.entry.length;s++){for(var r=0;r<e.feed.entry[s].link.length;r++)if("alternate"==e.feed.entry[s].link[r].rel){a=e.feed.entry[s].link[r].href;break}if("content"in e.feed.entry[s])var i=e.feed.entry[s].content.$t;else if("summary"in b_rc)i=e.feed.entry[s].summary.$t;else i="";(i=i.replace(/<\S[^>]*>/g,"")).length>120&&(i=i.substring(0,100)+"...");var l=e.feed.entry[s].title.$t,d=e.feed.entry[s].category[0].term,o=e.feed.entry[s].author[0].name.$t,c=e.feed.entry[s].published.$t,f=c.substring(0,4),m=c.substring(5,7),u=c.substring(8,10),p=month_format[parseInt(m,10)]+" "+u+", "+f,h=e.feed.entry[s].content.$t,g=$("
").html(h);if(h.indexOf("//www.youtube.com/embed/")>-1)var b=e.feed.entry[s].media$thumbnail.url;else if(h.indexOf("-1)b=g.find("img:first").attr("src");else b=no_image;n+=0==s?'

'+d+'

'+l+'
'+o+''+p+"

":'

'+l+'
'+p+'

'}n+="
"}$(".featured .HTML .widget-content").each(function(){$(this).parent().attr("id")==t&&($(this).html(n),$(this).parent().addClass("blsm"),$(this).parent().addClass("zunebt"),$(".featured").addClass("comload").removeClass("preload"),$(this).find(".zunebt-img,.zune-img").each(function(){$(this).attr("style",function(e,t){return t.replace("/default.jpg","/hqdefault.jpg")}).attr("style",function(e,t){return t.replace("s72-c","s1600")})}))})}})}),$(".post-home-image .post-thumb a").attr("style",function(e,t){return t.match("hqdefault.jpg")?t.replace("/hqdefault.jpg","/hqdefault.jpg"):t.match("default.jpg")?t.replace("/default.jpg","/hqdefault.jpg"):t.match("s72-c")?t.replace("/s72-c","/s1600"):t.match("w72-h72-p-nu")?t.replace("/w72-h72-p-nu","/s1600"):t.replace("https://3.bp.blogspot.com/-Yw8BIuvwoSQ/VsjkCIMoltI/AAAAAAAAC4c/s55PW6xEKn0/s1600-r/nth.png",no_image)}),$(document).ready(function(){var e=$("#sidetabs #tabside1 .widget h2").text();$(".menu-tab .item-1 a").text(e);var t=$("#sidetabs #tabside2 .widget h2").text();$(".menu-tab .item-2 a").text(t);var a=$("#sidetabs #tabside3 .widget h2").text();$(".menu-tab .item-3 a").text(a),$("#tabside1 .widget h2,#tabside2 .widget h2,#tabside3 .widget h2,#tabside1 .widget-title,#tabside2 .widget-title,#tabside3 .widget-title").remove(),$(this).find(".menu-tab li").addClass("hide-tab"),$(".sidetabs").tabslet({mouseevent:"click",attribute:"href",animation:!0}),0===$(".sidetabs .widget").length&&$(".sidetabs").remove()}),$(document).ready(function(){$(".cmm-tabs").simplyTab({active:1,fx:"fade",showSpeed:400,hideSpeed:400}),$(".blogger-tab").append($("#comments")),$(".cmm-tabs.simplyTab .wrap-tab").wrap("
")}),$(".PopularPosts ul li img").attr("src",function(e,t){return t.match("hqdefault.jpg")?t.replace("/hqdefault.jpg","/hqdefault.jpg"):t.match("default.jpg")?t.replace("/default.jpg","/hqdefault.jpg"):t.match("s72-c")?t.replace("/s72-c","/s1600"):t.match("w72-h72-p-nu")?t.replace("/w72-h72-p-nu","/s1600"):t.replace("https://3.bp.blogspot.com/-Yw8BIuvwoSQ/VsjkCIMoltI/AAAAAAAAC4c/s55PW6xEKn0/s1600-r/nth.png",no_image)}),$(document).ready(function(){$('span[name="author-social"]').before($(".post-author-social .widget-content").html()),$(".post-author-social .widget-content").html(""),$('span[name="author-post"]').before($(".post-author-widget .widget-content").html()),$(".post-author-widget .widget-content").html(""),$('a[name="ad-post-top"]').before($("#adwidegt2 .widget-content").html()),$("#adwidegt2 .widget-content").html(""),$('a[name="ad-post-bottom"]').before($("#adwidegt3 .widget-content").html()),$("#adwidegt3 .widget-content").html("")}),$(".zune-trigger .HTML .widget-content span.zune-recenetcomment").each(function(){var e=$(this).attr("data-no");$.ajax({url:"/feeds/comments/default?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length&&s!=t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}if("content"in t.feed.entry[s])var i=t.feed.entry[s].content.$t;else if("summary"in b_rc)i=t.feed.entry[s].summary.$t;else i="";(i=i.replace(/<\S[^>]*>/g,"")).length>70&&(i=i.substring(0,50)+"...");var l=t.feed.entry[s].author[0].name.$t,d=t.feed.entry[s].author[0].gd$image.src;if(d.match("https://img1.blogblog.com/img/blank.gif"))var o="https://img1.blogblog.com/img/anon36.png";else if(d.match("https://img2.blogblog.com/img/b16-rounded.gif"))o="https://img1.blogblog.com/img/anon36.png";else o=d;n+='

'+l+'"'+i+'"
'}n+='

',$(".zune-trigger .HTML .widget-content span.zune-recenetcomment").each(function(){$(this).attr("data-no")==e&&$(this).parent().html(n)})}})}),$(".zune-trigger .HTML .widget-content span.zune-lposts").each(function(){var e=$(this).attr("data-no");$.ajax({url:"/feeds/posts/default?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}var i=t.feed.entry[s].title.$t,l=(t.feed.entry[s].category[0].term,t.feed.entry[s].author[0].name.$t),d=t.feed.entry[s].published.$t,o=d.substring(0,4),c=d.substring(5,7),f=d.substring(8,10),m=month_format[parseInt(c,10)]+" "+f+", "+o,u=t.feed.entry[s].content.$t,p=$("
").html(u);if(u.indexOf("//www.youtube.com/embed/")>-1)var h=t.feed.entry[s].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(u.indexOf("-1)h=p.find("img:first").attr("src").replace("s72-c","s1600");else h=no_image;n+='

'+i+'
'+l+''+m+"

"}n+="
",$(".zune-trigger .HTML .widget-content span.zune-lposts").each(function(){$(this).attr("data-no")==e&&$(this).parent().html(n)})}})}),$(".zune-trigger .HTML .widget-content span.zune-label").each(function(){var e=$(this).attr("data-label"),t=$(this).attr("data-no");$.ajax({url:"/feeds/posts/default/-/"+e+"?alt=json-in-script&max-results="+t,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}var i=t.feed.entry[s].title.$t,l=(t.feed.entry[s].category[0].term,t.feed.entry[s].author[0].name.$t),d=t.feed.entry[s].published.$t,o=d.substring(0,4),c=d.substring(5,7),f=d.substring(8,10),m=month_format[parseInt(c,10)]+" "+f+", "+o,u=t.feed.entry[s].content.$t,p=$("
").html(u);if(u.indexOf("//www.youtube.com/embed/")>-1)var h=t.feed.entry[s].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(u.indexOf("-1)h=p.find("img:first").attr("src").replace("s72-c","s1600");else h=no_image;n+='

'+i+'
'+l+''+m+"

"}n+="
",$(".zune-trigger .HTML .widget-content span.zune-label").each(function(){$(this).attr("data-label")==e&&$(this).parent().html(n)})}})}),$(document).ready(function(){$('span[name="author-social"]').before($(".post-author-social .widget-content").html()),$(".post-author-social .widget-content").html(""),$('span[name="author-post"]').before($(".post-author-widget .widget-content").html()),$(".post-author-widget .widget-content").html("")}),$(".zune-comment").click(function(){$("html, body").animate({scrollTop:$("#put-your-comment").offset().top},1e3)}),$(".FeaturedPost .post-summary").map(function(){if($(this).find(".image")){var e=$(this).find(".image").attr("src");$(this).attr("style",";")}$(this).append("

")}),$(document).ready(function(){$("#related-posts").each(function(){var e,t,a,n=$(this),s=n.text();e=n,t=s,a=3,$.ajax({url:"/feeds/posts/default/-/"+t+"?alt=json-in-script&max-results="+a,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}var i=t.feed.entry[s].title.$t,l=t.feed.entry[s].content.$t,d=$("
").html(l);if(l.indexOf("https://www.youtube.com/embed/")>-1||l.indexOf("https://www.youtube.com/embed/")>-1)var o=t.feed.entry[s].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else o=l.indexOf("-1?d.find("img:first").attr("src").replace("s72-c","s600"):"https://1.bp.blogspot.com/-eAeO-DYJDws/Vkqtj4HFBFI/AAAAAAAAB0o/Q5OLsyONXM0/s1600-r/nth.png";n+='

'+i+"

"}n+="
",e.html(n)}})})}),$(".Label a").attr("href",function(e,t){return t.replace(t,t+"?&max-results="+perPage)}),$(".item .post-body img").parent("a").css("margin","0 auto!important");var s="[full_width]",o="[left_sidebar]",u="[right_sidebar]";$(".post *").replaceText(s,""),$(".post-body *").replaceText(o,""),$(".post-body *").replaceText(u,"");

 if(randompoststhumb.indexOf('s72-c') != -1){
        randompoststhumb = randompoststhumb.replace('s72-c','w450');
      }
            } else {
                randompoststhumb = "https://2.bp.blogspot.com/-IO-XEI1LgEs/VmPNKFp0BhI/AAAAAAAACOg/_JrYHMBXV5w/s1600-r/nothumb.jpg"
            }
        }

Answer: The problem is that on line 6 you have an extra } character but you already have one on line 5.
$(document).ready(function(){$(".header-search > .fa-search").click(function(){$("#search-bar .search-form").slideDown("",function(){}),$(".header-search > .fa-search").toggleClass("active"),$(".header-search > .fa-times").toggleClass("active")}),$(".header-search > .fa-times").click(function(){$("#search-bar .search-form").slideUp("",function(){}),$(".header-search > .fa-search").toggleClass("active"),$(".header-search > .fa-times").toggleClass("active")}),$("#menu .widget").attr("style","display:block!important;"),$("#menu a.mega-link").map(function(){var e=$(this),t=e.attr("href");if(t=t.toLowerCase(),e.hasClass("mega-link")){var a=e.text();$.ajax({url:"/feeds/posts/default/-/"+a+"?alt=json-in-script&max-results=4",type:"get",dataType:"jsonp",success:function(t){e.closest("li").addClass("isMega hasSubmenu");for(var n=0;n<t.feed.link.length;n++){var s=t.feed.link[n],r=s.rel,i=s.type;if("alternate"==r&&"text/html"==i){var l=s.href+"?&max-results="+perPage;e.attr("href",l)}}var d=t.feed.openSearch$totalResults.$t,o=t.feed.openSearch$startIndex.$t,c=t.feed.openSearch$itemsPerPage.$t;if(d>4);else;var f=Math.ceil(d/c);if(t.feed.entry){var m="

';for(n=0;n<t.feed.entry.length;n++){var u=t.feed.entry[n];if(u.media$thumbnail)-1!==(p=u.media$thumbnail.url).indexOf("/s72-c")&&(p=p.replace("/s72-c","/s1600")),-1!==p.indexOf("img.youtube.com")&&(p=p.replace("/default.jpg","/maxresdefault.jpg"));else var p="https://4.bp.blogspot.com/-wPwjv7-YYGY/Wc98wlDT8qI/AAAAAAAAAEE/mH8YkPl8qJAH9FMuFKcShQvXXYMmVyrIgCLcBGAs/s1600/notfound.png";for(var h=u.title.$t,g=0;g<u.link.length;g++)if("alternate"==u.link[g].rel)var b=u.link[g].href;m=m+'

'+h+"

"}m+="

",e.after(function(){$(this).after(m);var e=$(this).closest(".isMega");e.find(".mega-prev").click(function(){var e=$(this).closest("ul");e.find(".pixel-mega-loading").fadeIn(0);var t=e.attr("data-label"),a=Number(e.attr("data-start")),n=Number(e.attr("data-cstage")),s=(Number(e.attr("data-stages")),Number(e.attr("data-itemnums")));if(a-=s,n-1<=1?$(this).addClass("disable"):$(this).removeClass("disable"),e.find(".mega-next").removeClass("disable"),n>1){var r="",i="/feeds/posts/default/-/"+t+"?alt=json-in-script&start-index="+a+"&max-results="+s;$.ajax({url:i,type:"get",dataType:"jsonp",success:function(t){if(e.attr("data-start",a),e.attr("data-cstage",n-1),t.feed.entry){for(var s=0;s<t.feed.entry.length;s++){var i=t.feed.entry[s];if(i.media$thumbnail)-1!==(l=i.media$thumbnail.url).indexOf("/s72-c")&&(l=l.replace("/s72-c","/s1600")),-1!==l.indexOf("img.youtube.com")&&(l=l.replace("/default.jpg","/maxresdefault.jpg"));else var l="https://4.bp.blogspot.com/-wPwjv7-YYGY/Wc98wlDT8qI/AAAAAAAAAEE/mH8YkPl8qJAH9FMuFKcShQvXXYMmVyrIgCLcBGAs/s1600/notfound.png";for(var d=i.title.$t,o=0;o<i.link.length;o++)if("alternate"==i.link[o].rel)var c=i.link[o].href;r=r+'

'+d+"

"}e.find(".mega-inner").html(r),setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}},error:function(t){setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}})}}),e.find(".mega-next").click(function(){var e=$(this).closest("ul");e.find(".pixel-mega-loading").fadeIn(0);var t=e.attr("data-label"),a=Number(e.attr("data-start")),n=Number(e.attr("data-cstage")),s=Number(e.attr("data-stages")),r=Number(e.attr("data-itemnums"));if(a+=r,n+1==s?$(this).addClass("disable"):$(this).removeClass("disable"),n>=1?e.find(".mega-prev").removeClass("disable"):e.find(".mega-prev").addClass("disable"),s>n){var i="",l="/feeds/posts/default/-/"+t+"?alt=json-in-script&start-index="+a+"&max-results="+r;$.ajax({url:l,type:"get",dataType:"jsonp",success:function(t){if(e.attr("data-start",a),e.attr("data-cstage",n+1),t.feed.entry){for(var s=0;s<t.feed.entry.length;s++){var r=t.feed.entry[s];if(r.media$thumbnail)-1!==(l=r.media$thumbnail.url).indexOf("/s72-c")&&(l=l.replace("/s72-c","/s1600")),-1!==l.indexOf("img.youtube.com")&&(l=l.replace("/default.jpg","/maxresdefault.jpg"));else var l="https://4.bp.blogspot.com/-wPwjv7-YYGY/Wc98wlDT8qI/AAAAAAAAAEE/mH8YkPl8qJAH9FMuFKcShQvXXYMmVyrIgCLcBGAs/s1600/notfound.png";for(var d=r.title.$t,o=0;o<r.link.length;o++)if("alternate"==r.link[o].rel)var c=r.link[o].href;i=i+'

'+d+"

"}e.find(".mega-inner").html(i),setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}},error:function(t){setTimeout(function(){e.find(".pixel-mega-loading").fadeOut()},1e3)}})}})})}},error:function(e){}})}})}),$(document).ready(function(){$(".zune-ran-zunebt span").each(function(){$.ajax({url:"/feeds/posts/default?alt=json-in-script",type:"get",dataType:"jsonp",success:function(e){e=e.feed.entry.length-3,0==(e=Math.floor(Math.random()*(e-0+1))+0)&&(e=Math.floor(Math.random()*(e-0+1))+1),$.ajax({url:"/feeds/posts/default?alt=json-in-script&start-index="+e+"&max-results=1",type:"get",dataType:"jsonp",success:function(e){for(var t="",a="",n=0;n<e.feed.entry.length;n++){for(var s=0;s<e.feed.entry[n].link.length;s++)if("alternate"==e.feed.entry[n].link[s].rel){t=e.feed.entry[n].link[s].href;break}a+=''}$(".zune-ran-zunebt span").html(a)}})}})})}),$(".ticker .HTML .widget-content").each(function(){var e=$(this).find("span").attr("data-no")||"",t=$(this).find("span").attr("data-label")||"",a=$(this).find("span").attr("data-type")||"";null!=a&&a.match("zune-")?$.ajax({url:"/feeds/posts/default?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(e){for(var t="",a="
",n=0;n<e.feed.entry.length;n++){for(var s=0;s<e.feed.entry[n].link.length;s++)if("alternate"==e.feed.entry[n].link[s].rel){t=e.feed.entry[n].link[s].href;break}var r=e.feed.entry[n].title.$t,i=e.feed.entry[n].category[0].term,l=e.feed.entry[n].content.$t,d=$("
").html(l);if(l.indexOf("//www.youtube.com/embed/")>-1)var o=e.feed.entry[n].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(l.indexOf("-1)o=d.find("img:first").attr("src").replace("s72-c","s1600");else o=no_image;a+='

'+i+'
'+r+"

"}a+="
",$(".ticker .widget-content").each(function(){$(this).html(a),$(this).prev("h2").prepend(''),$(this).find("ul").webTicker()})}}):a.match("label")&&$.ajax({url:"/feeds/posts/default/-/"+t+"?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(e){for(var t="",a="
",n=0;n<e.feed.entry.length;n++){for(var s=0;s<e.feed.entry[n].link.length;s++)if("alternate"==e.feed.entry[n].link[s].rel){t=e.feed.entry[n].link[s].href;break}var r=e.feed.entry[n].title.$t,i=e.feed.entry[n].category[0].term,l=e.feed.entry[n].content.$t,d=$("
").html(l);if(l.indexOf("//www.youtube.com/embed/")>-1)var o=e.feed.entry[n].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(l.indexOf("-1)o=d.find("img:first").attr("src").replace("s72-c","s1600");else o=no_image;a+='

'+i+'
'+r+"

"}a+="
",$(".ticker .HTML .widget-content").each(function(){$(this).html(a),$(this).prev("h2").prepend(''),$(this).find("ul").webTicker()})}})}),$(".featured .HTML .widget-content").each(function(){var e=$(this).find("span").attr("data-label"),t=($(this).find("span").attr("data-no"),$(this).prev("h2").text(),$(this).parent().attr("id"));$(this).find("span").attr("data-type").match("blsm")&&$.ajax({url:"/feeds/posts/default/-/"+e+"?alt=json-in-script&max-results=3",type:"get",dataType:"jsonp",success:function(e){var a="",n='
';if(e.feed.entry){for(var s=0;s<e.feed.entry.length;s++){for(var r=0;r<e.feed.entry[s].link.length;r++)if("alternate"==e.feed.entry[s].link[r].rel){a=e.feed.entry[s].link[r].href;break}if("content"in e.feed.entry[s])var i=e.feed.entry[s].content.$t;else if("summary"in b_rc)i=e.feed.entry[s].summary.$t;else i="";(i=i.replace(/<\S[^>]*>/g,"")).length>120&&(i=i.substring(0,100)+"...");var l=e.feed.entry[s].title.$t,d=e.feed.entry[s].category[0].term,o=e.feed.entry[s].author[0].name.$t,c=e.feed.entry[s].published.$t,f=c.substring(0,4),m=c.substring(5,7),u=c.substring(8,10),p=month_format[parseInt(m,10)]+" "+u+", "+f,h=e.feed.entry[s].content.$t,g=$("
").html(h);if(h.indexOf("//www.youtube.com/embed/")>-1)var b=e.feed.entry[s].media$thumbnail.url;else if(h.indexOf("-1)b=g.find("img:first").attr("src");else b=no_image;n+=0==s?'

'+d+'

'+l+'
'+o+''+p+"

":'

'+l+'
'+p+'

'}n+="
"}$(".featured .HTML .widget-content").each(function(){$(this).parent().attr("id")==t&&($(this).html(n),$(this).parent().addClass("blsm"),$(this).parent().addClass("zunebt"),$(".featured").addClass("comload").removeClass("preload"),$(this).find(".zunebt-img,.zune-img").each(function(){$(this).attr("style",function(e,t){return t.replace("/default.jpg","/hqdefault.jpg")}).attr("style",function(e,t){return t.replace("s72-c","s1600")})}))})}})}),$(".post-home-image .post-thumb a").attr("style",function(e,t){return t.match("hqdefault.jpg")?t.replace("/hqdefault.jpg","/hqdefault.jpg"):t.match("default.jpg")?t.replace("/default.jpg","/hqdefault.jpg"):t.match("s72-c")?t.replace("/s72-c","/s1600"):t.match("w72-h72-p-nu")?t.replace("/w72-h72-p-nu","/s1600"):t.replace("https://3.bp.blogspot.com/-Yw8BIuvwoSQ/VsjkCIMoltI/AAAAAAAAC4c/s55PW6xEKn0/s1600-r/nth.png",no_image)}),$(document).ready(function(){var e=$("#sidetabs #tabside1 .widget h2").text();$(".menu-tab .item-1 a").text(e);var t=$("#sidetabs #tabside2 .widget h2").text();$(".menu-tab .item-2 a").text(t);var a=$("#sidetabs #tabside3 .widget h2").text();$(".menu-tab .item-3 a").text(a),$("#tabside1 .widget h2,#tabside2 .widget h2,#tabside3 .widget h2,#tabside1 .widget-title,#tabside2 .widget-title,#tabside3 .widget-title").remove(),$(this).find(".menu-tab li").addClass("hide-tab"),$(".sidetabs").tabslet({mouseevent:"click",attribute:"href",animation:!0}),0===$(".sidetabs .widget").length&&$(".sidetabs").remove()}),$(document).ready(function(){$(".cmm-tabs").simplyTab({active:1,fx:"fade",showSpeed:400,hideSpeed:400}),$(".blogger-tab").append($("#comments")),$(".cmm-tabs.simplyTab .wrap-tab").wrap("
")}),$(".PopularPosts ul li img").attr("src",function(e,t){return t.match("hqdefault.jpg")?t.replace("/hqdefault.jpg","/hqdefault.jpg"):t.match("default.jpg")?t.replace("/default.jpg","/hqdefault.jpg"):t.match("s72-c")?t.replace("/s72-c","/s1600"):t.match("w72-h72-p-nu")?t.replace("/w72-h72-p-nu","/s1600"):t.replace("https://3.bp.blogspot.com/-Yw8BIuvwoSQ/VsjkCIMoltI/AAAAAAAAC4c/s55PW6xEKn0/s1600-r/nth.png",no_image)}),$(document).ready(function(){$('span[name="author-social"]').before($(".post-author-social .widget-content").html()),$(".post-author-social .widget-content").html(""),$('span[name="author-post"]').before($(".post-author-widget .widget-content").html()),$(".post-author-widget .widget-content").html(""),$('a[name="ad-post-top"]').before($("#adwidegt2 .widget-content").html()),$("#adwidegt2 .widget-content").html(""),$('a[name="ad-post-bottom"]').before($("#adwidegt3 .widget-content").html()),$("#adwidegt3 .widget-content").html("")}),$(".zune-trigger .HTML .widget-content span.zune-recenetcomment").each(function(){var e=$(this).attr("data-no");$.ajax({url:"/feeds/comments/default?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length&&s!=t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}if("content"in t.feed.entry[s])var i=t.feed.entry[s].content.$t;else if("summary"in b_rc)i=t.feed.entry[s].summary.$t;else i="";(i=i.replace(/<\S[^>]*>/g,"")).length>70&&(i=i.substring(0,50)+"...");var l=t.feed.entry[s].author[0].name.$t,d=t.feed.entry[s].author[0].gd$image.src;if(d.match("https://img1.blogblog.com/img/blank.gif"))var o="https://img1.blogblog.com/img/anon36.png";else if(d.match("https://img2.blogblog.com/img/b16-rounded.gif"))o="https://img1.blogblog.com/img/anon36.png";else o=d;n+='

'+l+'"'+i+'"
'}n+='

',$(".zune-trigger .HTML .widget-content span.zune-recenetcomment").each(function(){$(this).attr("data-no")==e&&$(this).parent().html(n)})}})}),$(".zune-trigger .HTML .widget-content span.zune-lposts").each(function(){var e=$(this).attr("data-no");$.ajax({url:"/feeds/posts/default?alt=json-in-script&max-results="+e,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}var i=t.feed.entry[s].title.$t,l=(t.feed.entry[s].category[0].term,t.feed.entry[s].author[0].name.$t),d=t.feed.entry[s].published.$t,o=d.substring(0,4),c=d.substring(5,7),f=d.substring(8,10),m=month_format[parseInt(c,10)]+" "+f+", "+o,u=t.feed.entry[s].content.$t,p=$("
").html(u);if(u.indexOf("//www.youtube.com/embed/")>-1)var h=t.feed.entry[s].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(u.indexOf("-1)h=p.find("img:first").attr("src").replace("s72-c","s1600");else h=no_image;n+='

'+i+'
'+l+''+m+"

"}n+="
",$(".zune-trigger .HTML .widget-content span.zune-lposts").each(function(){$(this).attr("data-no")==e&&$(this).parent().html(n)})}})}),$(".zune-trigger .HTML .widget-content span.zune-label").each(function(){var e=$(this).attr("data-label"),t=$(this).attr("data-no");$.ajax({url:"/feeds/posts/default/-/"+e+"?alt=json-in-script&max-results="+t,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}var i=t.feed.entry[s].title.$t,l=(t.feed.entry[s].category[0].term,t.feed.entry[s].author[0].name.$t),d=t.feed.entry[s].published.$t,o=d.substring(0,4),c=d.substring(5,7),f=d.substring(8,10),m=month_format[parseInt(c,10)]+" "+f+", "+o,u=t.feed.entry[s].content.$t,p=$("
").html(u);if(u.indexOf("//www.youtube.com/embed/")>-1)var h=t.feed.entry[s].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else if(u.indexOf("-1)h=p.find("img:first").attr("src").replace("s72-c","s1600");else h=no_image;n+='

'+i+'
'+l+''+m+"

"}n+="
",$(".zune-trigger .HTML .widget-content span.zune-label").each(function(){$(this).attr("data-label")==e&&$(this).parent().html(n)})}})}),$(document).ready(function(){$('span[name="author-social"]').before($(".post-author-social .widget-content").html()),$(".post-author-social .widget-content").html(""),$('span[name="author-post"]').before($(".post-author-widget .widget-content").html()),$(".post-author-widget .widget-content").html("")}),$(".zune-comment").click(function(){$("html, body").animate({scrollTop:$("#put-your-comment").offset().top},1e3)}),$(".FeaturedPost .post-summary").map(function(){if($(this).find(".image")){var e=$(this).find(".image").attr("src");$(this).attr("style",";")}$(this).append("

")}),$(document).ready(function(){$("#related-posts").each(function(){var e,t,a,n=$(this),s=n.text();e=n,t=s,a=3,$.ajax({url:"/feeds/posts/default/-/"+t+"?alt=json-in-script&max-results="+a,type:"get",dataType:"jsonp",success:function(t){for(var a="",n='
',s=0;s<t.feed.entry.length;s++){for(var r=0;r<t.feed.entry[s].link.length;r++)if("alternate"==t.feed.entry[s].link[r].rel){a=t.feed.entry[s].link[r].href;break}var i=t.feed.entry[s].title.$t,l=t.feed.entry[s].content.$t,d=$("
").html(l);if(l.indexOf("https://www.youtube.com/embed/")>-1||l.indexOf("https://www.youtube.com/embed/")>-1)var o=t.feed.entry[s].media$thumbnail.url.replace("/default.jpg","/hqdefault.jpg");else o=l.indexOf("-1?d.find("img:first").attr("src").replace("s72-c","s600"):"https://1.bp.blogspot.com/-eAeO-DYJDws/Vkqtj4HFBFI/AAAAAAAAB0o/Q5OLsyONXM0/s1600-r/nth.png";n+='

'+i+"

"}n+="
",e.html(n)}})})}),$(".Label a").attr("href",function(e,t){return t.replace(t,t+"?&max-results="+perPage)}),$(".item .post-body img").parent("a").css("margin","0 auto!important");var s="[full_width]",o="[left_sidebar]",u="[right_sidebar]";$(".post *").replaceText(s,""),$(".post-body *").replaceText(o,""),$(".post-body *").replaceText(u,"");

 if(randompoststhumb.indexOf('s72-c') != -1){
        randompoststhumb = randompoststhumb.replace('s72-c','w450');
      }
            } else { // Delete the extra '}' character
                randompoststhumb = "https://2.bp.blogspot.com/-IO-XEI1LgEs/VmPNKFp0BhI/AAAAAAAACOg/_JrYHMBXV5w/s1600-r/nothumb.jpg"
            }
        }

Also it would be best if you beautify your code.


Exibir Interstitial ao clicar no botão home da ToolBar

Question: Tentei implementar a exibição de um banner interstitial no botão home  das minhas activitys mas não funcionou corretamente.
Utilizei
<code> @Override
 public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

   if (id == R.id.home){

      if (interstitialAd.isLoaded()) {
          interstitialAd.show();
      }else{
          finish();
      }
   }
}
</code>
Só que dessa forma o banner não aparece no click e sim apenas ao fechar o app.
Qual e forma correta de exibir o banner ao clicar no botão home?
QUESTÃO CORRIGIDA E FUNCIONANDO
OBs.: A configuração para a exibição do botão home eu fiz direto no manifest, não necessitando setar a toolbar na activity propriamente dita, bastando incluir o código abaixo para pegar a ação no botão home da toolbar.
MANIFEST
<code>    <activity
        android:name=".MinhaActivitySecundaria"
        android:screenOrientation="portrait"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:windowSoftInputMode="adjustResize"
        android:parentActivityName=".MainActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity" />
    </activity>
</code>
INCLUIR O CÓDIGO ABAIXO NA ACTIVITY SECUNDÁRIA
Lembre-se de utilizar a extensão AppCompatActivity
<code>@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

   if (id == android.R.id.home){

      if (interstitialAd.isLoaded()) {
          interstitialAd.show();
          finish();
      }else{
          finish();
      }
   }
   return true;
}
</code>
Answer: Henqsan,
Você deve usar o id abaixo que é o id correto para o back button da activity.
<code>    if (id == android.R.id.home){
         doSomethink();
    }
</code>
Lembrando que se você estiver usando Toolbar tem seta-lá.
<code>    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
</code>
Comment: Obrigado pela ajuda!

Eu estou setando o botão back home direto no manifest e estou utilizando  a extensão AppCompatActivity. Portanto, eu não seto a toolbar nas activitys secundárias, apenas na MainActivity.
Comment: mas isto resolveu seu problema ?
Comment: Infelizmente não resolveu.
Comment: Voltei para retificar o meu comentário feito no post do Ezequiel Messore. Pois além de não me atentar à forma correta de verificar a id `android.R.id.home` eu havia esquecido de chamar o `return true`. Agora está funcionando certinho. Obrigado!


For any $S \subseteq \mathbf{R}$, if $\partial S$ denotes the boundary of $S$, prove that $\partial(\partial S) \subseteq \partial S$.

Question: I am self-learning Real Analysis from Understanding Analysis by Stephen Abbott. I learnt the trick of constructing a $\delta$-neighborhood of a random point $y \in (x - \epsilon, x+ \epsilon)$ to always reside in this $\epsilon$-neighborhood of $x$.
I tried to write a proof for the below assertion, and would like to ask if my proof checks out.

For any $S \subseteq \mathbf{R}$, if $\partial S$ denotes the boundary of $S$, prove that $\partial(\partial S) \subseteq \partial S$.

My Attempt.
Let $x$ be an element of $\partial(\partial S)$.
By definition of the boundary of a set $S$, for every $\epsilon > 0$, the open interval $(x - \epsilon, x + \epsilon)$ contains at least one element of $\partial S$ and at least one element of $(\partial S)^C$.
We are interested to prove that, $\forall \epsilon>0$, the open interval $(x - \epsilon, x + \epsilon)$ contains at least one element of $S$ and at least one element of $S^C$.
Pick an arbitrary element $y \in (x - \epsilon, x + \epsilon)$, such that $y \in \partial S$. Then, for every $\delta > 0$, the open interval $(y - \delta, y + \delta)$ contains atleast one element of $S$ and atleast one element of $S^C$. If we choose,
\begin{align*}
\delta = \delta_0 = \min \left\{\frac{y - (x-\epsilon)}{2},\frac{(x + \epsilon) - y}{2}\right\}
\end{align*}
Then, $(y - \delta_0,y + \delta_0) \subseteq (x - \epsilon, x + \epsilon)$.
So, we found a small $\delta_0$-neighborhood, $(y - \delta_0,y + \delta_0)$ inside of $(x - \epsilon, x + \epsilon)$, which contains at least one element of $S$ and at least one element of $S^C$, for all $\epsilon>0$.
Consequently, we have shown that, $\forall \epsilon > 0$, $(x - \epsilon, x + \epsilon)$ contains at least one element of $S$ and at least one element of $S^C$.
So, $x \in \partial S$.
Hence, $\partial(\partial S) \subseteq \partial S$. This closes the proof.
Answer: What you did looks good to me.
Below another proof, that you can use depending on what you already proved.
If you know that:

The frontier $\partial S$ of a subset $S$ is closed.
$ \partial A \subseteq B$ whenever $ A \subseteq B$ and $B$ is closed.

Then is it almost immediate as $\partial S \subseteq \partial S$ and $\partial S$ is closed. Therefore $\partial(\partial S) \subseteq \partial S$.
Comment: @BCLC According to [Wikipedia](https://en.wikipedia.org/wiki/Boundary_(topology)) is seems that *frontier* is used by some authors. As I'm not a native English (that may be obvious in my answer...) I'm not able to elaborate on which situations *frontier* is used vs. *boundary*. I'm French and *frontière* is mainly used in topology... This is why I'm tempted to use *frontier* in English.
Comment: 'Some authors (for example Willard, in General Topology) use the term frontier instead of boundary in an attempt to avoid confusion with a different definition used in algebraic topology and the theory of manifolds.' --> ah thanks. convenient. frontier vs boundary. nice.
Comment: frontier = topological boundary? haven't heard that before but it is a convenient term to distinguish from manifold boundary, i guess
Comment: I have seen Fr($S$) for $\partial S$ on this site, and not only by the French.
Answer: Let $X$ be any topological space. And for any $T\subseteq X$ let $T^c=X\setminus T.$ For any $S\subseteq X$ we have $$(i)\quad\partial S=\overline S \cap \overline {S^c},$$ which is closed, as it is an intersection of closed sets. So we have $$(ii)\quad \overline {\partial S}=\partial S.$$ Therefore, by replacing $S$ with $\partial S$ in $(i),$ and applying $(ii),$ we have $$\partial (\partial S)=\overline {\partial S}\cap \overline {(\partial S)^c}\subseteq$$ $$ \subseteq \overline {\partial S}=$$ $$=\partial S.$$
Comment: $\partial T\subseteq T$ for any closed set $T$.
Comment: In any topological space $X$ and any $S\subseteq X$, the sets $int(S),\,int (S^c),\,\partial S$ are pair-wise disjoint and their union is $X$.


Watchguard VLAN Head-Grasping needed

Question: I am trying to wrap my head around setting up my new watchguard M400. Here's what I need to figure out and what I've done so far.
My ISP provided me with a P2P IP, which I plugged into my interface (107. address). They also have me a block of IPs on a different subnet (completely different range too, 50. range) so keep that in the back of your mind. I also have a private (192.) that I want to use.
I have interface0 setup with the P2P IP (external) and an internal setup (trusted) with a simple 192.
I have a few switches behind the firewall:
Switch one (name:CORE1) is a 48 port, which will have many VLANs on it. Port one if obviously going to be the firewall (trunk) port.
Port two will be an uplink to another switch (name:CORE2, VLAN=4) for my separate camera network.
Some other ports will be private to the office that the firebox is housed in (trusted network) VLAN=5
The rest of the ports on the 48 port (CORE1) will be plugged into servers that need public IPs assigned to them, and when communicating with the outside, they need to show their public IPs, not the IP of my firebox (which would normally show the P2P address)
I think I got this to work (sort of) but creating an optional interface, assigning the first IP of my block to it, then I set another one of the block to my laptop and it worked all magically.
The problem is with that approach I would need to have multiple connecting going from the firebox to the switch which I don't think would work.
I tried setting up VLAN on the box, but it wants me to create a seperate interface for that which I am not sure I want to do?
I have included a makeshift drawing I made to help you visualize:

Now, my interfaces on my firebox look as follows:

So you can see the three interfaces. I just made the "VLANUplink" just to test, so that is junk. I really would like to condense all that down as much as I can.
I tried playing with the VLAN properties, where it wanted me to setup a special interface for VLANs for some reason, thats why you see the "vlanuplink" interface. Again,this is all trash.
And for those of you who refer me to online articles, I have read over many articles all night and I am not allowed to post them since I don't have enough "reputation". But trust me on that.
I did find this awesome article here:
Since I can't post link, go to google type "use public Ip address behind xtm" it's the first PDF.
And I think I would be considered "scenario 1" but correct me if I am wrong. Please refer to my makeshift network map I drew to compare. I want everything behind the firewall, but nothing behind the firewall to communicate with each other, that is why the vlanning is there.
Comment: Anyone? I am surprised nobody knows how to do this.
Comment: Are you wanting the watchguard to do your vlan routing? This is really a gateway device, and you usually make out better by having a layer 3 switch or core router handle this.
Answer: As this has just been bumped to the front page - you probably didn't need the "use public IP address behind XTM" scenarios, and did want to make new VLAN interfaces.
Set Interface 0 as External, allocate the public address as you did.
Make new VLAN interfaces, one for each VLAN. Set them as 'optional', give the firewall an internal IP address in each VLAN and maybe configure DHCP if needed. Each device in a VLAN should get the firewall's IP in that VLAN as its gateway - using the firewall to serve DHCP will do that automatically, if they're configured manually or something else does DHCP you'll have to set that.
Then set Interface 1 as a VLAN interface, and tag it to send traffic for all the VLANs you just defined.
To get distinct public IP addresses for some servers, add 1-1 NAT entries to map the public IPs to the server's internal IPs.
Make firewall policies for traffic between the VLANs, e.g. Allow "Any from VLAN2 to VLAN5", whatever's appropriate to create the separate camera network and private office network.
On the switch side set it as a VLAN trunk port.
This setup only takes one cable from firewall to switch (although it's easy to add more cables if you need extra bandwidth - configure Interface 2 as a VLAN trunk and tag some VLANs onto Interface 1 and some onto Interface 2).
Answer: You're asking a lot here, and on some fairly specific hardware, so I'll just give some high-level guidance to keep this reasonable.
First, the servers. You want them to have public IPs. That's fine and good. However, they are also part of your internal network; give them internal IPs. Then you need to setup port forward policies on the watchguard to map the public IP for each server and forward the traffic to the correct internal address. You probably want to pair this with setting up records in your local DNS server so that any domains you have publicly pointed to the internet IPs will be pointed to the local IPs if you do the lookup from inside your network.
Next, the switches. Your diagram depicts the CORE1 switch as much more important/central than the others. If it can, you should have this switch do your vlan routing, instead of the watchguard. That switch should have a virtual interface for each vlan, and whatever is doing dhcp on your network should hand out the appropriate interface IP on the switch as the default gateway to all devices. The switch itself should set the watchguard's internal IP as it's gateway, and have routes to all of the vlans. Then set the port going to the watchguard as a trunk port, or just tag all of the vlans except the one for the watchguard's internal IP (that one will be an untagged member).
Now on the watchguard you to set up NAT policies and routes for each of your internal networks, and of course the port forward policies for the servers. You should only need to configure two of your interfaces to accomplish this, and a single cable will be able to handle all of this traffic.
Unfortunately, I can't be more specific than that. I have successfully configured a Watchguard 400 series in this manner, but only as a demo that we later returned, and so I can't be more specific at this time on where to go for each option. (FWIW, we're using Untangle now instead, and I like much better).
Comment: I know this is old now, but something bumped it to the front page again, so I thought it was worth adding a few words.

Watchguard VLAN Head-Grasping needed


Opening file using mPdfViewer.fromFile(file) shows an empty pdf

Question: I'm having a problem with opening file using PDFViewer library.
Inside DocumentCreator class:
1. First I create the document using iText library and it works perfectly fine and it writes document to the given directory.
2. Then I create an object of a File to display it using PDFViewer.
try {
        mDocument = new Document(); // new Document created
        String path = "/" + FirebaseAuth.getInstance().getCurrentUser().getUid() + "-" + recipe.getTitle() + ".pdf";
        String fullPath = Environment.getExternalStorageDirectory() + "/recipes" + path;
        mPdfWriter = PdfWriter.getInstance(mDocument, new FileOutputStream(fullPath));
        doTheWriting(recipe, activity);
        Log.d("OK", "done");

        mMyRecipeFile = new File(fullPath);

    }
    catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Inside same class (DocumentCreator) I created getter method for mMyRecipeFile.
public File getRecipeFile() {
    return mMyRecipeFile;
}

After that in the DocumentTestFragment,
I created PDFView, called mPdfView, and I try to open this file.
mPdfView.fromFile(mDocCreator.getRecipeFile());

The problem is it is displaying an empty document, which is weird, because I opened Android Device Monitor, opened given file and it's not empty.
Comment: `Log.d("OK", "done");` ?? Are you shure? You are not even checking the return value of doTheWriting().
Comment: `(Environment.getExternalStorageDirectory() + "/recipes" + path)` You construct that path yet another time: `String fullPath = Environment.getExternalStorageDirectory() + "/recipes" + path;`. Not good programming. Do it once. And use more times.
Comment: Yep, thanks for that. Agree, it's not the best programming. It is just a test, so I can see where the problem is. doTheWriting() works perfectly fine, the file is created and it's written. The problem is that the pdf file exists in given directory, but when I create an object of File it shows me empty pdf.
Comment: Will external apps show your pdf file ok?
Comment: Can you display other pdf files with pdf viewer?
Comment: 1. I'm testing it on virtual device
2.Yes, pdfViewer displays pdfs from assets, tried it on some random pdf file.
3. I opened the file on my mac and its written
Comment: From assets. Ok. But also other pdf's from file?
Comment: Please use a real device.
Comment: Ok I'll work on it more and let you know if I figured it out. It's not opening different pdf file, when I use pdfView.fromFile(file).
Answer: I found out what caused a problem. The thing is that I wrote:
PdfView.fromFile(file)

While proper form is
PdfView.fromFile(file).load();

It works just fine now.


how can we define a global method?

Question: I'm new to IOS Development and I'm unable to figure out how we can define a global method.
I have a function
func getBanners(){} declared in a class.
I want to declare and use it globally.
Comment: Methods cannot be defined globally but functions can.
Comment: Globals are usually a Bad Smell. Explain what you're _really_ trying to accomplish and perhaps we can suggest a better way.
Answer: you have several options here you could add it on global scope or introduce a class/enum with a static func. I personally would go with the enum, if functionality has to be available in another module, you have to set the access control to public.
Cheers
Sir SwiftAlot ✌
// on global scope
func getBanners() -> [Banners] {
    return []
}

// class static func
class Banners {
   static func get() -> [Banners] {
       return []
   }
}

// enum with static func
enum Banners {
    static func get() -> [Banner] {
        return []
    }
}

Answer: If you have a function defined in a class
class Foo
{
    func bar() { ... }
}

provided you have an instance of the class, you can call it anywhere in the module:
Foo()->bar()

Note that Foo() creates an instance of Foo and then bar is called on that instance.
If you want to be able to call the function without an instance, you need to mark it static:
class Foo
{
    static func bar() { ... }
}

To call it you need to specify the class:
Foo.bar()

Note that you can no longer access instance variables because the function is associated with the class itself, not a specific instance of the class.
Also, it doesn't need to be a class. You can also have static functions in enums and structs
You can also have a bare function not declared in a class:
func bar() { ... }

Call it like this
bar()

The above is not generally considered good practice, although there are occasions where it is used in the Standard library e.g. print() and zip()
To complicate things further, there are keywords to control the visibility of where you can call the function from
private func alpha() { ... } // Visible only in the current source file
internal func beta() { ... } // Visible only in the current module
func gamma() { ... }         // default visibility is internal so visible in the current module
public func delta() { ... } // visible anywhere in your program

how can we define a global method?


What's the negation of $\exists$ $x\in A$ and $y\in B$ s.t. $C$?

Question: What's the negation of $\exists$ $x\in A$ and $y\in B$ s.t. $C$? Is "$\forall x\in A$ or $\forall y\in B$, $\neg C$" correct?
Answer: The statement is written with a confusing "and", which leads to error.  It is typically not meaningful to have disjunction or conjunction among quantifiers.  The original statement should be interpreted as $$\exists x\in A~ \exists y\in B, C$$
whose negation is $$\forall x \in A~ \forall y\in B, \neg C$$
Answer: The negation of $~~~~~~\exists (x,y)\in (A\times B):C~~~~~~$ is $~~~~~~\forall (x,y)\in (A\times B):\lnot C$.
The "and" and "or" in the original question are somewhat misleading, particularly if one does not make the dependence of $C$ on $x$ and $y$ explicit.


How to break an array into blocks

Question: I have an array that represents points in a cuboid. It is a one dimensional array, which uses the following indexing function to realise the 3 dimensions:
int getCellIndex(int ix, int iy, int iz) {
    return ix + (iy * numCellsX) + (iz * numCellsX * numCellsY);
}

The number of cells in the domain is:
numCells = (numX + 2) * (numY + 2) * (numZ + 2)

Where numX/numY/numZ are the number of cells in the X/Y/Z direction. The +2 in each direction is to create padding cells around the outside of the domain. The number of cells in each direction is give by:
numX = 5 * numY
numZ = numY/2
numY = userInput

For each cell, I want to calculate a new value for that cell based upon it's neighbours value (i.e. a stencil), where it's neighbours are above, below, left, right, front and back. However, I only want to do this calculation for cells that aren't bad. I have a boolean array that tracks if a cell is bad. This is what the computation currently looks like:
for(int z = 1; z < numZ+1; z++) {
    for(int y = 1; y < numY+1; y++) {
        for(int x = 1; x < numX+1; x++) {
            if(!isBadCell[ getCellIndex(x,y,z) ] {
                // Do stencil Computation
            }
        }
    }
}

This is not great performance wise. I want to be able to vectorize the loop to improve performance, however I can't because of the if statement. I know if cells are bad in advance and this does not change throughout the computation. I'd like to split the domain up into blocks, preferably 4x4x4 blocks, so that I can calculate a priori per block if it contains bad cells, and if so process it as usual, or if not, use an optimized function that can take advantage of vectorization e.g.
for(block : blocks) {
    if(isBadBlock[block]) {
        slowProcessBlock(block) // As above
    } else {
        fastVectorizedProcessBlock(block)
    }
}

NOTE: It is not required for the blocks to physically exist i.e. this could be achieved by changing the indexing function, and using different indexes to loop over the array. I'm open to whatever works best.
The fastVectorizedProcessBlock() function would look similar to the slowProcessBlock() function, but with the if statement remove (since we know it doesn't contain bad cells), and a vectorization pragma.
How can I split up my domain into blocks so that I can accomplish this? It seems tricky because a) the number of cells in each direction are not equal, b) we need to take into account the padding cells, as we must never attempt to calculate their value, as this would lead to a memory access that is out of bounds.
How can I then process the blocks that don't contain bad cells without using an if statement?
EDIT:
This is the idea I originally had:
for(int i = 0; i < numBlocks; i++) { // use blocks of 4x4x4 = 64
    if(!isBadBlock[i]) {
        // vectorization pragma here
        for(int z = 0; z < 4; z++) {
            for(int y = 0; y < 4; y++) {
                for(int x = 0; x < 4; x++) {
                    // calculate stencil using getCellIndex(x,y,z)*i
                }
             }
         }
     } else {
         for(int z = 0; z < 4; z++) {
            for(int y = 0; y < 4; y++) {
                for(int x = 0; x < 4; x++) {
                    if(!isBadCell[i*getCellIndex(x,y,z)]) {
                    // calculate stencil using getCellIndex(x,y,z)*i
                }
             }
         }
     }
 }

Cells would now be stored in blocks, i.e. all the cells in the first 4x4x4 block would be stored in pos 0-63, then all cells in the second block would be stored in pos 64-127 etc.
However, I don't think will work if the numX/numY/numZ values are not kind. For example, what if numY = 2, numZ = 1 and numX = 10? The for loops would expect the z direction to be at least 4 cells deep. Is there a good way to get past this?
UPDATE 2 - Here is what the stencil computation looks like:
if ( isBadCell[ getCellIndex(x,y,z) ] ) {
  double temp = someOtherArray[ getCellIndex(x,y,z) ] +
                    1.0/CONSTANT/CONSTANT*
                    (
                      - 1.0 * cells[ getCellIndex(x-1,y,z) ]
                      - 1.0 * cells[ getCellIndex(x+1,y,z) ]
                      - 1.0 * cells[ getCellIndex(x,y-1,z) ]
                      - 1.0 * cells[ getCellIndex(x,y+1,z) ]
                      - 1.0 * cells[ getCellIndex(x,y,z-1) ]
                      - 1.0 * cells[ getCellIndex(x,y,z+1) ]
                      + 6.0 * cells[ getCellIndex(x,y,z) ]
                      );
  globalTemp += temp * temp;
  cells[ getCellIndex(x,y,z) ] += -omega * temp / 6.0 * CONSTANT * CONSTANT;
}

Comment: Side tip: rather than `ix + (iy * numCellsX) + (iz * numCellsX * numCellsY)`, use a chained computation `ix + numCellsX*(iy + iz * numCellsY)`, one less `*`.
Comment: If all blocks aren't 4x4x4, then how do you determine which ones that aren't? Do you allocate an array with the exact size `X*Y*Z` or do you round this so that you end up with exactly `(X*Y*Z) / (4*4*4)` cubes? I think you need to clear this out before the question can be answered.
Comment: @Lundin Blocks that aren't 4x4x4 could be padded to make them 4x4x4, however then I'd need to know which cells are padded cells when I loop through each block, which would require an if statement stopping vectorization. Any ideas how to get around this?
Comment: I am assuming that these are set up something like `int cells[numCellsZ][numCellsY][numCellsX]`... in which case case can't you just take the offset from cells[0][0][0] by doing something like `(int *) &cells[z][y][x] - (int *) &cells[0][0][0]`
Comment: @technosaurus the cells are declared cells[numCells] where numCells = (numX+2) + (numY+2) + (numZ+2). See the indexing function for the layout. Can you explain your solution a little bit more? I think it would only give me the global index of a cell, which is what the get index function does.
Comment: An if-statement by itself does not preclude vectorization, there just won't be a per-lane branch so some lanes will do useless work, and you'd have to able to ignore those lanes (in this case I imagine it's OK to write back an unchanged value). If you post the stencil computation we'd have more to work with there, the problem does not depend solely on the "if".
Comment: You say you use 7 cells centered around each cell to compute the stencil value.  Do you make sure the border cells have an appropriate value for the computation to give correct values for the edge cells?  Also do bad cells participate in the computation when the center cell is no bad?
Comment: @chqrlie There is a layer of padding around the domain such that the outer layer of non-padding cells will use the value of the padded cells in their stencil computation. The padded cells have their values normalized separately after each run through the domain. Essentially, bad cells are clustered together, into squares/cuboids for example. For good cells that have a boundary with bad cells, the value of the bad cell is used, however this means that only the outer layer of bad cells are used. The values of the outer layer of bad cells are updated after each run through the domain.
Comment: @harold Please see update 2 for the stencil computation. I should say that it is required that these cells are broken up into blocks, as the blocks are going to be used somewhere else.
Comment: 1) make the address-calculation function `static` to allow inlining. 2) use unsigned indexes, preferrably `size_t` 3) avoid conditional jumps inside loops (except maybe for `break` and `continue` )
Comment: Blocking will not help much. You can solve almost all of your problems by switching from a boolean map of bad cells to a list of bad cell indexes. See my suggestions below for details. (It's not really an answer, because you list *blocking* as a prerequisite. Which, in my experience, does not help here.)
Answer: Where does getCellIndex() retrieve the values of numCellX and numCellY? It would be better to pass them as arguments instead of relying on global variables, and to make this function static inline to allow the compiler to optimize.
static line int getCellIndex(int ix, int iy, int iz, int numCellsX, numCellsY) {
    return ix + (iy * numCellsX) + (iz * numCellsX * numCellsY);
}

for (int z = 1; z <= numZ; z++) {
    for (int y = 1; y <= numY; y++) {
        for (int x = 1; x <= numX; x++) {
            if (!isBadCell[getCellIndex(x, y, z, numX + 2, numY + 2)] {
                // Do stencil Computation
            }
        }
    }
}

You could also remove all multiplications with some local variables:
int index = (numY + 2) * (numX + 2);  // skip top padding plane
for (int z = 1; z <= numZ; z++) {
    index += numX + 2;  // skip first padding row
    for (int y = 1; y <= numY; y++) {
        index += 1;   // skip first padding col
        for (int x = 1; x <= numX; x++, index++) {
            if (!isBadCell[index] {
                // Do stencil Computation
            }
        }
        index += 1;   // skip last padding col
    }
    index += numX + 2;   // skip last padding row
}

Whether these directions are promissing or not depends a lot on the actual computations performed to get the stencil value.  You should post that too.
If you can change the format of the boolean array for bad cells, it would be useful to pad the lines to a multiple of 8 and to use horizontal padding of 8 columns to improve alignment.  Making the boolean array an array of bits allows to check for 8, 16, 32 or even 64 cells at a time with a single test.
You can adjust the array pointer to use 0 based coordinates.
Here is how it would work:
int numCellsX = 8 + ((numX + 7) & ~7) + 8;
int numCellsY = 1 + numY + 1;
int numCellsXY = numCellsX * numCellsY;
// adjusted array_pointer
array_pointer = allocated_pointer + 8 + numCellsX + numCellsXY;
// assuming the isBadCell array is 0 based too.
for (int z = 0, indexZ = 0; z < numZ; z++, indexZ += numCellsXY) {
    for (int y = 0, indexY = indexZ; y < numY; y++, indexY += numCellsX) {
        for (int x = 0, index = indexY; x <= numX - 8; x += 8, index += 8) {
            int mask = isBadCell[index >> 3];
            if (mask == 0) {
                // let the compiler unroll computation for 8 pixels with
                for (int i = 0; i < 8; i++) {
                   // compute stencil value for x+i,y,z at index+i
                }
            } else {
                for (int i = 0; i < 8; i++, mask >>= 1) {
                    if (!(mask & 1)) {
                       // compute stencil value for x+i,y,z at index+i
                    }
                }
            }
        }
        int mask = isBadCell[index >> 3];
        for (; x < numX; x++, index++, mask >>= 1) {
            if (!(mask & 1)) {
                // compute stencil value for x,y,z at index
            }
        }
    }
}

EDIT:
The stencil function uses too many calls to getCellIndex.  Here is how to optimize it using the index value computed in the above code:
// index is the offset of cell x,y,z
// numCellsX, numCellsY are the dimensions of the plane
// numCellsXY is the offset between planes: numCellsX * numCellsY

if (isBadCell[index]) {
    double temp = someOtherArray[index] +
                1.0 / CONSTANT / CONSTANT *
                ( - 1.0 * cells[index - 1]
                  - 1.0 * cells[index + 1]
                  - 1.0 * cells[index - numCellsX]
                  - 1.0 * cells[index + numCellsX]
                  - 1.0 * cells[index - numCellsXY]
                  - 1.0 * cells[index + numCellsXY]
                  + 6.0 * cells[index]
                );
    cells[index] += -omega * temp / 6.0 * CONSTANT * CONSTANT;
    globalTemp += temp * temp;
}

precomputing &cells[index] as a pointer might improve the code, but the compile should be able to detect this common subexpression and generate efficient code already.
EDIT2:
Here is a tiled approach: you can add the missing arguments, most sizes are assumed to be global but you should probably pass a pointer to a context structure with all these values. It uses isBadTile[] and isGoodTile[]: arrays of boolean telling if a given tile has all cells bad and all cells good respectively.
void handle_tile(int x, int y, int z, int nx, int ny, int nz) {
    int index0 = x + y * numCellsX + z * numCellsXY;
    // skipping a tile with all cells bad.
    if (isBadTile[index0] && nx == 4 && ny == 4 && nz == 4)
        return;
    // handling a 4x4x4 tile with all cells OK.
    if (isGoodTile[index0] && nx == 4 && ny == 4 && nz == 4) {
        for (int iz = 0; iz < 4; iz++) {
            for (int iy = 0; iy < 4; iy++) {
                for (int ix = 0; ix < 4; ix++) {
                    int index = index0 + ix + iy * numCellsX + iz + numCellsXY;
                    // Do stencil computation using `index`
                }
            }
        }
    } else {
        for (int iz = 0; iz < nz; iz++) {
            for (int iy = 0; iy < ny; iy++) {
                for (int ix = 0; ix < nx; ix++) {
                    int index = index0 + ix + iy * numCellsX + iz + numCellsXY;
                    if (!isBadCell[index] {
                        // Do stencil computation using `index`
                }
            }
        }
    }
}

void handle_cells() {
    int x, y, z;
    for (z = 1; z <= numZ; z += 4) {
        int nz = min(numZ + 1 - z, 4);
        for (y = 1; y <= numY; y += 4) {
            int ny = min(numY + 1 - y, 4);
            for (x = 1; x <= numX; x += 4) {
                int nx = min(numX + 1 - x, 4);
                handle_tile(x, y, z, nx, ny, nz);
            }
        }
    }
}

Here is a function to compute the isGoodTile[] array. The only offsets correctly computed correspond to values of x multiples of 4 + 1, y and z less than 3 from their maximum values.
This implementation is sub-optimal as fewer elements could be computed. Incomplete border tiles (less than 4 from the edge) could be flagged as not good to skip the good case with a single case. The test for bad tiles could work for these edge tiles if the isBadTile array was properly computed for the edge tiles, which is currently not the case.
void computeGoodTiles() {
    int start = 1 + numCellsX + numCellsXY;
    int stop = numCellsXY * numCellsZ - 1 - numCellsX - numCellsXY;

    memset(isGoodTile, 0, sizeof(*isGoodTile) * numCellsXY * numCellsZ);
    for (int i = start; i < stop; i += 4) {
        isGoodTile[i] = (isBadCell[i + 0] | isBadCell[i + 1] |
                         isBadCell[i + 2] | isBadCell[i + 3]) ^ 1;
    }
    for (int i = start; i < stop - 3 * numCellsX; i += 4) {
        isGoodTile[i] = isGoodTile[i + 0 * numCellsX] &
                        isGoodTile[i + 1 * numCellsX] &
                        isGoodTile[i + 2 * numCellsX] &
                        isGoodTile[i + 3 * numCellsX];
    }
    for (int i = start; i < stop - 3 * numCellsXY; i += 4) {
        isGoodTile[i] = isGoodTile[i + 0 * numCellsXY] &
                        isGoodTile[i + 1 * numCellsXY] &
                        isGoodTile[i + 2 * numCellsXY] &
                        isGoodTile[i + 3 * numCellsXY];
    }
}

void computeBadTiles() {
    int start = 1 + numCellsX + numCellsXY;
    int stop = numCellsXY * numCellsZ - 1 - numCellsX - numCellsXY;

    memset(isBadTile, 0, sizeof(*isBadTile) * numCellsXY * numCellsZ);
    for (int i = start; i < stop; i += 4) {
        isBadTile[i] = isBadCell[i + 0] & isBadCell[i + 1] &
                       isBadCell[i + 2] & isBadCell[i + 3];
    }
    for (int i = start; i < stop - 3 * numCellsX; i += 4) {
        isBadTile[i] = isBadTile[i + 0 * numCellsX] &
                       isBadTile[i + 1 * numCellsX] &
                       isBadTile[i + 2 * numCellsX] &
                       isBadTile[i + 3 * numCellsX];
    }
    for (int i = start; i < stop - 3 * numCellsXY; i += 4) {
        isBadTile[i] = isBadTile[i + 0 * numCellsXY] &
                       isBadTile[i + 1 * numCellsXY] &
                       isBadTile[i + 2 * numCellsXY] &
                       isBadTile[i + 3 * numCellsXY];
    }
}

Comment: Thanks for the answer, I'm going to go through it in a bit more detai, but I just wanted to ask how this would be extended so that we can skip whole blocks of cells? The main reason for the blocks optimisation is that we can calculate before the whole computation if a certain region/block contains badCells, and if not, we can use an optimised function to process it, and in other computations not shown here, we can actually skip these blocks altogether. Considering that the badCells take up a small fraction of the domain, this should make the code much faster. Does this make sense?
Comment: @JC2188: I updated the code for horizontal blocks of 8 pixels. You could easily extend this for 16, 32 or 64 pixels, but it is row oriented. If the bad blocks are clusters with smaller X dimensions but extend in the other dimensions, a more complicated approach could give good results, but I suspect you might need a different structure for the `isBadCell` array.
Comment: @JC2188: Optimizing the inner loop should provide for substantial improvements. Try it first without the bit oriented stuff.
Comment: Ok, I think I understand how this works. Would it be possible to do this so that rather than it being row-oriented, it is tiled? I think this would give better cache behaviour
Comment: @JC2188: it may give better cache behavior or it may not, only careful benchmarking will tell you which is more performant, and only for the architecture, sizes and compiler tested.  A tiled approach can be attempted by adding more loops, but the incremental computation of the index computation would become more complicated and costly, probably not worthwhile.  I shall post such an alternative.
Comment: @JC2188: I updated the answer with a tile version. If you can compute an `isBadTile` array to use in `handle_tile`, you can remove the test at the pixel level and see if it further improves the performance. Computing this array is a bit tricky but you only need to compute values for `x`, `y`, `z` values equal to 1 modulo 4.
Comment: Thanks for the update. I've tried to run the earlier version of EDIT2, however I think something is wrong with it. After each iteration, I'm expecting a value to be ~ 3x10^-6 and for it to stay roughly of that order throughout the computation, but for some reason, I'm a value of 12 on the first run, then this grows and grows throughout the computation. This might be something to do with how I've converted your example though. Shall I post the code here or can I message you with it? It's a lot of code to put on here, and I don't think it will be relevant once debugged.
Comment: I should also mention that the computation of good and bad cells/tiles only happens right at the beginning of the program, so there is no real need to optimise these.
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/134328/discussion-between-jc2188-and-chqrlie).
Answer: Although OP requires an approach using blocking, I would suggest against it.
You see, each consecutive sequence of cells (the 1D cells along the X axis) is already such a block. Rather than make the problem simpler, blocking just replaces the original problem with smaller copies of fixed size, repeated over and over.
Simply put, blocking does not help at all with the real problem at hand. It should not be a requisite feature of a solution at all.
Instead, I would suggest avoiding the root problem altogether -- just in a different fashion.
You see, rather than have a "bad cell" flag for each cell that you need to test (once for each cell, no less), you can keep a (sorted) list of the bad cells' indexes. Then you can process the entire data set at once, followed by a fix-up loop over the cells listed in the bad cells' index list.
Also note that unless you work on a copy of the cell values, the order in which you compute the new cell values will affect the result. This is almost certainly not what you want.
So, here's my suggestion:
#include <stdlib.h>
#include <errno.h>

typedef struct {
    /* Core cells in the state, excludes border cells */
    size_t   xsize;
    size_t   ysize;
    size_t   zsize;

    /* Index calculation: x + y * ystride + z * zstride */
    /* x is always linear in memory; xstride = 1 */
    size_t   ystride; /* = xsize + 2 */
    size_t   zstride; /* = ystride * (ysize + 2) */

    /* Cell data, points to cell (0,0,0) */
    double  *current;
    double  *previous;

    /* Bad cells */
    size_t   fixup_cells;  /* Number of bad cells */
    size_t  *fixup_index;  /* Array of bad cells' indexes */

    /* Dynamically allocated memory */
    void    *mem[3];
} lattice;

void lattice_free(lattice *const ref)
{
    if (ref) {
        /* Free dynamically allocated memory, */
        free(ref->mem[0]);
        free(ref->mem[1]);
        free(ref->mem[2]);
        /* then initialize/poison the contents. */
        ref->xsize = 0;
        ref->ysize = 0;
        ref->zsize = 0;
        ref->ystride = 0;
        ref->zstride = 0;
        ref->previous = NULL;
        ref->current = NULL;
        ref->fixup_cells = 0;
        ref->fixup_index = NULL;
        ref->mem[0] = NULL;
        ref->mem[1] = NULL;
        ref->mem[2] = NULL;
    }
}

int lattice_init(lattice *const ref, const size_t xsize, const size_t ysize, const size_t zsize)
{
    const size_t  xtotal = xsize + 2;
    const size_t  ytotal = ysize + 2;
    const size_t  ztotal = zsize + 2;
    const size_t  ntotal = xtotal * ytotal * ztotal;
    const size_t  double_bytes = ntotal * sizeof (double);
    const size_t  size_bytes = xsize * ysize * zsize * sizeof (size_t);

    /* NULL reference to the variable to initialize? */
    if (!ref)
        return EINVAL;

    /* Initialize/poison the lattice variable. */
    ref->xsize = 0;
    ref->ysize = 0;
    ref->zsize = 0;
    ref->ystride = 0;
    ref->zstride = 0;
    ref->previous = NULL;
    ref->current = NULL;
    ref->fixup_cells = 0;
    ref->fixup_index = NULL;
    ref->mem[0] = NULL;
    ref->mem[1] = NULL;
    ref->mem[2] = NULL;

    /* Verify size is nonzero */
    if (xsize < 1 || ysize < 1 || zsize < 1)
        return EINVAL;

    /* Verify size is not too large */
    if (xtotal <= xsize || ytotal <= ysize || ztotal <= zsize ||
        ntotal / xtotal / ytotal != ztotal ||
        ntotal / xtotal / ztotal != ytotal ||
        ntotal / ytotal / ztotal != xtotal ||
        double_bytes / ntotal != sizeof (double) ||
        size_bytes / ntotal != sizeof (size_t))
        return ENOMEM;

    /* Allocate the dynamic memory needed. */
    ref->mem[0] = malloc(double_bytes);
    ref->mem[1] = malloc(double_bytes);
    ref->mem[2] = malloc(size_bytes);
    if (!ref->mem[0] || !ref->mem[1] || !ref->mem[2]) {
        free(ref->mem[2]);
        ref->mem[2] = NULL;
        free(ref->mem[1]);
        ref->mem[1] = NULL;
        free(ref->mem[0]);
        ref->mem[0] = NULL;
        return ENOMEM;
    }

    ref->xsize = xsize;
    ref->ysize = ysize;
    ref->zsize = zsize;

    ref->ystride = xtotal;
    ref->zstride = xtotal * ytotal;

    ref->current = (double *)ref->mem[0] + 1 + xtotal;
    ref->previous = (double *)ref->mem[1] + 1 + xtotal;

    ref->fixup_cells = 0;
    ref->fixup_index = (size_t *)ref->mem[2];

    return 0;
}

Note that I prefer the x + ystride * y + zstride * z index calculation form over x + xtotal * (y + ytotal * z), because the two multiplications in the former can be done in parallel (in a superscalar pipeline, on architectures which can do two unrelated integer multiplications at the same time on a single CPU core), whereas in the latter, the multiplications have to be sequential.
Note that ref->current[-1 - ystride - zstride] refers to the current cell value at cell (-1, -1, -1), i.e. the border cell diagonal from the origin cell (0, 0, 0). In other words, if you have a cell (x, y, z) at index i, then
     i-1 is the cell at (x-1, y, z)
     i+1 is the cell at (x+1, y, z)
     i-ystride is the cell at (x, y-1, z)
     i+ystride is the cell at (x, y+1, z)
     i-zstride is the cell at (x, y, z-1)
     i+zstride is the cell at (x, y, z-1)
     i-ystride is the cell at (x, y-1, z)
     i-1-ystride-zstride is the cell at (x-1, y-1, z-1)
     i+1+ystride+zstride is the cell at (x+1, y+1, z+1)
and so on.
The ref->fixup_index array is large enough to list all cells, except for border cells.  It is a good idea to keep it sorted (or sort it after building it), because that helps with cache locality.
If your lattice has periodic boundary conditions, you can use six 2D loops, twelve 1D loops, and eight copies to copy the first and last valid cells to the border, before starting a new update.
Your update cycle is therefore essentially:

Compute or fill borders in ->current.
Swap ->current and ->previous.
Compute all cells for ->current using data from ->previous.
Loop over the ->fixup_cells indexes in ->fixup_index, and recalculate corresponding ->current cells.

Note that in step 3, you can do it linearly for all indexes between 0 and xsize-1 + (ysize-1)*ystride + (zsize-1)*zstride, inclusive; that is, including about 67% of the border cells. They are relatively few compared to the entire volume, and having a single linear loop is likely faster than skipping over the border cells -- especially if you can vectorize the computation. (Which, in this case, is nontrivial.)
You can even split the work for multiple threads, by giving each thread a continous set of indexes to work on. Because you read from ->previous and write to ->current, the threads won't trample over each other, although there may be some cacheline ping-pong if a thread reaches the end of its region while another is at the start of its region; because of how the data is oriented (and cache lines are just a few -- typically 2, 4, or 8 -- cells in size), that ping-pong should not be an issue in practice. (Obviously, no locks are needed.)
This particular problem is not really new in any way. Modeling Conway's Game of Life or square- or cubic-lattice Ising model, as well as implementing many other lattice models, involve the same problem (but often with Boolean data rather than doubles, and without "bad cells").
Answer: The way you currently have it set up, you can simply get the index by using a 3d array as follows:
#include <sys/types.h>
#define numX 256
#define numY 128
#define numZ 64
//Note the use of powers of 2 - it will simplify things a lot

int cells[numX][numY][numZ];

size_t getindex(size_t x, size_t y,size_t z){
  return (int*)&cells[x][y][z]-(int*)&cells[0][0][0];
}

This will lay out the cells like:
[0,0,0][0,0,1][0,0,2]...[0,0,numZ-1]
[0,1,0][0,1,1][0,1,2]...[0,1,numZ-1]
...
[0,numY-1,0][0,numY-1,1]...[0,1,numZ-1]
...
[1,0,0][1,0,1][0,0,2]...[1,0,numZ-1]
[1,1,0][1,1,1][1,1,2]...[1,1,numZ-1]
...
[numX-1,numY-1,0][numX-1,numY-1,1]...[numX-1,numY-1,numZ-1]

So efficient loops would look like:

for(size_t x=0;x<numX;x++)
  for(size_t y=0;y<numY;y++)
    for(size_t z=0;z<numZ;z++)
      //vector operations on z values

But, if you want to split it into 4x4x4 blocks, you could just use a 3d array of 4x4x4 blocks something like:
#include <sys/types.h>
#define numX 256
#define numY 128
#define numZ 64

typedef int block[4][4][4];
block blocks[numX][numY][numZ];
//add a compiler specific 64 byte alignment to  help with cache misses?

size_t getblockindex(size_t x, size_t y,size_t z){
  return (block *)&blocks[x][y][z]-(block *)&blocks[0][0][0];
}

I reordered the indices to x,y,z just so I could keep them straight in my head, but make sure that you order them so that the last one is the one you operate on a series of in your innermost for loops.
Answer: I think you may nest a couple of similar set of loops. Something like this:
for(int z = 1; z < numZ+1; z+=4) {
    for(int y = 1; y < numY+1; y+=4) {
        for(int x = 1; x < numX+1; x+=4) {
            if(!isBadBlock[ getBlockIndex(x>>2,y>>2,z>>2) ]) {
                for(int zz = z; zz < z + 4 && zz < numZ+1; zz++) {
                   for(int yy = y; yy < y + 4 && yy < numY+1; yy++) {
                      for(int xx = z; xx < x + 4 && xx < numX+1; xx++) {
                         if(!isBadCell[ getCellIndex(xx,yy,zz) ]) {
                             // Do stencil Computation
                            }
                        }
                    }
                }
            }
        }
    }
}

Comment: Inn the above code, `isBadBlock` is an array of booleans indicating the blocks will all cells bad. The OP seems to assume there are more blocks with all cells good and wants to optimize these first. I guess both approaches could be combined depending on the distribution of bad cells.

How to break an array into blocks


SVN commit txn-current-lock on Mountain Lion

Question: I have facing SVN problem in Mac OS X ..
When i am commit any file below are the error are generate.
svn: Commit failed (details follow):
svn: Can't get exclusive lock on file '/Volumes/SvnProject/db/txn-current-lock': Operation not supported
Comment: do you use a "file:///" protocol to a access a repository? Check this thread http://superuser.com/questions/401570/mac-svn-client-cant-commit-to-tortoise-svn-server
Comment: Yes i am using file:// protocol ...
Answer: On the SVN server, ensure that the owner and group of the repository (and all subfolders) are properly set.
For example, I created a repo by issuing the following from the SVN server as root:
svnadmin create /path/myrepo

Initially I was getting the txn-current-lock error from my SVN client.  On the SVN server, I noticed that /path/myrepo and all of its subfolders had owner:group of root:root.  To fix this, I issued the following from the SVN server:
chown -R newowner:newgroup

Ensure your newowner and newgroup items match the owner/group information being supplied by the SVN clients.
Important to make it recursive with the -R option.  This fixed the txn-current-lock error.


Android app and Web server

Question: I have an Android app, that needs to communicate with a webserver. However, I have no idea of how to do this. I do have a webserver., though I do not know how to use it(store/retrieve data). plz help me . any tips, advices will work for me. It is important. Thanks in advance.
Comment: [Google does not help you?](https://www.google.com/)
Comment: You can use an HttpClient:

HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(uri);
HttpResponse httpResponse = httpClient.execute(httpGet);
BufferedReader reader = new BufferedReader(
    new InputStreamReader(httpResponse.getEntity().getContent()));
// user reader to read & parse response
reader.close();
Comment: See also http://stackoverflow.com/questions/1047698/regarding-connecting-to-a-webserver-from-android so this is a duplicate? or do you need more info ? (and if so: what will it be?)
Answer: See This is only for reference .in that i just passing two variable to web service and receive the response form server as per condition.
At the server side i have mange PHP to accept POST request and response in JSON.
So create simple php web service. for that you will get idea form w3school or any other web resource . Now you are abel to do this task.
Native code for android is here.

Android app and Web server


How can i fetch the value from database in a simple module?

Question: I'm working in drupal 7 and I have tried all help but not able to fetch the value from database.
    function myModule_load($node){

    $result = db_query("SELECT * FROM {uc_auction_bids} WHERE nid = :nid", array(':nid' => 258,));
$record = $result->fetch();

    // print the fields/values of $record
print('
'); print_r($record); print('
');

and also
    function myModule_block_view($delta) {
       if (($node = menu_get_object()) && ($node->type === 'product')) {
        $results = db_query("SELECT * FROM {uc_auction_bids} WHERE nid = :nid", array(':nid' => $node->nid));
        $records = $results->fetchAllAssoc('bid');

        $content = ... // Format records here...

        return array(
          'subject' => t('Bids'),
          'content' => $content
        );   } }

I want to fetch the value in module and in the page, but not at the top of the drupal header
Comment: Did you try $result->execute() and then print_r ?
Answer: Something like this should work:
/**
 * Implements hook_block_view
 */
function MY_MODULE_block_view($delta = '') {

  if (($node = menu_get_object()) && ($node->type == 'product')) {
    $query = db_select('uc_auction_bids', 'bids');
    $query->fields('bids');
    $query->condition('nid', $node->nid);
    $result = $query->execute()->fetchAllAssoc('bid');

    // Debug
    drupal_set_message('
'.print_r($result,1).'
');

    $content = ''; // Format records here...

    return array(
      'subject' => t('Bids'),
      'content' => $content
    );
  }

}

Answer: To fetch values from database: you can try this.
   $query = db_select('uc_auction_bids', 'u');
   $query->fields('u', array('field1', 'field2')); // and other fields required
   $query->condition('nid', $nid_value, '=');
   $result = $query->execute();
   foreach ($result as $record) {

    //USE $record->field1;
    //USE $record->field2;
    // and so on

    }

Comment: hello sir but i m creating a module and i want to call this query in a function
Comment: you can put this inside a function. I gave only quering part.


Rename() function not working when attempting to add an extension to a file

Question: I have an extension-less file and I want to add an .avi extension to it. So I call this function after selecting the file via openfile dialog (I want to have the file opened after renaming):
int RenameVidAddExt(HWND hWnd, char oldname[MAX_PATH])
{
    int filenamesize=0, n=0;
    char extension [] = ".avi";
    char* newname;

    for (n=0 ; oldname[n]!=NULL ; n++)
    {
        filenamesize++;
    }

    newname = new char[filenamesize+sizeof(extension)];

    newname = oldname;
    strcat (newname, extension);
    //SetDlgItemTextA(hWnd, IDC_EDIT1, szFile);     //test print of filenameof selected file
    //SetDlgItemTextA(hWnd, IDC_EDIT2, newname);    //test print of newname
    rename(oldname,newname);
    return 0;
}

The filename just doesn't change and I don't know why. Test prints show that both oldname and newname contain correct strings (old without extension and new with it).
Comment: `new[]` count: 1. `delete[]` count: 0. Uh oh.  Have you considered `std::vector`?
Comment: Did you check the errno? http://msdn.microsoft.com/en-us/library/zw5t957f%28vs.71%29.aspx
Answer: Since you are using C++, consider also using std::string:
int RenameVidAddExt(HWND hWnd, char oldname[MAX_PATH])
{
    char extension [] = ".avi";
    std::string newname = oldname;

    newname += extension;

    rename(oldname, newname.c_str());

    return 0;
}

Some side notes:

Remember, when you use new or new[], you must use delete or delete[] later (when the object created with new or new[] is no longer needed).
When playing with strings, try and use std::string as much as possible. It will save you from having to handle memory manually, and they can be assigned / copied to other variables.
Rather than using new[], it is often recommended to use std::vector instead. Resize the vector to the desired size. When you require a pointer to the first element, use &vec[0]. The benefit to using a std::vector is that memory management is done for you.
Don't calculate the length of strings manually, use a function like strlen. Alternatively, the length of a std::string can be obtained with str.length().
Comment: Hi,
I know I have to delete[], I just didnt care about it when I realised the code is not working; I would simply add it in thenext step.
I have never worked with std::string but it really seems to be better option now so I will rewrite the code. Thank you very much for brief explaining of the basics of std::string
Answer: You can't copy a C-style string by assigning pointer values.  Your code dynamically creates a new buffer, then promptly orphans it by assigning to that pointer.
I suggest using std::string instead.  However, if you want to stay with the C-style strings,  try this:
newname = new char[filenamesize + sizeof(extension)];
strcpy(newname, oldname);   // Copies the original string character by character
strcat(newname, extension);

Good luck!
Comment: doesn't sizeof(extension) already include the null terminator?
Comment: @Pablo--whoops--you're right!  I was thinking it was a strlen, not a sizeof!  Correcting now...
Comment: Oh thanks, this worked.
I have never worked with it so far but I agree, std::string would be better as I have read something about it now.


How to deploy a Laravel-Vue project on shared server (GoDaddy)

Question: This is the first time I am developing a Laravel Vue app. When I use php artisan serve, everything works fine. But when I load it with http://localhost/myProject/public, assets are not loaded. My images are in img directory inside public folder. I was using blade templating to manage this issue when I use Laravel alone. But now I can't use blade since it is a Vue component. How can I run the project without php artisan serve? My Ultimate aim is to deploy the project in godaddy shared server. Please help me.
Comment: https://dev.to/asapabedi/deploying-laravel-5-applications-on-shared-hosting-without-the-use-of-ssh--16a6
Comment: Thank you brother, I have successfully deployed and half of my problem was solved. My project is done using Laravel and Vue. So now I can't send api request, gives a 404 error.
Comment: check my new added answer
Answer: Debug your application using 'php artisan serve' while you develop from your local machine.
When you publish it into godaddy,
compress the project folder (say 'my_project') and upload the zip file ('my_project.zip') to 'public_html' directory in godaddy.
unzip the folder.
Now the directory structure will be 'public_html/my_project...'
you will have a 'public' directory inside 'my_project'.
Now create a subdomain which points to the 'public' directory.
That's it. Now load the subdomain.
The assets and api's will work perfectly.
Answer: @ThasheelApps this is your solution to access api's.
Create a .htaccess file in root folder and paste the following code there:
<IfModule mod_rewrite.c>
  Options +FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

This issue occurs many times due index.php in url. if you try your api endpoint including index.php, it will work perfectly. to prevent this issue we need to follow above soution htaccess
Comment: Thank you, But unfortunately it did n't work for me. Still gives me the following error.

app.js:1 GET http://my_domain/api/profile 404 (Not Found)
app.js:1 Uncaught (in promise) Error: Request failed with status code 404
Comment: try `get` API in browser URL eg: `my_domain/index.php/api/profile`. Does it work?
Answer: just rungit clone [your_project_address] in the www folder and then run 'php artisan migrate', of course, you should have configured well.
Answer: Follow these steps:

zip your project after npm run dev and php artisan serve without
any error.
Go to your shared hosting location and outside fo public_html
make a folder name say myproject. Inside this folder extract all
your project files.
cut your public folder from  project folder on root, go to your
subdomain folder under public_html and paste.
go to index.php inside public folder and
    require DIR.'/../vendor/autoload.php'; and
    $app = require_once DIR.'/../bootstrap/app.php'; pointing to your project location on root.

That is all. Enjoy, if you have properly created and attached your DB to your project.


Find ideal width and height of n same rectangles inside a rectangle

Question: I have a rectangle, its width is a and its height is b
I want to cover a maximum of surface from that rectangle with n rectangles, those rectangles must have the same dimensions and respect a ratio of w on h
how can I compute the dimensions of the n rectangles ?
I tried the following
$$c = \sqrt{a*b* w/h \over n}$$
$$width = c * w$$
$$height = c * h$$
But it's not perfectly working because this is looking for covering the entire rectangle (so in some cases the result dimensions make a bigger rectangle then the rectangle ab
Answer:
Unless Fig. 1 depicts an example of what you are expecting, don't read any further, because the description given below is based on it.
It is assumed that $a$, $b$, $h$, $w$, and $n$ are given. Let the height of the small rectangles be $k$. Then, the width of the small rectangles is equal to $k\frac{w}{h}$. Now, we can find out how many small rectangles we need to cover the large rectangle as shown below
$$\mathrm{Nr.\space of\space small\space rectangles\space on\space a\space column} =n_c= \Big\lfloor \frac{b}{k}\Big\rfloor \le \frac{b}{k}\qquad\quad\space$$
$$\mathrm{Nr.\space of\space small\space rectangles\space on\space a\space row} = n_r=\Big\lfloor \frac{a}{k} \times \frac{h}{w}\Big\rfloor \le \frac{a}{k} \times \frac{h}{w}$$
$$\therefore\quad n = n_c\times n_r = \Big\lfloor \frac{b}{k}\Big\rfloor \times \Big\lfloor \frac{a}{k} \times \frac{h}{w}\Big\rfloor \le \frac{a}{k}\times \frac{b}{k}\times \frac{h}{w}.$$
As you see, the relationship between $n$ and the unknown $k$ has been obtained using floor functions. These functions prevent us from making $k$ the subject of an equation, which we need to determine both the height and the width of the small rectangles. Therefore, I think that your question cannot be resolved mathematically. However, one may find a solution experimentally.
Comment: I I have to test your solution experimentaly to be sure, tell me if I'm wrong but as I understood, you are sharing the area of the big rectangle in n parts, giving you the area of a small rectangle then apply the ratio to it to get its width and height of the small. Meaning that you are seeking for an equality between big rectangle area and the sum of the small rectangles areas. But in my problem there is one more constraint: the small rectangles can't be cut or rotate to fit the whole big rectangle, sometimes the sum of small rectangles areas could be less than the big rectangle area
Comment: So area of a small rectangle could be inferior to a * b / n
Comment: @Xeno I read your comments. I think I now know what you want. It is definitely not what I have given in my answer of yesterday. I hope to revise my answer in a few hours. So, please have patient.
Comment: @Xeno I have just posted a revised answer to your question. Please read it and let me know whether you agree with me or not.
Comment: Fig. 1 is exactly what I'm looking for, you answer seems really promising, I will take a closer look on it tomorrow !
Comment: thank you for the solution, I think I could implement something based on that, however do you think is there any mathematical way to know the width and height of a rectangle if n = 1 ?


SAS cannot save graphs to specified destination

Question: Why can't I save the graphs to specified file as expected? Could someone help me out on this? thanks very much.
Best regards,
Mi
%macro Corr(in,out,y,x,separateBy,titleString,xSize=900pt,ySize=600pt,saveDestination="c:\sas graph",saveResolution=400);
goptions reset=all hsize=&xSize vsize=&ySize;
ods graphics on;
ods listing gpath=&saveDestination image_dpi=&saveResolution;
ods graphics / imagename='Repeat' imagefmt=jpeg;

proc reg data=&in outest=&out simple edf;
    title "&titleString of #ByVal(_name_)";/*Double quotation required when macro variable present in title string*/
    model &y=&x / alpha=0.05 noprint;
    id bladeSerialNumber;
    by &separateBy;
    plot &y*&x;
run;

quit;

ods graphics off;
title '';
%mend;

*Invoke Example;
libname ro 'c:\sas output\ro';
%corr(ro.SUMMARY_SPLITBYITERATION_METHOD1,corrSummary,Iter2,Iter1,_name_,Repeatability);

Here are the partial notes from SAS:
%corr(ro.SUMMARY_SPLITBYITERATION_METHOD1,corrSummary,Iter2,Iter1,_name_,Repeatability);
WARNING: The variable _NAME_ or _TYPE_ exists in a data set that is not TYPE=CORR, COV, SSCP, etc.
NOTE: Graph's name, REG, changed to REG384. REG is already used or not a valid SAS name.
NOTE: Graph's name, REG, changed to REG112. REG is already used or not a valid SAS name.
NOTE: 29844 bytes written to C:\Users\mzhou7165825\AppData\Local\Temp\SEG8728\SAS Temporary Files\_TD9196_5K82J12A_\Prc2\reg384.png.
ERROR: Insufficient authorization to access C:\windows\system32\sasgraph.png
NOTE: The above message was for the following BY group:
      NAME OF FORMER VARIABLE=Amplitude10LVGA
NOTE: Graph's name, REG, changed to REG385. REG is already used or not a valid SAS name.
NOTE: Graph's name, REG, changed to REG113. REG is already used or not a valid SAS name.
Comment: I've gotten that from EG when I had the output was going to the listing destination. If you close that (either with menus, or perhaps `ODS listing close`) does that help?
Comment: thanks. ODS listing close helps to suppress the error but the graphs do not save to the destination.
Comment: Do you get a warning or error in the log?
Comment: there is only a warning message that WARNING: The variable _NAME_ or _TYPE_ exists in a data set that is not TYPE=CORR, COV, SSCP, etc.
Answer: First of all please make sure that the saveDestination="c:\sas graph" is pointing to an existing folder and that you assign a filename to the output.
Check:

if you are running sas locally, that your user has write access to the folder
if you are running sas on server, that the "server user" has write access to the folder.

Second, if the first sentence evaluates to false (and also sas is running locally) then create the folder with the required user access rights.
However if you are running sas remotely, you won't be able to write to your local computer, but to the server only. In case of windows server, you can use the following syntax to save your file:
[code start]
%let mypath = C:\Users\%sysfunc(dequote(&_CLIENTUSERID))\Documents\;

this
ods pdf file= "&mypath\yourfile.pdf";

or this
ods listing gpath = "&mypath\yourfile.jpeg";

*** your code***

ods _all_ close;

[code end]