Twitter Bootstrap witih Saas MakeFluidColumn mixin is missing - trying to not hardcode span into a class in HTML

Question: I'm using Thomas Macdonald's sass version of bootstrap (bootstrap-sass)
I'm trying to not embed Bootstrap classes (i.e. span7 or span10) in my html as described in here.
http://ruby.bvision.com/blog/please-stop-embedding-bootstrap-classes-in-your-html
in bootstrap-sass the only sass mixin that I know is available to apply the "span7" class to my div is with <code>@include makeColumn(7);</code>
This works for fixed grid but not for a fluid grid.  I need these columns to be fluid and responsive.
@Thomas Macdonald answered the question on StackOverflow with a mix-in that he created called makeFluidColumn
How to use twitter bootstrap with bootstrap-sass in rails app?
but it is not included anymore in the latest mixin file as is also mentioned per this github issue:
https://github.com/thomas-mcdonald/bootstrap-sass/issues/191
Is there something else that I need to do?  I need to be able to change the span as a mixin because I am trying to change the number of columns that a div spans depending on viewport size through media queries.
Comment: Writing your own mixin is always a possibility.  Just because you're using TB doesn't mean you can't mix and match with other libraries out there.  Susy (http://susy.oddbird.net/demos/grid-types/) is fairly popular and can be fixed or fluid (not a grid user myself, so I can't comment on how well it does the job).
Comment: I decided to not go with a grid also with this part. just calculating the div width percentage based on a 12 column grid.  I would like to avoid mixing in too many dependencies so would love it if I could just use the TWB grid or not at all.  If anyone can suggest a way to do makeFluidColumn mix-in that works in Sass, that'd be really awesome!
Answer: I ended up rolling my own @mixin.
so instead of using bootstrap's @include makeColumn(i); i can do @include col(i) to apply a width of i number of columns to a div or other element.  Just include this SCSS file
<code>    /*=VARIABLES - GRID
------------------------------------------------*/
$columns: $gridColumns; //from bootstrap/_variables.scss
$column-width: $gridColumnWidth; //from bootstrap/_variables.scss
$gutter-width: $gridGutterWidth; //from bootstrap/_variables.scss
$max-width: $columns * ($column-width + $gutter-width);

/*=VARIABLES - FONTS
------------------------------------------------*/
$font-base: $baseFontSize; //from bootstrap/_variables.scss
$font-base-line-height: $baseLineHeight; //from bootstrap/_variables.scss
$font-base-line-height-half: $font-base-line-height / 2;
$font-base-percentage: (($font-base / 16px) * 100) + 0%;

/*MIXINS
------------------------------------------------*/
@mixin col($n, $padding: 0px, $border: 0px, $container-width: $max-width) {
    float: left;
    margin-left: percentage($gutter-width / $container-width);
    width: percentage(($n * ($column-width + $gutter-width) - $gutter-width - ($padding * 2) - ($border * 2)) / $container-width);
    border-width: $border;
    padding: em($padding, $font-base) percentage($padding / $container-width);
}

/*FUNCTIONS
------------------------------------------------*/
@function em($target, $context: $font-base) {
    @if $target == 0 { @return 0 }
    @return $target / $context + 0em;
}

@function perc($width, $container-width: $max-width) {
    @return percentage($width / $container-width);
}

@function lh($amount: 1, $context: $font-base) {
    @return em($font-base-line-height * $amount, $context);
}

@function heading-line-height($size) {

    $line-height: $font-base-line-height;

    $match: false;
    @while $match != true {

        @if $size == $line-height {
            $match: true;
        } @else if  $size < $line-height {
            $match: true;
        } @else if $size > $line-height {
            $line-height: $line-height + $font-base-line-height;
        } @else {
            $match: true;
        }

    }

    @return ($line-height / $size) + 0em;
}
</code>


Ubuntu 14.04 not booting before Windows 8.1

Question: I try to boot my computer into Ubuntu, but I end up having to manually select Ubuntu from the devices menu, even though it was supposed to boot first. Instead Windows 8 boots up like Ubuntu isn't even there! And GRUB works just fine when Ubuntu is selected in the boot device menu. (How else am I on?) I tried using EasyBCD but kept getting errors from the Windows Boot Manager. And just in case it helps, during installation of Ubuntu it didn't recognize Windows 8, and I had to resize and install manually. Anything I can do?
Notes: EVERYONE!!! GRUB WORKS PERFECTLY!!! IT IS AN ERROR IN THE HP BOOT MENU AS I HAVE PREVIOUSLY SAID!!! PLEASE DO NOT GIVE ME ANSWERS FOR GRUB EDITS IN THE FUTURE!!!
Here are my specs:
PC type: HP 2000-2d49WM Notebook PC
RAM: 4GB
Swap: 2GB
Processor: AMD E-300 Vision 1.3 GHz x2
BIOS Edition: N\A Until further notice
Comment: What do you want to happen? That Ubuntu is set to be the default OS? Can we assume you have multiple operating systems installed? Which ones? How do you normally boot? Please [edit] your question and clarify.
Comment: I do not have Ubuntu set as the first OS to boot. It installed as third in line, then after the update to 14.04 I got was bumped up to second in line. The UEFI Support menu for hp computers needs to be installed through Windows, but the Windows 8.1 BCD is defective and my friend is letting me borrow his installation disk on Monday June 2. As far as I know the UEFI Boot configuration order can NOT be changed in my laptop. I can still access Ubuntu, that is actually what I am using right now, but the boot menu won't be changed.
Comment: Probable duplicate of [How do I change the GRUB boot order?](http://askubuntu.com/questions/100232/how-do-i-change-the-grub-boot-order)
Comment: Try `sudo update-grub` in the terminal.
Comment: Where did you set Ubuntu as the first OS to boot? Because if you have a computer with (U)EFI you might have to set the first OS to boot in the UEFI-menu.
Comment: Do you have Ubuntu and Windows 8 installed in different partitions or are you using Wubi?
Comment: Post link to BootInfo report. You do need both installed in UEFI mode, otherwise you have to boot from UEFI menu. But HPs are not really friendly and many need work arounds. https://help.ubuntu.com/community/Boot-Repair
Comment: @user280244 - this looks similar to this Q&A - can you try the answer please? http://askubuntu.com/questions/235567/windows-8-removes-grub-as-default-boot-manager
Answer: I've faced a similar problem with another HP notebook.
The problem is that even if you change the EFI boot order permanently (with command: "efibootmgr -0", for example), your change will be overwritten each time you boot Windows.
To workaround the problem, I had to install rEFInd manually.
Then, I've located the default EFI boot loader (.efi), backed it up and replaced it by the one from rEFInd (renamed) [don't forget to copy other folders and files pertaining to rEFInd in the same folder]. I don't remember which one was the default EFI boot loader and I can't check on the computer since it is owned by one of my customers.
WARNING : If you have to apply that tricky workaround, please ensure that you can boot on the normal installation of rEFInd via the boot menu before, so that you can easily revert the changes in case of problem or if you change your mind in the future!!!!!
rEFInd manual installation procedure is available here: http://www.rodsbooks.com/refind/installing.html#linux
For a clear example for changing EFI boot order permanently with efibootmgr (will probably not work on your computer, as stated above, however I highly recommend to try that first), please take a look at this post from Rod Smith (the creator of rEFInd).
It seems that the renaming trick is now fully documented on the official Web site of rEFInd : http://www.rodsbooks.com/refind/installing.html#naming, http://www.rodsbooks.com/refind/installing.html#manual_renaming
rEFInd is really user-friendly (once installed) and allows to workaround such poor EFI implementations.
Step by step, failsafe approach
Trying to change UEFI boot order with efibootmgr

Under Ubuntu, open a terminal and install "efibootmgr", if it is not already installed, by using the following command:
sudo apt-get install efibootmgr
Retrieve EFI boot order and entries with the command:
sudo efibootmgr -v
Notes:
BootCurrent: 0002 (indicates the UEFI boot entry used for booting).
BootOrder: 0002,0003,0001,0000 (indicates the UEFI boot order defined).
Boot000x* (represents one boot entry. It is followed by its name, HD and EFI file. All the boot entries are listed below "BootOrder").
Define the new boot order with the command:
sudo efibootmgr -o 0001,0002,0000,0003
In the command above, I suppose that Ubuntu entry is 0001, Windows is 0002, Recovery is 0000, Diagnostics is 0003. Of course, you may have more or less entries and/or wish to setup a different order. I suggest that you copy the "BootOrder" value from the command "sudo efibootmgr -v" and adapt it as you want. Then check the result of the command.
Check again the "BootOrder" with the command used at step 2.
Restart your computer properly and check that the system boots the expected (first) entry of the new boot order (here, Ubuntu). If it works, restart and try to boot Windows (via UEFI menu), then restart the computer again and check that Ubuntu is still booted by default. If it works as expected, you're done! The EFI implementation is correct and you don't need to do anything more. If not, jump to the next solution.

Installing and configuring rEFInd

