Displaying a hidden field

Question: I am trying to set a hidden textblock that I want to appear upon a button click. I am using XAML and Caliburn.Micro.
Seems like a simple task, but I have to learn it first!
Thanks
Answer: To hide
Visibility.Collapsed
<TextBlock Visibility="Collapsed">

To display
<TextBlock Visibility="Visible">

programmatically something like this in your button click
textboxid.Visibility =
    ( textboxid.Visibility == Visibility.Visible ) ?
       Visibility.Collapsed : Visibility.Visible;

Comment: Thanks, but I am trying to change from Collapsed/Hidden to Visible on a button click.
Comment: @Josh - that you can do by programaticaly by assinging is and writritng like textboxid.Visiblity = Visiblity.Collapse; or textboxid.Visiblity = Visiblity.Visible; write this code in button click

Displaying a hidden field


how to remove language prefix from rewriting administrator url in joomla 2.5

Question: Recently i was asked to move a site to a new server. The site is on Joomla 220.127.116.11 and has 2 languages. The move seemed smooth but when i tried to access the administrator, i got a 404 page.
What happens is this: after typing the url for the admin/login page (www.mysite.com/administrator) this address changes to www.mysite.com/el/administrator and isnt recognized. So i dont have access to the backend at all and all changes must be made via ftp and on the db directly. At the live site this doesnt happen and everything works as intended.
I checked the .htaccess and is the default of the installation. The php ver of the two servers are almost the same (5.4 and 5.4.41).
The site has many modules and virtuemart but the one responsible i think is Falang. When i deactivated it almost nothing changes and the rewrite still happens.
Any clues and ideas?
Comment: http://forum.joomla.org/viewtopic.php?f=617&t=713477#p2794600
Comment: I realize that you may have to do that via PHPMyAdmin, but it may be a solution. Also, http://joomla.stackexchange.com.
Comment: Thank you, the option was already set to No. I will also try posting at your second link that is more focused on Joomla.
Answer: Unfortunetly the solution was dissapointing. Somewhere between zipping, downloading, uploading to the new server and extracting something went wrong and some files were corrupted or not copied.
Solution was to use akeeba backup and do the whole proccess again, where everything worked at once as they should.


Intersection of Hyperbolas

Question: I have two hyperbolas, given in the form:
$$\tag{1}A_1x^2+2B_1xy+C_1y^2+2D_1x+2E_1y+F_1=0$$
$$\tag{2}A_2x^2+2B_2xy+C_2y^2+2D_2x+2E_2y+F_2=0$$
With $A_1=A_2=0$.
I wish to attain all intersection points. I saw this example, but my representation is different. In addition, somehow this transformation does not seem to work for me.
Thanks!
Comment: @Narasimham, that doesn't sound quite right unless I'm misreading what you said.  There can be 1 real solution (e.g. $xy + y^2 + x + y + 1 = 0$ and $-2xy + y^2 + x + y + 1 = 0$) or 3 real solutions (e.g. $xy + y^2 + x + y + 1 = 0$ and $2xy -12y^2-3x-31y+37=0$), etc.
Comment: There can be 2 real, one double or a single complex root & conjugate.
Comment: Are you looking for a general formula?  Or do you have a specific problem?
Comment: @tilper I have a set of hyperbolas of this form ($A_i=0$), and I'm looking for a general formula to find all intersection points of any two hyperbolas in the set.
Comment: In the last example you gave in the question you chose axes rotated hyperbolas without an $xy$ term,
Comment: @omerbp when *considering double branches*  as distinct the number of roots can  increase to 4, and minimum two real roots.. Can you upload the graphs?
Answer: The case $A_1=A_2=0$ leads to a cubic equation. They are at least one or up to three intersection points :

The general case, valid not only for two hyperbolas but for two quadratic curves, leads to a quartic equation, so from zero up to four intersection points.
Comment: Yes some terms are missing. I will correct it. Thanks.
Comment: Great, this is exactly what I looked for. Thanks!
Comment: Just a correction, the term $k_1$ should be $2(E_1 D_2 + F_1 B_2 - 2 E_2 D_1-F_2B_1)$
Answer: The solution is voluminous, found by Cramer's Rule solving for 2 unknowns from 2 equations.  Roots are as quadratic equation depending on sign of quantity under the radical
$$
(-2 B2^2 C1 D1 + 2 B1 B2 C2 D1 + A2 C1 C2 D1 - A1 C2^2 D1 +
    2 B1 B2 C1 D2 - A2 C1^2 D2 - 2 B1^2 C2 D2 + A1 C1 C2 D2 +
    A2 B2 C1 E1 - 2 A2 B1 C2 E1 + A1 B2 C2 E1 + A2 B1 C1 E2 -
    2 A1 B2 C1 E2 + A1 B1 C2 E2)/(-4 A2 B1 B2 C1 + 4 A1 B2^2 C1 +
    A2^2 C1^2 + 4 A2 B1^2 C2 - 4 A1 B1 B2 C2 - 2 A1 A2 C1 C2 +
    A1^2 C2^2)  + ..... + \sqrt {...}
$$
EDIT 1:
Considering a single brach it may be like one of three situations:

But for  two branches, there is a situation of double the number of roots/intersections  as may be in a quadratic equation.
Comment: Do you mean [Cramer's rule](https://en.wikipedia.org/wiki/Cramer%27s_rule)? Any point to a valuable explanation?
Comment: Changed spelling.
Comment: My hope is that since $A_i=0$ this expression can be simplified....
Comment: To an extent may be by dividing by $ F$ s , $A_i =0$  but depends on the discriminant basically.
Comment: Do you refer to $D$ or $\Delta$ [here](https://en.wikipedia.org/wiki/Hyperbola#Quadratic_equation)? Anyway, it holds that $x_c=0$ (in the same notations)

Intersection of Hyperbolas


Where should the main stack vent go?

Question: Where does my primary stack vent go? Does it have to be at the end of the run? I have a pretty simple plumbing system. From the highest point to where the drain enters the house (lowest) I have
Tub, then bathroom sink, toilet, kitchen sink, laundry, exit to sewer.
I'd like to put my main stack as the vent on the bathroom sink. Is that ok even though tub is higher up on the run?
My code says:

Vent connection at base. Every vent stack shall connect to the base of the drainage stack. The vent stack shall connect at or below the lowest horizontal branch. Where the vent stack connects to the building drain, the connection shall be located downstream of the drainage stack and within a distance of 10 times the diameter of the drainage stack.
Answer: You have one main stack typically.  All of the plumbing drains into it and goes down.  The venting for the plumbing should be above the highest drain-to-main-stack connection.  The venting goes up - on a typical home it would vent out the roof.  If you had the vents below then you may get water/sewage in them and your house would stink and possibly drains would not function as well.  If you are more specific I can touch on how to do this right.
Comment: Thanks, the clarification that the venting for the main stack should be above the highest drain to main stack is what I needed. Do you know if the main vent can be used as the P trap vent for more than one fixture (toilet, tub and vanity) if it is close enough to those fixtures? Any idea how close is close enough?
Comment: @michael - Depending on the size of the pipe you can vent many different branches through one line.  We use 2" PVC for bathrooms and all the fixtures vent up through that.  That is generalizing but yes you can have more than one per vent-to-stack connection and that is common practice.
Answer: In answer to your question, yes it's ok to put a vent near your sink, but there should already be a vent from your main stack to your roof.
But are you asking if it's ok to have no vent except a vent near the sink?  This depends on how far the other fixtures are from the main stack and other questions.

Where should the main stack vent go?


move files whose creation time or modified time is less than 25 mins to a different folder

Question: I want move a file from dir1 to dir2 , but the catch is it should move if the creation time or modified time is less than 25 mins.
please suggest command for this.
Answer: This can be done with the find command. It allows to find files changed after a specified time. The -type f option allows to specify only files, not directories, should be found. The -mtime option allows to specify a period. The -exec option allows to do something with the found file. See man find for how find works and find one of many tutorials on line that teach you how to do this.


Readable, Nested PHP Loops/Ifs in HTML

Question: I am trying to separate my PHP and HTML. I am passing an array of PHP variables to my HTML code. I am creating a select dropdown and trying to select a specific option based on my variables. Like this:
//example vars from PHP array (uses magic getter and accessed by $this->varName)
//$array = array('aaa' => '123', 'bbb' => '456', 'ccc' => '789');
//$selected = 'bbb';

<select name="name" id="id">
<option value="0">Choose n Option</option>
<?
foreach($this->array as $key => $value)
{
    ?>
    //$selected may not be set
    <option value="<?=$key?>" <? echo isset($this->selected) ? (strcmp($key,$this->selected)==0 ? 'selected' : '') : '' ?> ><?=$value?></option>
    <?
}
?>
</select>

The outcome is:
<select name="name" id="id">
    <option value="0">Choose an Option</option>
    <option value="aaa"  >123</option>
    <option value="bbb" selected >456</option> //'selected' determined by code above
    <option value="ccc"  >789</option>
</select>

Is there a better to way write which option should be selected? Either using PHP or changing my logic? <? echo isset($this->selected) ? (strcmp($key,$this->selected)==0 ? 'selected' : '') : '' ?> does not seem very readable. I would like to know if there is better way to write code in situations where the HTML/view code needs to use nested loops and ifs, especially when inside an HTML tag like this case.
I thought about putting the result of <? echo isset($this->selected) ? (strcmp($key,$this->selected)==0 ? 'selected' : '') : '' ?> into a variable and then I would just have
$newSelectVar = <? echo isset($this->selected) ? (strcmp($key,$this->selected)==0 ? 'selected' : '') : '' ?>;
<option value="<?=$key?>" <?=$newSelectVar?> ><?=$value?></option>

I didn't want to do this because I was trying to only use inline PHP (I read this makes the HTML more readable and maintainable), but I guess I am already breaking that rule with the foreach.
Comment: when writing HTML using loops I often append all the HTML code to a variable and echo it at the end. For the `selected` variable, instead of using true or false, put `selected` or nothing, then always use the variable (1 if less)
Answer: Most people will start screaming at you to use a templating system... but since PHP IS a templating system, that's redundant. Instead of breaking out of PHP mode to output a few chars of text, try something more like:
foreach($this->array as $key => $value)
   $sel = isset($this->selected) ? (strcmp($key,$this->selected)==0 ? 'selected' : '') : '';
   echo <<<EOL
<option value="{$key}" {$sel}>{$value}></option>
EOL;
}

Comment: Sounds reasonable to me. So the advice I read that said "only use inline PHP in HTML" shouldn't be used in this case?
Comment: it all comes down to just how much php you're embedding. a simple `` is no problem. But if you're embedding complicated logic (and especially nested ternaries), then you're better off using something else, like an intermediate variable.
Answer: You should never bind your business logic and presentation layer (HTML template in this case). All what you're doing now already breaks SoC.
Well, in order to keep this thing more maintainable you need something like HTML Helper class. This avoids any kind of logic within presentation.
class HTMLHelper
{
   public static function isSelected($actual, $expected)
   {
       if ($actual === $expected){
           print 'selected="selected"';
       }
   }

   public static function isChecked()
   {
      // The same goes for checkbox, but you want
      // checked="checked" instead of selected="selected" here
   }
}

Note: You should use a full alternate for templates that dedicated for them and only, not <?php { ... ?>
Then in your presentation
<select>

<?php foreach($this->array as $key => $value) : ?>

    <option value="<?php echo $key;?>" <?php HTMLHelper::isSelected($this->selected, $key);?> ><?php echo $value; ?></option>

<?php endforeach; ?>

</select>

The major benefits you get are:
1) Modularity. The same HTMLHelper::isSelected could be used for another templates as well.
2) Separation of concerns
3) Code becomes easy to maintain
Comment: This alternative syntax is new to me and looks like a great idea.
Comment: One more thing. `  `. This syntax works as well. I like this since it keeps the brackets. Is this okay as well?
Comment: The alternative syntax **should** only be used within templates. Yep, standard syntax works as well, (I didn't say it doesn't), but you'd better avoid this. So, more appropriate syntax for templates would be `..html stuff here..` the same goes for : `foreach/endforeach`, `while/endwhile`
Comment: Ha, I usually separate the bracket onto a new line so initially it looked like an alternative-alternative syntax. Oops, obviously just standard syntax. Why should I avoid this (in templates)? It still seems to be inline PHP.
Comment: You should avoid default syntax in templates(`<?php { `) because: 1) Alternate syntax makes your logic more template-specific. 2) The alternate syntax has been dedicated for templates since the beginning (Again: Alternate syntax is not for classes or whole php scripts, but for templates only). Don't ask me why - just start using it, and you would feel the difference :)
Comment: And also, ` html stuff ` works as well(as you said before), but its just ugly. `html stuff` is more cleaner and maintainable.

