Wednesday, February 28, 2018

php - Laravel regex validation for price OR empty




I am trying to make a regex for price OR empty.
I have the price part (Dutch uses comma instead of point) which actualy works



/^\d+(,\d{1,2})?$/


The regex above validates ok on the value 21,99



Now I try to add the empty part so the field can be... just empty ^$




/(^$|^\d+(,\d{1,2})?$)/


But Laravel starts to complain as soon as I change the regex:
"Method [validate^\d+(,\d{1,2})?$)/] does not exist."



Works ok:



$rules = [
'price' => 'regex:/^\d+(,\d{1,2})?$/'

];


Laravel says no...:



$rules = [
'price' => 'regex:/(^$|^\d+(,\d{1,2})?$)/'
];



Kenken9990 answer - Laravel doesn't break anymore but an empty value is still wrong:



$rules = [
'price' => 'regex:/^(\d+(,\d{1,2})?)?$/'
];

Answer



is this work ?



$rules = [

'price' => 'nullable|regex:/^(\d+(,\d{1,2})?)?$/'
];

javascript - Template literal trapped in a string variable

I also had this problem sometimes when I have my labels variables in another file, and those labels should have a template literal. I this cases I usually use a workaround to simulate this behaviour (take this code as a guide :D )




labels.js:



export default:{
labelWithSpeudoliteral: "text to {{change}}"
}


MyHelper.js:



    generateLiteral(s, params) {

const entries = Object.entries(params);
let sentence = s;
entries.forEach((entry) => {
const literal = `{{${entry[0]}}}`
sentence = sentence.replace(literal, entry[1]);
}
)
return sentence;
}



Now in my code I use this helper the following way:



console.log(generateLiteral(labels.labelWithSpeudoliteral, {'change': 'literal'})


And the result of the label should be:



text to literal



As you can see using the {{ }} symbols as marks, generateLiteral() use them and the params received to change the text value with the template literal. It is not the best way, but I hope it can help you.

c# - Trying to use a class as a property for other class

Usually, I only use a simple class to organize my code, but today I've tried to use a class inside another class as a property so it becomes even more organized, but I'm not being able to make it work.



This is the .cs file which contains the classes:



namespace TestZone
{

class Item
{
public Category Category1 { get; set; }
public Category Category2 { get; set; }
}

class Category
{
public string Title { get; set; }
public string Content { get; set; }

}
}


And this is the Program.cs file:



using System;

namespace TestZone
{

class Program
{
static void Main(string[] args)
{
Item myItem = new Item();
myItem.Category1.Title = "My title"; //This line throws an error.

Console.WriteLine(myItem.Category1.Title);
Console.ReadLine();
}

}
}


For some reason, the 10th line of Program.cs, where I try to assign a value to myItem.Category1.Title, this error shows up:




System.NullReferenceException: 'Object reference not set to an
instance of an object.'
TestZone.Item.Category1.get returned null.





I have also tried to put the 'Category' class inside the 'Item' class too and changed it to public like the code below, but still didn't work.



namespace TestZone
{
class Item
{
public Category Category1 { get; set; }
public Category Category2 { get; set; }



public class Category
{
public string Title { get; set; }
public string Content { get; set; }
}
}
}



I'm surely doing something wrong and I would appreciate if you could tell me what it is.

html - CSS stroke on half of web font

CSS stroke allows to outline a font.
I want to outline only 50% of a font.




I've seen a few workaround with JavaSCript to set css on half a letter, but i would like to this with CSS.



My goal is to able to add class to the the right star web font to look like the left full star. The image is 2 diffrent icons, I want to able to create the "half" look on the star with CSS stroke effect on the web font of the icon.



enter image description here



This is codepen that has a one icon without the stroke CSS effect, one with CSS stroke. How can I set in the css the so the stroke effect will create half icon "full" and other half "empty"?



.empty {

-webkit-text-fill-color: white;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: black;
}


enter image description here

javascript - The right way parse html to jQuery object

Answer


Answer




I want to parse a html string to jQuery object then find an element by ID.



I tried 3 ways bellow, but only the last works. I don't know why the others not works?



var html = "
";

// Not work, return 0
console.log($(html).find('#main').length);

// Not work, return 0
console.log($($.parseHTML(html)).find('#main').length);
// Works, return 1
console.log($("").html(html).find('#main').length);


Here is the sample:
http://jsfiddle.net/nbyofkam/2/


Answer



It's documented :





When passing in complex HTML, some browsers may not generate a DOM that exactly replicates the HTML source provided. As mentioned, jQuery uses the browser"s .innerHTML property to parse the passed HTML and insert it into the current document. During this process, some browsers filter out certain elements such as , </code>, or <code><head></code> elements. As a result, the elements inserted may not be representative of the original string passed.</p><br/></blockquote><br/><br/><p>As a result, <code>$(html)</code> is reduced to <code>"<div id="main"></div>"</code>. You can verify that by logging <code>$(html)[0].outerHTML</code>.</p><br/><br/><p>So you can't use <code>find</code> without wrapping it, which is what you do.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/javascript-right-way-parse-html-to.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/javascript-right-way-parse-html-to.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T14:13:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/javascript-right-way-parse-html-to.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=197823948879501571&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=197823948879501571&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=197823948879501571&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=197823948879501571&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=197823948879501571&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=197823948879501571&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='2145110294994007106' itemprop='postId'/> <a name='2145110294994007106'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/php-laravel-regex-validation-for-price.html'>php - Laravel regex validation for price OR empty</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-2145110294994007106' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><br/><p>I am trying to make a regex for price OR empty.<br/>I have the price part (Dutch uses comma instead of point) which actualy works</p><br/><br/><pre><code>/^\d+(,\d{1,2})?$/<br/></code></pre><br/><br/><p>The regex above validates ok on the value 21,99</p><br/><br/><p>Now I try to add the empty part so the field can be... just empty ^$</p><br/><br/><br/><pre><code>/(^$|^\d+(,\d{1,2})?$)/<br/></code></pre><br/><br/><p>But Laravel starts to complain as soon as I change the regex: <br/>"Method [validate^\d+(,\d{1,2})?$)/] does not exist."</p><br/><br/><p>Works ok:</p><br/><br/><pre><code>$rules = [<br/> 'price' => 'regex:/^\d+(,\d{1,2})?$/'<br/><br/>];<br/></code></pre><br/><br/><p>Laravel says no...:</p><br/><br/><pre><code>$rules = [<br/> 'price' => 'regex:/(^$|^\d+(,\d{1,2})?$)/'<br/>];<br/></code></pre><br/><br/><br/><p>Kenken9990 answer - Laravel doesn't break anymore but an empty value is still wrong:</p><br/><br/><pre><code>$rules = [<br/> 'price' => 'regex:/^(\d+(,\d{1,2})?)?$/'<br/>];<br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>is this work ?</p><br/><br/><pre><code>$rules = [<br/><br/> 'price' => 'nullable|regex:/^(\d+(,\d{1,2})?)?$/'<br/>];<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/php-laravel-regex-validation-for-price.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/php-laravel-regex-validation-for-price.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T11:21:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/php-laravel-regex-validation-for-price.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=2145110294994007106&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=2145110294994007106&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=2145110294994007106&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=2145110294994007106&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=2145110294994007106&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=2145110294994007106&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='5092929480359074246' itemprop='postId'/> <a name='5092929480359074246'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/the-dark-knight-rises-why-did-nolan.html'>the dark knight rises - Why did Nolan want to end the Batman series? - Movies & TV</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-5092929480359074246' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><br/><p>According to numerous sources, The Dark Knight Rises will be the end of the Batman series. I think all the three Batman movies directed by Nolan was successful and did well at the box office. Since his great success in Batman series, <strong><em>Why did Nolan want to end the Batman series?</em></strong> </p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>There are numerous magazine articles and interviews with Nolan in which he states that he always conceived his Batman films as a three-act story. He and his brother had the basic arc mapped out from the beginning, it was just a case of putting meat on the bones when the time came to write the next script.</p><br/><br/><p><a href="http://collider.com/christopher-nolan-speaks-updates-on-dark-knight-sequel-and-superman-man-of-steel/18819/">Quoting Nolan:</a></p><br/><br/><blockquote><br/> <p>Without getting into specifics, the key thing that makes the third film an great possibility for us is that we want to finish our story. And in viewing it as the finishing of a story rather than infinitely blowing up the balloon and expanding the story ... I’m very excited about the end of the film, the conclusion, and what we’ve done with the characters. My brother has come up with some pretty exciting stuff. Unlike the comics, these thing don’t go on forever in film and viewing it as a story with an end is useful. Viewing it as an ending, that sets you very much on the right track about the appropriate conclusion and the essence of what tale we’re telling. And it hearkens back to that priority of trying to find the reality in these fantastic stories. That’s what we do.</p><br/></blockquote><br/><br/><br/><p>BTW - DC and Warner really want to move on with their attempt at a Justice League movie, and Nolan's Batman does not fit into that scheme in any way; the character would need to be rebooted in order to allow the more fantastical elements of the JL stories to be told - right now he is too grounded.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/the-dark-knight-rises-why-did-nolan.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/the-dark-knight-rises-why-did-nolan.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T10:26:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/the-dark-knight-rises-why-did-nolan.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=5092929480359074246&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5092929480359074246&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5092929480359074246&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5092929480359074246&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5092929480359074246&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5092929480359074246&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='4886283523689236326' itemprop='postId'/> <a name='4886283523689236326'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/javascript-what-is-difference-between.html'>javascript - What is the difference between substr and substring?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-4886283523689236326' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>What is the difference between</p><br/><br/><pre><code>alert("abc".substr(0,2));<br/></code></pre><br/><br/><br/><p>and</p><br/><br/><pre><code>alert("abc".substring(0,2));<br/></code></pre><br/><br/><p>They both seem to output “ab”.</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>The difference is in the second argument. The second argument to <code>substring</code> is the index to stop at (but not include), but the second argument to <code>substr</code> is the maximum length to return.</p><br/><br/><p>Links?</p><br/><br/><br/><p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/substr" rel="noreferrer">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/substr</a></p><br/><br/><p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/substring" rel="noreferrer">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/substring</a></p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/javascript-what-is-difference-between.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/javascript-what-is-difference-between.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T10:07:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/javascript-what-is-difference-between.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=4886283523689236326&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4886283523689236326&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4886283523689236326&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4886283523689236326&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4886283523689236326&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4886283523689236326&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='643355526576795391' itemprop='postId'/> <a name='643355526576795391'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/c-what-difference-between-passing.html'>c++ - What's the difference between passing argument by value and by reference?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-643355526576795391' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><blockquote><br/> <br/></blockquote><br/><br/><br/><br/><br/><p>I read that in C arguments are passed by value, but what's is the difference between passing arguments by value (like in C) or by refencence (like C++ - C#)?<br/>What's the difference between a pointer and a reference?</p><br/><br/><pre><code>void with_ptr(int *i)<br/>{ *i = 0; }<br/><br/>void with_ref(int &i)<br/>{ i = 0; }<br/><br/></code></pre><br/><br/><p>In these cases are modified both value? If yes, why C++ allows to pass arguments by reference? I think it is not clear inside the function that the i value could be modified.</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><blockquote><br/> <p>what's is the difference between passing arguments by value or by reference</p><br/></blockquote><br/><br/><p>If you pass by value, changes to the variable will be local to the function, since the value is <em>copied</em> when calling the function. Modifications to reference arguments will propagate to the original value.</p><br/><br/><br/><blockquote><br/> <p>What's the difference between a pointer and a reference?</p><br/></blockquote><br/><br/><p>The difference is largely syntactic, as you have seen in your code. Furthermore, a pointer can be reassigned to point to something else (unless it’s declared <code>const</code>), while a reference can’t; instead, assigning to a reference is going to assign to the referenced <em>value</em>.</p><br/><br/><blockquote><br/> <p>I think it is not clear inside the function that the i value could be modified.</p><br/></blockquote><br/><br/><br/><p>On the contrary, it’s absolutely clear: the function signature tells you so.</p><br/><br/><p>There’s actually a case to be made that it’s not clear <em>outside</em> the function. That’s why original versions of C# for instance mandated that you explicitly annotate any by-reference calling with <code>ref</code> (i.e. <code>f(ref x)</code> instead of plain <code>f(x)</code>). This would be similar to calling a function in C++ using <code>f(&x)</code> to make it clear that a pointer is passed.</p><br/><br/><p>But in recent versions of C#, the use of <code>ref</code> for calling was made optional since it didn’t confer enough of an advantage after all.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/c-what-difference-between-passing.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/c-what-difference-between-passing.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T10:01:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/c-what-difference-between-passing.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=643355526576795391&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=643355526576795391&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=643355526576795391&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=643355526576795391&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=643355526576795391&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=643355526576795391&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='5585907227162062721' itemprop='postId'/> <a name='5585907227162062721'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/thread-exceptions-android-caused-by.html'>thread exceptions - Android : Caused by: android.os.NetworkOnMainThreadException</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-5585907227162062721' itemprop='description articleBody'> <pre><code>String response = getResultForRequest(url);<br/><br/></code></pre><br/><br/><p>Where 'url' is JSON formatted which return bunch of data using http GET method.</p><br/><br/><pre><code>public static String getResultForRequest(String urlString)<br/> throws IOException {<br/> URL url = new URL(urlString);<br/> HttpURLConnection urlConnection = (HttpURLConnection) url<br/> .openConnection();<br/> urlConnection.setRequestMethod("GET");<br/><br/> urlConnection.setDoInput(true);<br/> urlConnection.setDoOutput(true);<br/> urlConnection.connect();<br/><br/> InputStream is = urlConnection.getInputStream();<br/> if (is == null)<br/> return null;<br/> StringBuffer sb = new StringBuffer();<br/> BufferedReader br = new BufferedReader(new InputStreamReader(is));<br/> String line = null;<br/><br/> try {<br/> while ((line = br.readLine()) != null)<br/> sb.append(line);<br/> } finally {<br/> br.close();<br/> is.close();<br/> }<br/><br/> return sb.toString();<br/>}<br/><br/></code></pre><br/><br/><p>I can not fetch JSON formatted data from 'url' which i have passed in getResultForRequest(url) method.I got an error in <strong>urlConnection.connect();</strong>. Internet Permission is also given in AndroidManifest.xml file.</p><br/><br/><p>Here is my Log.</p><br/><br/><pre><code>10-09 13:27:35.264: E/AndroidRuntime(9984): FATAL EXCEPTION: main<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.os.NetworkOnMainThreadException<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)<br/><br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.ActivityThread.access$600(ActivityThread.java:140)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.os.Handler.dispatchMessage(Handler.java:99)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.os.Looper.loop(Looper.java:137)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.ActivityThread.main(ActivityThread.java:4898)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at java.lang.reflect.Method.invokeNative(Native Method)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at java.lang.reflect.Method.invoke(Method.java:511)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at dalvik.system.NativeStart.main(Native Method)<br/><br/>10-09 13:27:35.264: E/AndroidRuntime(9984): Caused by: android.os.NetworkOnMainThreadException<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at java.net.InetAddress.getAllByName(InetAddress.java:214)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)<br/><br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:165)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at com.csoft.foursquare.FoursquareService.getResultForRequest(Service.java:564)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at com.csoft.foursquare.FoursquareService.getUserDetails(Service.java:376)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at com.csoft.checkin.CheckinHistoryActivity.onCreate(HistoryActivity.java:52)<br/><br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.Activity.performCreate(Activity.java:5206)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)<br/>10-09 13:27:35.264: E/AndroidRuntime(9984): ... 11 more<br/></code></pre><br/><br/><p>Thanks in Advance.</p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/thread-exceptions-android-caused-by.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/thread-exceptions-android-caused-by.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T07:27:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/thread-exceptions-android-caused-by.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=5585907227162062721&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5585907227162062721&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5585907227162062721&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5585907227162062721&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5585907227162062721&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5585907227162062721&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='8161916244730320371' itemprop='postId'/> <a name='8161916244730320371'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/why-is-it-bad-style-to-rescue-exception.html'>Why is it bad style to `rescue Exception => e` in Ruby?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-8161916244730320371' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>Ryan Davis’s <a href="http://www.zenspider.com/ruby/quickref.html#general-tips" rel="noreferrer">Ruby QuickRef</a> says (without explanation):</p><br/><br/><blockquote><br/> <p>Don’t rescue Exception. EVER. or I will stab you.</p><br/></blockquote><br/><br/><p>Why not? What’s the right thing to do?</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><br/><p><strong>TL;DR</strong>: Use <code>StandardError</code> instead for general exception catching. When the original exception is re-raised (e.g. when rescuing to log the exception only), rescuing <code>Exception</code> is probably okay.</p><br/><br/><hr /><br/><br/><p><code>Exception</code> is the root of <a href="http://rubylearning.com/images/exception.jpg" rel="noreferrer">Ruby's exception hierarchy</a>, so when you <code>rescue Exception</code> you rescue from <em>everything</em>, including subclasses such as <code>SyntaxError</code>, <code>LoadError</code>, and <code>Interrupt</code>.</p><br/><br/><p>Rescuing <code>Interrupt</code> prevents the user from using <kbd>CTRL</kbd><kbd>C</kbd> to exit the program.</p><br/><br/><p>Rescuing <code>SignalException</code> prevents the program from responding correctly to signals. It will be unkillable except by <code>kill -9</code>.</p><br/><br/><br/><p>Rescuing <code>SyntaxError</code> means that <code>eval</code>s that fail will do so silently.</p><br/><br/><p>All of these can be shown by running this program, and trying to <kbd>CTRL</kbd><kbd>C</kbd> or <code>kill</code> it:</p><br/><br/><pre><code>loop do<br/> begin<br/> sleep 1<br/> eval "djsakru3924r9eiuorwju3498 += 5u84fior8u8t4ruyf8ihiure"<br/> rescue Exception<br/> puts "I refuse to fail or be stopped!"<br/><br/> end<br/>end<br/></code></pre><br/><br/><p>Rescuing from <code>Exception</code> isn't even the default. Doing</p><br/><br/><pre><code>begin<br/> # iceberg!<br/>rescue<br/> # lifeboats<br/><br/>end<br/></code></pre><br/><br/><p>does not rescue from <code>Exception</code>, it rescues from <code>StandardError</code>. You should generally specify something more specific than the default <code>StandardError</code>, but rescuing from <code>Exception</code> <em>broadens</em> the scope rather than narrowing it, and can have catastrophic results and make bug-hunting extremely difficult.</p><br/><br/><hr /><br/><br/><p>If you have a situation where you do want to rescue from <code>StandardError</code> and you need a variable with the exception, you can use this form:</p><br/><br/><pre><code>begin<br/><br/> # iceberg!<br/>rescue => e<br/> # lifeboats<br/>end<br/></code></pre><br/><br/><p>which is equivalent to:</p><br/><br/><pre><code>begin<br/> # iceberg!<br/><br/>rescue StandardError => e<br/> # lifeboats<br/>end<br/></code></pre><br/><br/><hr /><br/><br/><p>One of the few common cases where it’s sane to rescue from <code>Exception</code> is for logging/reporting purposes, in which case you should immediately re-raise the exception:</p><br/><br/><pre><code>begin<br/><br/> # iceberg?<br/>rescue Exception => e<br/> # do some logging<br/> raise # not enough lifeboats ;)<br/>end<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/why-is-it-bad-style-to-rescue-exception.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/why-is-it-bad-style-to-rescue-exception.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T04:43:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/why-is-it-bad-style-to-rescue-exception.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=8161916244730320371&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8161916244730320371&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8161916244730320371&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8161916244730320371&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8161916244730320371&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8161916244730320371&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='1805312155157933937' itemprop='postId'/> <a name='1805312155157933937'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/javascript-index-loop-does-not-change.html'>javascript - Index loop does not change</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-1805312155157933937' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><p>I'm trying to gather tweets from twitter, on console if I choose 5 tweets to gather it displays every one of them but if I choose the mysql module to insert them into a database it inserts the last line 5 times.</p><br/><br/><p>Can't figure out how to resolve it. </p><br/><br/><p>Asking again, had no luck in the last 3 hours making this script work. Was pointed out to <a href="https://stackoverflow.com/questions/33216881/for-loop-does-not-change-index-inside-function">for loop does not change index inside function</a> . Can someone please help me fix this problem?</p><br/><br/><pre><code>for (var i = 0; i < data.length ; i++) { // get all the messages from username, devfined in search term<br/><br/> var retweetId_str = data[i].id_str; // id_str = id not rounded more precise<br/> console.log('id_str:', retweetId_str); // <br/><br/> //id_str: 656087507604402176<br/> //id_str: 656063345192255488<br/> //id_str: 656063056947126272<br/> //id_str: 656062911530606592<br/> //id_str: 656062750574182400 <br/> con.query('SELECT retweetid_str FROM droid_retweets WHERE retweetId_str=?', retweetId_str, function(error,result){ <br/> console.log('id_str:', retweetId_str); <br/><br/><br/> //id_str: 656062750574182400<br/> //id_str: 656062750574182400<br/> //id_str: 656062750574182400<br/> //id_str: 656062750574182400<br/> //id_str: 656062750574182400<br/> }); <br/>} // for close<br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><br/><p>It's because of closures in javascript. </p><br/><br/><p><a href="https://stackoverflow.com/a/750506/222403">This</a> answer should help explain it and there are a couple ways to handle it. </p><br/><br/><p>The easiest being to use <code>.forEach()</code></p><br/><br/><pre><code>data.forEach(function(d) { // get all the messages from username, devfined in search term<br/><br/> var retweetId_str = d.id_str; // id_str = id not rounded more precise<br/> console.log('id_str:', retweetId_str); // <br/><br/> con.query('SELECT retweetid_str FROM droid_retweets WHERE retweetId_str=?', retweetId_str, function(error,result){ <br/> console.log('id_str:', retweetId_str); <br/><br/> }); <br/><br/> }); // for close<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/javascript-index-loop-does-not-change.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/javascript-index-loop-does-not-change.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T04:15:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/javascript-index-loop-does-not-change.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=1805312155157933937&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1805312155157933937&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1805312155157933937&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1805312155157933937&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1805312155157933937&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1805312155157933937&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='3086735595487370202' itemprop='postId'/> <a name='3086735595487370202'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/php-parse-error-syntax-error-unexpected_28.html'>php - Parse error: syntax error, unexpected 'endif' (T_ENDIF)?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-3086735595487370202' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>I getting error with php endif, couldn't find the error. here I have given my code. please help me to fix this</p><br/><br/><br/><pre><code> <!--php if( have_rows('home-video-slider') ): ?--><br/> <!--php while( have_rows('home-video-slider') ): the_row(); <br/--> $video_banner = get_sub_field('video-banner');<br/> ?><br/> <div class="item"><br/> <div class="fm-video-banner"><br/> <!--php if( $video_banner ); ?--><br/> <img src="<?php echo $video_banner['url']; ?>"/><br/> <!--php endif; ?--><br/><br/><br/> <a class="popup-youtube fm-play-icon" <br/> href="https://www.youtube.com/embed/5ktgB9hlETw"><br/> <span><br/> <i class="fa fa-play" aria-hidden="true"></i><br/> </span><br/> </a><br/> </div><br/> </div><br/> <!--php $p++; endwhile; ?--><br/><br/> <!--php endif; ?--><br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>Wrong syntax there :</p><br/><br/><pre><code><!--php if( $video_banner ); ?--><br/></code></pre><br/><br/><p>To be replaced by</p><br/><br/><br/><pre><code><!--php if( $video_banner ): ?--><br/></code></pre><br/><br/><p>writting a <code>;</code> after the condition of a if is like writting</p><br/><br/><pre><code><!--php<br/--> if( $video_banner )<br/> {<br/> ; //Do nothing<br/> }<br/><br/>?><br/></code></pre><br/><br/><p>This means you have one <code>endif;</code> in excess</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/php-parse-error-syntax-error-unexpected_28.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/php-parse-error-syntax-error-unexpected_28.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T03:19:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/php-parse-error-syntax-error-unexpected_28.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=3086735595487370202&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3086735595487370202&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3086735595487370202&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3086735595487370202&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3086735595487370202&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3086735595487370202&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='6881600029007111632' itemprop='postId'/> <a name='6881600029007111632'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/regex-in-vba-excel.html'>Regex in Vba excel</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-6881600029007111632' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><p>Can anyone provide the regex for extracting the data between the 2nd and the 3rd "|"</p><br/><br/><p>For example, for the below data</p><br/><br/><p>2016 Annual | 1.1 - 12.31 | COH (NP) | #21485</p><br/><br/><p>The result should be <br/>COH (NP)</p><br/><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>A regex is overkill for this. Just split on "|" and take the desired component:</p><br/><br/><pre><code>Sub test()<br/> Dim S As String<br/> S = "2016 Annual | 1.1 - 12.31 | COH (NP) | #21485"<br/> Debug.Print Split(S, "|")(2) 'prints COH (NP)<br/>End Sub<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/regex-in-vba-excel.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/regex-in-vba-excel.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T02:05:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/regex-in-vba-excel.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=6881600029007111632&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6881600029007111632&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6881600029007111632&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6881600029007111632&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6881600029007111632&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6881600029007111632&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> </div></div> <div class="date-outer"> <h2 class='date-header'><span>Tuesday, February 27, 2018</span></h2> <div class="date-posts"> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='6121499957557910920' itemprop='postId'/> <a name='6121499957557910920'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/compiler-construction-compiling-cc-files.html'>compiler construction - Compiling .cc files?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-6121499957557910920' itemprop='description articleBody'> <p>guys i am having a weird problem it has been working fine but suddenly messed up<br/>Here is the problem. I have test.h and test.cc and mainP.cc. </p><br/><br/><p>In mainP.cc:</p><br/><br/><pre><code>#ifndef test_H<br/><br/>#include "test.h"<br/>#endif<br/></code></pre><br/><br/><p>in test.h:</p><br/><br/><pre><code>#ifndef test_H<br/>#define test_H<br/></code></pre><br/><br/><br/><p>in test.cc:</p><br/><br/><pre><code>#ifndef test_H<br/>#include "test.h"<br/>#endif<br/></code></pre><br/><br/><p>now when I say test tInstance; it gives me undefined reference to test::test();<br/>I checked my def. constr. is public . everything looks ok to me. I am not sure what i wrong? i use g++ to compile it.</p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/compiler-construction-compiling-cc-files.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/compiler-construction-compiling-cc-files.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T22:00:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/compiler-construction-compiling-cc-files.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=6121499957557910920&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6121499957557910920&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6121499957557910920&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6121499957557910920&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6121499957557910920&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6121499957557910920&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7728039515288972711' itemprop='postId'/> <a name='7728039515288972711'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/what-is-androidems-attribute-in-edit.html'>What is android:ems attribute in Edit Text?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7728039515288972711' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><blockquote><br/><br/> <br/></blockquote><br/><br/><br/><br/><p>In <code>EditText</code> there is an attribute named <code>android:ems</code>. The description<br/>is "Makes the <code>EditText</code> be exactly this many ems wide"</p><br/><br/><p>What does ems mean? </p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><br/><p>Taken from: <a href="http://www.w3.org/Style/Examples/007/units">http://www.w3.org/Style/Examples/007/units</a>:</p><br/><br/><blockquote><br/> <p>The em is simply the font size. In an element with a 2in font, 1em<br/> thus means 2in. Expressing sizes, such as margins and paddings, in em<br/> means they are related to the font size, and if the user has a big<br/> font (e.g., on a big screen) or a small font (e.g., on a handheld<br/> device), the sizes will be in proportion. Declarations such as<br/> 'text-indent: 1.5em' and 'margin: 1em' are extremely common in CSS.</p><br/></blockquote><br/><br/><br/><p><code>em</code> is basically CSS property for font sizes.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/what-is-androidems-attribute-in-edit.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/what-is-androidems-attribute-in-edit.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T20:59:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/what-is-androidems-attribute-in-edit.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7728039515288972711&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7728039515288972711&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7728039515288972711&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7728039515288972711&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7728039515288972711&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7728039515288972711&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7133850777313935881' itemprop='postId'/> <a name='7133850777313935881'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/redirect-from-html-page.html'>Redirect from an HTML page</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7133850777313935881' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>Is it possible to set up a basic HTML page to redirect to another page on load?</p><br/><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>Try using:</p><br/><br/><pre><code><meta http-equiv="refresh" content="0; url=http://example.com/" /><br/></code></pre><br/><br/><p>Note: Place it in the head section.</p><br/><br/><p>Additionally for older browsers if you add a quick link in case it doesn't refresh correctly:</p><br/><br/><br/><p><code><p><a href="http://example.com/">Redirect</a></p></code></p><br/><br/><p>Will appear as </p><br/><br/><p><a href="http://example.com/" rel="noreferrer">Redirect</a></p><br/><br/><p>This will still allow you to get to where you're going with an additional click.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/redirect-from-html-page.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/redirect-from-html-page.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T18:11:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/redirect-from-html-page.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7133850777313935881&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7133850777313935881&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7133850777313935881&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7133850777313935881&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7133850777313935881&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7133850777313935881&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='3049576752907758324' itemprop='postId'/> <a name='3049576752907758324'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/optimization-how-to-index-1-million.html'>optimization - How to index 1 million rows mySQL table for simple query</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-3049576752907758324' itemprop='description articleBody'> <p>I have a mySQL DB of ~1 milllion entries.</p><br/><br/><br/><p>I run the query:</p><br/><br/><pre><code>SELECT a.id as aid, a.title as atitle, a.slug, summary, <br/> a.link as alink, author, published, image, a.cat as acat, <br/> a.rss as arss, a.site as asite <br/> FROM articles a <br/> ORDER BY published DESC <br/> LIMIT 616150, 50;<br/></code></pre><br/><br/><br/><p>It takes about 5 minutes or more ot load.</p><br/><br/><p>My TABLE and INDEXes:</p><br/><br/><pre><code>CREATE TABLE IF NOT EXISTS `articles` (<br/> `id` int(11) NOT NULL AUTO_INCREMENT,<br/> `title` varchar(255) NOT NULL,<br/> `slug` varchar(255) NOT NULL,<br/> `summary` text NOT NULL,<br/><br/> `link` text NOT NULL,<br/> `author` varchar(255) NOT NULL,<br/> `published` datetime NOT NULL,<br/> `image` text NOT NULL,<br/> `cat` int(11) NOT NULL,<br/> `rss` int(11) NOT NULL,<br/> `site` int(11) NOT NULL,<br/> `bitly` varchar(255) NOT NULL,<br/> `checked` tinyint(4) NOT NULL DEFAULT '0',<br/> PRIMARY KEY (`id`),<br/><br/> UNIQUE KEY `title` (`title`),<br/> KEY `cat` (`cat`),<br/> KEY `published` (`published`),<br/> KEY `site` (`site`),<br/> KEY `rss` (`rss`),<br/> KEY `checked` (`checked`),<br/> KEY `id_publ_index` (`id`,`published`)<br/>) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1230234;<br/></code></pre><br/><br/><br/><p>What explain says:</p><br/><br/><pre><br/>mysql> EXPLAIN EXTENDED SELECT a.id as aid, a.title as atitle, a.slug, summary, a.link as alink, author, published, image, a.cat as acat, a.rss as arss, a.site as asite FROM articles a ORDER BY published DESC LIMIT 616150, 50;<br/>+----+-------------+-------+-------+---------------+-----------+---------+------+--------+----------+-------+<br/>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |<br/>+----+-------------+-------+-------+---------------+-----------+---------+------+--------+----------+-------+<br/>| 1 | SIMPLE | a | index | NULL | published | 8 | NULL | 616200 | 152.94 | |<br/>+----+-------------+-------+-------+---------------+-----------+---------+------+--------+----------+-------+<br/>1 row in set, 1 warning (0.46 sec)<br/><br/></pre><br/><br/><p>Any tips of how to optimize this query? Why mySQL needs to read all 616200 rows and not just the 50 that were asked?</p><br/><br/><p>Thank you for your time.</p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/optimization-how-to-index-1-million.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/optimization-how-to-index-1-million.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T17:54:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/optimization-how-to-index-1-million.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=3049576752907758324&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3049576752907758324&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3049576752907758324&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3049576752907758324&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3049576752907758324&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3049576752907758324&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7560185336844594040' itemprop='postId'/> <a name='7560185336844594040'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/php-vs-as-operator.html'>php - 'AND' vs '&&' as operator</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7560185336844594040' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>I have a codebase where developers decided to use <code>AND</code> and <code>OR</code> instead of <code>&&</code> and <code>||</code>.</p><br/><br/><p>I know that there is a difference in operators' precedence (<code>&&</code> goes before <code>and</code>), but with the given framework (<a href="https://en.wikipedia.org/wiki/PrestaShop" rel="noreferrer">PrestaShop</a> to be precise) it is clearly not a reason.</p><br/><br/><p>Which version are you using? Is <code>and</code> more readable than <code>&&</code>? Or is there no difference?</p><br/><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>If you use <code>AND</code> and <code>OR</code>, you'll eventually get tripped up by something like this:</p><br/><br/><pre><code>$this_one = true;<br/>$that = false;<br/><br/>$truthiness = $this_one and $that;<br/></code></pre><br/><br/><p>Want to guess what <code>$truthiness</code> equals?</p><br/><br/><br/><p>If you said <code>false</code>... bzzzt, sorry, wrong!</p><br/><br/><p><code>$truthiness</code> above has the value <code>true</code>. Why? <code>=</code> has a <a href="http://www.php.net/manual/en/language.operators.precedence.php" rel="noreferrer">higher precedence</a> than <code>and</code>. The addition of parentheses to show the implicit order makes this clearer:</p><br/><br/><pre><code>($truthiness = $this_one) and $that<br/></code></pre><br/><br/><p>If you used <code>&&</code> instead of <code>and</code> in the first code example, it would work as expected and be <code>false</code>.</p><br/><br/><br/><p>As discussed in the comments below, this also works to get the correct value, as parentheses have higher precedence than <code>=</code>:</p><br/><br/><pre><code>$truthiness = ($this_one and $that)<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/php-vs-as-operator.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/php-vs-as-operator.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T17:44:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/php-vs-as-operator.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7560185336844594040&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7560185336844594040&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7560185336844594040&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7560185336844594040&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7560185336844594040&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7560185336844594040&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='8622936482771293694' itemprop='postId'/> <a name='8622936482771293694'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/php-when-should-i-use-memcache-instead.html'>php - When should I use Memcache instead of Memcached?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-8622936482771293694' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>It seems that PHP has two memcached libraries named <a href="http://us3.php.net/manual/en/book.memcache.php" rel="noreferrer">memcache</a> and <a href="http://us3.php.net/manual/en/book.memcached.php" rel="noreferrer">memcached</a>. What is the difference and how do you know which one to use? Is one outdated? It seems that memcached offers more methods so I would assume that means it has had the most development - but it also seems to require <a href="http://tangent.org/552/libmemcached.html" rel="noreferrer">external C/C++ libraries</a> so I'm not sure if I can install it.</p><br/><br/><p>It seems that memcache has been around longer, does not require additional libraries, and has <a href="http://downloads.php.net/pierre/" rel="noreferrer">pre-compiled binaries</a> for even windows! I would think that it would be the better choice for now. However, being new to memcached (server) I'm not sure if there is some super important features in memcached (php) that make it worth the extra trouble.</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p><a href="http://www.php.net/manual/en/book.memcached.php" rel="noreferrer">Memcached client</a> library was just recently released as stable. It is being used by <strong>digg</strong> ( was developed for digg by Andrei Zmievski, now no longer with digg) and implements much more of the <a href="http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt" rel="noreferrer">memcached protocol</a> than the older memcache client. The most important features that memcached has are:</p><br/><br/><ol><br/><li><a href="http://www.php.net/manual/en/memcached.cas.php" rel="noreferrer">Cas tokens</a>. This made my life much easier and is an easy preventive system for stale data. Whenever you pull something from the cache, you can receive with it a cas token (a double number). You can than use that token to save your updated object. If no one else updated the value while your thread was running, the swap will succeed. Otherwise a newer cas token was created and you are forced to reload the data and save it again with the new token.</li><br/><br/><li>Read through <a href="http://www.php.net/manual/en/memcached.callbacks.php" rel="noreferrer">callbacks</a> are the best thing since sliced bread. It has simplified much of my code.</li><br/><li><a href="http://www.php.net/manual/en/memcached.getdelayed.php" rel="noreferrer">getDelayed()</a> is a nice feature that can reduce the time your script has to wait for the results to come back from the server.</li><br/><li>While the memcached server is supposed to be very stable, it is not the fastest. You can use binary protocol instead of ASCII with the newer client.</li><br/><li>Whenever you save complex data into memcached the client used to always do serialization of the value (which is slow), but now with memcached client you have the option of using <a href="http://github.com/phadej/igbinary" rel="noreferrer">igbinary</a>. So far I haven't had the chance to test how much of a performance gain this can be.</li><br/></ol><br/><br/><p>All of this points were enough for me to switch to the newest client, and can tell you that it works like a charm. There is that external dependency on the <a href="http://tangent.org/552/libmemcached.html" rel="noreferrer">libmemcached</a> library, but have managed to install it nonetheless on Ubuntu and Mac OSX, so no problems there so far.</p><br/><br/><p>If you decide to update to the newer library, I suggest you update to the latest server version as well as it has some nice features as well. You will need to install <a href="http://www.monkey.org/~provos/libevent/" rel="noreferrer">libevent</a> for it to compile, but on Ubuntu it wasn't much trouble.</p><br/><br/><br/><p>I haven't seen any frameworks pick up the new memcached client thus far (although I don't keep track of them), but I presume <a href="http://framework.zend.com/" rel="noreferrer">Zend</a> will get on board shortly.</p><br/><br/><h2>UPDATE</h2><br/><br/><p>Zend Framework 2 has an adapter for Memcached which can be found <a href="http://framework.zend.com/manual/current/en/modules/zend.cache.storage.adapter.html#the-memcached-adapter" rel="noreferrer">here</a></p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/php-when-should-i-use-memcache-instead.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/php-when-should-i-use-memcache-instead.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T17:28:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/php-when-should-i-use-memcache-instead.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=8622936482771293694&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8622936482771293694&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8622936482771293694&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8622936482771293694&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8622936482771293694&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8622936482771293694&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='1636093718406038051' itemprop='postId'/> <a name='1636093718406038051'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/static-declaration-and-definition-of.html'>static - Declaration and Definition of variables in c</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-1636093718406038051' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>I understand the terms declaration and definition as below.</p><br/><br/><p><strong>Declaration:</strong> This is just a heads up to the compiler that a variable of specified <strong>"name"</strong> and <strong>"type"</strong> exists in the code. So that it can be defined/assigned at later point of time</p><br/><br/><br/><p><strong>Definition:</strong> This is the process where an instance of the type is created by allocating a suitable space of memory.</p><br/><br/><pre><code>int var; //Declaration and Definition-Agreed!!!<br/>extern int var; //Declaration only ?<br/>static int var; //Declaration only ?<br/></code></pre><br/><br/><p>My mind refuses to agree the second and third ones as <strong>declaration only</strong> statements. Because in many references I see, <strong>"extern and static variables are automatically initialized to zero upon memory allocation"</strong>. And as you see in following code. </p><br/><br/><br/><pre><code>#include <stdio.h><br/>int main()<br/>{<br/> static int i;<br/> printf("%d\n",i);<br/> return 0;<br/>}<br/></code></pre><br/><br/><p>The output is 0. So Here it looks like the <strong>static int i;</strong> is declaration,definition and auto initialization statement. So please add your justification for this</p><br/><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>Objects with static storage duration are initialized by zero in C.</p><br/><br/><pre><code>static int a; // initialized by zero<br/>int b; // file-scope, static storage duration, initialized by zero<br/><br/>int main(void)<br/>{<br/> int c; // automatic storage duration, indeterminate value<br/> static int d; // initialized by zero<br/><br/>}<br/></code></pre><br/><br/><p><code>a</code>, <code>c</code> and <code>d</code> are declarations and definitions of objects.</p><br/><br/><p><code>b</code> is a declaration and a definition because there is no other file-scope occurrence of <code>b</code> until the end of the translation unit. Before the end of the translation unit, the declaration is a <em>tentative</em> definition.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/static-declaration-and-definition-of.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/static-declaration-and-definition-of.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T16:06:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/static-declaration-and-definition-of.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=1636093718406038051&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1636093718406038051&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1636093718406038051&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1636093718406038051&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1636093718406038051&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1636093718406038051&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='8494130095672256569' itemprop='postId'/> <a name='8494130095672256569'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/nodejs-javascript-dependency-management.html'>node.js - JavaScript dependency management: npm vs. bower vs. volo</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-8494130095672256569' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><p>How do you compare <code>npm</code>, <code>bower</code> and <code>volo</code>?</p><br/><br/><p>All three can be used to install JavaScript dependencies for a UI project.<br/><br/>I understand <code>npm</code> is more node specific.</p><br/><br/><p>So, when to use what?</p><br/><br/><p><code>npm</code> still stands distant, but <code>bower</code> and <code>volo</code> seem to be solving exactly the same problem, although I am not able to draw a line between <code>npm</code> and <code>bower-volo</code>.</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>A description that best describes the difference between npm and bower is: npm manages JavaScript modules called packages and Bower manages front-end components (i.e. css, html, and JavaScript) called components. npm is also used to install bower. Here is an <a href="http://codylindley.com/techpro/2013_04_12__package-managers-an-introducto/" rel="noreferrer">expansive article on npm and bower</a> (does not cover volo) it goes into plenty of detail. </p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/nodejs-javascript-dependency-management.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/nodejs-javascript-dependency-management.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T14:29:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/nodejs-javascript-dependency-management.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=8494130095672256569&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8494130095672256569&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8494130095672256569&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8494130095672256569&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8494130095672256569&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8494130095672256569&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7918327887460509598' itemprop='postId'/> <a name='7918327887460509598'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/performance-using-lttng-to-sample-perf.html'>performance - Using LTTng to sample perf counters in linux-kernel trace</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7918327887460509598' itemprop='description articleBody'> <p>I am looking into some of the tools and mechanisms that can be used in order to trace events on the Linux-kernel. I was interested in particular in the LTTng tool. I understand that the tool allows you to add extra context to traced events, for instance perf counters like cache-misses, branch-misses etc. Does anyone know whether or not LTTng allows sampling of performance counters ? And if so, can you configure the perf counters, that is, choose which events are to be monitored ? </p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/performance-using-lttng-to-sample-perf.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/performance-using-lttng-to-sample-perf.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T13:08:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/performance-using-lttng-to-sample-perf.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7918327887460509598&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7918327887460509598&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7918327887460509598&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7918327887460509598&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7918327887460509598&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7918327887460509598&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='8363815094943767375' itemprop='postId'/> <a name='8363815094943767375'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/php-mysql-error-in-sql-syntax-check.html'>php - MySQL Error in SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-8363815094943767375' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><br/> <br/><p>I am trying to insert a sample blog post into my 'posts' table in MySQL (using PHP) however I receive a syntax error whenever a large character post is submitted. If I submit content of say 20 characters it works but something like 500 characters will throw the following error: </p><br/><br/><blockquote><br/> <p>Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''uid', 'username', 'p_date', 'title', 'content') VALUES('1','Mark Twain', '2014-' at line 1</p><br/></blockquote><br/><br/><br/><p>The 'content' is to be inserted into the database via a varchar(1000) variable. The table is defined in mysql as: </p><br/><br/><pre><code>CREATE TABLE posts<br/>(<br/> pid int NOT NULL AUTO_INCREMENT,<br/> uid int NOT NULL,<br/> username varchar(100) NOT NULL,<br/> p_date date NOT NULL,<br/> title varchar(225) NOT NULL,<br/> content varchar(10000) NOT NULL,<br/><br/> PRIMARY KEY(pid),<br/> FOREIGN KEY(uid) REFERENCES users(uid)<br/>);<br/></code></pre><br/><br/><p>The actual content I am trying to submit is this: </p><br/><br/><blockquote><br/> <p>Secondly, these missionaries would gradually, and without creating suspicion or exciting alarm, introduce a rudimentary cleanliness among the nobility, and from them it would work down to the people, if the priests could be kept quiet. This would undermine the Church. I mean would be a step toward that. Next, education -- next, freedom -- and then she would begin to crumble. It being my conviction that any Established Church is an established crime, an established slave-pen, I had no scruples, but was willing to assail it in any way or with any weapon that promised to hurt it. Why, in my own former day -- in remote centuries not yet stirring in the womb of time -- there were old Englishmen who imagined that they had been born in a free country: a "free" country with the Corporation Act and the Test still in force in it -- timbers propped against men's liberties and dishonored consciences to shore up an Established Anachronism with.</p><br/></blockquote><br/><br/><br/><p>The insert statement for this is the following: </p><br/><br/><pre><code>$sql = "INSERT INTO posts ('uid', 'username', 'p_date', 'title', 'content') VALUES('$uid','$uname', '$date', '$title', '$content')";<br/><br/>if(!mysql_query($sql,$con)){<br/> echo "Oops! Something went wrong during the posting process. Please try again. ";<br/> die('Error: ' . mysql_error($con));<br/> header('Refresh: 1; URL=postingform.php'); <br/>}else{<br/><br/> // Now return the user to their post page <br/> header('Refresh: 0; URL=postlist.php?uid='.$uid.'');<br/>}<br/></code></pre><br/><br/><p>For some reason it is error-ing out during the INSERT process. The one thing strange I notice is that the date is cut off in the error. To call the date I am using. $date = date("Y-m-d"); </p><br/><br/><p>I have used this same syntax before without issues. </p><br/><br/><p>****Edit </p><br/><br/><br/><p>A few posters have pointed out that there are single quotations in my INSERT column statements. I have changed these to back tics and completely removed them but the error still results. </p><br/><br/><p>New Error: </p><br/><br/><blockquote><br/> <p>Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Court', 'Secondly, these missionaries would gradually, and without creating su' at line 1</p><br/></blockquote><br/><br/><p>There is something still wrong with my insert syntax but everything I am reading says it should be correct. </p><br/><br/><br/><pre><code>$sql = "INSERT INTO posts (`uid`, `username`, `p_date`, `title`, `content`) VALUES('$uid','$uname', '$p_date', '$title', '$content')";<br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>Remove all the quotes in (for your columns)</p><br/><br/><pre><code>('uid', 'username', 'p_date', 'title', 'content')<br/></code></pre><br/><br/><p>Those aren't the correct column identifiers</p><br/><br/><br/><br/><br/><p>use</p><br/><br/><pre><code>(uid, username, p_date, title, content)<br/></code></pre><br/><br/><p>or use backticks.</p><br/><br/><br/><pre><code>(`uid`, `username`, `p_date`, `title`, `content`)<br/></code></pre><br/><br/><p><em>However</em> and as a quick FYI, backticks are mostly used for reserved keywords, or if a table/column contains spaces, hyphens.</p><br/><br/><br/><br/><hr /><br/><br/><p>The error message was letting you know here</p><br/><br/><br/><blockquote><br/> <p>check the manual that corresponds to your MySQL server version for the right syntax to use near ''uid',<br />^--« right there</p><br/></blockquote><br/><br/><p>Notice the quote just before <code>'uid'</code>? That's where the problem starts.</p><br/><br/><hr /><br/><br/><p><strong>Edit:</strong></p><br/><br/><br/><p>Try the following using prepared statements and replace <code>xxx</code> with your own credentials.</p><br/><br/><p>This should take care of the quotes issue from your input values.</p><br/><br/><p>You will need to add the variables according to your inputs.</p><br/><br/><pre><code><!--php<br/-->$DB_HOST = "xxx";<br/>$DB_NAME = "xxx";<br/><br/>$DB_USER = "xxx";<br/>$DB_PASS = "xxx";<br/><br/>$conn = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);<br/>if($conn->connect_errno > 0) {<br/> die('Connection failed [' . $conn->connect_error . ']');<br/>}<br/><br/>$uid = ""; // replace with proper value<br/>$uname = ""; // replace with proper value<br/><br/>$date = ""; // replace with proper value<br/>$title = ""; // replace with proper value<br/>$content = ""; // replace with proper value<br/><br/>$stmt = $conn->prepare("INSERT INTO posts (`uid`, `username`, `p_date`, `title`, `content`) VALUES (?, ?, ?, ?, ?)");<br/><br/>$stmt->bind_param('sssss', $uid, $uname, $date, $title, $content);<br/><br/> if (!$stmt->execute()) {<br/> echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;<br/><br/> }<br/><br/> else{<br/> echo "Success";<br/> }<br/><br/>$stmt->close(); // Statement<br/>$conn->close(); // MySQLi<br/></code></pre><br/><br/><br/><hr /><br/><br/><p><strong><em>Footnotes:</em></strong></p><br/><br/><p>In order to allow single and/or double quotes, based yourself on the following, while using the <a href="http://php.net/manual/en/function.stripslashes.php" rel="nofollow"><code>stripslashes()</code></a> function.</p><br/><br/><pre><code>$content = stripslashes($_POST['content']);<br/></code></pre><br/><br/><p>This will enter in DB properly:<br /><code>Bob's sister was here today and said: "Bob, what lovely hair you have!".</code></p><br/><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/php-mysql-error-in-sql-syntax-check.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/php-mysql-error-in-sql-syntax-check.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T13:02:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/php-mysql-error-in-sql-syntax-check.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=8363815094943767375&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8363815094943767375&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8363815094943767375&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8363815094943767375&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8363815094943767375&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8363815094943767375&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='3918033150873267693' itemprop='postId'/> <a name='3918033150873267693'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/php-function-not-sending-email_27.html'>PHP 'mail()' Function Not Sending Email</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-3918033150873267693' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><br/><p>I'm using a basic script on a 1&1 hosted server:</p><br/><br/><pre><code>$recipient = "email@domain.com";<br/>$sender_name = $_POST['name'];<br/>$sender_email = $_POST['email'];<br/>$subject = $_POST['subject'];<br/>$message = $_POST['message'];<br/><br/>$headers = "MIME-Version: 1.0"."\r\n";<br/>$headers .= "Content-type:text/html; charset=UTF-8"."\r\n";<br/><br/>$headers .= "From: {$sender_name} <{$sender_email}>"."\r\n";<br/>$headers .= "Reply-to: {$sender_name} <{$sender_email}>"."\r\n";<br/><br/>mail($recipient, $subject, $message, $headers);<br/></code></pre><br/><br/><p>..but for some reason am not receiving any emails, nor any errors as per <a href="https://stackoverflow.com/questions/18854572/php-mail-function-not-sending-email">PHP mail() function not sending email</a> instructs.</p><br/><br/><p>I thought this may be a server issue but <a href="https://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/php-c37728/send-e-mails-using-php-a657019.html" rel="nofollow noreferrer">1&1 states</a> that it is fully supported. I've also sent emails from this server/hosting before using just a recipient, subject and body and so I'm rather unsure as to why it is not working now!</p><br/><br/><br/><p><strong>UPDATE</strong></p><br/><br/><p>Sending without headers, i.e.:</p><br/><br/><pre><code>mail($recipient, $subject, $message);<br/></code></pre><br/><br/><p>..does work, so it would appear to be an issue with using the headers?</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>There may be many reasons, for example you should study what SPF is. </p><br/><br/><br/><p>The $sender_email can't be any address, for example you can't put a gmail address and send emails claiming to be that sender, without any authentication, you aren't allowed to send email on behalf on that address, because I could for example send emails putting your address in the from, pretenting to be you when I'm not (I tried to use simple words)</p><br/><br/><p>You should use in the <code>From</code> something ending in @yourdomain.com, and set up SPF to allow your server's IP to send emails for that domain. OR otherwise send emails through SMTP (with PHPmailer, for example, it's very easy)</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/php-function-not-sending-email_27.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/php-function-not-sending-email_27.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T10:34:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/php-function-not-sending-email_27.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=3918033150873267693&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3918033150873267693&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3918033150873267693&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3918033150873267693&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3918033150873267693&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3918033150873267693&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='6933187372692299465' itemprop='postId'/> <a name='6933187372692299465'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/javascript-html-unable-to-execute-code.html'>javascript - HTML : Unable to execute code in block, but able to run in console</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-6933187372692299465' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><p>Here is my code :</p><br/><br/><pre><code><html><br/> <head><br/><br/> <script><br/> document.getElementById("id").onclick = function(){<br/> alert();<br/> }<br/> </script><br/> </head><br/> <body><br/> <label id="id">A label</label><br/> </body><br/></html><br/><br/></code></pre><br/><br/><p>It is simple, but I can't get it to work.</p><br/><br/><p>When I copied the code inside <code><script></code> and ran it at console, it worked perfectly.</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>The onclick event isn't firing because the element doesn't exist at the time you bind the click event (DOM isn't loaded yet).</p><br/><br/><p>To fix this you can put the script before you close the body tag (1)<br/>or wrap your code in a DOM loaded event (2). </p><br/><br/><br/><p>1)</p><br/><br/><pre><code><html><br/> <head> <br/> </head><br/> <body><br/> <label id="id">A label</label><br/> <script><br/> document.getElementById("id").onclick = function(){<br/><br/> alert();<br/> }<br/> </script><br/> </body><br/></html><br/></code></pre><br/><br/><p>2)</p><br/><br/><pre><code>window.onload = function () {<br/><br/> document.getElementById("id").onclick = function(){<br/> alert();<br/> }<br/>}<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/javascript-html-unable-to-execute-code.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/javascript-html-unable-to-execute-code.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T09:28:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/javascript-html-unable-to-execute-code.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=6933187372692299465&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6933187372692299465&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6933187372692299465&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6933187372692299465&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6933187372692299465&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6933187372692299465&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7436099186525418887' itemprop='postId'/> <a name='7436099186525418887'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/javascript-how-do-i-export-array-with.html'>javascript - How do I export an array with module.exports in node js?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7436099186525418887' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>I have a project using node.js. It's my first time using nodejs and I want to export an array to my app. Here is some code:</p><br/><br/><pre><code>module.exports = { <br/> var arrays = [];<br/> arrays[0] = 'array 0';<br/><br/> arrays[1] = 'array 1';<br/> arrays[2] = 'array 2';<br/> arrays[3] = 'array 3';<br/> arrays[4] = 'array 4';<br/> var r_array = arrays[Math.floor(Math.random() * arrays.length)].toString();<br/>}<br/></code></pre><br/><br/><p>At the end I want to use the <code>var r_array</code> in my app.js but I don't know how. </p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><br/><p>You'd want to define a function which returns the randomized portion of the array:</p><br/><br/><pre><code>module.exports = {<br/> getRArray: function() {<br/> var arrays = [];<br/> arrays[0] = 'array 0';<br/> arrays[1] = 'array 1';<br/> arrays[2] = 'array 2';<br/> arrays[3] = 'array 3';<br/> arrays[4] = 'array 4';<br/><br/> return arrays[Math.floor(Math.random()*arrays.length)];<br/> }<br/>};<br/></code></pre><br/><br/><p>Also you should embed the array into the function so it actually returns something.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/javascript-how-do-i-export-array-with.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/javascript-how-do-i-export-array-with.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-27T05:10:00-08:00'>February 27, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/javascript-how-do-i-export-array-with.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7436099186525418887&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7436099186525418887&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7436099186525418887&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7436099186525418887&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7436099186525418887&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7436099186525418887&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> </div></div> <div class="date-outer"> <h2 class='date-header'><span>Monday, February 26, 2018</span></h2> <div class="date-posts"> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='4916017351703319326' itemprop='postId'/> <a name='4916017351703319326'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/vba-i-am-getting-error-can-find-project.html'>vba - I am getting 'Compile error: Can't find project or library' in a only some Excel 2010 versions. Difficult to test this</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-4916017351703319326' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><br/><p>My customer is getting a Compile Error; Can't find project or Library on his version of Excel 2010, however i am not getting this on my version of 2010. How can i adjust this code so it will not appear. When the error appears in the following code the text "cell" in "For each cell in selection" is highlighted:</p><br/><br/><pre><code>Private Sub Worksheet_Change(ByVal Target As Range)<br/>If Target.Address = "$B$9" Then<br/>Columns("D:CB").Select<br/>Selection.EntireColumn.Hidden = False<br/>Application.ScreenUpdating = False<br/><br/>Sheet17.Range("E48:CB48").Select<br/><br/><br/>For Each cell In Selection<br/> If cell = 0 Then<br/> Range(cell.Address).EntireColumn.Hidden = True<br/> End If<br/>Next<br/><br/>Application.ScreenUpdating = True<br/>Sheet17.Range("b9").Select<br/>End If<br/><br/><br/>End Sub`<br/></code></pre><br/><br/><p>My customer is also reporting a bug in the following code with the word "Response" being highlighted. This, as well, is not an issue for me, on my version of Excel 2010. Any and all help is greatly appreciated.</p><br/><br/><pre><code>If Sheet1.Range("E18") = 3 Then<br/>Response = MsgBox("Reminder Emails have been set to be sent automatically at " & Sheet1.Range("f18").Value & ", " & Sheet1.Range("Q4").Value & " day(s) before" & vbCrLf & "the scheduled appointment. Do you want to send reminder e-mails now anyway?", vbYesNo)<br/> If Response = vbNo Then<br/> Exit Sub<br/><br/> End If<br/> End If<br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>In the VBA window, go to <code>Tools --> References</code> and ensure the same libraries are toggled on for all computers. Also make sure all active libraries are in the same order top-to-bottom. </p><br/><br/><p>Many libraries "come standard" but one may need to be toggled on. Or, a library reference may need to be toggled <em>off</em> due to a functional interference. A library may be altogether missing, but I doubt this is the case since it's a fairly standard suite and you aren't aware of having tinkered with it. </p><br/><br/><p>This is a typical issue and usually not considered too great a burden on your distribution clientele. If it is, you can rework your code to use fewer references; or you may be able to <a href="http://it.toolbox.com/wiki/index.php/Add_references_programmatically_with_VB_or_VBA">load the needed libraries programmatically</a> (but I haven't ever tried that). </p><br/><br/><br/><p>I suggest you include <code>Option Explicit</code> at the top of all modules. This problem looks a bit like a failure to declare your variables; and I think that requirement can vary by setting. <code>Option Explicit</code> will force all variables to be declared, which is beneficial in general and could cause all client installs to act the same. </p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/vba-i-am-getting-error-can-find-project.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/vba-i-am-getting-error-can-find-project.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T22:33:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/vba-i-am-getting-error-can-find-project.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=4916017351703319326&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4916017351703319326&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4916017351703319326&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4916017351703319326&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4916017351703319326&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4916017351703319326&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='5156210298446203347' itemprop='postId'/> <a name='5156210298446203347'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/css-flexbox-align-items-horizontally.html'>css - Flexbox align items horizontally</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-5156210298446203347' itemprop='description articleBody'> <p>Is there a method to align child items in that way: [i][i]______[i][i][i], regardless how many items are in each of the groups?</p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/css-flexbox-align-items-horizontally.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/css-flexbox-align-items-horizontally.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T20:07:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/css-flexbox-align-items-horizontally.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=5156210298446203347&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5156210298446203347&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5156210298446203347&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5156210298446203347&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5156210298446203347&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=5156210298446203347&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='6696540085270606802' itemprop='postId'/> <a name='6696540085270606802'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/advanced-javascript-why-is-this.html'>Advanced JavaScript: Why is this function wrapped in parentheses?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-6696540085270606802' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/> <br/><blockquote><br/> <p><strong>Possible Duplicate:</strong> <br /><a href="https://stackoverflow.com/questions/8228281/what-is-this-construct-in-javascript">What is the (function() { } )() construct in JavaScript?</a></p><br/></blockquote><br/><br/><br/><br/><br/><p>I came across this bit of JavaScript code, but I have no idea what to make out of it. Why do I get "1" when I run this code? What is this strange little appendix of (1) and why is the function wrapped in parentheses?</p><br/><br/><pre><code>(function(x){<br/> delete x;<br/> return x;<br/>})(1);<br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><br/><p>There are a few things going on here. First is the <a href="http://en.wikipedia.org/wiki/Immediately-invoked_function_expression" rel="noreferrer">immediately invoked function expression</a> (IIFE) pattern:</p><br/><br/><pre><code>(function() {<br/> // Some code<br/>})();<br/></code></pre><br/><br/><p>This provides a way to execute some JavaScript code in its own scope. It's usually used so that any variables created within the function won't affect the global scope. You could use this instead:</p><br/><br/><pre><code>function foo() {<br/><br/> // Some code<br/>}<br/>foo();<br/></code></pre><br/><br/><p>But this requires giving a name to the function, which is not always necessary. Using a named function also means at some future point the function could be called again which might not be desirable. By using an anonymous function in this manner you ensure it's only executed once.</p><br/><br/><p>This syntax is invalid:</p><br/><br/><pre><code>function() {<br/><br/> // Some code<br/>}();<br/></code></pre><br/><br/><p>Because you have to wrap the function in parentheses in order to make it parse as an expression. More information is here: <a href="http://benalman.com/news/2010/11/immediately-invoked-function-expression/" rel="noreferrer">http://benalman.com/news/2010/11/immediately-invoked-function-expression/</a></p><br/><br/><p>So to recap quickly on the IIFE pattern:</p><br/><br/><pre><code>(function() {<br/> // Some code<br/><br/>})();<br/></code></pre><br/><br/><p>Allows 'some code' to be executed immediately, as if it was just written inline, but also within its own scope so as not to affect the global namespace (and thus potentially interfere with or be interfered with by, other scripts).</p><br/><br/><p>You can pass arguments to your function just as you would a normal function, for example,</p><br/><br/><pre><code>(function(x) {<br/> // Some code<br/>})(1);<br/><br/></code></pre><br/><br/><p>So we're passing the value '1' as the first argument to the function, which receives it as a locally scoped variable, named x.</p><br/><br/><p>Secondly, you have the guts of the function code itself:</p><br/><br/><pre><code>delete x;<br/>return x;<br/></code></pre><br/><br/><br/><p>The delete operator will remove properties from objects. It doesn't delete variables. So;</p><br/><br/><pre><code>var foo = {'bar':4, 'baz':5};<br/>delete foo.bar;<br/>console.log(foo);<br/></code></pre><br/><br/><p>Results in this being logged:</p><br/><br/><pre><code>{'baz':5}<br/><br/></code></pre><br/><br/><p>Whereas,</p><br/><br/><pre><code>var foo = 4;<br/>delete foo;<br/>console.log(foo);<br/></code></pre><br/><br/><p>will log the value 4, because foo is a variable not a property and so it can't be deleted.</p><br/><br/><br/><p>Many people assume that delete can delete variables, because of the way autoglobals work. If you assign to a variable without declaring it first, it will not actually become a variable, but a property on the global object:</p><br/><br/><pre><code>bar = 4; // Note the lack of 'var'. Bad practice! Don't ever do this!<br/>delete bar;<br/>console.log(bar); // Error - bar is not defined.<br/></code></pre><br/><br/><p>This time the delete works, because you're not deleting a variable, but a property on the global object. In effect, the previous snippet is equivalent to this:</p><br/><br/><br/><pre><code>window.bar = 4;<br/>delete window.bar;<br/>console.log(window.bar);<br/></code></pre><br/><br/><p>And now you can see how it's analogous to the foo object example and not the foo variable example.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/advanced-javascript-why-is-this.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/advanced-javascript-why-is-this.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T13:00:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/advanced-javascript-why-is-this.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=6696540085270606802&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6696540085270606802&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6696540085270606802&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6696540085270606802&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6696540085270606802&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6696540085270606802&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='3995496162677879873' itemprop='postId'/> <a name='3995496162677879873'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/plot-explanation-what-career-was-troy.html'>plot explanation - What career was Troy planning on? - Movies & TV</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-3995496162677879873' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><br/><p>One of the arcs in the TV show <em>Community</em> is what career Troy Barnes is going to pick. In season 1, one of the community college's plumbers tries to encourage Troy to become a plumber. Later the Air Conditioning School tries to get Troy to join them. Troy has actively avoided choosing either, but to my knowledge, he's never stated what career he was planning on.</p><br/><br/><p>Given that he wasn't planning on becoming either a plumber or an A/C repairman, what was Troy planning on for his post-community college career?</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>I am fairly sure it was never mentioned that Troy had specific plans for his career after community college. My assumption is that he does not have anything planned yet. That is backed by several facts:</p><br/><br/><ul><br/><li>His original plan was to play football and go to a elite university. That plan was ruined (by himself) when he dislocated both his shoulders before the big game, because he could not handle the pressure. He probably had no alternative career plan when this failed.</li><br/><li>His reasons to come to Greendale where rather arbitrary than a real career choice. From the <a href="http://community-sitcom.wikia.com/wiki/Troy_Barnes">community wiki</a>:<br/><br/><br/><blockquote><br/> <p>Ultimately, Troy chose Greendale because it was close to his house, and because the Greendale commercial had a student giving a thumbs up sign in a "cool way."</p></blockquote></li><br/> <li>As you said, he toyed around with several alternatives during his time in Greendale (plumber, AC repairman). If he really had his career planned out, he probably would not have picked those up that easily.</li><br/> </ul><br/> Apart from that, I think the dialogue with Jerry the Janitor from Episode 1x24 "English as a second language" also hints at the fact that he actually does not really know what reason he goes to college for:<br/><br/><br/><blockquote><b>Jerry:</b> This is a life, kid. A real one. Doing something that matters. Something that makes sense. <p><b>Troy:</b> The only thing that makes sense is this. Learning. Thoughts.<br />So I can think,<br />and get a student loan,<br />and grind my own coffee,<br />and understand HBO.</p><p><b>Jerry:</b> You don't have to do that, kid. You're special. You could be a plumber!<br/></p></blockquote><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/plot-explanation-what-career-was-troy.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/plot-explanation-what-career-was-troy.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T12:07:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/plot-explanation-what-career-was-troy.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=3995496162677879873&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3995496162677879873&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3995496162677879873&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3995496162677879873&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3995496162677879873&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=3995496162677879873&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='1997997244201297659' itemprop='postId'/> <a name='1997997244201297659'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/c-how-do-i-make-unit-test-to-test_26.html'>c# - How do I make a unit test to test a method that checks request headers?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-1997997244201297659' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>I am very, very new to unit testing and am trying to write a test for a pretty simple method:</p><br/><br/><br/><pre><code>public class myClass : RequireHttpsAttribute<br/>{<br/> public override void OnAuthorization(AuthoizationContext filterContext)<br/> {<br/> var request = filterContext.HttpContext.Request;<br/> var header = Convert.ToBoolean(request.Headers["Special-Header-Name"]);<br/><br/> if (!(header || request.IsSecureConnection))<br/> {<br/><br/> HandleNonHttpsRequest(filterContext);<br/> }<br/> }<br/>}<br/></code></pre><br/><br/><p>This method, which inherits from the <code>RequireHttpsAttribute</code>, checks if a certain header is present from a page, if it's missing or false, and the page is not secure, then it will call <code>HandleNonHttpsRequest</code>, otherwise it does nothing.</p><br/><br/><p>We are using Moq and Nunit for testing. I have found some resources to help build a fakeHttpContext with Moq, but honestly I'm not sure how to use it or where to go within my unit tests to ensure that fake HttpContexts are or are not causing the <code>HandleNonHttpsRequest</code> method to call. </p><br/><br/><br/><p>I really appreciate any guidance with this issue. </p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><pre><code>// arrange<br/>var context = new Mock<httpContextBase>();<br/>var request = new Mock<httpRequestBase>();<br/>var headers = new NameValueCollection<br/>{<br/> { "Special-Header-Name", "false" }<br/>};<br/>request.Setup(x => x.Headers).Returns(headers);<br/><br/>request.Setup(x => x.HttpMethod).Returns("GET");<br/>request.Setup(x => x.Url).Returns(new Uri("http://www.example.com"));<br/>request.Setup(x => x.RawUrl).Returns("/home/index");<br/>context.Setup(x => x.Request).Returns(request.Object);<br/>var controller = new Mock<controllerBase>();<br/><br/>var actionDescriptor = new Mock<actionDescriptor>();<br/>var controllerContext = new ControllerContext(context.Object, new RouteData(), controller.Object);<br/>var filterContext = new AuthorizationContext(controllerContext, actionDescriptor.Object);<br/>var sut = new myClass();<br/><br/><br/>// act<br/>sut.OnAuthorization(filterContext);<br/><br/>// assert<br/>Assert.IsInstanceOfType(filterContext.Result, typeof(RedirectResult));<br/>var redirectResult = (RedirectResult)filterContext.Result;<br/>Assert.AreEqual("https://www.example.com/home/index", redirectResult.Url);<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/c-how-do-i-make-unit-test-to-test_26.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/c-how-do-i-make-unit-test-to-test_26.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T11:37:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/c-how-do-i-make-unit-test-to-test_26.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=1997997244201297659&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1997997244201297659&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1997997244201297659&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1997997244201297659&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1997997244201297659&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=1997997244201297659&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='6730454074067551856' itemprop='postId'/> <a name='6730454074067551856'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/android-studio-082-gradle-project-sync.html'>Android Studio 0.8.2 - Gradle project sync failed</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-6730454074067551856' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><br/><p>In hindsight I should not have enabled L build stuff.</p><br/><br/><p>I am new to programming and I created a new Android Studio project which is throwing the Gradle errror right away.</p><br/><br/><p>Errors are:</p><br/><br/><p>yellow bar at the top - Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly. Try again Open Event Log Show Log in Finder</p><br/><br/><p>messages gradle sync - compileSdkVersion android-L requires compiling with JDK-7. open sdk settings, open file.</p><br/><br/><br/><p>tried looking through google and other comments but did not find much I could make sense of except for <a href="https://stackoverflow.com/questions/22148584/android-studio-gradle-sync-project-failed">Android Studio - Gradle sync project failed</a> </p><br/><br/><p>tried converting URL to 1.10 instead of 1.12 and syncing but that failed after syncing</p><br/><br/><p>I need help either getting L working or removing it so that a new studio project can compile to device without errors.</p><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>I too faced the same issue and after days of trouble I figured it out. Just check if Java is installed</p><br/><br/><ul><br/><li>Open a Terminal window and type:</li><br/><br/></ul><br/><br/><p><strong><em>java -version</em></strong></p><br/><br/><p>Any version above JDK 6 is OK</p><br/><br/><ul><br/><li>In terminal type</li><br/></ul><br/><br/><br/><p><strong><em>open -a TextEdit ~/.bash_profile</em></strong> </p><br/><br/><ul><br/><li>Copy and paste the following lines of into textedit</li><br/></ul><br/><br/><p><em>export JAVA_HOME=$(/usr/libexec/java_home)</em></p><br/><br/><p><em>export JDK_HOME=$(/usr/libexec/java_home)</em></p><br/><br/><br/><ul><br/><li>Save it, close editor and type the following to apply changes</li><br/></ul><br/><br/><p><strong><em>source ~/.bash_profile</em></strong></p><br/><br/><p>Now try gradle sync now, you must be able to complete sync</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/android-studio-082-gradle-project-sync.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/android-studio-082-gradle-project-sync.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T09:14:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/android-studio-082-gradle-project-sync.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=6730454074067551856&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6730454074067551856&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6730454074067551856&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6730454074067551856&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6730454074067551856&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=6730454074067551856&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='4444028878844951028' itemprop='postId'/> <a name='4444028878844951028'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/regex-regular-expressions-in-excel-vba.html'>regex - Regular Expressions in Excel VBA</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-4444028878844951028' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>I'm using the Microsoft regular expression engine in Excel VBA. I'm very new to regex but I have a pattern working right now. I need to expand it and I'm having trouble. Here is my code so far:</p><br/><br/><pre><code>Sub ImportFromDTD()<br/><br/>Dim sDTDFile As Variant<br/>Dim ffile As Long<br/>Dim sLines() As String<br/><br/>Dim i As Long<br/>Dim Reg1 As RegExp<br/>Dim M1 As MatchCollection<br/>Dim M As Match<br/>Dim myRange As Range<br/><br/>Set Reg1 = New RegExp<br/><br/>ffile = FreeFile<br/><br/><br/>sDTDFile = Application.GetOpenFilename("DTD Files,*.XML", , _<br/>"Browse for file to be imported")<br/><br/>If sDTDFile = False Then Exit Sub '(user cancelled import file browser)<br/><br/><br/>Open sDTDFile For Input Access Read As #ffile<br/> Lines = Split(Input$(LOF(ffile), #ffile), vbNewLine)<br/>Close #ffile<br/><br/><br/>Cells(1, 2) = "From DTD"<br/>J = 2<br/><br/>For i = 0 To UBound(Lines)<br/><br/> 'Debug.Print "Line"; i; "="; Lines(i)<br/><br/> With Reg1<br/> '.Pattern = "(\<\!ELEMENT\s)(\w*)(\s*\(\#\w*\)\s*\>)"<br/> .Pattern = "(\<\!ELEMENT\s)(\w*)(\s*\(\#\w*\)\s*\>)"<br/><br/><br/> .Global = True<br/> .MultiLine = True<br/> .IgnoreCase = False<br/> End With<br/><br/> If Reg1.Test(Lines(i)) Then<br/> Set M1 = Reg1.Execute(Lines(i))<br/> For Each M In M1<br/> sExtract = M.SubMatches(1)<br/><br/> sExtract = Replace(sExtract, Chr(13), "")<br/> Cells(J, 2) = sExtract<br/> J = J + 1<br/> 'Debug.Print sExtract<br/> Next M<br/> End If<br/>Next i<br/><br/>Set Reg1 = Nothing<br/><br/><br/>End Sub<br/></code></pre><br/><br/><p>Currently, I'm matching on a set of data like this:</p><br/><br/><pre><code> <!--ELEMENT DealNumber (#PCDATA) --><br/></code></pre><br/><br/><p>and extract Dealnumber but now, I need to add another match on data like this:</p><br/><br/><br/><pre><code><!--ELEMENT DealParties (DealParty+) --><br/></code></pre><br/><br/><p>and extract just Dealparty without the Parens and the + </p><br/><br/><p>I've been using this as a reference and it's awesome but I'm still a bit confused. <a href="https://stackoverflow.com/questions/22542834">How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops</a></p><br/><br/><p><strong>EDIT</strong></p><br/><br/><p>I have come across a few new scenarios that have to be matched on. </p><br/><br/><br/><pre><code> Extract Deal<br/> <!--ELEMENT Deal (DealNumber,DealType,DealParties) --><br/><br/> Extract DealParty the ?,CR are throwing me off<br/> <!--ELEMENT DealParty (PartyType,CustomerID,CustomerName,CentralCustomerID?,<br/--> LiabilityPercent,AgentInd,FacilityNo?,PartyReferenceNo?,<br/> PartyAddlReferenceNo?,PartyEffectiveDate?,FeeRate?,ChargeType?) ><br/><br/> Extract Deals<br/><br/> <!--ELEMENT Deals (Deal*) --><br/></code></pre><br/> </div><div class="post-text" itemprop="text"> <div style="font-weight: bold;"><p class="normal">Answer</p> <br/></div><br/><p>You could use this <code>Regex</code> pattern;</p><br/><br/><pre><code> .Pattern = "\<\!ELEMENT\s+(\w+)\s+\((#\w+|(\w+)\+)\)\s+\>"<br/></code></pre><br/><br/><ol><br/><li>This portion</li><br/><br/></ol><br/><br/><p><code>(#\w+|(\w+)\+)</code></p><br/><br/><p>says match <em>either</em></p><br/><br/><blockquote><br/> <p>#a-z0-9<br />a-z0-9+</p><br/></blockquote><br/><br/><br/><p>inside the parentheses.</p><br/><br/><p>ie match either</p><br/><br/><blockquote><br/> <p>(#PCDATA)<br />(DealParty+)</p><br/></blockquote><br/><br/><p>to validate the entire string</p><br/><br/><br/><ol start="2"><br/><li>Then the submatches are used to extract <em>DealNumber</em> for the first valid match, <em>DealParty</em> for the other valid match</li><br/></ol><br/><br/><p><em>edited code below - note submatch is now <code>M.submatches(0)</code></em></p><br/><br/><pre><code> Sub ImportFromDTD()<br/><br/>Dim sDTDFile As Variant<br/>Dim ffile As Long<br/><br/>Dim sLines() As String<br/>Dim i As Long<br/>Dim Reg1 As RegExp<br/>Dim M1 As MatchCollection<br/>Dim M As Match<br/>Dim myRange As Range<br/><br/>Set Reg1 = New RegExp<br/>J = 1<br/><br/><br/>strIn = "<!--ELEMENT Deal12Number (#PCDATA) --> <!--ELEMENT DealParties (DealParty+) -->"<br/><br/>With Reg1<br/> .Pattern = "\<\!ELEMENT\s+(\w+)\s+\((#\w+|(\w+)\+)\)\s+\>"<br/> .Global = True<br/> .MultiLine = True<br/> .IgnoreCase = False<br/>End With<br/><br/>If Reg1.Test(strIn) Then<br/><br/> Set M1 = Reg1.Execute(strIn)<br/> For Each M In M1<br/> sExtract = M.SubMatches(2)<br/> If Len(sExtract) = 0 Then sExtract = M.SubMatches(0)<br/> sExtract = Replace(sExtract, Chr(13), "")<br/> Cells(J, 2) = sExtract<br/> J = J + 1<br/> Next M<br/>End If<br/><br/><br/>Set Reg1 = Nothing<br/><br/>End Sub<br/></code></pre><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/regex-regular-expressions-in-excel-vba.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/regex-regular-expressions-in-excel-vba.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T09:13:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/regex-regular-expressions-in-excel-vba.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=4444028878844951028&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4444028878844951028&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4444028878844951028&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4444028878844951028&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4444028878844951028&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=4444028878844951028&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7656980899964635270' itemprop='postId'/> <a name='7656980899964635270'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/mysql-having-issue-backing-up-my.html'>mysql - Having An Issue Backing Up MY Database From Php</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7656980899964635270' itemprop='description articleBody'> <p>the issue that I'm having is with the fopen(), fwrite(), and fclose() function. This is the error I am receiving: </p><br/><br/><p>Warning: fopen(/db-backup-salisbury_school-20121128-021138.sql) [function.fopen]: failed to open stream: Permission denied in C:\inetpub\wwwroot\omarejaz\sbyschool\q5.php on line 177</p><br/><br/><p>Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\omarejaz\sbyschool\q5.php on line 178</p><br/><br/><p>Warning: fclose() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\omarejaz\sbyschool\q5.php on line 179</p><br/><br/><br/><p>The code for this portion of php can be found below any help would be greatly appreciated!</p><br/><br/><pre><code> * Save SQL to file<br/> * @param string $sql<br/> */<br/>protected function saveFile(&$sql, $outputDir = '.')<br/>{<br/> if (!$sql) return false;<br/><br/> try<br/><br/> {<br/> $handle = fopen($outputDir.'/db-backup-'.$this->dbName.'-'.date("Ymd-His", time()).'.sql','w+');<br/> fwrite($handle, $sql);<br/> fclose($handle);<br/> }<br/> catch (Exception $e)<br/> {<br/> var_dump($e->getMessage());<br/> return false;<br/> }<br/><br/><br/> return true;<br/>}<br/></code></pre><br/><br/><p>}<br/>?></p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/mysql-having-issue-backing-up-my.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/mysql-having-issue-backing-up-my.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T07:31:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/mysql-having-issue-backing-up-my.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7656980899964635270&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7656980899964635270&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7656980899964635270&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7656980899964635270&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7656980899964635270&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7656980899964635270&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='8870718779330254593' itemprop='postId'/> <a name='8870718779330254593'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/html-php-mail-not-working-properly.html'>html - PHP Mail not working properly</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-8870718779330254593' itemprop='description articleBody'> <p>I have a very long form and the content of the form is sent via mail (HTML email).</p><br/><br/><br/><p>My PHP mail function is working perfectly for the rest of the content. But when I add the following content to the message body, the mail is not working.</p><br/><br/><pre><code><h4><span style="text-decoration:underline">OCCUPATION:</span></h4><br/><br/><p>Please provide a specific and identifiable business activity and<br/>your current position . Vague references such as"Businessman" or<br/>"Manager" will not be accepted and will delay the incorporation<br/>process. In the case of no employment please describe the normal<br/>day to day activities such as "House Wife" In case of retirement<br/>please provide details of previous occupation and your last<br/><br/>position.<br/><textarea name="personal_information_occupation"><br/><br/></textarea></p><br/><hr /><br/></code></pre><br/><br/><p>I went through each and every line but cannot find whats wrong with these particular lines.</p><br/><br/><p>My PHP mail sends HTML email. </p><br/><br/><br/><pre><code><!--php<br/--><br/>if(mail($to, $subject, $message, $headers)){<br/> $mail_status_message = "<p class='success-msg'> Form Submitted Successfully. </p>";<br/> }else{<br/> $mail_status_message = "<p class='error-msg'> Something went wrong. Please try again later. </p>";<br/> }<br/><br/>?><br/><br/></code></pre><br/><br/><p>Basically I am getting the <code>Something went wrong. Please try again later</code> when I add the above code to the message body.</p><br/><br/><p><strong>The mail headers are</strong> </p><br/><br/><pre><code> $headers = 'MIME-Version: 1.0' . "\r\n";<br/> $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";<br/><br/> // Additional headers<br/><br/> $headers .= 'To: '.$to_name.'<'.$to_email.'>' . "\r\n";<br/> $headers .= 'From: Business Name <email@example.com>' . "\r\n";<br/></code></pre> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/html-php-mail-not-working-properly.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/html-php-mail-not-working-properly.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T07:08:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/html-php-mail-not-working-properly.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=8870718779330254593&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8870718779330254593&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8870718779330254593&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8870718779330254593&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8870718779330254593&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=8870718779330254593&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7791777601463341836' itemprop='postId'/> <a name='7791777601463341836'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/how-i-write-function-in-python-that.html'>How I write a function in python that determines whether a word has no vowels?</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7791777601463341836' itemprop='description articleBody'> <p>How I write a function "noVowel" in python that determines whether a word has no vowels?</p><br/><br/><p>In my case, "y" is not a vowel.</p><br/><br/><p>For example, I want the function to return True if the word is something like "My" and to return false if the word is something like "banana".</p> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://dynflt.blogspot.com/2018/02/how-i-write-function-in-python-that.html' itemprop='url'/> <a class='timestamp-link' href='https://dynflt.blogspot.com/2018/02/how-i-write-function-in-python-that.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-26T07:05:00-08:00'>February 26, 2018</abbr></a> </span> <span class='post-comment-link'> <a class='comment-link' href='https://dynflt.blogspot.com/2018/02/how-i-write-function-in-python-that.html#comment-form' onclick=''> No comments: </a> </span> <span class='post-icons'> <span class='item-control blog-admin pid-1320717773'> <a href='https://www.blogger.com/post-edit.g?blogID=7041661965231401935&postID=7791777601463341836&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7791777601463341836&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7791777601463341836&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7791777601463341836&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7791777601463341836&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=7041661965231401935&postID=7791777601463341836&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> </div> <div class='post-outer'> <div class='post hentry uncustomized-post-template' itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'> <meta content='7041661965231401935' itemprop='blogId'/> <meta content='7352278372609544045' itemprop='postId'/> <a name='7352278372609544045'></a> <h3 class='post-title entry-title' itemprop='name'> <a href='https://dynflt.blogspot.com/2018/02/html-marathi-language-not-shown.html'>html - marathi language not shown properly in browser</a> </h3> <div class='post-header'> <div class='post-header-line-1'></div> </div> <div class='post-body entry-content' id='post-body-7352278372609544045' itemprop='description articleBody'> <div class="post-text" itemprop="text"><br/><br/><p>In my html document, I have my html as:</p><br/><br/><pre><code><html><br/><head><title>title