Disable Secure Boot feature in your BIOS, if it is not already done, in order to avoid extra complications;
Under Ubuntu, Download the binary ZIP file of rEFInd from this page: http://www.rodsbooks.com/refind/getting.html;
Unzip the ZIP archive;
Open a terminal and move to the folder where the archive files have been extracted (the command should look like: cd ~/Downloads/refind-bin-0.8.1/);
Follow the steps (1 to 6) described here: http://www.rodsbooks.com/refind/installing.html#linux. Your architecture is very probably x86-64, so use rm refind_ia32.efi at step 3;
Edit the configuration file (refind.conf). Simply use sudo nano ./refind.conf or sudo -i gedit ./refind.conf. I'm assuming that the current directory is still rEFInd's directory on the ESP. You will be very interested in "timeout" (value like: 1) and "default_selection" (value like: Ubuntu) parameters to configure automatic boot to Ubuntu.
Restart the computer, use the UEFI boot menu for launching rEFInd and checking that its configuration fulfil your needs. If not, start Ubuntu and edit refind.conf in its directory on the ESP and repeat this step until the settings fit all your requirements. Please check that you can boot Ubuntu and Windows as well from rEFInd (longer timeout value may help).
Identify which EFI file is used by default by your system and locate its folder on the ESP (It might be something like "EFI/Microsoft/Boot/bootmgfw.efi" or else). Don't forget the command sudo efibootmgr -v which can be very helpful to get this information.
Copy the content of the refind folder on the ESP in the folder of the default EFI file identified at step 7 ("EFI/Microsoft/Boot/" in the example). You can even use command sudo -i nautilus if you are not very familiar with the command line. Assuming that the ESP is mounted at /boot/efi, you can use the following command : sudo cp -r /boot/efi/EFI/refind/* /boot/efi/EFI/Microsoft/Boot/. Don't forget to adapt the destination path as required.
Rename default EFI file ("bootmgfw.efi" in the example) in "bootmgfw.bak" (sudo mv bootmgfw.efi bootmgfw.bak, if you are in the right folder. You can use cd /boot/efi/EFI/Microsoft/Boot/ to switch to that folder [I'm still assuming that ESP is mounted at "/boot/efi" and that the relative path to the default EFI file is "EFI/Microsoft/Boot/"]);
Rename rEFInd EFI file ("refind_x64.efi") as the default EFI file (here, "bootmgfw.efi"). Use sudo mv refind_x64.efi bootmgfw.efi, if you are in the right folder.
Restart your computer and if everything is OK, you're done! If something goes wrong, you can still use UEFI boot menu to launch rEFInd, boot Ubuntu and revert the changes made in steps 8 to 10.
Comment: can I get a step by step cause this looks pretty freakin' hard
Comment: @user280244: Done. Step by step, failsafe approach added.
Comment: can you find a way to do it in ubuntu?
Comment: windows broke, oh wait
Comment: oops it is ubuntu
Comment: Almost all these steps should be done from Ubuntu. Do you mean not replacing default EFI file by the one for Ubuntu (no rEFInd install)? It should be possible, but making a mistake might be annoying in such a case...
Comment: You may also try with secure boot feature enabled if Windows does not start anymore...
Comment: stuck on step 9. How do I do that? I am a noob so plz help.
Comment: I've added command lines (to adapt if needed) for steps 9 and 10.
Comment: UH OH!!! Windows deleted rEFInd's stuff from the Windows boot file! What now?
Comment: @user280244: I've never faced that problem before. It may be due to a reinstall, a repair (after a crash, for example) or an upgrade of Windows 8.1... In the worst case it might simply be due to an update... If I were you, I would try to re-apply steps 8/9 to 12 in order to fix the issue. Windows 8.1 should not replace the EFI file every time, but it would be interesting to identify exactly what has triggered the update/replacement of the EFI file (repair, upgrade, update or else).
Comment: you see, I did everything again, and only to find that rEFInd's EFI was taken over by Windows.
Comment: @user280244: The EFI file which is used by default by your system might be replaced every time by another one located in another sub-folder. If you have another EFI menu entry which allows you to directly launch Windows 8.1, you could try to apply the procedure above to this specific EFI file. If it is copied every time, it should do the trick and solve your problem. I've had such a problem with another HP laptop, but it was like that from the beginning... Have you upgraded the BIOS or else? I'm still wondering what exactly has changed to cause this new behaviour of the system...
Comment: IKR! I have had no BIOS updates, no HP Reco. Env. update, no nothing!
Comment: @user280244: Very very strange! I'm afraid that I'm not aware of any other solution if you can't locate the EFI file which is used as source of the copy for replacing the one which is taken over by "Windows"...
Comment: so i did the other thing you posted; efibootmgr. But everytime I try to reboot, it is reverted on startup! _WHAT IS GOING ON!!!_
Comment: @user280244: Using rEFInd the way indicated above is the trick to workaround the loss of your changes in UEFI boot order made with efibootmgr. It's precisely the problem I've now faced with several HP laptops and their EFI implementation. In fact, on another HP laptop, the EFI file (rEFInd one) was replaced each time I was booting Windows. I've replaced the EFI file which was the source of the copy to solve the problem. If I remember well It was located in one HP subfolder instead of something like "EFI/Microsoft/Boot/". Please note that the name of the EFI file might also be different.
Comment: OH! I didn't see your comment! Let me try that.
Comment: found the file. is it called "bootmgfw.efi.mui"?
Comment: I really don't remember the exact file name. I think that it was still one with .efi extension, but I'm not sure about it. Anyway, please double check file size, modification date and time and/or use any tool to compare the files in order to ensure that the file you suspect is the source of the copy... Once you've identified that source file, make a backup of it and/or rename it and then replace it by rEFInd one. This should solve your problem.
Comment: okay I will try
Answer: First boot from live ubuntu cd or Live ubuntu flash drive and connect to internet. After that go to termianl by ctlr+alt+T and just use the command below,
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo sed 's/trusty/saucy/g' -i /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list
sudo apt-get update
sudo apt-get install -y boot-repair && (boot-repair &)

This actually fix any problems with boot. If it still do not work for you just leave the error report in the add command section. You will find I have attached a link, it has screen short and clear instruction. Just go to the link if something still not clear to you. Have Fun.
Reference link:  FOLLOW ME FOR FURTHER CLARIFICATION !
Answer: Sounds to me like you have done a UEFI install. Windows 8.1 is not going to quietly let you use Linux next to it. If you absolutely must use Windows Boot Manager instead of Ubuntu's UEFI option, in the case that your motherboard somehow won't accept anything other than the Windows Boot Manager option, you need to edit Windows Boot Manager inside Windows by opening command prompt with admin rights and using bcdedit like so:
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
If you are using Secure Boot, you will need to use the following:
bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi
Comment: Now which `bootmgr` are we using? Windows or Ubuntu? My BCD is not functioning right now and that may affect boot, not that it has yet.
Comment: As stated in the answer above, this is from Windows and it modifies the boot configuration data so that the Windows UEFI entry points to Ubuntu's bootloader instead of Windows'.
Comment: But when I boot to windows I get an error message saying "The BCD File does not have the valid information for an operating system" Would that affect anything?
Comment: I did it in support mode, but my only problem, the BCD is corrupted, and even though it says the operation was successful, I still can't boot right because the bcd is bad. My only option is to reset my system. That would completely erase and reset the BCD
Comment: Windows can rebuild the BCD if you run bootrec /rebuildbcd
Comment: just `bootrec /rebuildbcd`? Nothing else?
Comment: Feel free to look up the documentation on Microsoft's website. That's the command.
Answer: Sounds to me like you have done a UEFI install.
Windows 8.1 is not going to quietly let you use Linux next to it. If you absolutely must use Windows Boot Manager instead of Ubuntu's UEFI option, in the case that your motherboard somehow won't accept anything other than the Windows Boot Manager option, you need to edit Windows Boot Manager inside Windows by opening command prompt with admin rights and using bcdedit like this:
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

This worked fine for me.
Comment: Tried that. Look at the answer right above your's.
Comment: @user280244 The order for answers **will** change. Better click on "share" below the answer and use that link as a reference
Comment: @MadMike http://askubuntu.com/a/475674/280244
Answer: Start up in ubuntu.  Go to the terminal.  And re-install your grub with the following command:
sudo-grub-install  /dev/sda
This in the suppose that ubuntu is installed on sda (the most likely).  Otherwise change this to the wright component.
Comment: @user280244, no need to yell (all uppercase). You can flag the answer. Comment it why it doesn't apply and, with enough reputation. you can vote the answer down.
Comment: Change your  Uefi to start from boot manager and follow the instructions bewlos if necessary. (you can start from boot manager or from EFI file).From the Startup Menu, you can access system information and diagnostics. While running UEFI applications use the arrow keys and the enter key to navigate to "Boot device options".


How to turn on a Honeywell gas heater

Question: I am trying to understand how to turn the heater on in our unit.
There is a thermostat on the living room wall that looks like this:

And there is a trapdoor below the heater in the wall looking like this (yes, it's upside down in the wall):

So far I have tried to turn on the [B] button, and turned the black know 1 to either "on" or "pilot" and pressed the button 2 but I'm not sure what to look out for to show whether or not I'm doing the right thing, and I'm also not trying to blow up the apartment or gas myself, so I turned everything back to "off" until I know what's what.
Comment: Have you verified that there isn't a closed valve outside of the fireplace?
Answer: Looks like:
System "on" at B.
1 to pilot, 2 should either press or turn (and will need to be held, if it's what I think it is) and 3 should be pressed in (and will make a "clunk" sort of noise) one to three times.
There should be some place you can see the pilot light - you might need to move a flap, you might not. When you see it light, stop pressing 3 but hold 2 for (typically 30 seconds, but it varies.) If you don't see it light after a few presses of 3, or can't figure out where to look, re-evaluate.
1 is the gas valve, I believe that 2 is the over-ride that allows you to light the pilot, and what it over-rides turns off the gas if the pilot is out, and 3 appears to be a spark igniter (you may have seen them on gas barbecue grills) to light the pilot.
When the pilot has ben lit for long enough it will stay lit when 2 is released - at which point you can move 1 to "on" and proceed with heating.
Answer:
I'm also not trying to blow up the apartment or gas myself, so I turned everything back to "off" until I know what's what.

The good news is, it's hard to cause any trouble with these because they're designed to be safe. Also, small amounts of unburnt gas will quickly mix into the air and be no longer concentrated enough to burn. I used to have similar worries, but advice and experience showed me that the conditions for actually burning gas are quite specific. The "blow up the apartment" case is if something leaks lots of unburnt gas into the room, usually over a long time, but the valve you've got is designed to prevent doing that by accident.
Just to get more familiar with what all the parts are, have a look at this part of your picture:

The large pipe on the left is the pilot's gas pipe. You might be able to see the burner end of it through a hole or window to see when the pilot is lit.
The white wire in the middle must be the igniter, because it goes off to the separate red button on the right which has the shape of one, and doesn't connect to the valve.
The coppery pipe on the right is the thermocouple, or thermopile: it detects the heat of the pilot light and signals the valve, and the valve will not let the gas continue to flow if the pilot goes out, for safety. (In gas appliances which don't have an electrical hookup, a similar device might actually provide power to operate the gas valve, solely from the heat of the pilot.)

Now as to lighting it: there may well be lighting instructions in the information sticker visible on the right side of your picture. If not, or if they're unclear, here's how it might go:

You usually do not need to turn the thermostat on to light a pilot light, so I'd recommend leaving it off: set the switch to "system off" (B), or turn the temperature setting (A) down, or both. That way, you can't be startled by the main burner lighting while you're working with the valve.

There might be a manual gas valve on the other end of the yellow flexible pipe, wherever it goes. Make sure that valve is turned on (handle in line with the pipe).

You need to get gas to flow so you can light the pilot, even though the abovementioned safety sensor doesn't see a flame. This is done by some combination of turning the knob (1) to the PILOT position and holding down the red button on the valve (2) — it looks like the button moves to the side, but I haven't personally used this style of valve to check. You might also have to push in the knob (1) to turn it. In any case, there will be something that must be held down for gas to flow (this is for safety, so it can't continue to flow unattended).

You may be able to hear the gas flowing as a faint hiss. In any case, it'll take a few seconds for the gas to flow through the length of the pipe and flush out the air.
Wait a couple seconds, then press the red button (3) firmly until it goes "snap" — this creates a spark which can ignite the pilot light. If you can see where the pilot light burns, just do this until you see the flame; if you can't see it, give it something like 10 seconds, trying every couple seconds.
No need to frantically press the igniter — as I mentioned above, any gas that doesn't get lit will quickly dissipate and there won't be a dangerous fwoosh even if you're "late".

Now the pilot is lit, but the thermocouple will not instantly heat up enough to keep the gas valve flowing. So, keep holding down whatever you started holding down in step 2 for several more seconds. If you let go too soon, the pilot will go out and you'll have to start over.

Once the pilot is lit, turn the knob (2) from the PILOT position to ON. The heater should now be controllable from the thermostat.

How to turn on a Honeywell gas heater


Can't get my array numbers to compare to the other set

Question: I have two arrays that both hold 5 sets of random numbers.
First I display a list of all the numbers in the first array; then I need to add to that list, any number that's not in the first array, and display each of those. To do that, I use another array to put the unique values in to display.
I already have a function that displays the current array.
Here's the code where I have the problem:
//SIZE is defined in the beginning as 5.

printArray(array1);
 int i, j;
 //For each number in array1, compare each number in array2 to it.
 for(j=0; j<SIZE; j++)
 {
  for(i=0; i<SIZE; i++)
     {
    if(array2[j] != array1[i])//?
    {
     arraySum[j] = array2[j];
     std::cout << arraySum[j] << std::endl;
     break;
    }

     }
 }
 //printArray(arraySum);

Comment: There's nothing inherently wrong with that code.  `arraySum` won't necessarily be completely filled in, is that your problem?  Could you explain your question more clearly?
Comment: I know, but the results I get aren't what I want.
I want an algorithm that compares one number in array2 with all the numbers of array1. If it doesn't match any of them, assign that number from array2 to arraySum[j]. Then display arraySum[j].
Answer: It sounds like you're looking for std::set_difference. Example:
std::set_difference(array2, array2 + SIZE, array1, array1 + SIZE,
    std::ostream_iterator<int>(std::cout, "\n"));

Note that array1 and array2 have to be sorted for set_difference.... you can use std::sort on the input arrays if need be.
You'll need to #include <algorithm> for std::set_difference and you'll need to #include <iterator> for std::ostream_iterator.
EDIT: If you want output similar to wheaties' post, you can use std::set_union instead of std::set_difference:
std::set_union(array1, array1 + SIZE, array2, array2 + SIZE,
    std::ostream_iterator<int>(std::cout, "\n"));

Answer: I believe this is what you're looking for...
#include <iostream>
int main(){
int i, j, count;
int SIZE = 5;
int array1[] = {1,3,4,5,7};
int array2[] = {0,9,14,5,18};
int arraySum[5];
//For each number in array1, compare each number in array2 to it.
for(j=0; j<SIZE; j++)
{
    count = 0;
    for(i=0; i<SIZE; i++)
    {
        if(array2[j] != array1[i])
        {
        count++;
        }
    }
    if(count >= 5){
        arraySum[j] = array2[j];
        std::cout << arraySum[j] << std::endl;
    }
}
return 0;
}

Hope this helps.


Multiple arrays creation using for loop

Question: How do you create 10 separate arrays using a for loop? For example my loop is from 1 to 10 and i want to create 10 arrays. I do this and it gives a notice and doesn't display my array.
<code>for($i=0;$i<12;$i++)
{
$match.$i = array();
}
</code>
Comment: What is `$match`? What is this code for? Are you aware that your loop goes up to `11` and has 12 iterations? And are you aware that English sentences start with a capital letter, and questions end in a question mark like `?`?
Comment: `$match.$i` on the left-hand side of an expression is illegal syntax.
Comment: @MarcB: [No, it's not](http://codepad.org/AHphCVY0)
Comment: well, maybe not illegal, but definitely useless. if `$match` is "hello", then `$match.$i = array()` is going to produce `helloArray` and that gets assigned nowhere.
Answer: Just change your loop code to this:
<code>$match[$i] = array();
</code>
Comment: doesnt adding $match[$i] make my array a two dimensional array? i want to save it a 1 dimensional array.
Comment: please describe what EXACTLY you want to achieve, what should be the result ?
Answer: Use the following code:
<code>$myArray = array();
for ( $i=0; $i<10; $i++ )
{
  $myArray[$i] = array();
}
</code>
Comment: still dont need it in js :-P `var param = [];`
Comment: Yeeees, the `new` comes from JavaScript! ;)
Comment: doesnt adding $match[$i] or $myArray[$i] make my array a two dimensional array? i want to save it a 1 dimensional array. –
Comment: Yes, you're right. So do you want to create an array with 10 empty elements?
Comment: no i want to create 10 arrays using for loop. let me know if its even possible?

Multiple arrays creation using for loop


Show enum in a comboBox

Question: <Grid
    xmlns:local="clr-namespace:SortedEnumInComboBox"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase">
<Grid.Resources>
  <CollectionViewSource x:Key="ComparatorsView">

    <CollectionViewSource.Source>
      <ObjectDataProvider
        MethodName="GetNames"
        ObjectType="{x:Type sys:Enum}">
        <ObjectDataProvider.MethodParameters>
          <x:Type TypeName="local:Comparators"/>
        </ObjectDataProvider.MethodParameters>
      </ObjectDataProvider>
    </CollectionViewSource.Source>
  </CollectionViewSource>
</Grid.Resources>

<ComboBox
  DataContext="{StaticResource ComparatorsView}"
  ItemsSource="{Binding}"
  VerticalAlignment="Center" />

public enum Comparators
{
    MinorThan = -1, Equals = 0, GreaterThan = 1
}

I'm trying to set the enum in a comboBox. In Display must show <, =, and > and SelectedValue will be Comparators value.
I'm not sure if am I use a converter or what?
Comment: Check this answer http://stackoverflow.com/a/4398752/416497
Comment: Did you find a solution?  I have a converter/attribute solution but there's a fair bit of code.
Comment: No, I didn't. Is possible that you post it?
Answer: This solution - which was not created by me - allows you to associate localized strings with enum values.
So assuming we have an enum defined as
[EnumResourceManagerForLabels(typeof(Resources))]
public enum Operator
{
    EqualTo = 0,
    GreaterThan = 1,
    LessThan = -1
}

Step 1: Add a Windows resource (.resx) file called in this case Resources.resx
Step 2: Add string resources to the file of the form EnumTypeName_EnumName for each enum value, e.g:
Operator_EqualTo     =
Operator_GreaterThan >
Operator_LessThan    <

Now we need the EnumResourceManagerForLabels attribute which is used by our converter so it know which resource file to use (see usage above):
[AttributeUsage(AttributeTargets.Enum)]
public sealed class EnumResourceManagerForLabelsAttribute : Attribute
{
    private readonly Type m_resourceManagerType;

    public EnumResourceManagerForLabelsAttribute(Type resourceManagerType)
    {
        m_resourceManagerType = resourceManagerType;
    }

    public Type ResourceManagerType
    {
        get { return m_resourceManagerType; }
    }
}

Now we need the converter:
///
/// An <see cref="IValueConverter"/> converter that converts between strings and enum types.
///
public class EnumLabelConverter : IValueConverter
{
    private readonly Dictionary<object, string> m_labelsByValue = new Dictionary<object, string>();

    private readonly SortedDictionary<string, object> m_valuesByLabel =
        new SortedDictionary<string, object>(StringComparer.Ordinal);

    private Type m_enumType;
    private bool m_labelsAreUnique;
    private bool m_sortDisplayNamesAlphanumerically = true;

    public Type EnumType
    {
        get { return m_enumType; }
        set
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (m_enumType != value)
            {
                m_valuesByLabel.Clear();
                m_labelsByValue.Clear();
                m_labelsAreUnique = true;
                m_enumType = value;

                if (m_enumType.IsEnum)
                {
                    const bool lookAtInheritedAttributes = false; // Ignored.
                    var enumResourceManagerAttribute =
                        m_enumType.GetCustomAttributes(typeof (EnumResourceManagerForLabelsAttribute),
                                                       lookAtInheritedAttributes).FirstOrDefault() as
                        EnumResourceManagerForLabelsAttribute;

                    ResourceManager manager;
                    if (enumResourceManagerAttribute != null)
                    {
                        manager = new ResourceManager(enumResourceManagerAttribute.ResourceManagerType);
                    }
                    else
                    {
                        // We use the invariant culture for detailing exceptions caused by programmer error.
                        throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                                  "The enum '{0}' does not have a '{1}' attribute.",
                                                                  m_enumType.FullName,
                                                                  typeof (EnumResourceManagerForLabelsAttribute).
                                                                      FullName), "value");
                    }

                    // For each field, retrieve the label from the resource manager.
                    foreach (FieldInfo fieldInfo in m_enumType.GetFields(BindingFlags.Public | BindingFlags.Static))
                    {
                        // We use the invariant culture to compute the string to use as the key to the resource.
                        string resourceKey = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", m_enumType.Name,
                                                           fieldInfo.Name);

                        string description = manager.GetString(resourceKey);

                        if (string.IsNullOrEmpty(description))
                        {
                            // We use the invariant culture for detailing exceptions caused by programmer error.
                            throw new InvalidOperationException(
                                string.Format(CultureInfo.InvariantCulture,
                                              "The label for the field {0} of the enum {1} is either null, empty, or the string resource with key {2} is absent from the {3} resource file.",
                                              fieldInfo.Name,
                                              m_enumType.FullName,
                                              resourceKey,
                                              manager.BaseName));
                        }

                        object fieldValue = fieldInfo.GetValue(null);

                        if (m_valuesByLabel.ContainsKey(description))
                        {
                            // We already have an entry with that label so we cannot provide ConvertBack()
                            // functionality because of the ambiguity.
                            m_labelsAreUnique = false;
                        }
                        else
                        {
                            m_valuesByLabel.Add(description, fieldValue);
                        }

                        m_labelsByValue.Add(fieldValue, description);
                    }
                }
                else
                {
                    // We use the invariant culture for detailing exceptions caused by programmer error.
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                              "The type '{0}' is not an enum type.", m_enumType.Name),
                                                "value");
                }
            }
        }
    }

    ///
    /// Gets or sets whether the <see cref="DisplayNames"/> are to be sorted alphanumerically.
    ///
    /// <value>true if the <see cref="DisplayNames"/> are to be sorted alphanumerically; otherwise, false.</value>
    public bool SortDisplayNamesAlphanumerically
    {
        get { return m_sortDisplayNamesAlphanumerically; }
        set { m_sortDisplayNamesAlphanumerically = value; }
    }

    ///
    /// Gets the display names (labels) for the fields of the associated enum type.
    ///
    /// <value>The display names.</value>
    public IEnumerable<string> DisplayNames
    {
        get
        {
            return (SortDisplayNamesAlphanumerically)
                       ? m_valuesByLabel.Keys
                       : m_labelsByValue.Values as IEnumerable<string>;
        }
    }

    #region IValueConverter Members

    ///
    /// Converts the enum value into a string.
    ///
    /// <param name="value">The value.</param>
    /// <param name="targetType">Type of the target.</param>
    /// <param name="parameter">The parameter.</param>
    /// <param name="culture">The culture.</param>
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        // We intentionally do not assert anything about 'value', so that we fail gracefully if the binding was not hooked up correctly.
        // (this may be the case when first loading some UI).
        object result = DependencyProperty.UnsetValue;

        if (value != null)
        {
            // See if we have been given a single value or a collection of values.
            var values = value as IEnumerable;
            if (values != null)
            {
                var labels = new List<string>();

                foreach (object item in values)
                {
                    string labelString;

                    if (m_labelsByValue.TryGetValue(item, out labelString))
                    {
                        labels.Add(labelString);
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }

                result = labels;
            }
            else
            {
                string labelString;
                result = m_labelsByValue.TryGetValue(value, out labelString) ? labelString : DependencyProperty.UnsetValue;
            }
        }

        return result;
    }

    ///
    /// Converts the string back into an enum of the appropriate type.
    ///
    /// <param name="value">The value.</param>
    /// <param name="targetType">Type of the target.</param>
    /// <param name="parameter">The parameter.</param>
    /// <param name="culture">The culture.</param>
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (!m_labelsAreUnique)
        {
            throw new InvalidOperationException(
                GetType().Name + ".ConvertBack() requires that enum labels are unique to avoid ambiguity.");
        }

        // We intentionally do not assert anything about 'value', so that we fail gracefully if the binding was not hooked up correctly,
        // (this may be the case when first loading some UI).
        object enumValue;
        var labelString = value as string;

        if (!string.IsNullOrEmpty(labelString))
        {
            if (!m_valuesByLabel.TryGetValue(labelString, out enumValue))
            {
                // The value for the label could not be found.
                enumValue = DependencyProperty.UnsetValue;
            }
        }
        else
        {
            // The value we were passed was a null or empty string, or not a string.
            enumValue = DependencyProperty.UnsetValue;
        }

        return enumValue;
    }

    #endregion
}

and finally an example of usage:
<Grid>
    <Grid.Resources>
        <Converters:EnumLabelConverter x:Key="OperatorConverter" EnumType="{x:Type ViewModel:Operator}" />
    </Grid.Resources>

    <StackPanel>

        <TextBlock Text="{Binding Source={x:Static ViewModel:Operator.GreaterThan}, Converter={StaticResource OperatorConverter}}"/>

        <TextBlock Text="{Binding SelectedOperator, Converter={StaticResource OperatorConverter}}"/>

        <ComboBox
            SelectedValue="{Binding SelectedOperator, Converter={StaticResource OperatorConverter}}"
            ItemsSource="{Binding Source={StaticResource OperatorConverter}, Path=DisplayNames}"/>

        <ComboBox
            SelectedValue="{Binding Source={x:Static ViewModel:Operator.GreaterThan}, Converter={StaticResource OperatorConverter}, Mode=OneWay}"
            ItemsSource="{Binding Source={StaticResource OperatorConverter}, Path=DisplayNames}"/>
    </StackPanel>
</Grid>

Where the view model (using MVVM light) is:
public class EnumBindingSampleViewModel : ViewModelBase
{
    private Operator _selectedOperator;
    public Operator SelectedOperator
    {
        get { return _selectedOperator; }
        set { Set(()=>SelectedOperator, ref _selectedOperator, value); }
    }
}

Show enum in a comboBox


What diameter pipe do I need to adjust this basin waste pipe?

Question: I fitted a new tap and waste outlet to a small basin, because the new outlet is shorter than the old, the plastic pipework no longer reaches (see photo) I can force the parts to mate but I don't like having the pipe under a lot of strain and it doesn't seal properly (I havent tried applying copious amounts of plumbers putty).

I am considering cutting off the white-painted down-pipe (at right of photo) and using a solvent-weld straight coupling to insert a new section of pipe to raise the pipework about 1 cm.
The existing pipe has an outside diameter of 36 mm.
The pipes available in catalogues are listed as 32 mm or 40 mm.
I understand that a nominal 32 mm plastic waste pipe has an outside diameter of 34.5 mm. Is this the right pipe?
Comment: I am a little concerned about those 2 90 degree bends that are visible.  Those look like vent 90s that should not be used to waste.  IMO they should be smoothe bends instead of sharp corners.
Comment: @auujay: Thanks for taking the time to respond. I think this may reflect a difference in plumbing practices in the US and UK. The bend on the left is part of a standard "P trap" basin waste outlet ([example](http://www.screwfix.com/p/tubular-swivel-p-trap-32mm/17159?cm_mmc=GoogleBase-_-Datafeed-_-Heating%20and%20Plumbing-_-Tubular%20Swivel%20P%20Trap%2032mm)) and the bend on the right is also a fairly common part marketed for basin waste pipes ([example](http://www.screwfix.com/p/floplast-90-bend-white-32mm-pack-of-5/78220?_requestid=575769))
Answer:
Cut where marked, but adjust the location so you've got clearance to work later.
Seeing as you only need a couple of millimeters, you might be able to get away with buying only the coupling connector similar to this:

So a good straight cut where marked, insert the connect and solvent weld it back into place.
Take the cut piece in with you, and just make sure you've got a snug dry fit in the store.
No need to actually figure out the exact diameter.  Just buy the piece that fits.
Comment: Thanks, I guess I'll have to try sanding off the gloss paint from the pipe before welding.
Answer: So far I have discovered there are at least two incompatible types of "32mm" plastic waste pipe.

"solvent weld" PVC or ABS pipe with an inside diameter of 32mm and outside diameter of ~37mm.
"push fit" plastic pipe with an inside diameter of ~29mm and an outside diameter of ~35mm

Because of the difference in diameters, you can't use push-fit fittings on "solvent weld" pipe and you can't use solvent-weld fittings on push-fit pipe. I guess this is deliberate to stop people trying to use solvent to weld a pipe made of a material that the solvent won't melt.
Diameters above are approximate measurements made with a cheap vernier gauge.


Configuration to rebuild/reload angular application on saving changes

Question: The --watch and --live-reload works on change detection, and they are usable with serve command. But is there any configuration so that rebuild and reload happens only when I save my changes?
Answer: I think that the problem comes from your IDE. --watch rebuild the app when some file change, so if your IDE save when the focus change (Like Jetbrains IDE Collections such WebStorm), your app is rebuilt.
Change that option in your IDE and everything must work like you want :)
Comment: Thanks for the hint. I just discovered my VSCode is not respecting the `"files.autoSave": "off"` setting.
Comment: Disabling auto-save so you can prevent some automatic rebuilds seems like using a nuclear warhead to prune the bushes... some fallout is likely.
Answer: You can use ngOnChanges() hook with your function.


javascript stop form submitting

Question: I have a login form that I am trying to handle with ajax.
At first appearance it works fine,
You click the login button,
if your details are correct you are logged in and redirected.
If your details are incorrect an error message is shown.
If you wait for the error message to disappear and click the login button again it works fine.
if you dont wait it seems to submit the form.
why does it do this?
here is the code
var timeout = null;

$(function() {
    $('form').submit(function() {
        var action = $(this).attr('action');
        var type = $(this).attr('method');
        $.ajax({
            url: action,
            type: type,
            data: {
                email: $('input[name=email]').val(),
                pass: $('input[name=pass]').val()
            },
            success: function(data) {
                switch (data.status) {
                    case false:
                        login_error(data.message);
                        return false;
                        break;
                    case true:
                        window.location = data.message;
                        return false;
                        break;
                }
                return false;
            }
        });
        return false;
    })
});

function login_error(message) {
    $('form').effect('shake', { distance: 10, times: 3 }, 50);
    if (timeout !== null) {
        clearTimeout(timeout);
        $('#login').stop().hide();
        show_error(message);
    } else {
        show_error(message);
    }
}

function show_error(message) {
    $('#error').html(message)
            .show("drop", {direction: 'left'}, 500);
    timeout = setTimeout(function() {
        $('#error').hide("drop", {direction: 'right'}, 500);
        timeout = null;
    }, 5000);
}

Edit
Ok, so its not actually refreshing the page,
Something is setting the form to display:none;
I have added a whole pile of console.log()'s through the code and clicked login twice so it now looks like:
var timeout = null;

$(function() {
    $('form').submit(function() {
        console.log(1);
        var action = $(this).attr('action');
        console.log(2);
        var type = $(this).attr('method');
        console.log(3);
        $.ajax({
            url: action,
            type: type,
            data: {
                email: $('input[name=email]').val(),
                pass: $('input[name=pass]').val()
            },
            success: function(data) {
                console.log(4);
                switch (data.status) {
                    case false:
                            console.log(5);
                        login_error(data.message);
                        return false;
                        break;
                    case true:
                            console.log(6);
                        window.location = data.message;
                        return false;
                        break;
                }
                console.log(7);
                return false;
            }
        });
        console.log(8);
        return false;
    })
});

function login_error(message) {
    console.log(9);
    $('form').effect('shake', { distance: 10, times: 3 }, 50);
    console.log(10);
    if (timeout !== null) {
        console.log(11);
        clearTimeout(timeout);
        $('#login').stop().hide();
        console.log(12);
        show_error(message);
        console.log(13);
    } else {
        console.log(14);
        show_error(message);
        console.log(15);
    }
}

function show_error(message) {
    console.log(16);
    $('#error').html(message)
            .show("drop", {direction: 'left'}, 500);
    console.log(17);
    timeout = setTimeout(function() {
        console.log(18);
        $('#error').hide("drop", {direction: 'right'}, 500);
        timeout = null;
    }, 5000);
    console.log(19);
}

With the output being:

1
  2
  3
  POST http://localhost/buzz/ajax/login 200 OK 30ms
  8
  4
  5
  9
  10
  14
  16
  17
  19
  15
Second Click
  1
  2
  3
  POST http://localhost/buzz/ajax/login 200 OK 30ms
  8
  4
  5
  9
  10
  11
  12
  16
  17
  19
  13
  18
Comment: An easy solution would be to make your error dialog modal.  Then the user would have to dismiss it before attempting to login again.  Another possibility is putting the error message right onto the web page, instead of using a dialog.
Comment: although practical, I personally think Modal dialogs are a crime against ui (except in certain cases e.g. lightbox for gallery) ;)
Comment: I agree with you, actually. Gosh, why did I even suggest it? :) That said, if you are going to use an error dialog, the proper way to do it is to make it modal. So for me, it's a choice between a modal dialog and no dialog at all.
Answer: One choice is to have a regular button, not a submit button. Use the onclick on the button you call your validation/ajax.
Answer: I'm guessing it has to do with the animation of the form and/or #error not being completed.  You may want to make sure something has changed after a failed login.  So some if/else statements prior to submitting the form in code to make sure the form is submittable may make this work...  It probably would be a good idea to make sure there is a value for username and password prior to submitting the form....
Here is a quick sample of untested code, with some comments on changes...
$('form').submit(function() {
     //DEFINE "ISVALID()"....
     if($('input[name=pass]').val().ISVALID())
     {
         //your do login code here...
     }
     else
     {
         login_error("Please enter a password!");
     }
})
function login_error(message) {
    //CLEAR PASSWORD
    $('input[name=pass]').val() = "";
    //THE REST OF YOUR CODE HERE...
}

Comment: although it would save me a call to the server, I like to have all my error handing in one file :)

By the fact that the form is getting set to display:none makes me think you are right about the animations, the console.log output is also weird.
Comment: then put it all in one file...  but you are not validating anything at the moment, hence your issue...

javascript stop form submitting


How to run wire along 2x3 studs

Question: Doing a basement build, using 2x3 studs for drywalling over wrapped insulation. How do I fasten the nmsc to the studs? I'm not about to drill through these smaller studs because the wood is already thinner than 2x4.
Any wrap-around type staple or other solutions available?
Answer: 2x3 studs are only (correctly) used for non-load-bearing walls, (as far as I understand) and certainly the wall in question is not load bearing.
Non-bearing studs can be notched 40% or drilled 60% per code. That's a 1 inch notch or a 1-1/2" hole on a 2-1/2" "2x3" in the "3" direction.
Drilling holes for NM cable is utterly not a problem. Use protective plates if your wires end up within 1-1/2" of the room-facing edge of the stud, and keep your holes at least 5/8" from either edge.
Comment: * 1-1/4" of the room facing edge of stud.

How to run wire along 2x3 studs


objects.last() or objects.latest('id') ? which one is faster ?(django)

Question: i need to get the most recent data of a table in django but I want the fastest way to do this.
which one is fastest?
foo.objects.latest("id")
foo.objects.last()

or should i use get() with one of above methods ?
Answer: If your Foo model did not specify an get_latest_by model option [Django-doc], then the two are equivalent. Indeed, as discussed in my answer on the difference between .last() and .latest():

.first() and .last() will work with the ordering of the queryset if there is one, .earliest(…) and
.latest(…) will omit any
.order_by(…) clause that has already been used;
if the queryset is not ordered .first() and .last() will order by the primary key and return the first/last item of that queryset,
.earliest(…) and .latest(…)
will look for the get_latest_by model
option [Django-doc] if no fields are specified;

If get_latest_by is thus not specified, or the primary key, both queries will result in a query that looks like:
SELECT *
FROM foo
ORDER BY id DESC
LIMIT 1
Both methods are not equivalent, but in this case will produce the same query, and thus have the same impact on the database.

or should i use get() with one of above methods?

No, .last and .latest() are eager methods, they will directly make the query and return a Foo object (or None), it thus does not make sense to call .get() since a model has no .get() method defined on it.
Comment: thanks for your answer but you mean any one these two go through all of objects then select the last one ?is it true that this takes time when there are a lot of data ? i wanted a code that go right at the last one
Comment: @webdeveloper: no, both make a query to the database to fetch a *single* record (see the `LIMIT 1`).


How HibernateTemplate works internally

Question: We are using Spring and Hibernate in our application and use getHibernateTemplate() method for all hibernate stuff. My questions are:

How HibernateTemplate internally works?
What is the difference between getHibernateTemplate().save(entity) and session.save(entity)? Which one is better to use?

I have already searched on this but yet not found any satisfactory answer.
Answer: Spring is open-source - you can just download the source and have a look for yourself.
HibernateTemplate is nothing more than a light wrapper around the Hibernate Session interface, providing its own interface that's more consistent with the Spring conventions.
If you don't want to download the source, you can read it here.
Answer: Hibernate provides convenient methods that handle resource management (like transaction setup, as well as session acquisition) in easy to use methods. It also knows about Spring's declarative transaction management and can participate in a transaction.
however, at one point a few years ago Hibernate made it very easy to support similar use cases with a little help from Spring. Spring now offers support for Hibernate session-based access using AOP to acheive a lot of the same results.
See this blog for the proper way to setup that support and for a discussion over which approach. There is simialar support for JPA and its EntityManager.
http://blog.springsource.com/2007/06/26/so-should-you-still-use-springs-hibernatetemplate-andor-jpatemplate/

How HibernateTemplate works internally


SystemExit: `requests` library you installed has been been hijacked

Question: I am trying to import libraries I have used previously to calculate metrics between text, one being evaluate package. When I import the package it says the requests package has been hijacked
I tried uninstalling python-requests, evaluate, and requests and reinstalling requests and evaluate but nothing changed. Also tried installing python-dotenv.
I have
python==3.9.13
requests==2.31.0
This is the output
from evaluate import load

bertscore = load("bertscore")
predictions = ["hello there", "general kenobi"]
references = ["hello there", "general kenobi"]

results = bertscore.compute(predictions=predictions, references=references, lang="en")

Well . The `requests` library you installed has been been hijacked
An exception has occurred, use %tb to see the full traceback.

SystemExit:

Edit: Screenshot of pip freeze
Comment: (if you have a greybearded long-time sysadmin handy, ask them how they feel about modern packages -- especially in the npm would, but increasingly now in the Python data-science world as well -- with dependency chains that reach into the hundreds fo packages; it's an utter mess, and congrats -- you stumbled into an example of why; everything in that chain is something you're trusting to install and run any code it wants on your computer).
Comment: Generally, this means what it says. Be more careful about `pip` commands, and/or about auditing the dependencies of the packages you install. (If you use `pip install python-requests` instead of `pip install requests`, f/e, there was something typosquatting there for a while; but `requests` is common enough to be a frequent target, so it's not like it has only one impersonator).
Comment: Can you update your question with `pip freeze` result?
Comment: Sounds like you may have installed something else with a very similar name to `requests`.
Comment: pip isn't always right about everything -- it only knows what its bookkeeping tells it. `import requests`, then `print(requests.__file__)` to see where it's coming from.
Comment: @CharlesDuffy but it says I dont have python-requests installed so what else could it be?
Comment: If you can't get that far, there are plenty of options; you could use `importlib` to try to break down the import process into steps and stop before actual execution. You could use `strace` to run your Python interpreter to trace execution so you have a log of every file it read. You could use the PYTHONVERBOSE environment variable to tell the interpreter to log more of what it's doing... etc, etc, etc.
Comment: Try `PYTHONVERBOSE=2 python3 yourscript`, and read the log to see where the unwanted file is being read from.
Answer: You have apparently installed python-requests. Uninstall it.
Comment: That's what I thought but if I go to uninstall it, it says not found.
Comment: BTW, the dev's profile is interesting. See [python-wheel readme](https://github.com/kalefranz/python-wheel)
Comment: `pip uninstall python-requests`
Answer: [TL;DR: specific solution at the bottom, OP needs to run step 2]
This happens because an installed package overwrote the original package's namespace (and files). While there may be cases where such behavior is actually desired, this isn't one of them. Packages like this attempt to exploit common typos or use confusing names similar to legitimate packages, so unsuspecting victims would install (and then run) them on their environments. Many packages using such practices are usually malicious, though sometimes this can happen in error, or as a proof-of-concept (which while may be annoying, are relatively innocent).
Generally speaking (not just for the specific package in question), it is hard to predict the extent of exposure, however if this happens I'd suggest assuming that at the very least the python environment is compromised, and in some cases the entire system may be as well. Generally I'd suggest searching for further information about such a package (hoping that you're not the first to encounter it), and follow reputable suggestions. In some extreme cases it may be required to wipe and reinstall the entire OS.
Specific solution for python-requests==0.0.0.2
Seeing as this appears to be a proof-of-concept and does not execute malicious code (other than destroying requests), this can be fixed by first uninstalling python-requests, and since it overwrote the original package, repairing requests is also needed. Assuming you are using pip, follow these steps:

First, remove the offending package with pip uninstall -y python-requests
The -y flag prevents pip from asking for confirmation.
Now, repair the original package with pip install --force-reinstall requests
This will fix the installation, as it will rewrite the overtaken (and now deleted) files from the damaging package.

I would not recommend this for all such packages, only for this one, at this point in time, and for this specific version. There's nothing (at the moment) to stop the maintainer from actually injecting malicious code into newer releases of this package. Seeing as you have already uninstalled the package but are still stuck with a broken requests installation, simply fix the package (as mentioned in step 2), and you should be good to go.


Third-party GCM clients for receiving push notifications?

Question: I'm trying to create a server that generates its own registration ID and uses it to receive GCM notifications. I'm sure it's possible (since Chrome can receive GCM messages—it's just a matter of reverse-engineering the protocol) — are there any libraries out there that implement that?
Comment: There is a library in python for that https://github.com/Francesco149/push_receiver and in js https://github.com/MatthieuLemoine/push-receiver
Answer: Registration ID is not generated by Chrome, so I don't think you will be able to write a server that would generate Registration IDs that are valid for use with GCM.
The client side request to get a Registration Id is in fact open-sourced and available here.


injecting HTML lines using knitr markdown

Question: Is there a way to inject R code output into the generated document without the sourounding format tags
 or
? I ask this because I want to use .Rmd not .Rhmtl but at the same time inject some extra HTML lines. Doing so using e.g. cat("HTML code") will fail as the output is sourrounded by
.
The example I try to run the follwing .Rmd file (with additional HTML lines) which file not work out right:

```{r}
1:10
```

Antwort anzeigen

```{r}
1:10
```

Comment: Could you show what you want finally?
Comment: You JS script might do that too for you.
Comment: @kohske What I want is the same format as the usual R output in the 2nd part. I want to be able to show and hide the 2nd part of the output. Currently the of the second part of the output gets destroyed.
Comment: @daroczig: I am new to JavaScript so any ideas are very welcome :)
Comment: What I want is [something like this](http://www.gridhub.uni-bremen.de/public/test.html) but using markdown Rmd.:
Answer: You should be able to do this with knitr's hooks.  You'll probably want to check out the source code to see what the default hooks are for render_markdown():
> library(knitr)
> render_markdown()
> knit_hooks$get('echo')
NULL
> knit_hooks$get('message')
function (x, options)
{
    if (strict) {
        str_c("\n\n", indent_block(x), "\n")
    }
    else str_c("\n\n```\n", x, "```\n\n")
}
<environment: 0x2a3f590>
> knit_hooks$get('output')
function (x, options)
if (output_asis(x, options)) x else hook.t(x, options)
<environment: 0x2a3f590>
> knitr:::output_asis
function (x, options)
{
    is_blank(x) || options$results == "asis"
}
<environment: namespace:knitr>

I'm not sure what exactly hook.t does, but check it out.
Also, have you tried the asis option?  I'm not totally clear on how you want things formatted, but you might be able to get it working with asis.
You can do lots of cool stuff with hooks.
Comment: see https://github.com/yihui/knitr/blob/master/R/hooks-md.R if you are interested in the default output hooks in `knitr`; I agree with you that this question can be better answered by hooks but `chunk hooks` may be even better
Comment: Agreed.  Especially if he doesn't mind changing the Rmd to add options.  I've found it handy to just augment the knitr hooks at knit-time without making changes to the source document.  However, what I was doing was not specific to one or even a few documents, so I didn't want to deal with adding chunk options.  If he just wants to do this for one or two documents, chunk hooks might be better.
Answer: What I did now was following darozcig's advice and I used JS. This solution seems tedious though. Something easier neatly fitting knitr would be nicer! Below my complete .Rmd script.

```{r}
1:10
```

```{r}
1:10
```

Comment: probably you can ask this guy: http://carlboettiger.info/2012/06/13/Sethi-policy-functions.html


How do you force start ubuntu on Macbook Pro

Question: My MacBook stopped running LION OS so i decided to install Ubuntu on it. I followed the steps set out (see below) and got Ubuntu working well for a few days. Then it would not boot past the famous 'Mac white screen startup screen.' (The one with the question mark on a folder) It would intermittently boot to Ubuntu.
From the white screen- Hard shutdown- power on- white screen; then Hard shutdown- power on- Ubuntu.
Eventually tho it just stopped booting Ubuntu completely.
What is the correct procedure for forcing Mac to boot Ubuntu considering that I have installed it correctly following tested procedures.
Why did it stop after a few days? perhaps it could to do with the Updating that Ubuntu provides that changed something?
Some Info about my system

Install version of Ubuntu is 14.10 bootable USB
MacBookPro Retina 13inch (was running Lion OS)
New SSD installed before Lion crashed see here [
Grub install version (GNU GRUB 0.97)
EFI boot and extra partitioning table []
I have a directory called /sys/firmware/efi. I checked this by <code>/sys/firmware/efi</code> in terminal. Which I think confirms I am booting in EFI
Boot order is []

This is my install procedure see here Procedure used to install 14.10. Please note that I did NOT partition in Lion(Mac OS) as Lion stopped working all together and had to go straight to the MacBook start up screen.
One last thing as I continue to work this out is that I can not change Grub in this 'try ubuntu bootable usb' so I loaded Grub Customizer and have this red flag screen shot which I have not encountered Before []
Moderator. Please let me know If I need more information before you post this question. I have no problem in changing it.
Comment: You can try using `boot-repair`, which you can find on community.ubuntu.com
Comment: Holding `ALT` at startup should get you into the Mac's boot menu.
Comment: yes it does. But that does not achieve the required goal.
Comment: So no Ubuntu is shown?
Comment: Boot Repair installed well. Followed all the steps and proceeded to Repair. I also opted to Upgrade Grub to the latest version in Advanced options but that was all.
Now I have rebooted and I have looked good with No Mac boot menu but computer failed to open
'EFI/BOOT/grubx64.efi - 80'0E' 'Failed to load image' ' Failed to open EFI/BOOT/MokManager.efi - 80'0E' 'Failed to load image' It is now frozen here
Comment: Use the LiveUSB/CD you have to see if you can reinstall GRUB on the partition.
Comment: To clarify, reinstall Grub on my the partition where Ubuntu is currently installed sda5, or sda1 which is the EFI system.
Comment: sda1, since that's where the problem is occurring.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/27398/discussion-between-carlos-dunick-and-zacharee1).
Answer: The White Folder with a question mark means that your MAC is missing a important boot folder from you OS.
If holding alt does not provide a solution:
You can try to reinstall MAC osx my holding Command + R at start up and letting go when you hear the boot chime. It will boot into internet recovery.
Comment: Reinstalling Mac isn't the goal here.
Comment: Thank you for your reply. Are you saying that it is necessary to reinstall the Mac OS to get that 'important boot folder' ?  Will this enable be to boot ubuntu? Because i do not want Dual Boot. @Vault108
Comment: @CarlosDunick If you were able to boot for such a long time without Mac installed, it wouldn't make sense that Mac would have an important file.
Comment: Then what are we trying to do. Please be specific. I am able to get into Internet recovery for Mac by simply holding the Option key. all the Mac startup options work including option+R
Answer: This is an ancient question, but google finds it and maybe my answer will help someone.
In 2021 the best way I found is this:
Boot from the ubuntu flash drive.
Then:
<code>$ sudo apt-add-repository ppa:rodsmith/refind
$ sudo apt-get update
$ sudo apt-get install refind
</code>
https://www.rodsbooks.com/refind/installing.html


TYPO3 own extension using RTE

Question: Im writing my own extension. Now i like my textarea to be edited i RTE. I tried some configurations from web and i cannot make it work..
Part of my TCA:
    'tasks' => array(
        'exclude' => 0,
        'label' => 'LLL:EXT:jobs/Resources/Private/Language/locallang_db.xlf:tx_jobs_domain_model_joboffer.tasks',
        'config' => array(
            'type' => 'text',
            'cols' => 40,
            'rows' => 15
        ),
        'defaultExtras' => 'richtext[]'

    ),

Like here: http://docs.typo3.org/typo3cms/CoreApiReference/Rte/InTheBackend/Index.html
NOT WORKING :(
I also tried similar to this: http://typo3blogger.de/der-t3editor-im-tca/ and also cannot make it work. In cms i always see simple textarea. Any ideas how to plug it in?
my TCA script:
'types' => array(
    '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, add_date, reference_number, position, link_url, localization, title, requirements;;;richtext:rte_transform[mode=ts_links], tasks;;;richtext::rte_transform[flag=rte_disabled|mode=ts_css], offer;;;richtext:rte_transform[mode=ts_links], category, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, starttime, endtime'),
),

and columns:
'tasks' => array(
        'exclude' => 0,
        'label' => 'LLL:EXT:jobs/Resources/Private/Language/locallang_db.xlf:tx_jobs_domain_model_joboffer.tasks',
        'config' => array(
            'type' => 'text',
            'cols' => 40,
            'rows' => 15
        ),
        'defaultExtras' => 'richtext[]'

    ),

Comment: Which version of TYPO3?
Answer: If you field is called tasks, you need in your *showitem** section this code:
tasks;;;richtext::rte_transform[flag=rte_disabled|mode=ts_css],
see e.g. https://github.com/TYPO3-extensions/news/blob/master/Configuration/TCA/tx_news_domain_model_news.php#L612
Comment: I have tried it but no change.. i post below whole file.

TYPO3 own extension using RTE


Fixed point of curve automorphism

Question: Exercise I.F-8 from "Arbarello, Cornabla, Griffiths, Harris: Geometry of algebraic curves" states that for a complex algebraic genus $g$ curve and its automorphism $\varphi$ of order $n$ the number of fixed points $\alpha$ of $\varphi$ satisfies
$\alpha\leq \frac{2g-2+2n}{n-1}$
with inequality only if the quotient $C/\varphi$ has genus $0$ (i.e. $\mathbb{P}^1$).
So the inequality itself is an easy part (it follows from Riemann-Hurwitz). But I can't see why the number of fixed points is exactly that number if $g(C/\varphi)\ne 0$. Can you help me?
Edited: in fact this number can be non-integer and it's confusing.
Answer: The map $\pi:C\to C/\varphi$ is totally ramified over the fixed points of $\varphi$. So if equality holds in the given inequality, we obtain that the degree of the ramification divisor of $\pi$ is $\geq \alpha.(n-1)=2g-2+2n$. On the other hand, it is an easy observation that for a degree $n$ morphism of curves $f:X\to Y$, the degree of the ramification divisor is maximal if $Y=\mathbb{P}^1$ and in this case is equal to $2g-2+2n$.
So, $\mbox{deg} R=2g-2+2n$ and by Riemann Hurwitz $g(C/\varphi)=0$.

Fixed point of curve automorphism


Rotation of meshes in PyTorch

Question: I am doing some project on object reconstruction and I need to rotate an object in PyTorch during the training to make sure I am augmenting the data properly. My data consists of points and it's normals. My question is, how should I (or should I train them at all) rotate the normals of my mesh. Note that this rotation also needs to keep the object inside the unit cube, where it was before the transformation.
Answer:
My question is, how should I (...) rotate normals of my mesh.

Normals are rotated the same way as the rest of your mesh/point cloud. But make sure that you use a "pure rotation matrix" for this (no scaling, no translation). Since rotations preserve lengths, you do not need to renormalize your normals (usually - floating-point errors might accumulate).
This sentence of you

Note that this rotation also needs to keep object in unit cube, where it was before running this code.

lets me guess, that you are actually asking how to rotate an object and its normals and not just the normals. In python, you can use the packages SciPy and NumPy for that.
The Rotation package (documentation) of SciPy helps you to generate an arbitrary rotation matrix. Then you can use NumPys matmul function to rotate your points and normals.
Here is a short example script that rotates a single point 20 degrees around the z axis:
from scipy.spatial.transform import Rotation as Rot
import numpy as np

p = np.array([1, 1, 0]).transpose()
rot_mat = Rot.from_euler(seq="z", angles=20, degrees=True).as_matrix()

p_r = np.matmul(rot_mat, p)

print(p)
print(p_r)
print(np.linalg.norm(p))
print(np.linalg.norm(p_r))

output:
[1 1 0]
[0.59767248 1.28171276 0.        ]
1.4142135623730951
1.414213562373095

Info: Depending on your SciPy version you might need to replace as_matrix with as_dcm

As you can see, apart from some minor floating-point error, the length (last 2 outputs) did not change. Furthermore, I chose the example point, so that it gets outside the unit cube. To address this problem, you need to find the maximum absolute value inside the transformed data. You can use amax and amin to get the maximum and minimum value (see also here) if you put all your coordinates into one large 2d array (a matrix). Then compare the absolute values of the amax and amin results and pick the larger one. Divide all your coordinates (not the normals!) by this value, to scale your model back into the unit cube. Alternatively, you can create a uniform scaling matrix
$$
\begin{bmatrix}
s&0&0\\
0&s&0\\
0&0&s
\end{bmatrix}
$$
with $s$ being the reciprocal of the maximum absolute value. Multiply this matrix with all points.
To sum it up:

calculate the rotation matrix with SciPy
Multiply the rotation matrix with all points and normals
find the maximum absolute value in the rotated data
scale your coordinates with the found maximum value

Remark: If you put your points and normals into 2 matrices, you can apply the rotations and scaling matrices without a loop, which makes it much faster.
Comment: But if the model is centered around the center (0,0,0) in a unit cube, is there really a need for rescaling points back to the unit cube?  Moreover, can I use the same rotation matrix for normals as I used for points?
Comment: also, I don't like your approach by scaling by maximum value across all axises (x,y,z), since it degrades pointcloud objects significantly. Say you have a pencil like object, if you scale it by it's maximum value, which is surely going to be along the pencil length, and divide both it's width and height by the same value, you will get something that looks more like a small radius stick than the pencil.
Comment: Question 1: Depends on your model. But take the unit cube itself as an example. If you rotate it by any angle that isn't a multiple of 90 degrees, The corners will end up outside the unit cube. To visualize it, take two dice and put them on top of each other so that they are aligned. Now rotate the upper one by 45 degrees. See the problem? Only if all your points are initially inside the unit sphere, you can be sure that no point will end up outside the unit cube after an arbitrary rotation.
Comment: Also, why scaling by some value, it's rotation and should be shape and length preserving, wouldn't shifting/translation be correct way of bringing object back to the unit cube?
Comment: Question 2: Yes, actually you HAVE to, otherwise you get wrong normals. A quote from my answer: "Normals are rotated the same way as the rest of your mesh/point cloud."
Comment: Regarding your second comment: If you use the scaling I described, it just shrinks the model. So you will just get a smaller pencil, but the ratio between thickness and length is preserved. Maybe you should read a little bit more about the basic operations that are used in computer graphics: Scaling, rotation, translation. See [this tutorial](https://learnopengl.com/Getting-started/Transformations).
Comment: Question of your 3. comment: Translation MIGHT work, but in case of the rotated unit cube (angles != 90° * N)  as a model, there is no way to translate it into the unrotated unit cube. The only way to fit it without scaling is to rotate it back.
Comment: Is centroid (central point of the pointcloud) preserved after rotation translation? Could I by just shifting centroid to 0,0,0 bring back my object to unit cube?

Rotation of meshes in PyTorch


Bash control+c process

Question: I have a couple of servers each that have a 'screen' that is running a program. This way, i am able to ssh in and monitor their out putat any given time.
The problem, is that i am often having to ssh in, log into the screen, control+c the process and then restart it.
I would like to write a bash script that would do this for each of my servers, and i think i understand how to do it, aside from the control+c bit.
ssh ubuntu@ipaddress
screen -dr that_one_screen
#control+c somehow
restart_process

Can someone please help me out?
Answer: Instead of ctrl-C, just kill the process using "kill."
Follow-up (re: PID determination):
Generically, on Linux try something like:
ps -e | grep <your process name> | awk {'print $1'}

Start with "ps -e" to get the lay of the land and an idea of what you can filter on.
Comment: You'll have to know the process ID of the process you want to kill, of course. Should be easy with the right pgrep line...
Comment: Can @JonahBishop or conrad please explain how to obtain the PID so i can kill the process? say to start my process i say 'bundle exec rake start_that_one_process'
Comment: The [Wikipedia article on pgrep](http://en.wikipedia.org/wiki/Pgrep) has some useful examples. Also see the [man page](http://linux.die.net/man/1/pgrep). I forgot about **pkill**, but it's also an option (see second link for more).
Comment: I don't use Ruby/rake, so I can't give specific advice.  You might be able to get your framework to give you the PID directly (Googling "bundle exec rake process id" gave some plausible results), but this is outside my expertise.

Adding generic comments as a follow-up to my answer...
Comment: Jonah's comment on pgrep is spot on and may well be better than mine... I'm so accustomed to grep/awk/sed that I sometimes overlook the more purpose-built utilities.
Comment: @ConradShultz pgrep ended up not working for me.. because it would only return the correct result if i fed in the name 'ruby' and i had multiple ruby processes on some servers. I would not have been able to solve the issue without your post. Thanks. :] (also, i thought i'd let you know i ended up having to do `ps aux -e` so i could get the actual name)
Answer: One alternative way I might implement a solution to this problem is the following:
On each system I wish to control, I would place a bash script that does two things: (1) kills the running process and (2) restarts it. I could then have a second bash script on my 'master' system that would simply call this script via an ssh command. Example:
Script 1: recycle_process.sh (placed on each system I wish to control)
#!/bin/bash
pid=`pgrep 'my_process_name'`
kill $pid
# Launch 'my_process_name' (as a background process!)

Script 2: do_recycle.sh (placed on the master controller system)
#!/bin/bash
_host=$1
if(-z $_host) {
  echo "Gimme a host name to connect to!";
  exit(1);
}
ssh root@$_host screen -dm /path/to/recycle_process.sh

Now all you have to do is run do_recycle.sh myhostname from the command line of your master system, and (I believe) your problem will be solved. In this case, I don't think you'd need to keep a screen session alive. The process is just always running in the background. That said, I'm not exactly sure how you have things set up; you may have to alter the screen line in script 2 above to work with your environment.
Comment: Much if not all of this can also be accomplished with monit. If your needs include a "keepalive" function to protect against crashes, etc., you might take a look at it.

Bash control+c process


Default HDD partitions on Dell Inspiron 3551 laptop

Question: I got a brand new dell inspiron 15 3551 with ubuntu 14.04 preinstalled.
3,7GB RAM, Intel Celeron CPU N2840 2´16 GHz x2, Graf. Intel Bay Trail, HDD 500GB.
It comes with the following disc partitions;
<code>/dev/sda1 (ESP), EFI, 524MB, mounted on /boot/efi.
/dev/sda2 (DIAGS), FAT 32, 42MB, not mounted.
/dev/sda3 (OS), FAT 32, 3´2GB, not mounted.
/dev/sda4 (File System), ext4, 488GB, mounted on /.
/dev/sda5, swap, 8,3GB.
Free space 1´1MB.
</code>
I´m considering reinstalling ubuntu 14.04 from a USB stick, mainly to repartition the HDD and set the root (/) in one partition and an other one with /home.
I wonder...
What is the purpose of each ESP, DIAGS and OS partitions? I suppose ESP if for booting. Can I eliminate any of them?
8,3GB of exchange menory is not too much?  How much could I reasignate to Exch. Mem.?
Thanks
Answer: You can remove all partitions if you like. But you will lose the recpvery feature that allows to restore everything to factory defaults.
/dev/sda1 is EFI boot. It is needed for UEFI.
/dev/sda3 must be Ubuntu OEM distribution image.
I do not know what /dev/sda2 is for, but it may be also needed for factory restore.
Regarding swap partition that you call "exchange memory" I can say that 4 GB will be enough. Hibernation must work and RAM size is a common size.


Windows 10 UWP MapControl moved event

Question: When the user is manually moving the map, I'd like to evaluate some criteria and optionally do something when they're finished. I can't seem to find the right MapControl event to hook into for this.
I've tried using CenterChanged, but it fires constantly while the map is moving and degrades performance.
Which MapControl event can I use to know when the user has finished moving the map?
Comment: You might use the ManipulationCompleted event. Otherwise a typical approach would be to stop and restart a timer in a CenterChanged handler, and do the final processing in the timer's Tick handler.
Comment: Thanks for the comment. I tried using ManipulationCompleted previously but the event never fires. Do you have an example of the timer approach?
Comment: You have to set the ManipulationMode to a value other than None or System, e.g. to All. See [here](https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.manipulationcompleted.aspx).
Comment: I saw that too. Didn't make any difference. The event never fires.
Comment: I remember something about that in WP with Here, I'll take a look
Comment: Well I tried but I refuse to continue when I set IsHitTestVisible and stills moving. This control does not follow any Control rule, The only approach I did is setting  Window.Current.CoreWindow.SetPointerCapture(); but it is like it is a DirectX and goes by its way, even tried to edit the template but literally explodes  VS and Blend
Comment: Check the LoadingStatusChanged event. See @S.Matthews answer for complete solution.
Answer: I know I'm about a year too late on this, but in case anyone runs into this question... I'm pretty sure the right way to do this is to listen to the LoadingStatusChanged event, then take action when you get back MapLoadingStatus.Loaded.
public void LoadingStatusChangedEventHandler(MapControl sender, Object o)
{
    if (sender.LoadingStatus == MapLoadingStatus.Loaded)
    {
        // The map has stopped moving and finished rendering
        DoSomething();
    }
}

I know the documentation for that event isn't great, but there's a little more information at this code sample, and you may be able to find even more on the git repo.
Comment: This is the best solution. Exactly what I needed. Thanks for sharing.
Answer: I ended up using a timer to check the map center every second and update my view model accordingly. It feels like a hack to me but it's much more performant than using CenterChanged. The DispatchTimer is used to allow the timer to run on the UI thread so it has access to the MapControl.
DispatcherTimer mapCenterTimer = new DispatcherTimer();
mapCenterTimer.Tick += (object sender, object e) =>
{
  ViewModel.MapCenter = MyMapControl.Center;
};
mapCenterTimer.Interval = new TimeSpan(0, 0, 1); // fire every second
mapCenterTimer.Start();

It sure would be nice if the MapControl exposed some sort of ManualMoveComplete event for those of us who want to take action when a user has finished moving the map. I've created a request for it here on uservoice: https://binglistens.uservoice.com/forums/283355-ideas/suggestions/9494889-add-a-centermanuallychanged-event-to-mapcontrol
Answer: As I would agree with you that I'd prefer some kind of delayed event, I also prefer verbose controls and rather filter the events myself. From your solution, instead of firing a periodic timer every second, just restart it when the event fires. When the event stops firing, the timer will tick and you'll get the final value:
DispatcherTimer mapCenterTimer = new DispatcherTimer();
mapCenterTimer.Tick += (object sender, object e) =>
{
  mapCenterTimer.Stop();
  ViewModel.MapCenter = MyMapControl.Center;
};
mapCenterTimer.Interval = TimeSpan.FromMilliseconds(500); // map idle for .5 seconds
MyMapControl.CenterChanged += (map, args) => { mapCenterTimer.Stop(); mapCenterTimer.Start(); };

Windows 10 UWP MapControl moved event


How does one obtain the Staff of Wisdom?

Question: I was perusing the Dark Souls wiki when I found the comparative list of Staves in the game, but three (now two) of the staves did not have wiki pages, only their stats. Those staves are Staff of Armana, and the most powerful looking, Staff of Wisdom. Without a page for this item, I haven't any clue how to go about getting it. Where does one find it? Is it from a quest, or killing a friendly NPC?
Answer: Here is a video describing how to get the Staff of Wisdom. You start at

Dragon Shrine

after the first enemy there is a Pharros Lockstone port. Unlock it to reveal a hidden wall which has the chest containing the Staff of Wisdom.


3ds max fractures in baked textures

Question: I'm not sure if stackoverflow is a right place to ask these kinds of questions(I have only asked development questions here) . I need to import a 3d model to my flash program and I need to bake the texture . I baked the texture using this tutorial method http://www.youtube.com/watch?v=MLsvOASj1zw&list=FLWTAhDxhhT8BYGfGx1aFS7A&index=3&feature=plpp
and it works , the only problem is that after baking the texture there are some fractures in my object when I render it , seems like 3ds max can't assemble the parts of the baked material image file properly. anyone has any ideas or had any experience with such a problem?
thanks
Comment: can you upload a sample image somewhere please?
It's very hard to understand exactly what you mean.
Answer: Haven't worked with 3dsmax in a few years, but remember using it to bake textures for papervision scenes.
If the material isn't mapped correctly at all, texture channels might not be matching.
If you use Automatic Unwrap, make sure the channel on the right matches the channel in the UnwrapUVW modifier. I tested first without baking.

create the model,
add the unwrap modifier
select polygons, flatten mapping and render UVW Template from the tools in Edit > Unrwap UVW .

I've added the rendered template into the diffuse map, just to make sure the texture is set to the unrwap and noticed it only set up properly on Channel 1. The next step was to remove the template image from the diffuse map and render to texture.
Another tiny issue I had sometimes had, seams were showing, but that can be fixed manually in UV.
HTH
Comment: I found this tutorial and it's specifically for papervision , and it works ! http://www.screencast.com/users/PabloBandin/folders/Default/media/9bc9cf64-92e8-4dde-9d87-8410f4e365e4

3ds max fractures in baked textures


Resize div to top center of the page with respect to window when window increases or decreases in its width

Question: I'm facing problem in fixing CSS, I have one div, I need to adjust div with respect to window width when it increase or decrease, the div must be at top center of the page. I tried like

But this will not fit to center when window width increase.
How can I achieve this?
Comment: Show us what you have tried.... Yout markup and CSS
Comment: Add your markup and css in question
Comment: I have this div   for the  and inside this  ..i have to adjust div1
Answer: Is this what you need ?

mydiv

Answer: You need to set CSS like following,
div {
width:70%; // set width in '%' to adjust with respect to window.
margin:0 auto; // to centerlize div.
}


How to run multiple kotlin couroutines in parallel android?

Question: I am fetching images, videos and music files from android device. I want to run my code in background using three couroutines in parallel without blocking the UI thread.
suspend fun getImages() : ArrayList<VideoData> {

}
suspend fun getVideos() : ArrayList<ImageData> {

}
suspend fun getAudio() : ArrayList<AudioData> {

}

These three functions must execute in parallel. I do not want to wait for all of them to complete. When one function is completed I want to execute some code on main thread i.e UI thread.
Comment: Isn't https://stackoverflow.com/questions/57457079/run-two-kotlin-coroutines-inside-coroutine-in-parallel basically the same?
Answer: Using Coroutines is an option.
Create your suspend functions :
suspend fun getImages() : ArrayList<VideoData> {

    withContext(Dispatchers.IO) {
        // Dispatchers.IO
        /* perform blocking network IO here */
    }
}
suspend fun getVideos() : ArrayList<ImageData> {...}
suspend fun getAudio()  : ArrayList<AudioData> {...}