Readable, Nested PHP Loops/Ifs in HTML


3-Way Wifi Switch Installation Question

Question: I'm attempting to install a Kasa Smart 3 Way Switch (HS210).  The installation instructions rely on the outlet box have two neutral (WHITE) wires being currently unused and wire-nutted together in the back of the outlet box.
When I took the plate off my the current switches (both of which control the same lights) this is what I found:
Box 1: There are two cables in this Box.  One cable has a BLACK, WHITE and RED wire.  The RED and WHITE wire go to the switch.  The BLACK wire is under a wire nut with the WHITE wire from the second cable.  The second cable has a WHITE and BLACK wire.  The BLACK wire goes to the switch and the WHITE wire is under a wire nut with the BLACK wire from the first cable.  [Going into the switch is a RED wire (top right), a WHITE wire (top left) a BLACK wire (bottom right) and a ground.  In the back of the outlet box there was a BLACK wire and a WHITE wire, connected together by a wire nut.]
BOX 2:  There is one cable in this box, with BLACK, WHITE and RED wires.
[Going into the light switch is a WHITE wire (top right), a RED wire (top left) a BLACK wire (bottom right) and a ground.  In the box, there is a no other wires.]
Coming off the KASA switch is a GREEN wire (labeled ground), a WHITE wire (labeled neutral) and than three screws: one labeled "load" and the other two labeled "travelers".
As mentioned, the instructions call for the outlet box having two WHITE wires connected together in the back box.  Is there a way to safely install this if I don't have two WHITE wires, but do have a BLACK and WHITE wire connected together?
EDIT:  Thank you for the replies.  Edited to respond to the questions below.  Here is a link to pictures of the boxes:  https://drive.google.com/drive/folders/1OibESpeo_cEZXrPeIJdK1yjbl_s7ucUF?usp=sharing
Comment: Can you post photos of the insides of the boxes involved please?
Comment: There is a way to configure an old (not smart) three way switch where one of the switches is on a switch loop and does not have a neutral available.   Black connected to white is a sign you might have this configuration.  It would help if you identified which wires come from which cables where there is more than one cable entering a box, and also the color of the screws they are connected to on the old switch.
Comment: Switch positions don't help, they differ on every switch.  Please go to the browser you posted your question on, and [edit] your question to tell us "how wires are grouped into cables" and 3-way screw colors.  In fact, the 2 brass 3-way screws are for *travelers*, so feel free to just say something like "black and red from cable 1 are travelers".
Comment: Unfortunately, switch *positions* don't mean much on 3-way switches - varies by brand and product. What **colors** are the screws on those switches (the "top left", "top right", etc.) - normal choices are black, brass, silver. Also, each of the switch boxes likely has **2 cables** - can you match up (don't move anything, just tell us what you have) the black, white and (for one cable in each box) red - so that we know which wires are "together".
Comment: *Is there a way to safely install this if I don't have two WHITE wires, but do have a BLACK and WHITE wire connected together?* This sounds like "connect to the neutral bundle" - that may or may not actually be necessary. **However, black and white together are definitely NOT neutrals!** White in a cable can sometimes be hot, and that is quite likely the case here. But black can never (except really large sizes, not applicable here) be neutral.
Comment: from the count of cable-ends  it's failrly clear that these two switches are on a switrch loop with no neutral.
Answer: Box #2 is the "far end" of your multi-way switch. The only wire is your 3-line cable with your hot (black) and two travelers (white and red).
Box #1 has the other end of this... but the problem is your other cable only has two wires. The white wire is being used as the incoming hot, as evidenced by

In the back of the outlet box there was a BLACK wire and a WHITE wire, connected together by a wire nut.

The black wire it's nutted to goes to the common screw of your "far" switch. So, you don't have a neutral in your setup. Your only real solution here would be to replace that wire coming from your fixture with a three-line cable (14/3 in this case). It would involve

Connect the new black wire where the existing 2-line white is for your incoming hot
Connect the red to where the existing 2-line black is for your incoming hot
Connect the white to the neutral at your fixture