विजय कदम





I am getting output as:



à¤ÂµÃ ¤¿Ã ¤Å“य कदम


Any idea? what do I need to specify?


Answer




  1. Save your file in UTF-8 encoding


  2. Add meta tag to the html to support UTF-8

  3. Make sure your server supports UTF-8 encoding, an example for Apache.



How to change the page encoding to UTF-8:



Add the following tag to the HTML:



 



Or the HTML5 equivalent:






for more information about characters encoding check this out.


Sunday, February 25, 2018

c - How do structs behave in terms of visibility to other files?



This is taken from an answer to a different question on SO:




A structure definition is private to a source file unless placed in a
shared header file. No other source file can access the members of the
struct, even if given a pointer to the struct (since the layout is not

known in the other compilation unit).



If the struct needs to be used elsewhere, it must be used only as a
pointer. Put a forward declaration of the form struct structname;
typedef struct structname structname; in the headerfile, and use
structname * everywhere else in your codebase. Then, since the
structure members appear only in one source file, the structure's
contents are effectively 'private' to that file.





This confuses me. Why can you only use pointers to a struct even if you include a header file that declares it (but does not define it)?



I mean, if I include a header that declares a function, a function which is defined in a separate implementation file, I can still access that function-- why are structs different? Why are their members private even if you can get to the declaration?