Create a Job
val coroutineJob_1 = Job()

Create a Scope
val coroutineScope_1 = CoroutineScope(coroutineJob + Dispatchers.Main)

Launch the Job with the scope, in your Activity/Fragment...
coroutineScope_1.launch {

     // Await
     val response = getImages()

     show(response)
}

show() has your UI code.
You can launch multiple Jobs to do work in parallel...
coroutineScope_2.launch {...}
coroutineScope_3.launch {...}

Comment: I want to execute them in parallel. launch vs async? where is the use of async?
Comment: https://medium.com/androiddevelopers/coroutines-on-android-part-i-getting-the-background-3e0e54d20bb  Have a look at this for more details on using Coroutines...
Comment: You can launch multiple Jobs to do work in parallel...

coroutineScope_2.launch {...}
coroutineScope_3.launch {...}
Comment: https://stackoverflow.com/a/46226519/6269691 Have a look at this for the difference between launch vs async,

Basically in launch, you will do all the work inside and not wait for any results as such. For async you get the result and then do it at the place you called it...


How do I access a variable of one class in the function of another class?

Question: I'm having a class Main (which has public static void main(String []args))and another class MyDocument.
There is a variable text present in the Main class which I want to access from a function alphabetOccurrence() present in the MyDocument class. How do I do this? I don't want to use it as a static variable. And any changes can be done only in the function, rest of the code should be untouched.
import java.util.*;