The only other alternative would be to buy a switch that does not require a neutral.
Comment: Thank you! Based on what you wrote, I think I will get this (https://www.amazon.com/gp/product/B082LKCXV9/) which says no neutral is required.  Thanks again.

3-Way Wifi Switch Installation Question


In Unison's UCM, is there a way to display a diff before running update?

Question: This would basically be analogous to git diff. I see there are namespace diffing commands for things already committed to a Unison code base, but I may have missed how to do a diff prior to updating, if it is possible.
Answer: At present, there isn't a way to get a line-by-line diff of your work-in-progress in a scratch file with already added content of a namespace. You can see which terms and functions would be changed with the update.preview command and then view 1-n of the terms listed there in the console to see the last saved state of your code, but that command alone won't give a content breakdown.
The fork, update, then merge workflow for adding a feature might provide a lightweight way of viewing incremental changes without polluting your original namespace.
To do this, fork your original namespace to a myWIP namespace, then update your changes in this namespace. You can use the namespace diffing and view source tools between your original namespace and this myWIP one to see changes. Once you're done you can merge your namespace back into the original one and delete ones you don't need.
Comment: I ended up using `diff.namespace` (in place of view tools), followed by `delete.namespace` to remove the WIP namespace, as that seemed to be a straightforward path.


PHP module shows in php cli, not in Apache (XAMPP, Mac OS Mojave)

Question: I have managed to enable the intl module on my machine (it was quite tricky), and when I do php -m | grep intl I see the module listed. My problem is that it seems the module is enabled, but still XAMPP is probably loading some other version of PHP where it isn't.
The output of which php is:

/email@example.com/bin/php

The output of php -v is:

PHP 7.1.26 (cli) (built: Feb 26 2019 10:26:24) ( NTS ) Copyright (c)
  1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018
  Zend Technologies
      with Zend OPcache v7.1.26, Copyright (c) 1999-2018, by Zend Technologies

Output of php -i | grep intl is:

Configure Command =>  './configure'
  '--firstname.lastname@example.com/7.1.26'
  '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/7.1'
  '--with-config-file-path=/usr/local/etc/php/7.1'
  '--with-config-file-scan-dir=/usr/local/etc/php/7.1/conf.d'
  '--firstname.lastname@example.comemail@example.com/pear'
  '--enable-bcmath' '--enable-calendar' '--enable-dba' '--enable-dtrace'
  '--enable-exif' '--enable-ftp' '--enable-fpm' '--enable-intl'
  '--enable-mbregex' '--enable-mbstring' '--enable-mysqlnd'
  '--enable-opcache-file' '--enable-pcntl' '--enable-phpdbg'
  '--enable-phpdbg-webhelper' '--enable-shmop' '--enable-soap'
  '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem'
  '--enable-sysvshm' '--enable-wddx' '--enable-zip'
  '--with-apxs2=/usr/local/opt/httpd/bin/apxs'
  '--with-bz2=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-curl=/usr/local/opt/curl-openssl' '--with-fpm-user=_www'
  '--with-fpm-group=_www' '--with-freetype-dir=/usr/local/opt/freetype'
  '--with-gd' '--with-gettext=/usr/local/opt/gettext'
  '--with-gmp=/usr/local/opt/gmp'
  '--with-iconv=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-icu-dir=/usr/local/opt/icu4c'
  '--with-jpeg-dir=/usr/local/opt/jpeg'
  '--with-kerberos=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-layout=GNU' '--with-ldap=/usr/local/opt/openldap'
  '--with-ldap-sasl=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-libedit=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-libxml-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-libzip' '--with-mcrypt=/usr/local/opt/mcrypt'
  '--with-mhash=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd'
  '--with-ndbm=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-openssl=/usr/local/opt/openssl'
  '--with-pdo-dblib=/usr/local/opt/freetds' '--with-pdo-mysql=mysqlnd'
  '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc'
  '--with-pdo-pgsql=/usr/local/opt/libpq'
  '--with-pdo-sqlite=/usr/local/opt/sqlite'
  '--with-pgsql=/usr/local/opt/libpq' '--with-pic'
  '--with-png-dir=/usr/local/opt/libpng'
  '--with-pspell=/usr/local/opt/aspell'
  '--with-sqlite3=/usr/local/opt/sqlite'
  '--with-tidy=/usr/local/opt/tidy-html5'
  '--with-unixODBC=/usr/local/opt/unixodbc'
  '--with-webp-dir=/usr/local/opt/webp' '--with-xmlrpc'
  '--with-xsl=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  '--with-zlib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr'
  intl intl.default_locale => no value => no value intl.error_level => 0
  => 0 intl.use_exceptions => 0 => 0

These are the paths in my bash profile:

export PATH="/firstname.lastname@example.com/bin:$PATH" export
  PATH="/firstname.lastname@example.com/sbin:$PATH"

Then, in php.ini I uncommented this line:

extension=intl.so

xdebug is also enabled:

; Enable xdebug
  zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
  xdebug.remote_enable=on xdebug.remote_handler=dbgp
  xdebug.remote_host=localhost xdebug.remote_port=9000
  xdebug.max_nesting_level=500

In httpd.conf, I load the PHP module like this:

LoadModule  php7_module /firstname.lastname@example.com/lib/httpd/modules/libphp7.so

I've checked that httpd.conf is not being included in an additional file (as suggested by this answer). I got this:

Include "/Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf"

But that additional config file only contains virtual directories.
My phpinfo spits this PHP version:
PHP Version 7.1.13
I've read that PHP cli and PHP module for Apache2 don't necessarily have the same version, but here's my question:
why the intl module is loaded correctly in PHP cli and not in the Apache2 PHP module?
PS: There are no errors in the logs about loading an incorrect module, there were before I renamed it from php_intl.dll to intl.so, but not anymore.
Answer: XAMPP has its own bundled Apache+PHP. it runs php as apache module.
to run php as apache module, you should re-compile mod php from source with parameter --with-apxs.


gsutil copy, how to specify max number of objects to copy?

Question: I need to move files from one bucket to another in GCS for processing, each time I just need to copy and process certain amount of files, say 100, how can I configure it in the command line?
gsutil -m mv gs://bucket1/file001.json gs://bucket2/
Thanks for your help.
Comment: Are the source objects named sequentially? e.g. file001, file002, etc?
Answer: You could write a script that builds a list of all objects to be copied and then walks through them 100 at a time, calling gsutil mv one at a time. That would lose parallelism compared to running gsutil -m mv, so you could run each of those gsutil mv commands in the background and then wait for all 100 to complete before moving on to the next batch.


In ios 6 project, using ARC, is it safe to return from function NSDictionary created inside function?

Question: In ios 6 project, using ARC, is it safe to return from function NSDictionary created inside function ?
NSDictionary is required by AFHTTPClient to send parameters and I have nested blocks ( I hopes that is right way to send second request only if first was successful) for sending ( I first upload image of survey and if that was successful I upload answers in nested block). This requires to function be very long so I thought to create function which collect parameters  and returns NSDictionary to be more readable.( I am totally new to ios, so apologize if question no makes sense)
Comment: Do you have any example code to show? It would help me understand your question better.
Answer: Yes, this is common and expected. You should read over Acquire Foundational Programming Skills to make sure you have a basic understanding of Objective-C object models before proceeding.


Proxy settings ubuntu 15.10: proxy to no proxy switch

Question: At work, I need to use a proxy to get online. So, I go to the System>Preferences>Proxy settings and I fix the proxy manually.
Because I also wanted my package manager to connect to the internet, I went into
/etc/apt/apt.conf.d

and created a 95proxies file containing these lines:
Acquire::http::Proxy "http://18.104.22.168:3128";
Acquire::https::Proxy "https://22.214.171.124:3128";
Acquire::socks::Proxy "socks://22.214.171.124:3128";
Acquire::ftp::Proxy "ftp://126.96.36.199:3128";

(the numbers are just random)
after
sudo apt-get update

the package manager works fine.
But, now that I'm back at home, I turned off the proxy and mozilla connects fine, but the package manager cannot connect anymore. It still tries to connect through the proxy. I didn't have this issue in ubuntu 14.04. Does anyone have an idea how to fix this? In other words how to make the direct internet connection work again?
Comment: Surprisingly, the out commenting worked. What didn't work is removing the 95proxies file.
Comment: Awesome, I'm glad I could help :). If you could please mark the answer bellow as the correct answer?
Answer: I also face a similar problem. What I normally do is that I simply comment out the content of that file(ie 95proxies) and I'm good to go. In other words I am constantly commenting and un-commenting that file depending on where I am at. I wonder if there is a is a more elegant solution perhaps.


Why won't my Whirlpool washer go to high speed spin?

Question: Whirlpool Duet model wfw9750ww01 won't ever get up to high speed spin even with an empty washer. It will go to hi speed spin in diagnostics.
When it's time for spin, the machine always rotates alternating directions a few times, then turns the drain pump on and slowly spins up. It gets up to a fair it stops and starts over.
Comment: Is this a new machine?  If so send it back.  Is this a new problem on an older machine that work right before?
Comment: I have an older model and it behaves that way. It doesn't reach "full speed spin" until after it goes through the slow spin/pump cycle a few times. Have you waited long enough for it?
Comment: The machine is about 10 years old, It never goes to high speed spin except in diagnostics.
Comment: It does go to a medium speed spin after it goes through the slow spin/pump cycles, if its got a load or not. It seems to be stuck in unbalanced load with or without a load. but if you run in diagnostics it goes to high speed every time.
Comment: There are no error codes. As I said above when running machine empty there is no shaking when this is done. The four shock absorbers were replaced the springs are unbroken there is no sagging and there is only very little play in the bearing, the drum spins by hand with very little resistance. The CCU was replaced and the level sensor and the MCU. The machine is sensing an  unbalanced load when there is none. Also the washer was ran through a diagnostics cycle and it runs on hi speed spin every time.
Answer: First, check the Whirlpool Duet Washer Job Aid for the meaning of the error codes, which you should include in your question.
That said, it might due to shaking from being out of balance. "The unbalance detection routine occurs.. while basket spin is accelerating from 40 to 400 rpm...  If the Motor Control Unit senses an unbalanced condition, the drive motor is stopped."
A few likely causes of excessive shaking:

There are two suspension springs. If one breaks, the drum tilts to one side and drops lower.
There are four shock absorbers. Over time, they can deteriorate, causing excessive shaking.
The drum bearing can be loose.

The first two can be easily fixed with comparatively inexpensive parts, using the Job Aid and readily-found online videos. Use caution, particularly with electrical safety and with spring replacement. This is not a good DIY project for a beginning learner.
However, replacing the drum and/or bearing are not a DIY project, nor is it inexpensive. For a 10 year-old washer, it's likely not worthwhile.


Why does my code does not have decimal? c#

Question: Why does my result does not have decimal?
<code>***///Get api/example/{id}
///Get api/example/33 -> 4
public string GET (int id)
   { int product = id/7;
     return product;
   }***
</code>
If the input number is 33, I would get the answer '4' without decimal, it does not even round up.
Comment: Hint: `product` is an integer type. If you want a fraction use a float or decimal type. If you want to round, use `Math.Round()`.
Comment: Hi Sunny. Please [edit] the question and clarify if the problem is the lack of decimal, or the truncation method (lack of rounding). The post and the title are a bit confusing since those are two different questions.
Comment: Please post real code. `product` is an `int` so C# has a compiler error when you try to return it for a function with a `string` return type.
Answer: It is because you are storing result of you calculation in a variable of data type "int". int can not take fractional values. Use float or double to get decimal points.
Also in C# when you do division and if both the numerator and the denominator are integers then result will be integer. So to convert it to decimal point you will need to convert either denominator or both to decimal.
You can to like this..
<code>    float product = (float)id/(float)7; or
    float product = id/7f; // using literals
</code>
So your function should look like this..
<code>public string GET (int id)
{
    float product = id/7f;
    return product.ToString();
}
</code>
Also use ToString() on final product result while returning because your method expect String value as return type.
hint : https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types
Comment: `id/7` doesn't _return_ a fractional value. Also, this code doesn't compile.
Comment: Could you please share error message here ?
Comment: error CS0029: Cannot implicitly convert type 'float' to 'string'
Comment: But even if we change `return product;` to `return product.ToString();` to fix that error, calling `GET(33)` returns `"4"`: [Example](https://rextester.com/YDTP47542).
Comment: Sorry, it was my fault. I posted answer in hurry. I have edit the main answer, please check. Also I have provided the description of solution.


Calculus Made Easy

Question: In S. Thompson's Calculus Made Easy (pg. 31)
He talks about an example which he writes, and I quote:

(4) The volume of a cylinder of radius $r$ and height $h$ is given by the formula $V = πr²h$. Find the rate of variation of volume with the radius when $r = 5.5  in.$ and $h = 20  in.$ If $r = h$, find the dimensions of the cylinder so that a change of 1 in. in radius causes a change of 400 cub. in. in the volume.
The rate of variation of $V$ with regard to $r$ is
$dV/dr = 2πrh$
If $r = 5.5 in.$ and $h = 20 in.$ this becomes $690.8$. It means that a change of radius of 1 inch will cause a change of volume of $690.8$ cub. inch. This can  easily be verified, for the volumes with $r = 5$ and $r = 6$ are $1570 cub. in.$ and $2260.8 cub. in.$ respectively, and $2260.8 – 1570 = 690.8$
Also, if
$r = h$,
$dV/dr = 2πr² = 400$ and $r = h = √(400/2π) = 7.98 in$

Forget about the second part for now.
Considering only the first part,
Does that mean for every consecutive increase in radius, the increase in volume is $690.8 in³$? Because if I use radii other than the ones used in the example, the increase in volume is different every time. For instance if radius is $30$ in., the volume is $56540 in³$ and radius $31$ gives volume $60530.8 in³$ the difference being $3990.8 in³$ which contradicts the statement

It means that a change of radius of 1 inch will cause a change of volume of $690.8$ cub. inch.

Is there anything I'm missing? Or am I interpreting it the wrong way? Please explain?
Answer: A small change from $r$ to $r+\delta$  will cause a change in $V$ of $ approximately $ $2\pi rh\delta .$
A small change from $r^*=r+\delta$ to $r^*-\delta =r$ will cause  a change in $V$  of $approximately$ $-2\pi r'h\delta.$
But (if $r\ne 0\ne h$)  $2\pi rh\delta \ne 2\pi r'h\delta$ unless $\delta =0.$
And note  that $2\pi rh \delta$ is different for different values of $r$.
The book is misleading because it refers to these formulas for changes as if they were exact and not approximate.
Answer: Throw.  This.  Book.  Away.
The author shows very little fundamental understanding of calculus.  Let's try the same arguments with the volume of a sphere:
$$V=\frac43\pi r^3\ ,\qquad \frac{dV}{dr}=4\pi r^2\ .$$
If $r=5.5$ and we find the difference in volumes for $r=5$ and $r=6$, exactly as in the book, we get
$$\frac{dV}{dr}=121\pi\ ,\qquad V(6)-V(5)=(121\tfrac13)\pi\ ,$$
which are clearly not the same, though as we would expect from a proper understanding of calculus, they are approximately the same.
So, why did it work for the cylinder?  Purely because the volume formula for the cylinder involves an $r^2$.  We can easily do the algebra for any value of $r$, varying it by $\frac12$ each way as in the book:
$$V(r+\tfrac12)-V(r-\tfrac12)=\pi\bigl((r+\tfrac12)^2-(r-\tfrac12)^2\bigr)h
  =2\pi rh=\frac{dV}{dr}\ .$$
This is purely algebra, nothing to do with calculus.  And more importantly, as shown in the sphere example, it won't work for other examples.
Answer: You are absolutely right in thinking.
The change itself depends on the radius. This is not surprising. Only in case of linear functions like ax+b, the change doesn't depend on the value of parameter. But, in general, the change depends on the parameters/variables. That is why it is specifically mentioned in the question $r=h$. If every function was like that(linear), life would have been so easy! And, that is where the differentiation and integration are helpful. If things were constant, then we would not even need calculus!
Comment: So what does that mean? Is there anything in the question that remains constant? Why does he say "It means that a change of radius of 1 inch will cause a change of volume of $690.8$ cub. inch."? If that's wrong, is there something that remains constant throughout?
Comment: The height of cylinder is constant for this question

Calculus Made Easy


Solving a binomial when one of the terms is in the form $e^x$

Question: Say I have the function $y=4e^{-2x}-3x$. I can use a graphing calculator to approximately determine the roots, but how do I find an exact answer?
Answer: An exact answer is only possible in terms of the Lambert $W$ function (Wikipedia link):
$$\begin{align*}
0 &= 4e^{-2x}-3x\\\\
3x &= 4e^{-2x}\\\\
2xe^{2x}&=\tfrac{8}{3}\\\\
ye^y&=\tfrac{8}{3}\;\;(y=2x)\\\\
y&=W(\tfrac{8}{3})\\\\
x&=\tfrac{1}{2} W(\tfrac{8}{3})
\end{align*}$$


Delete rows with Sub Query?

Question: I can't seem to get the SQL to work when using LIKE
DELETE FROM `customer_numbers`
WHERE number NOT LIKE (SELECT number FROM number_part)%

Basically delete all the rows from constomer_numbers table if number does not contain in number_part table
Example:
customer_numbers.number = 0559354544 and number_part.number = 05593 - it shouldn't delete it.. However if 05593 does not contain in customer_numbers.number then delete row from customer_numbers table.. It should match first 5 digits from number_part
Answer: You can't use not like with a list (in most databases, I'm pretty sure this is true in mysql).
Instead, you can use a correlated subquery:
DELETE FROM `customer_numbers`
WHERE not exists (SELECT number FROM number_part
                  where customer_numbers.number like concat(number, '%')
                 )

Comment: If `customer_numbers.number` = 0559354544 and `number_part.number` = 05593 - it shouldn't delete it.. However if 05593 does not contain in 0559354544 then delete number from customer_numbers table.. It should match first 5 digits from  `number_part.number`
Comment: The inner subquery would return a number, when there is a match.  The "not exists" would preclude this from being updated.  Isn't this what you want?
Answer: Your query is rather broken.  In at least two ways:

Your subquery returns multiple rows, but is in a place where it looks like you expect a single result.
You need your LIKE string to be quoted.

2 is probably easy to fix. Try:
... WHERE number LIKE CONCAT((SELECT ... LIMIT 1),'%');

1 is really your problem, though.  If you run your subselect as a single command, I expect you'll get multiple rows, right? How do you expect to treat a list of numbers (let's say, 1, 2, 3, 4, 5) as part of a LIKE string?
What I'm guessing you're hoping for is something like LIKE '1%' OR LIKE '2%' OR LIKE '3%'..., etc... No?
At any rate, if you can tell us more precisely what you're trying to do, we can probably help you solve your problem better.
As your question is worded, all I can say is:  It doesn't work that way.
Comment: Thanks for detailed response.. There are about 100 rows in `number_part` table (`number` could look like this: 1200, 1300, 1666, etc). In the `customer_numbers` table number could look like this 15343443455.  If 1200, 1300, 1666 number does not contain in 15343443455 then delete it.
Comment: MySQL uses `CONCAT` function, so `CONCAT((SELECT ... LIMIT 1), '%')`
Comment: If `customer_numbers.number` = 0559354544 and `number_part.number` = 05593 - it shouldn't delete it.. However if 05593 does not contain in 0559354544 then delete number from customer_numbers table.. It should match first 5 digits from  `number_part.number`
Answer: You named your fields numbers but it seems like they are character values because of the leading 0s so I am going to assume they are character fields.
If your part number is always going to be 5 characters long then you can do the following:
DELETE FROM `customer_numbers`
WHERE substring(number,1,5) NOT IN (SELECT number FROM number_part)