Answer



It has nothing to do with visibilty. The quote is referring to a struct forward declaration (so, no definition available)



The header effectively contains something like :



struct X;  // No definition available



A forward declaration introduces an incomplete type. There are very few things you can do with an incomplete type, but one of them is declaring a pointer (not dereferencing it).



As long as the compiler doesn't know the size of the struct, or it's members (it certainly can't with a simple forward declaration), it won't allow any declaration of an X, nor any dereferencing of a pointer to an X.


c# - How do I make a unit test to test a method that checks request headers?




I am very, very new to unit testing and am trying to write a test for a pretty simple method:



public class myClass : RequireHttpsAttribute
{
public override void OnAuthorization(AuthoizationContext filterContext)
{
var request = filterContext.HttpContext.Request;
var header = Convert.ToBoolean(request.Headers["Special-Header-Name"]);


if (!(header || request.IsSecureConnection))
{
HandleNonHttpsRequest(filterContext);
}
}
}


This method, which inherits from the RequireHttpsAttribute, checks if a certain header is present from a page, if it's missing or false, and the page is not secure, then it will call HandleNonHttpsRequest, otherwise it does nothing.




We are using Moq and Nunit for testing. I have found some resources to help build a fakeHttpContext with Moq, but honestly I'm not sure how to use it or where to go within my unit tests to ensure that fake HttpContexts are or are not causing the HandleNonHttpsRequest method to call.



I really appreciate any guidance with this issue.


Answer



// arrange
var context = new Mock();
var request = new Mock();
var headers = new NameValueCollection
{
{ "Special-Header-Name", "false" }

};
request.Setup(x => x.Headers).Returns(headers);
request.Setup(x => x.HttpMethod).Returns("GET");
request.Setup(x => x.Url).Returns(new Uri("http://www.example.com"));
request.Setup(x => x.RawUrl).Returns("/home/index");
context.Setup(x => x.Request).Returns(request.Object);
var controller = new Mock();

var actionDescriptor = new Mock();
var controllerContext = new ControllerContext(context.Object, new RouteData(), controller.Object);

var filterContext = new AuthorizationContext(controllerContext, actionDescriptor.Object);
var sut = new myClass();

// act
sut.OnAuthorization(filterContext);

// assert
Assert.IsInstanceOfType(filterContext.Result, typeof(RedirectResult));
var redirectResult = (RedirectResult)filterContext.Result;
Assert.AreEqual("https://www.example.com/home/index", redirectResult.Url);


RUBY Nokogiri CSS HTML Parsing



I'm having some problems trying to get the code below to output the data in the format that I want. What I'm after is the following:




CCC1-$5.00
CCC1-$10.00
CCC1-$15.00
CCC2-$7.00




where $7 belongs to CCC2 and the others to CCC1, but I can only manage to get the data in this format:





CCC1-$5.00
CCC1-$10.00
CCC1-$15.00
CCC1-$7.00
CCC2-$5.00
CCC2-$10.00
CCC2-$15.00
CCC2-$7.00




Any help would be appreciated.



require 'rubygems'  
require 'nokogiri'
require 'open-uri'


doc = Nokogiri::HTML.parse(<<-eohtml)










CCC1








$5.00
$10.00
$15.00










CCC2






$7.00



eohtml


doc.css('td.BBB > span.CCC').each do |something|
doc.css('tr > td.EEE, tr > td.FFF').each do |something_more|
puts something.content + '-'+ something_more.content
end
end

Answer



How about this?



doc.css('td.BBB > span.CCC').each do |something|

something.parent.parent.css('tr > td.EEE, tr > td.FFF').each do |something_more|
puts something.content + '-'+ something_more.content
end
end

Reading from JSON File C#

Hey guys I have this json file (excerpt):
https://hastebin.com/uzifiteqol.json
I have created a discord bot which responds to commands and one of the commands is *card (card name)
This JSON file provides the stats of all the cards, but I want the user to access the lvl 9 stats based on the idname (card name he puts)
For example:
*card arrows
This should give the user the area damage of lvl 9 arrows that are shown in the json, but I am not sure how to access this stat. Heres what I have so far:



string jsonString = File.ReadAllText("/Users/me/Desktop/cardstatsfile.json");



This is where the json file location is on my computer (mac)
I am not sure how to go from there, I was thinking that I would need JToken.parse and parse through the file to look for the "idname" or the card specified by the user. Thanks in advance!



EDIT: Clarification: Because there are 75 cards, I want to obtain the values of elixircost, rarity, ect and also all the lvl 9 stats just by providing the idname. Or do I need to reformat the JSON to do this?

plot explanation - How does Blake know that Bruce Wayne is Batman? - Movies & TV



In The Dark Knight Rises at the scene when Bruce first meets Blake (where the latter goes calling at Wayne Manor), the way Blake confidently asserts to Bruce that Batman is needed seems to suggest that he has more than hunch about Batman's true identity.




How did he come across that (it is later acknowledged by Bruce in the car scene, when he says that Batman could be anyone...), and why does Bruce accept his assertion?


Answer



Blake doesn't have a full confirmation that Wayne is Batman, but as he explains to Bruce, he always had an inkling.



Blake talks about losing parents is something no child can ever move on from, not someone stuck in an orphanage like him, or someone like Wayne, with boundless money and potential. Its a kind of unspoken comradery that only those in the situation can understand, hinted at when Blake says




Blake: No one knows how it feels to be angry in your bones.





From this, and from the time that Bruce visited the boys home, the boys always had a fantasy of Bruce being Batman, as a bit of a joke. But Blake could tell from Bruce's face that day, from the look and smile he gave everyone, that it wasn't just pure fantasy. As Blake also explains:




Blake: I know that smile you put on...its the same one I taught myself




From this, Blake has a gut feeling that Bruce isn't who he lets on to everyone, billionaire playboy extraordinaire. But something different.
Not to mention one big element from the movie, Bruce goes into seclusion almost around the same time Batman disappears. Putting these pieces together, Blake makes the assumption that Bruce is Batman, and confronts him with Gordon's shooting.



This turns out to be correct, of course, and garner's Bruce's trust because Blake is someone who can understand Bruce's situation, coming from it himself. And Blake is also someone who share's Batman's ideals, as he says:





Blake: I don't know why you took the fall for Dent's murder, but I'm still a believer in the Batman




Showing us and Bruce that he has, at least similar, ideals to how Bruce was when he first put on his cape and cowl. And also the reason why he trusts Blake with the cave at the end.


java - What is Dependency Injection?











Spring is the framework from where the concept Dependency Injection came to picture.



What is purpose of DI ? How does it benefit ? How is it implemented ?


Answer



Start here.




Also see A-beginners-guide-to-Dependency-Injection. (Obsolete)



Elsewhere on SO:




javascript - Php form emailing but $_POST['email'] is failing

This summary is not available. Please click here to view the post.

How to Store dynamic table value using SharedPreference in android

I am developing web services based android application below i mentioned my application output....
here's my dynamic table view



final LinearLayout linear = new LinearLayout(
MainActivity.this);
MainLayout.setWeightSum(1.0f);
TableRow row1 = new TableRow(MainActivity.this);

row1.setId(1000 + sCount);
text1 = new TextView(MainActivity.this);
text1.setText(button.getText());
text1.setTextColor(Color.WHITE);
LayoutParams params = new TableRow.LayoutParams(0,
LayoutParams.WRAP_CONTENT, 2f);
text1.setLayoutParams(params);

// text1.setGravity(100);
final Button button = new Button(MainActivity.this);

EditText e = new EditText(MainActivity.this);
LayoutParams params1 = new TableRow.LayoutParams(0,
LayoutParams.WRAP_CONTENT, 0.5f);
e.setLayoutParams(params1);
e.setInputType(InputType.TYPE_CLASS_NUMBER);
arryList.add(text1.getText().toString());
nameArray = arryList.toArray(new String[arryList
.size()]);
String itemname = text1.getText().toString();


button.setText(" X ");
button.setId(2000 + sCount);
LayoutParams params2 = new TableRow.LayoutParams(0,
LayoutParams.WRAP_CONTENT, 0.5f);
button.setLayoutParams(params2);
button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
MainLayout.removeView(findViewById(v

.getId() - 1000));
}
});

sCount++;
row1.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));
row1.setGravity(Gravity.CENTER_VERTICAL);
row1.setPadding(1, 1, 1, 1);

row1.addView(text1);
row1.addView(e);

row1.addView(button);
MainLayout.addView(row1);


}
ll.addView(MainLayout);
// TODO Auto-generated method stub



the output is



enter image description here



i want store the textview values and edittext values in sharedpreference...after that i want to retrieve the same value and load the same table layout...how can i do that??
please any help me...thanks in advance..

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...