class Main {
    public static void main(String[] args) {
        MyDocument document = null;
        String text;
        text = "good morning. Good morning Alexander. How many people are there in your country? Do all of them have big houses, big cars? Do all of them eat good food?";
        char letter = 'd';
        document = new MyDocument();
        document.setDocumentText(text);
        System.out.println("Letter " + letter + " has occured "
                + document.alphabetOccurrence(letter) + " times");
    }
}

class MyDocument {
    private ArrayList<Character> document = new ArrayList();

    public MyDocument() {
    }

    void setDocumentText(String s) {
        for (int i = 0; i < s.length(); i++)
            document.add(s.charAt(i));
    }

    ArrayList getDocumentText() {
        return this.document;
    }

    public int alphabetOccurrence(char letter) {
        // use text variable here..
    }
}

Comment: not homework:) it is my personal work
Answer: You should change your MyDocument class  to add new String field to hold text:
import java.util.ArrayList;

class MyDocument {

    private String text;
    private ArrayList<Character> document = new ArrayList();

    public MyDocument() {
    }

    void setDocumentText(String s) {
        this.text = text;
        for (int i = 0; i < s.length(); i++)
            document.add(s.charAt(i));
    }

    ArrayList<Character> getDocumentText() {
        return this.document;
    }

    public int alphabetOccurrence(char letter) {

        this.text; //do something

    }
}