Answer:
You can't do a LIKE on a numerical field.
You can't do an equality on a sub-select that isn't DISTINCT.

You must use "IN".
DELETE FROM `customer_numbers` WHERE number NOT IN (SELECT number FROM number_part)

Answer: How about something like this:
DELETE FROM customer_numbers WHERE number NOT IN (SELECT number FROM number_part)

Delete rows with Sub Query?


Entity Framework 4.1 - How to get a name of a column for a generated poco object

Question: I am using entity framework 4.1, an edmx mapping file is used to generate poco classes using T4 templates.
How can I get a name of the data base column out of object context for my poco entity properties (if it is possible at all).
I believe the mapping between properties and columns should be in one of the containers:
var container = objectContext.MetadataWorkspace
    .GetEntityContainer(objectContext.DefaultContainerName, DataSpace.CSpace);
...

But I was not able to identify a link between CSpase and SSpace, it looks like CSSpase might do the job, but this container is empty.
Any ideas?
Comment: I used to take the non public reflection route, but things started to break with differences in data models. I ended up abandoning it in favor of the xml route which is slightly less of a hack (I guess). You don't need to read the edmx itself. The edmx is embedded in your output assembly as three manifest resources (an ssdl, csdl, and msl)....so you can load the xml right from those.
Comment: CSSpace is entirely internalized. You'll need to do non public member reflection or read the raw csspace xml to get the info you need.
Comment: I can read edmx file, but this is something I would like to avoid. Do you have an example of how to hack into CSSpace?
Answer: I used a mixed approached to get the mapping information (we have to implement custom data reader/writer for certain types):

First get EntityType object to extract meta information for your POCO type:
public static EntityType GetEntityTypeForPoco(this ObjectContext context,
                                                         Type pocoEntityType)
{
    EntityType entityType
             = context.MetadataWorkspace.GetItem<EntityType>
               (pocoEntityType.FullName, DataSpace.OSpace);

    return (EntityType)context.MetadataWorkspace
           .GetEdmSpaceType((StructuralType)entityType);
}

Read mapping XML document: this part is basically hardcoded, mapping xml document is saved in the assembly where edmx file is, it's called [your_edmx_file_name].msl
currentMslSchemaDocument = new StreamReader(
            Assembly.GetExecutingAssembly().
            GetManifestResourceStream(CurrentMslSchemaDocumentName)
          ).ReadToEnd();

Read property to column mapping from XML document:
var mappingFragments = MslSchemaDocument
.Descendants(XName.Get(ElementNameEntityTypeMapping, NamespaceNameMsl))
.Where(mp => (mp.Attributes(AttributeNameTypeName).Any()
&& mp.Attribute(AttributeNameTypeName).Value == entityTypeModelName));

if (mappingFragments.Count() == 0)
{
    throw new Exception(String.Format("Entity mapping {0} is not found in the given schema stream", entityTypeModelName));
}

//theoretically could be several fragments mapping one entity ytpe to several table
XElement mappingFragment = mappingFragments.First();

string tableName = mappingFragment.Descendants(XName.Get(ElementNameMappingFragment, NamespaceNameMsl))
.First().Attribute(AttributeNameStoreEntitySet).Value;

List<KeyValuePair<string, string>> propertyColumnMappingList = new List<KeyValuePair<string, string>>();

foreach (var xScalarProperty in mappingFragment.Descendants(XName.Get(ElementNameScalarProperty, NamespaceNameMsl)))
{
   propertyColumnMappingList.Add(new KeyValuePair<string, string>(xScalarProperty.Attribute(AttributeNameName).Value,
            xScalarProperty.Attribute(AttributeNameColumnName).Value));
}

Comment: I find it ridiculous that one needs to jump through so much hoops, just to get some basic mapping info that EF uses all along the route. 2 years have passed now. I'm curious if anything has changed.
Comment: As far as I know not yet, they (microsoft) has promised to make it available as a part of API, maybe will come with a new version of dev tools. But honestly I am not tracing the issue anymore, the existing code works, meaning library interfaces and behavior are more or less the same.


Can not established a connection to jdbc with Hibernate-SQL Server 2008

Question: I made a connection to SQL server with Hibernate configuration wizard, when I click test connection, I get success message, but when I want to make hibernate mapping, I cannot I get error message, Cannot established a connection to jdbc.  The below code is jdbc connection with hibernate; please say me, what is the problem?
<hibernate-configuration>
 <session-factory>
<property   name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property     name="hibernate.connection.url">jdbc:sqlserver://localhost; databaseName=Test</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">sa123</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
</session-factory>
</hibernate-configuration>

Best Regards
Comment: Please paste the logs
Comment: when i want to make mapping in new hibernate mapping->select mapping class, I get error: "unable to connect. can not establish a connection to jdbc"
Answer: After looking into your code i found you did not specify the port number for database connection
<property     name="hibernate.connection.url">jdbc:sqlserver://localhost; databaseName=Test</property>

There should be a port number if your trying to connect on your local machine for an example please refer following line
 <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;DatabaseName=syv</property>

Please check and let me know ...if there is any further issue
Ok here i am sending you the basic hibernate configuration : -
STEP 1 :- *Create a Java File "AddStudent" and paste the below code into that.*
//package code;
import java.sql.*;
import java.io.*;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class AddStudent {
    private static SessionFactory sessionFactory;

    public static void main(String args[]) throws Exception {

        DataInputStream d = new DataInputStream(System.in);
        System.out.println("ENTER YOUR NAME");
        String name = d.readLine();
        System.out.println("ENTER YOUR DEGREE");
        String degree = d.readLine();
        System.out.println("ENTER YOUR PHONE");
        String phone = d.readLine();
        System.out.println("Name: " + name);
        System.out.println("Degree: " + degree);
        System.out.println("Phone: " + phone);
        if ((name.equals("") || degree.equals("") || phone.equals(""))) {
            System.out.println("All informations are Required");
        } else {
            try {
                // begin try
                sessionFactory = new Configuration().configure()
                        .buildSessionFactory();
            } catch (Exception e) {
                System.out.println(e.getMessage());
                System.err.println("Initial SessionFactory creation failed."
                        + e);
            }
            Session s = sessionFactory.openSession();
            Transaction tx = s.beginTransaction();
            Student stu = new Student();
            stu.setName(name);
            stu.setDegree(degree);
            stu.setPhone(phone);
            s.save(stu);
            tx.commit();
            System.out.println("Added to Database");
            if (s != null)
                s.close();
        }
    }
}

STEP 2 : Create a Java File "Student" paste the below code into that.
//package code;
import java.io.*;

public class Student implements Serializable {
    private long id;
    private String name;
    private String degree;
    private String phone;

    public long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getDegree() {
        return degree;
    }

    public String getPhone() {
        return phone;
    }

    public void setId(long string) {
        id = string;
    }

    public void setName(String string) {
        name = string;
    }

    public void setDegree(String string) {
        degree = string;
    }

    public void setPhone(String string) {
        phone = string;
    }

    public String toString() {
        return name;
    }
}

Step 3: Create an xml file "hibernate.cfg.xml" place the below code into that.
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory name="studentFactory">
        <property name="connection.driver_class">
            oracle.jdbc.OracleDriver
            </property>
        <property name="connection.url">
            jdbc:oracle:thin:@localhost:1521:XE
        </property>
        <property name="connection.username">
            system
        </property>
        <property name="connection.password">
            system
        </property>
        <property name="connection.pool_size">5</property>

        <property name="dialect">
            org.hibernate.dialect.OracleDialect
            </property>

        <property name="show_sql">false</property>
        <mapping resource="Student.hbm.xml" />
    </session-factory>
</hibernate-configuration>

Step 4:Create an xml File "student.hbm.xml" and place below code into that.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
    <class name="Student" table="Stutbl" >
         <id name="id" type="long" column ="ID">
        <generator class="increment"/>
         </id>
         <property name="name" column="name" not-null="true"/>
         <property name="degree" column="degree" />
         <property name="phone" column="phone" />
    </class>
</hibernate-mapping>

Step 5: Add the required jar to your project
Hope it will solve your problem
Comment: Did you included the correct jdbc.jar in your WEB-INF/lib folder so that your application would be able to make connection with database
Comment: thank you, my application is java application, i add jar file "sqljdbc4.jar" to my project.
Comment: Please post the exceptions logs which you are getting while running your application...
Comment: when i want to make mapping in new hibernate mapping->select mapping class, I get error: "unable to connect. can not establish a connection to jdbc"
Comment: Are you using any plugin to create mapping with the class?
Comment: I  use Hibernate mapping wizard in net-beans for creating hibernate-mapping.
Comment: I would suggest to do it manually. You can post the Entity class and hibernate mapping file i will help to map you..
Comment: Thank you, i have a Entity, Entity name is Role_T, it has tow columns,the first ID and the second is RoleName_nvc, i made hbm, the below code is for hbm file:

the name of hbm file is Role_T.hbm, when i run the program  for read data from role_t i get the error of "/hibernate.cfg.xml not found".
Comment: For your reference i have posted a step wise tutorial to create a simple hibernate project without using any plugin.....so just go through it and create the similar one .....it will definitely solve your problem
Comment: Thank you, i put this code in my project but i take the error: "/hibernate.cfg.xml not found", i changed file "hibernate.cfg"  , because you used oracle, but i wan to use sql server, but when i run project i get that error: "/hibernate.cfg.xml not found".
Comment: Hibernate XML configuration file "hibernate.cfg.xml" is always put at the root of your project classpath, outside of any package. If you place this configuration file into a different directory, you may encounter the following error :"/hibernate.cfg.xml not found"
Comment: thank you,i add to default package but i can not make sessionFactory, this  line i take below error:
Comment: Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
 at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96)
 at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1385)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
 at testhibernate1.AddStudent.main(AddStudent.java:40)
Comment: The javax.persistence.Entity is a class inside the J2EE SDK library "javaee.jar", you are missing this jar file in your project classpath.
Comment: thank you fro your helping, that error solved with your suggestion but i get new error:                                                                 "Could not parse mapping document from resource Student.hbm.xml"
Comment: Please check in your hibernate.cfg.xml that you have included Student.hbm.xml or not. If you have included than did you included twice or not...its basically configuration exception you are getting just check all the configuration once and than run
Comment: thank you, I have problem yet, hibernate.cfg.xml includes Student.hbm.xml
Comment:
com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc:sqlserver://localhost:1433;databaseName=ACM
sa
sa123
org.hibernate.dialect.SQLServerDialect
1
Comment: thread
false
Answer: Add this:

    <property name="connection.pool_size">1</property>

    <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

    <property name="current_session_context_class">thread</property>

and verify if your Database accept connections.


Difference between deploying bundle with quickstart or juju-deployer?

Question: What's the difference between deploying a juju bundle with quickstart or juju-deployer?
Answer: Great question! Juju Quickstart is a user-friendly wrapper application around juju-deployer and Juju. Quickstart's purpose in life is to help users get started with Juju as fast as possible by installing Juju (if it's not already installed), giving you a UI to manage your environment definitions, bootstrapping those environments, and getting you a Juju GUI in that environment in the most light weight way possible. The final feature it does is allow you to deploy a bundle from the charmstore (https://jujucharms.com) or a local bundle you've got on disk.
juju-deployer is a single purpose python tool used to deploy bundles from any location - such as github, launchpad branches, local charm repositories, and/or deployer files. The general purpose of juju-deployer was to be consumed either directly by developers, or to be consumed by applications. It provides a more in depth control of those bundle deployments by supporting things like retry in case of failure.
Juju Quickstart uses the deployer but wraps it in an easy to use shell as it presents a single way to get going with Juju as its primary goal.
However its important to note that deployer does expose some additional functionality that you wont find in Juju Quickstart - such as deploying directly from GitHub repositories. (this is subject to change)
Examples:
juju deployer -c /path/to/my/bundle
juju quickstart path/to/my/bundle

juju deployer -c bundle:mediawiki-single/7
juju quickstart mediawiki-single/7

Command Reference
This can be found in juju-deployer -h
usage: juju-deployer [-h] [-c CONFIGS] [-d] [-L] [-u] [-l] [-D] [-T]
                     [-t TIMEOUT] [-f FIND_SERVICE] [-b] [-S] [-B]
                     [-s DEPLOY_DELAY] [-e JUJU_ENV] [-o OVERRIDES]
                     [--series SERIES] [-v] [-W] [-r RETRY_COUNT]
                     [--ignore-errors] [--diff] [-w REL_WAIT]
                     [deployment]

positional arguments:
  deployment

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIGS, --config CONFIGS
                        File containing deployment(s) json config. This option
                        can be repeated, with later files overriding values in
                        earlier ones.
  -d, --debug           Enable debugging to stdout
  -L, --local-mods      Allow deployment of locally-modified charms
  -u, --update-charms   Update existing charm branches
  -l, --ls              List available deployments
  -D, --destroy-services
                        Destroy all services (do not terminate machines)
  -T, --terminate-machines
                        Terminate all machines but the bootstrap node. Destroy
                        any services that exist on each
  -t TIMEOUT, --timeout TIMEOUT
                        Timeout (sec) for entire deployment (45min default)
  -f FIND_SERVICE, --find-service FIND_SERVICE
                        Find hostname from first unit of a specific service.
  -b, --branch-only     Update vcs branches and exit.
  -S, --skip-unit-wait  Don't wait for units to come up, deploy, add rels and
                        exit.
  -B, --bootstrap       Bootstrap specified environment, blocks until ready
  -s DEPLOY_DELAY, --deploy-delay DEPLOY_DELAY
                        Time in seconds to sleep between 'deploy' commands, to
                        allow machine provider to process requests. On
                        terminate machines this also signals waiting for
                        machine removal.
  -e JUJU_ENV, --environment JUJU_ENV
                        Deploy to a specific Juju environment.
  -o OVERRIDES, --override OVERRIDES
                        Override *all* config options of the same name across
                        all services. Input as key=value.
  --series SERIES       Override distro series in config files
  -v, --verbose         Verbose output
  -W, --watch           Watch environment changes on console
  -r RETRY_COUNT, --retry RETRY_COUNT
                        Resolve CLI and unit errors via number of retries
                        (default: 0). Either standalone or in a deployment
  --ignore-errors       Proceed with the bundle deployment ignoring units
                        errors. Unit errors are also automatically ignored if
                        --retry != 0
  --diff                Generate a delta between a configured deployment and a
                        running environment.
  -w REL_WAIT, --relation-wait REL_WAIT
                        Number of seconds to wait before checking for relation
                        errors after all relations have been added and
                        subordinates started. (default: 60)

And the following can be obtained from juju-quickstart -h
usage: juju-quickstart [-h] [-e ENV_NAME] [-n BUNDLE_NAME] [-i]
                       [--environments-file ENV_FILE]
                       [--gui-charm-url CHARM_URL] [--no-browser]
                       [--distro-only] [--ppa] [--version] [--debug]
                       [--description] [--upload-tools]
                       [--upload-series UPLOAD_SERIES]
                       [--constraints CONSTRAINTS]
                       [BUNDLE]

Juju Quickstart is a Juju plugin which allows for easily setting up a Juju
environment in very few steps. The environment is bootstrapped and set up so
that it can be managed using a Web interface (the Juju GUI).

positional arguments:
  BUNDLE                The optional bundle to be deployed. The bundle can be:
                        1) a bundle path as shown in jujucharms.com, e.g.
                           "mediawiki-single" or "django".
                           Non promulgated bundles can be requested providing
                           the user, e.g. "u/bigdata-dev/apache-analytics-sql".
                           A specific bundle revision can also be requested,
                           e.g. "mediawiki-scalable/7".
                           If not specified, the most recent revision is used;
                        2) a jujucharms.com full URL of the bundle detail page,
                           with or without the revision. e.g.
                           "https://jujucharms.com/mongodb-cluster/4" or
                           "https://jujucharms.com/openstack";
                        3) a URL ("http:" or "https:") to a YAML/JSON, e.g.
                           "https://raw.github.com/user/my/master/bundle.yaml";
                        4) a local path to a YAML/JSON file with ".yaml" or
                           ".json" extension, e.g. "~/bundles/django.yaml";
                        5) a legacy fully qualified bundle URL, starting with
                           "bundle:", e.g. "bundle:mediawiki/single".
                           Non promulgated bundles can be requested providing
                           the user, e.g. "bundle:~user/mediawiki/single".
                           A specific bundle revision can also be requested,
                           e.g. "bundle:~myuser/mediawiki/42/single".
                           If not specified, the last bundle revision is used.
                           Note that this form is DEPRECATED, and a deprecation
                           warning is printed suggesting the new value to use