Answer: you could pass variable text as a parameter in your function
public int alphabetOccurrence(char letter, String text){
    String text2 = text;
    // use text variable here...
}


How to resolve error to get SSL certificate using Letsencrypt certbot?

Question: Using certbot from Let'sEncrypt, I couldn't manage to create secure access for tleis.nl, but if I copy the site into chess.tleis.nl, then secure access is done without problems. But I still cannot get secure access for the base domain tleis.nl.
I have the following:

OS: Ubuntu server 18.04
Nginx: 1.15.5

My website files are in:
/var/www/tleis.nl

In the file /etc/nginx/sites-available/tleis.nl:
server {
  root /var/www/tleis.nl;
  index index.html index.htm;
  server_name tleis.nl www.tleis.nl;
  location / {
     try_files $uri $uri/ =404;
  }
}

Now if I do:
sudo certbot --nginx -d tleis.nl

Then I am getting a message that tleis.nl is unauthorized:
The following errors were reported by the server:
Domain: tleis.nl
Type: unauthorized

If I duplicate this site into chess.tleis.nl for example:
sudo cp -r /var/www/tleis.nl /var/www/chess.tleis.nl
sudo cp /etc/nginx/sites-available/tleis.nl /etc/nginx/sites-available/chess.tleis.nl
sudo ln -s /etc/nginx/sites-available/chess.tleis.nl /etc/nginx/sites-enabled/chess.tleis.nl
sudo nginx -t
udo certbot --nginx -d chess.tleis.nl

Then I change the content of chess.tleis.nl to point to the new site. For example the 'root' is set to /var/www/chess.tleis.nl; and server_name chess.tleis.nl;
Running the command sudo certbot --nginx -d chess.tleis.nl' works perfectly and as a resulthttps://chess.tleis.nl` is accessible now!
chess.tleis.nl is just an example to illustrate that I could get a certificate for any sub-domain (I also duplicated it to many other sub-domains and generated separate certificates for each without problems, for example: python.tleis.nl and ds.tleis.nl). But still couldn't manage to get the certificate for the root 'tleis.nl'.
Any hints where should I look next?
Comment: If you look at your certificate details (from a Web browser), you will see that it is for `chess.tleis.nl`, and not for `tleis.nl` or anything else. You may need another certificate or use a "wildcard certificate".
Comment: Thank you for your comment! I am using chess.tleis.nl as an example. I have as well duplicated the root website 'tleis.nl' into many others that start with anything.tleis.nl. For example python.tleis.nl or ds.tleis.nl. I could get the certificate with no problems. I still cannot do it for tleis.nl (the root domain)!
Answer: The problem turned out to be a faulty AAAA record.
the base domain tleis.nl had both an A and AAAA record. The AAAA record was pointing to a wrong ip v.6 address.
'*.tleis.nl' had only an A record.
Apparently letsencrypt was checking all the available records.