optional arguments:
  -h, --help            show this help message and exit
  -e ENV_NAME, --environment ENV_NAME
                        The name of the Juju environment to use (amazon)
  -n BUNDLE_NAME, --bundle-name BUNDLE_NAME
                        The name of the bundle to use.
                        This must be included in the provided bundle YAML/JSON.
                        Specifying the bundle name is not required if the
                        bundle YAML/JSON only contains one bundle. This option
                        is ignored if the bundle file is not specified
  -i, --interactive     Start the environments management interactive session
  --environments-file ENV_FILE
                        The path to the Juju environments YAML file
                        (/home/charles/.juju/environments.yaml)
  --gui-charm-url CHARM_URL
                        The Juju GUI charm URL to deploy in the environment.
                        If not provided, the last release of the GUI will be
                        deployed. The charm URL must include the charm version,
                        e.g. "cs:~juju-gui/precise/juju-gui-162". This option is
                        ignored if the GUI is already present in the environment
  --no-browser          Avoid opening the browser to the GUI at the end of the
                        process
  --distro-only         Do not use external sources when installing and setting up Juju
  --ppa                 Use external sources when installing and setting up Juju
                        (enabled by default, use --distro-only to disable)
  --version             show program's version number and exit
  --debug               Turn debug mode on. When enabled, all the subcommands
                        and API calls are logged to stdout, and the Juju
                        environment is bootstrapped passing --debug
  --description         Show program's description and exit
  --upload-tools        upload local version of tools before bootstrapping
  --upload-series UPLOAD_SERIES
                        upload tools for supplied comma-separated series list
  --constraints CONSTRAINTS
                        If constraints are specified, they will apply to the machine
                        provisioned for the Juju state server.
                        They will also be set as default constraints on the
                        environment for all future machines, exactly as if the
                        constraints were set with "juju set-constraints".

Features include the following:

* New users are guided, as needed, to install Juju, set up SSH keys, and
  configure it for first use.
* Juju environments can be created and managed from a command line interactive
  session.
* The Juju GUI is automatically installed, adding no additional machines
  (installing on an existing state server when possible).
* Bundles can be deployed, from local files, HTTP(S) URLs, or the charm store,
  so that a complete topology of services can be set up in one simple command.
* Quickstart ends by opening the browser and automatically logging the user
  into the Juju GUI.
* Users with a running Juju environment can run the quickstart command again to
  simply re-open the GUI without having to find the proper URL and password.

To start Juju Quickstart, run the following:

    juju-quickstart [-i]

Once Juju has been installed, the command can also be run as a juju plugin,
without the hyphen ("juju quickstart").

Comment: I added the output from both commands - unfortunately we dont have great docpages for them (yet). What exists for deployer is mostly a reference for the bundle format - and quickstart has a todo item for being documented in official capacity. Hope this helps :)
Comment: Thanks! Is there a place to find more information about the command itself, not the bundle file format?
Answer: In the few years since this question was asked, deploying bundles has been simplified. juju quickstart and juju-deployer have been replaced by built-in functionality.
Bundles that have been uploaded to the charm store are able to be added with a single command:
  juju deploy mediawiki-single

Locally-defined bundles are recognised by being file-system paths:
  juju deploy /path/to/bundle.yaml


Save and Load Data - Unity3D

Question: I've written this code, and I tried to save and load Data into Unity. Here is my code:
<code>using UnityEngine;
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Collections.Generic;
using System.Linq;

public class GameControl : MonoBehaviour
{
    public static GameControl control;

    public float health =10;
    public float experience=10;

    public  Dictionary<string, object> Name_Dic = new Dictionary<string, object>()
    {
        {"laura",""},
        {"steph ",""},
        {"Ryan",""},
    };

    void Start()
    {
        control = this;
    }

    void OnGUI()
    {
        GUI.Label(new Rect(10,10,100,30),"Health"+health);
        GUI.Label(new Rect(10,40,100,30),"Experience"+experience);
    }

    public void Save()
    {
    BinaryFormatter bf = new BinaryFormatter();
    FileStream file = File.Create(Application.persistentDataPath +"/playerInfo.dat");

    PlayerData data = new PlayerData();
    data.experience = experience;
    data.health = health;
    data.Name_Dic = Name_Dic;

    bf.Serialize(file, data);

    file.Close();
}

public void Load()
{
    if(File.Exists(Application.persistentDataPath+"/playerInfo.dat"))
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Open(Application.persistentDataPath+"/playerInfo.dat",FileMode.Open);
        PlayerData data = (PlayerData)bf.Deserialize(file);
        file.Close();

        health = data.health;
        experience = data.experience;
        Name_Dic = data.Name_Dic;
    }
}
}

[Serializable]

class PlayerData
{
public float health;
public float experience;

public  Dictionary<string, object> Name_Dic = new Dictionary<string, object>()
{
    {"laura",""},
    {"steph ",""},
    {"Ryan",""},
};

public  Dictionary<string, string> Dialogs_Dic = new Dictionary<string, string>()
{
    {"A1", "Hello"},
    {"A2", "Nice"},
    {"A3", "Test"},
};
</code>
}
The problem now that when i click on save button , i save the health and experience int because when i click on load button i finc that these two variables are saved and loaded. My problem is with the dictionary, i can't know if when i click on button save the dictionary values are saved or not. How can i now if the dictionary values are saved when i click on function saved and loaded if i click on button load.Is there a solution for that, thanks for your help
Answer:
How can i now if the dictionary values are saved ... Is there a solution for that

Yes, by reading it back with BinaryReader and comparing it to your original value.

Save and Load Data - Unity3D


ESP8266 wifi module to read PHP file

Question: Seeking advice on getting the arduino and the ESP8266 wifi module to read a PHP file on a web page (not LAN; i am using a domain name and hosting service for the webpage) that echoes '1' or '0'. If it is a '1', i am looking at turning an LED on, and if '0', turning it off.
for example the PHP file looks like this to turn LED on:
<?php echo 1; ?>
i need to be able to read off the php file to turn the LED on. What would be the best possible approach in this scenario?  Is it better to send a HTTP GET request to the IP address of the ESP8266 wifi module or is there a way to program the module to read the echoed data off the php file? Is there another wifi module that would make this easier ?
if i have not made myself clear or you need further information to advise me please let me know.
thanks in advance !
Comment: PHP file looks like this
Comment: Welcome to SO. To be clear, you have an Arduino that is calling a PHP Page. Based on the result of the PHP page, you want the LED to turn on or off. What information are you passing to the PHP Page? What is the condition? Please also post an example of your Arduino code and the PHP Code.
Answer: I would advise using an HTTP GET request from the Arduino. Depending on your stack code, it may not be able to resolve the domain name if DNS is not setup. So I would advise using the IP unless you know it can resolve your domain to the proper IP. You can see more on the WebClient examples: http://www.arduino.cc/en/Tutorial/WebClient
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /arduino.php?led=1 HTTP/1.1");
    client.println("Host: www.yourwebsite.com");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }

Then in your Loop, you look for the correct response (assuming LEDPIN has been defined in setup):
void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    if(c == 1){
      digitalWrite(LEDPIN, HIGH);
    } else {
      digitalWrite(LEDPIN, LOW);
    }
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}

The PHP can then do something like:
<?php

if(isset($_GET['led']) && $_GET['led']){
  // LED is on, send 0 to turn it off
  echo "0";
} else {
  // Turn LED on
  echo "1";
}

?>

So the page will always show a 0 unless you pass an led is passed and the conditions are met.
If you need more info or a more clear response, please update your question with more details. Post your code.

ESP8266 wifi module to read PHP file


Connection authentication failure JDBC