Why the bars out of the parent div?

Question: I want to make a div which contains bars(divs).
The problem is :
The  bars seems out of the parent div but it should be in it.
The parent div id is block_gantt and it has scroll.
Everything is fine in internet explorer but in google chrome it is problem.
the screenshot is from google chrome (I do not want this):

//////////////////////////////////////////////////////////////////
the screenshot from internet explorer(it is correct)

Here is my code:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx     39%

...same for above
...same for above
...same for above

my fiddle :
http://jsfiddle.net/LFUah/2/
Comment: Post some code too... We didn't get anything ...
Comment: We can't help you fix the problem if we can't see/ modify your code.
Please provide the relevant HTML / CSS to reproduce this issue.
Comment: which code can I paste here? thanks for answer
Comment: set width to inherit and ooverflow to hidden
Comment: @ErsinGülbahar probably the one that is producing your issue...
Comment: try to set your DIVs  css overflow:hidden
Comment: @SajithaRathnayake you can see above code, I add already overflow:hidden
Comment: @Krishna I add code please look
Comment: Better wayn is to create a fiddle please make a jsfiddle demo. http//:jsfiddle.net
Comment: I edit my question you can see the fiddle :http://jsfiddle.net/LFUah/2/ why the child div out of the parent div
Comment: @Krishna sorry I edit my fiddle you can see : http://jsfiddle.net/LFUah/2/
Answer: Try to add position:relative to your block_gantt div
Comment: sorry I see your answer now, should I add this to div propoerty?
Comment: you are welcom ... hard luck

Why the bars out of the parent div?