Question: When calling this method in the main project class, filling in parameters etc, I receive an error. The field in the table is listed as ID and I am receiving user input from the user field comparing it to the ID field in the SQL table. If the input from the user matches the ID field and PASSWORD field from the SQL table, it should send the user to the Main GUI screen. However, this is not the case.
Error:
run:
java.sql.SQLSyntaxErrorException: Comparisons between 'INTEGER' and 'CHAR (UCS_BASIC)' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1')
    at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
    at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
    at org.apache.derby.client.am.Statement.executeQuery(Unknown Source)
    at GUI.Login_Check.CoLogin(Login_Check.java:27)
    at GUI.Login.btnSubmitActionPerformed(Login.java:208)
    at GUI.Login.access$200(Login.java:17)
    at GUI.Login$3.actionPerformed(Login.java:110)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6525)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6290)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2278)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: org.apache.derby.client.am.SqlException: Comparisons between 'INTEGER' and 'CHAR (UCS_BASIC)' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1')
    at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)
    at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)
    at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)
    at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
    at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
    at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
    at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
    at org.apache.derby.client.am.Statement.flowExecute(Unknown Source)
    at org.apache.derby.client.am.Statement.executeQueryX(Unknown Source)
    ... 41 more
Code:
public static void CoLogin(String username, String password){
    try{
        String dbuser = "";
        String dbpass = "";
        String url = "jdbc:derby://localhost:1527/Java-App";
        String user = username;
        String pass = password;
        Connection con = DriverManager.getConnection(url, "admin", "admin");

        Statement stmt = con.createStatement();
        String SQL = "SELECT * FROM MEMBERS WHERE ID='" + user + "' && PASSWORD='" + pass + "'";
        ResultSet rs = stmt.executeQuery(SQL);

        while(rs.next()){
            dbuser= rs.getString("ID");
            dbpass = rs.getString("PASSWORD");
        }
        if(user.equals(dbuser) && pass.equals(dbpass)){
                 Main x = new Main();
                 x.setVisible(true);
        }
        else{
            Login x = new Login();
            x.setVisible(true);
        }

        //Connection con = DriverManager.getConnection(url, user,     pass);

    }
    catch(SQLException error){
        System.out.println(error.getMessage());
    }

Comment: Your error description "However, this is not the case" is too vague. A good way to dig deeper into the root cause of your problem is debugging. Check if `rs.next()` returns `true` at least once. Check the values returned by `rs.getString("ID")` and `rs.getString("PASSWORD")`. Check if there is no error in the System Error log. This will narrow down your root problem and, even if you cannot understand its cause, come back again with the results and we can help.
Comment: Does `&&` even work? I would have expected it to be `AND`. You should also be using parameterised queries instead of dumping the values directly into the query string to avoid SQL injection.
Comment: @RobertoLinares I added a sout to print rs.getString value and it just returns the same connection authentication failure occurred. So it basically goes straight to the catch statement.
Comment: Can you add to the question the stack trace printed by the exception?
Comment: @RobertoLinares done
Answer: According to your log, the root cause of your error is at the momment you establish the connection to your database, in th line:
Connection con = DriverManager.getConnection(url, "admin", "admin");

The error messsage Connection authentication failure occurred.  Reason: Userid or password invalid. is telling you that the "admin" user or passowrd you are using to connect to your derby database is incorrect.
What you can do is, before using that authentication data to connect to your database, check them in a database client like the Data Source Explorer in Eclpise or the Data Base Explorer in Netbeans. Once you are sure that your database's authentication data is correct, use it in your code.
Comment: Additionally, for background information on how Derby implements connection authentication, see the authentication chapters in the manual: https://db.apache.org/derby/docs/10.12/security/
Comment: Thanks, it was uppercase admin. However I have come across another error.
Comment: Well, the error seems to be related to the data types in your `MEMBERS`  table. In your query you assume that both `ID` and `PASSWORD` fields are of type `VARCHAR` but the error suggests that one of them is really of type `INTEGER` so the comparison in the query is not valid. Check the data types again and I would also suggest you to try the query in a database client first.
Answer: Your problem could have many causes.
However, if a user types username="", password="" he's going to be authenticated on any case. Also mind about SQL injection.

Connection authentication failure JDBC


How to use quotes on jsp page in  tag

Question: I have JSP page and on jsp page I have this:
<c:when test="${empty findAttributes && param.value1 != null}">

<spring:message code="label.msg"/>

</c:when>

instead of param.value1 !=null I have to use param.value1 !="", but it does't work, gives me an error. Please help to bring it to correctness.
Answer: The proper way is using the empty keyword. This covers both nullness and emptiness.
<c:when test="${empty findAttributes && empty param.value1}">

Your condition would otherwise still fail if the parameter name value1 is not supplied at all (which then evaluates to null not to empty string). A request parameter only evaluates to empty string when the parameter name is supplied without a value like so value0=foo&value1=&value2=bar. However, if the request parameter is totally absent like so value0=foo&value2=bar then it evaluates to null which isn't the same as an empty string.
Comment: Thanks, but my parameter won't absent at all. I have script inside  and it's trigger just when it's empty string... So I'm not expecting null and when it's null it will behave different How to be?
Comment: Request parameters are controllable by the enduser by simply manipulating the HTTP request. Empty string is not the same as null. When you use `empty`, both cases are covered.
Comment: Got you. Thank you BalusC
Answer: You should use empty operator of JSTL instead of using  !=
<c:when test="${empty findAttributes && empty param.value1}">

From the 2.1 Spec:
To evaluate empty A:

If A is null, return true,
Otherwise, if A is the empty string, then return true.
Otherwise, if A is an empty array, then return true.
Otherwise, if A is an empty Map, return true
Otherwise, if A is an empty Collection, return true,
Otherwise return false.

How to use quotes on jsp page in  tag


Is there a way to merge in the latest changes from develop to just one file?

Question: I've been working on a branch off from develop called branch A which contains a file called F, in develop this file has been deleted.
In Github I have PR to merge branch A in to develop but Github says that Branch A has conflicts in file F
I cannot resolve these conflicts in Github as the file no longer exists in develop to compare it against
I don't need this file and I'm happy to delete it on branch A however if I don't believe I can just delete this file as then my PR will be trying to delete a file that doesn't exist in develop when I do bring in the latest changes to develop .. maybe I'm wrong?
I do not want to merge in the latest changes that have been done on develop to branch A just yet
Is there a way to merge in the latest changes from develop to just one file? Or another solution to my issue
Hope that all makes sense
Comment: Well, unless I am mistaken and the workflow is different when working with GitHub and PRs, you should deal with integration issues in the feature branch. Therefore, once your feature is completed you should be either merging `develop` into `A`, or rebasing `A` onto `develop` and fix conflicts then. Rebasing is cleaner IMO, but you would have to force push into `A` on GitHub.
Answer: The conflict arises because one side modifies a file which does not exist on the other side.
Checkout branch A then delete your unwanted file and push that on remote A. Then make your PR between A and develop, your conflict should be gone.


what are pros and cons of an air handler located in cooled space?

Question: The air handler unit on my central air conditioning system in Florida is located in a closet that opens to the attic. The air handler is exposed to the attic temperatures (hot) which seems counter intuitive for maximum cooling capability. The cooling coils are bolted to a metal frame that's as hot as the attic.
Should I insulate the closet so the majority of the indoor unit is, truly in cooled indoor space?
What are the pros and cons of my current (typical) setup versus an indoor air handler that resides in the cooled space?
Comment: Are your ducts in said vented attic as well?
Comment: Do you have a strip heater in the air handler?  Is there one main return?
Comment: yes to both. Ducts are insulated from top of air handler to each room via attic. There is only 1 return air intake located immediately below the air handler. Indoor air returns through intake vent near floor then goes vertically through air handler, across cooling coils, out the top into cooling ducts.
Comment: @MarcCompere -- how much insulation is around the ducts?
Comment: I've got standard insulated air ducts. Some 4-inch. Some 6-inch with plenty of pink and older style dark grey fiberglass insulation on the tops of the rooms
Answer: This is the same arrangement as in all 270 houses in my tract development in Dallas TX. It is the standard arrangement. There is some insulation on the inside of the sheetmetal panels.
EDIT Given the new info that this is a heat pump it would be some benefit to put an insulated ceiling on the closet. Possibly the original heating was a gas fired furnace and the heat pump a retrofit.
EDIT2 If there is a gas fired water heater in this closet,then it is probably necessary to have an opening for combustion air or to expel heat to the attic.
EDIT3 Our closet has an insulated drywall ceiling with one small section of screening to supply combustion air from the attic to the gas fired furnace and the gas fired water heater.
Comment: Additionally, "leave it alone" can be a perfectly good and valid answer if there's nothing to worry about and no changes should be made to a professionally installed system that was installed according to the manufacturer's directions and all current conventional wisdom.
Comment: leave it alone is not a useful answer. it seems that an HVAC unit would deliver more cooling to the air if it didn't have to cool the metal frame exposed to hot attic temperatures
Comment: Do you have a gas furnace in the same unit? If so, does it get its combustion air from the closet or from outside?
Comment: In Dallas TX many houses have the air handler with refrigeration coils in the attic, not just in a closet connected to the attic.
Comment: mines a heat pump. no gas furnace.
Comment: it works great now. No complaints. But there's a penalty for heating coils that could otherwise remain significantly cooler. Surely I'm not the first to wonder about this
Comment: So there is no need to have the closet connected to the attic and you could seal and insulate any existing connection.
Comment: @MarcCompere be aware that some of the heat in that closet that you're worried about may be helping prevent the coils from freezing over which would render the AC useless until they've been defrosted.
Comment: @JimStewart, the edit #1 is helpful. the house was built in 1957 and has no gas supply. the gas line run is too far to make sense and the local provider won't run the line. I'm not sure how heating was done originally. Probably electric. But the heat pump is within the last 10 years. Insulating the closet top sure makes a lot of sense as long as coils don't freeze. I can't figure out why closet tops with heat pumps aren't all insulated. Maybe just additional cost for marginal cooling improvement.  (???)
Comment: exhaust for gas fired heating would certainly need venting. this unit has no gas and nothing with combustion
Comment: Is there no ceiling at all in this closet? Is it just open to the attic?
Comment: yes, wide open to the attic. I think it's pretty typical but that doesn't mean it's smart. It has occured to me that measuring temperature differential between exiting coil air temperature and air temperature leaving ducts (entering the house) would be one way to monitor any closet insulation effects. I'll set this up.
Comment: A lot of work to do this. My guess is no measurable effect would be seen. Presumably the walls of the closet are not insulated so installing an insulated ceiling would greatly reduce heat flow through the walls of the closet. Measurement of air temp in duct might not reveal this, but if you keep the thermostat setting the same your ele usage should decline somewhat.


How do I update a GitHub forked repository with submodule

Question: My question is similar with the following:
How do I update a GitHub forked repository?
But it's a bit complicated, because my upstream is a very large project which have a lot of sub modules.
<code>git remote -v
navi_dev        ssh://firstname.lastname@example.com/navi_development (fetch)
navi_dev        ssh://firstname.lastname@example.com/navi_development (push)
origin  email@example.com:navi_int_internal.git (fetch)
origin  firstname.lastname@example.com:navi_int_internal.git (push)
</code>
nave_dev is the root upstream I want to get from, and origin is my local fork.
but in this project, there are lots of sub modules:
such as:
<code>[submodule "ai_osal_common"]
        path = ai_osal_common
        url = gitolite:ai_osal_common
[submodule "ai_osal_darwin"]
        path = ai_osal_darwin
        url = gitolite:ai_osal_darwin

...
</code>
My Question is, I also want to fork these submodules into my local repo.
The submodules could be updated, and the root upstream could also be updated, (root upstream may update its submodule hash).
How could I sync both the root upstream and its submodules into my local repo?
Answer: Just do the same thing in each submodule as the link you provided suggested, but that will lead to that each submodule will have the latest from their respective master branch, and that may not be correct.
So my suggestion is the following:
<code># Fetch all the branches of navi_dev remote into remote-tracking branches:

git fetch navi_dev --recurse-submodules

# Make sure that you're on your master branch:

git checkout master --recurse-submodules

# Rewrite your master branch so that any commits of yours that
# aren't already in navi_dev/master are replayed on top of that
# other branch:

git rebase navi_dev/master
</code>
If you have made any changes yourself in any submodule, you have to rebase them also on top of their original remote master branch.


Interval of Convergence examples (-6,6)

Question: There was a book problem I recently solved going like this:
$\sum_{n=0}^\infty a_n^2x^n$ converges on $[-6,6]$
What is the largest interval $\sum_{n=0}^\infty a_nx^n$ is guaranteed to converge on?

I already understand this:
$\limsup_{n\rightarrow\infty}|a_n^2|^{1/n}=1/6$
$\Rightarrow\limsup_{n\rightarrow\infty}|a_n|^{1/n}=1/\sqrt6$
$\Rightarrow$Radius of Convergence is $(-\sqrt6,\sqrt6)$ for $\sum_{n=0}^\infty a_nx^n$

What I was wondering however, is what are examples of what the values for $a_n$ could be where the endpoints dont converge for the series, but the series with $a_n^2$ converges on [-6,6]?
Comment: Can you think of something if I tell you to consider $a_n = \frac{1}{n}\cdot b_n$?
Comment: The first = should be $\le.$
Answer: Let $R$ be the radius of convergence of the power series
$$\sum_{n = 0}^{\infty} a_n x^n.\tag{1}$$
Then define $c_n = a_n\cdot R^n$. We want the series
$$\sum_{n = 0}^{\infty} a_n^2 x^n\tag{2}$$
to converge on the closed interval $[-R^2,R^2]$, and that is the case if and only $(2)$ converges for $x = R^2$ and $x = -R^2$. If we consider only real coefficients $a_n$, then $a_n^2 \geqslant 0$ for all $n$, and the convergence of $(2)$ for $x = R^2$ already implies the (absolute and uniform) convergence on the interval $[-R^2,R^2]$. Plugging $x = R^2$ into $(2)$, we want the convergence of
$$\sum_{n = 0}^{\infty} a_n^2 R^{2n} = \sum_{n = 0}^{\infty} c_n^2.$$
And we want the series $(1)$ to diverge for $x = R$ and for $x = -R$. Plugging those values in, we want the divergence of
$$\sum_{n = 0}^{\infty} a_n R^n = \sum_{n = 0}^{\infty} c_n\qquad\text{and}\qquad \sum_{n = 0}^{\infty} a_n (-R)^n = \sum_{n = 0}^{\infty} (-1)^n c_n.$$
So we look for a sequence $(c_n)$ such that $\sum c_n$ and $\sum (-1)^n c_n$ diverge, but $\sum c_n^2$ converges. If we don't care about $\sum (-1)^n c_n$, then a famous example of such a sequence is $\bigl(\frac{1}{n+1}\bigr)_{n\in\mathbb{N}}$. Unfortunately, the alternating harmonic series converges, so we cannot use just that sequence. But we can modify that sequence to reach our goal.
One easy way is to nullify the effect of the $(-1)^n$ by inserting zeros into the sequence, say $c_n = 0$ for odd $n$ and $c_n = \frac{1}{n+1}$ for even $n$.

Interval of Convergence examples (-6,6)


Is it useful to have all the input controls in a form the same width?

Question: All the input controls are the same size in this question about form design: Why might right aligned field labels be better?
My question is if does it help with something, or it is just a matter of taste?
Wouldn't it be a waste to have for example, a calendar widget, which only receives 10 characters of input, the same size of the other elements?
Comment: They are very similar, and the top answers are making the same argument
Comment: sorry, guys, I hadn't found that question when I searched first. I should have worked harder... although the answers to this question are really great. :)
Answer: The size (length) of a field is a matter of usability in that it can provide a valuable affordance to the user.
Take the following example:

download bmml source – Wireframes created with Balsamiq Mockups
Even without labels you can probably guess what the fields are:

download bmml source
Obligatory Wroblewsky quote (The above example is from Ch. 5 of his book Web Form Design (p. 73-74)):

Because affordances provide valuable clues about how to structure answers, people will naturally consider those clues when they are thinking about how to fill in an input field.  If that input field is arbitrarily sized, you may leave people thinking about what that means for no reason.  [...]  Said another way, if this input field is long but my answer is short, have I misunderstood the question?  Best not to make people think too much and instead use a consistent length for all fields that don't benefit from clear affordances.

With regard to your question, no, it is not useful to have all the input fields the same width.
Depending on the context of the data the user will be entering, it may make sense to have variable widths, though those widths should not be arbitrary.  Rather, the field widths should instead give the user a clue (affordance) as to what should be entered in the field if appropriate.
Answer: It's a mostly a matter of design, not usability there.  The main issue is that they are left aligned (for left to right languages), and not that they are all the same length.
I would however argue that it is better to make a field for which you know the length of the content (like a postcode) about as long as the content would be.  Making it longer may hint that you expect a longer input and cause some confusion.
In summary: If you know the length of the input, make the inputs only a little longer, unless you have some design reason not to.
Answer: Form elements are tricky and need to be logically grouped, visually grouped and also visually distinguishable at the same time. Form elements when visually  grouped together follow the laws of Proximity. Now where proximity is good, it becomes a visual "jail" when over-used. Look at these example.
A form without proximity

Overly used proximity

Something Right

-- To Summarize --

Group Form elements logically before grouping them visually. If Logical grouping is working, you have only a little visual grouping needs left.
If you had to apply "equal-width" on different form elements, don't apply that on more than 4 form elements together. If all the elements were of same types (for example all input boxes), you can keep their width the same.
Personally I like to introduce periodic space within the form elements to break this "visual jail". This approach works and might be helpful in your case as well.
Comment: Thanks a lot, man, very helpful examples! I'm accepting Charles's answer, though, as it gives a more direct answer to my question. But really, thanks!
Answer: In my opinion the most important question to ask yourself about is not whether they should all be the same size or not, but whether the input should be constrained/validated or not.
If there is not going to be any constraints or validation on the input, then it is simply a matter of aesthetics to make it look as neat and organized as possible (and making them all the same is one way to achieve a particularly neatness).
If there are constraints or validation, then using common patterns for input (which includes size and input field type) provides the best usability and helps reduce errors from the user.


What else can I infer from this data?

Question: If $a,b,c$ all real numbers and $1$ is root of $ax^2 + bx + c = 0$, then $y = 4ax^2 + 3bx + 2c$ , a is not 0 intersects  x-axis at how many points?
I could infer that $a + b + c = 0$ and $4ax^2 + 3bx + 2c = 0$. But what else should I do to solve the problem?
Answer: We have the discriminant of $y=4ax^2+3bx+2c $ as: $$\Delta = B^2-4AC $$ $$=(3b)^2-4 (4a)(2c) $$ $$=9b^2-32ac $$ $$=9 (-a-c)^2-32ac $$ $$=9 (a-c)^2+ 4ac $$ Hence, both roots are real and will cut the $x$-axis at $\boxed {2\text {  points  }} $. Hope it helps.
Comment: @Resorcinol  $(-a-c)^2 =(a+c)^2 =(a-c)^2+4ac $ $9 (-a-c)^2 =9 (a+c)^2 =9 (a-c)^2+36ac $.
Comment: oh! I apologise I didn't notice the negative sign.

What else can I infer from this data?


Save JS output with PHP

Question: i want to save output/result of JavaScript code. For example:

For PHP i have no problem:
$ip = $_SERVER['REMOTE_ADDR'];
$file = "log.txt";
$open = fopen($file, "a+");

Then write:
fwrite($open, "IP Address: " .$ip . "
");

Now i'd like to write result of JavaScript with same method.
Of course this will not work:
fwrite($open, "");

Any help?
Thanks
Comment: Have you tried writing the result using AJAX? You'd send `navigator.appVerison` to a PHP file using AJAX.
Comment: You can't do it like that, javascript runs on the client side. You will have to first get the data and send it back to the server, or you can use the user agent
Comment: use "echo" function to write to the page
Comment: If you want to do this all server side then you'll need some sort of headless browser to render the javaScript. There are lots available for linux, a quick google just pointed me towards this: http://phantomjs.org/
Answer: If you need to get information about the user's browser, use a PHP function. You can't get the Javascript output from PHP unless you send it back using Ajax.
To get the browser information using PHP, use get_browser()

Save JS output with PHP