Get href,src,width,height of image using jQuery

Question: I want to get the href, src, width, height of all images on a page.  The jQuery code is
$('img:regex(data:extension, jpg)').each(function() {

var imgsrc = $(this).attr('href');

//$(this).attr('width') =0;

var newImg = new Image();
newImg.src = imgsrc;
var width = newImg.width;
//width is 0;

});

Not sure what is wrong, any ideas?
Thanks
Jean
Answer: Well IMG tags use 'src' not 'href'.
Comment: assuming
Comment: Ah, ok, then you need to use a parent selector to get the anchor. Could you elaborate on the application? Is the inner image a thumbnail or the full thing? If you are loading the image for the first time, you will need to wait until the image loads to know the width/height for example...
Comment: hmm...how do I trigger height after page load and I want to get the anchor too
Comment: Not sure what you're asking...but the javascript image object has an onload event you can set to be called once the image loads. To get the anchor tag you could use $('A:has(img:regex(data:extension, jpg))'). (I assume you are using James Padolsey's regex filter.)
Answer: This example works for your problem.
$("img").each(function(){
    alert($(this).attr('src') + " - " + $(this).attr('width') + " - " + $(this).attr('height'));
});

Answer: $('img').each(function() {
   var imgwidth  = $(this)[0].offsetWidth;
   var imgheight = $(this)[0].offsetHeight;
    console.log(imgwidth ,' X ' , imgheight);
});

I think this should help
Answer: I wouldn't be surprised if this doesn't work -- at least, not until the document and all of its resources are completely loaded. HTML doesn't normally specify the width or height of an image unless it's been specified in the tag itself.
So you'd have to at least wait for the onload event.
The other solution, which could prove to be a bit of a pain, is to check the rendered width/height of the image on the server side and provide that in the  attributes.
Answer: Assuming that you have this markup:

You can obtain the wrapping link by jQuery.closest() as follows:
$('img[src$=.jpg]').each(function() {
    $img = $(this);
    $link = $img.closest('a');
    var href = $link.attr('href');
    // ...

    // Assuming you want the image's client width/height:
    var width = $img.width();
    var height = $img.height();
    // ...
});

The [name$=value] is by the way the attribute-ends-with selector.
Answer: In regards to the above answer from Rei...that's correct, you really want to be sure everything has completely loaded first before you start grabbing dimensions.
A helpful tool for this is jquery.imagesloaded .


Powershell -invokesql with character parameter

Question: I have code that reads an excel file and searches the value in the sql database. This is a part of the code:
    for ($i=1; $i -le $rowMax-1; $i++)
    {
        $name = $sheet.Cells.Item($rowName+$i,$colName).text
        $mail = $sheet.Cells.Item($rowMail+$i,$colMail).text
        #test   $Query = ' SELECT  * FROM dbo.tbl1 where value = ' + "'" +$mail + "'"
        $Query = ' SELECT  * FROM dbo.tbl1 where id = 3'

        Invoke-Sqlcmd -serverinstance $DatabaseServerName -Database $Database -Username $Uid -Password $Pwd -query $Query   -ErrorAction Stop

        Write-Host ("My Name is: "+$name)
        Write-Host ("My mail is: "+$mail)
        Write-Host $query
    }
    #close excel file
    $objExcel.quit()

If I query with a number (SELECT  * FROM dbo.tbl1 where id = 3), it goes ok:
id           : 3
className    : PersonBase
keyValue     : 3
typeCd       : 6
value        : firstname.lastname@example.com
description  :
usermodify   :
datemodify   :
My Name is: G Karen
My mail is: firstname.lastname@example.com
 SELECT  * FROM dbo.tbl1 where id = 3

If I execute with the query :
$Query = ' SELECT  * FROM dbo.tbl1 where value = ' + "'" +$mail + "'"

I get this error:

Invoke-Sqlcmd : Incorrect syntax near '''.
       Msg 102, Level 15, State 1, Procedure , Line 1.
      At line:8 char:1
      + Invoke-Sqlcmd -serverinstance $DatabaseServerName -Database $Database ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException
      + FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

When I debug, to me, the output looks fine. I Can paste it onto the server and the select statement works fine:
My Name is: G Karen
My mail is: email@example.com
 SELECT  * FROM dbo.tbl1 where value = 'firstname.lastname@example.com'

What is going wrong?
Answer: PowerShell happily accepts Unicode (non-ASCII-range) quotation marks instead of the usual, ASCII-range ones - see this answer
For instance, as in your code:

' (LEFT SINGLE QUOTATION MARK, U+2018) can be used in lieu of the ASCII-range  ' (APOSTROPHE, U+0027) , aka single quote.
" (LEFT DOUBLE QUOTATION MARK, U+201C) can be used in lieu of the ASCII-range " (QUOTATION MARK, U+0022), aka double quote.

By contrast, I suspect, SQL Server does not suspect these substitutions, so you'll have to use ASCII-range ' and " for quotation marks embedded in your queries.
Therefore, the immediate fix is:
$Query = ' SELECT  * FROM dbo.tbl1 where value = ' + "'" +$mail + "'"

Note how only the characters inside "..." were changed from ' to '; the outer quoting, which is interpreted - and removed - by PowerShell can keep using the non-ASCII-range quotes.

However, you can more simply use an expandable string ("...") with embedded variable references:
$Query = " SELECT  * FROM dbo.tbl1 where value = '$mail'"

Note that I've also switched the outer double quotes to their ASCII-range versions.
It is generally better even in PowerShell to stick with the usual, ASCII-range quotation marks, lest problems arise due to character encoding when sharing code.
Comment: Thanks!! That worked. Putting my code into notepad instead of word did the trick.
Comment: Glad to hear that worked, @Nancy. A good editor to use for PowerShell is [Visual Studio Code](https://code.visualstudio.com/) with the [PowerShell extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell). Also, allow me to give you the standard advice to newcomers in the next comment.


Can no longer see the crosshair or hotbar

Question: I can no longer see the crosshair or the hotbar in Minecraft. How do I turn them back on?
Comment: That + is also called "crosshair" in first person games.
Answer: You may have accidentally hit F1. This key hides the HUD: the crosshair (+ in the middle) and the hotbar (1-9 at the bottom).
If you're on a Mac, you need to hold down FN then press F1 at the same time, and if you're on a PC you will most likely just press F1.


Ubuntu 18.04 Gnome bar on all monitors

Question: I know many people have asked already how to get the Gnome shell top bar to display on all monitors in Ubuntu 18.04 but the answers were never satisfactory. The multi-monitors addon adds a bar that lacks the shutdown and other buttons (which is the main reason I want the bar on the other monitors as well).
Is there any other option to get the bar on all monitors? E.g. write my own extension and just copy the whole bar onto the other desktops?
Comment: I'm wondering whether trying the same approaches on the non-Ubuntu Gnome would work? I'm still on 17.10 but for me I've just been using the standard Gnome on X11 (instead of Ubuntu Gnome at login) and all the extensions seem to work better there.
Answer: It seems like you can't right now. There's an open issue which you can follow to get updates about when this will be implemented.
Comment: Sorry, I completely forgot to accept your answer as the right one. Three years later :D
Comment: Although it seems it's possible now, according to the closed issue. I'm not really using gnome anymore, so I can't test it right now.

Ubuntu 18.04 Gnome bar on all monitors


Compile a command line script for iOS

Question: I coded an iOKit fuzzer for iOS. Here is the code:
<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mach/mach.h>
#include <mach/vm_map.h>
#include <IOKit/IOKitLib.h>

int main()
{
  io_service_t service = IOServiceGetMatching(kIOMasterPortDefault, IOserviceMatching("IOUSBHIDDriver")); // change service each time
  if(!service)
  {
    return -1;
  }
  io_connect_t connect;
  kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &connect);
  if(kr != kIOReturnSuccess)
  {
    return -1;
  }

  uint32_t selector =3;
  uint64_t input[0];
        input[0] = 0x44444444444;
  IOConnectCallMethod(connect, selector, input, 1, 0, 0, NULL, NULL, NULL, NULL);
  printf("Did it crash? No? Do it again! -Toxic\n");
}
</code>
I've been trying to compile this with GCC for a while now, but I get all kinds of errors. I'd like to know if anyone know exactly how to compile a command line tool for iOS. Thanks.
Answer: As far as I'm aware, there's no such thing as a command line tool for (non-jailbroken) iOS, although you can output to the log using NSLog from an App. Also, Apple's toolchain for iOS uses clang (llvm) although the 'gcc' command is typically aliased to clang. The easiest way to get a script is to create a test project in Xcode, build it and look at the build log. This shows you all the commands that were run with what arguments.
Comment: Ah, sorry. Can't help you there, although I suspect you can still get most of the way there by inspecting Xcode's build steps.
Answer: Idk have you found the solution or not but anyways.
If you want to conpile with clang on device type:
clang -framework IOKit your_app.c -isysroot /var/theos/sdks/iPhoneos_whatever_sdk_you_have -o output
And this should compile.
On the mac same just without isysroot & /var...
And if you try in xcode make sure that the driver can run inside the sandbox and include iokit headers
:D

Compile a command line script for iOS


"efibootmgr: Could not set variable Boot0000: No such file or directory" and "efibootmgr: Could not prepare boot variable: No such file or directory"

Question: grub-efi-amd64-signed installing for x86_64-efi platform occasionally (~1 out of 20 tests) fails to create the Boot0000 record with the following errors "efibootmgr: Could not set variable Boot0000: No such file or directory" and "efibootmgr: Could not prepare boot variable: No such file or directory"
I have even attempted to delete all boot records before running grub-install -v /dev/sda without success.
I want to get this reliability working using grub over suggested readings to use rEFInd.
The rEFInd Boot Manager: Keeping rEFInd Booting
The following sequence is my debug information:
+ efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
Boot0002* Hard Drive    BBS(HD,,0x0)AMGOAMNO........m.K.I.N.G.S.T.O.N. .S.M.S.2.0.0.S.3.6.0.G....................A.........................>..Gd-.;.A..MQ..L.0.5.2.0.B.22.214.171.124.126.96.36.199.B.B.D. . . . ......AMBOAMNO........{.K.i.n.g.s.t.o.n.D.a.t.a.T.r.a.v.e.l.e.r. .3...0.P.M.A.P....................A.......................N..Gd-.;.A..MQ..L.K.i.n.g.s.t.o.n.D.a.t.a.T.r.a.v.e.l.e.r. .3...0.P.M.A.P......AMBO
Boot0003* UEFI: KingstonDataTraveler 3.0PMAP    PciRoot(0x0)/Pci(0x1d,0x7)/USB(2,0)/HD(1,MBR,0x4294967189,0x800,0x1cdf000)AMBO

+ update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
Found memtest86+ image: /boot/memtest86+.bin
done

++ seq 0 9
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0000 -B
efibootmgr: Could not delete Boot0000: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0001 -B
efibootmgr: Could not delete Boot0001: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0002 -B
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
Boot0003* UEFI: KingstonDataTraveler 3.0PMAP
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0003 -B
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0004 -B
efibootmgr: Could not delete Boot0004: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0005 -B
efibootmgr: Could not delete Boot0005: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0006 -B
efibootmgr: Could not delete Boot0006: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0007 -B
efibootmgr: Could not delete Boot0007: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0008 -B
efibootmgr: Could not delete Boot0008: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0009 -B
efibootmgr: Could not delete Boot0009: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery

+ grub-install -v /dev/sda
grub-install: info: executing modprobe efivars 2>/dev/null.
grub-install: info: Looking for /sys/firmware/efi ...
grub-install: info: ...found.
Installing for x86_64-efi platform.
grub-install: info: cannot open `/boot/grub/device.map': No such file or directory.
grub-install: info: /dev/sda1 is not present.
grub-install: info: Looking for /dev/sda1.
grub-install: info: /dev/sda is a parent of /dev/sda1.
grub-install: info: /dev/sda1 starts from 34.
grub-install: info: opening the device hostdisk//dev/sda.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 34.
grub-install: info: /dev/sda1 is present.
grub-install: info: Looking for /dev/sda1.
grub-install: info: /dev/sda is a parent of /dev/sda1.
grub-install: info: /dev/sda1 starts from 34.
grub-install: info: opening the device hostdisk//dev/sda.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 34.
grub-install: info: /dev/sda1 is present.
grub-install: info: Looking for /dev/sda1.
grub-install: info: /dev/sda is a parent of /dev/sda1.
grub-install: info: /dev/sda1 starts from 34.
grub-install: info: opening the device hostdisk//dev/sda.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 34.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
...grub-install info continued...
grub-install: info: adding 170 padding fixup entries.
grub-install: info: writing 960 bytes of a fixup block starting at 0xc000.
grub-install: info: reading /usr/lib/grub/x86_64-efi/fshelp.mod.
grub-install: info: reading /usr/lib/grub/x86_64-efi/ext2.mod.
grub-install: info: reading /usr/lib/grub/x86_64-efi/part_gpt.mod.
grub-install: info: reading /usr/lib/grub/x86_64-efi/search_fs_uuid.mod.
grub-install: info: reading /boot/grub/x86_64-efi/load.cfg.
grub-install: info: kernel_img=0xd7cc90, kernel_size=0x18a00.
grub-install: info: the core size is 0x1dbd8.
grub-install: info: writing 0x1ee00 bytes.
grub-install: info: copying `/usr/lib/shim/shimx64.efi.signed' -> `/boot/efi/EFI/ubuntu/shimx64.efi'.
grub-install: info: copying `/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed' -> `/boot/efi/EFI/ubuntu/grubx64.efi'.
grub-install: info: copying `/usr/lib/shim/mmx64.efi' -> `/boot/efi/EFI/ubuntu/mmx64.efi'.
grub-install: info: copying `/boot/grub/x86_64-efi/load.cfg' -> `/boot/efi/EFI/ubuntu/grub.cfg'.
grub-install: info: Registering with EFI: distributor = `ubuntu', path = `\EFI\ubuntu\shimx64.efi', ESP at hostdisk//dev/sda,gpt1.
grub-install: info: executing efibootmgr --version </dev/null >/dev/null.
grub-install: info: executing modprobe -q efivars.
grub-install: info: executing efibootmgr -c -d /dev/sda -p 1 -w -L ubuntu -l \EFI\ubuntu\shimx64.efi.
efibootmgr: Could not set variable Boot0000: No such file or directory
efibootmgr: Could not prepare boot variable: No such file or directory
Installation finished. No error reported.

+ update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
Found memtest86+ image: /boot/memtest86+.bin
done

+ efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery

I have written a bash script to 100% reproduce this problem:
#!/bin/bash
# UEFI NVRAM Variable Reproducibility Unit Test
set -x
while true
do
        efibootmgr -v
        for i in $(seq 0 9)
        do
                efibootmgr -b 000$i -B
        done
        efibootmgr -v
        grub-install
        if [ $(efibootmgr -v | grep -c ubuntu) -eq 0 ]
        then
                echo "BUG!!! OS will now fail to boot!!!"
                exit 0
        fi
done

The following is my workaround solution:
# ensure fallback UEFI NVRAM boot record variable exists
efibootmgr -c -d /dev/sda -p 1 -w -L fallback -l '\EFI\ubuntu\grubx64.efi'

Creating a second redundant boot record is a perfect workaround for my unreliable hardware problem. This way grub-install can continue to delete, edit and use the Boot0000/ubuntu record. If the Boot0000/ubuntu record is ever lost then the Boot0001/fallback untouched record will be automatically selected by the BIOS and boot the OS.
/var/log/kern.log -> kernel: [ 179.804812] efivars: set_variable() failed: status=8000000000000009
This in combination with the efi_no_storage_paranoia=1 kernel parameter gives me the hardware reliability I need.
Comment: Have you updated UEFI from vendor? What brand/model system.
Comment: How do I exactly update the UEFI from vendor? Product Name KEEX-1650, BIOS Version 1.01, BIOS Build Date 09/12/2013 and Intel(R) Atom(TM) CPU D2550 @ 1.86GHz.
Comment: Vendor should have a support page, and then you select your specific model to download new BIOS/UEFI if newer than your 1.01.  That is an earlier model with UEFI, so updates should help. Found this quickly with Google, but limit systems like that also have limited support. http://www.quanmax.com/site/download/
Answer: I have a similar problem with my ACER SWITCH3 SW312-31.
I contacted ACER support and received the answer, that the only way to update the EFI (frimware) is to use the installed windows10. I could not find any way with the installed EFI to update the firmware.
Fortunately now I could boot and log in regularly into my (root) account. I am not certain how I maged it.
Before I could not, I updated ubuntu 19.04 to 19.10 and on EFI I uploaded the new GRUB / EFI files. Than it happend again, that I could not log in. It seamed that a graphic driver did not work properly.
The latest action was to disable the EFI secure cheeck and I could log in.
I will check all logging.


Why am I having an attic ventilation problem this year when I didn't last year?

Question: This winter in the attic I noticed ice on the roofing nails. Obviously warm moist air condensed and then froze on the cold nails. When the weather broke and warmed up a bit, I was back up in the attic and noticed black mold on certain areas of the lower attic ceiling going toward the eaves.
Some interesting facts:

I have been in the house two years and did not notice this happening last year.
This is only occurring on one side of the attic ceiling, the other side is completely fine (no rusted nails poking through, no mold)
I recently put down some more plywood so I can have more area for storage, and before I did that I added some more insulation to the attic floor (rolls). I wonder if that has anything to do with it?
It was also a colder drier winter this year so we had humidifiers in use more, so that may also have something to do with it.

I am just curious why it is happening this year and not last year, and why on only one side of attic ceiling (roof).
Important Information:

For ventilation of the attic we have only two gable vents (one on each side of the house), about 1.5ft x 2ft rectangle each. These do not have any fans.
There are no soffit vents or ridge or roof vents; just the 2 gable vents.
Looking at the lower part of where the attic roof slopes down and meets the wall I notice there is a board that blocks the attic area from the soffit area/eave. So if I was to put in soffit vents from outside, I believe I would have to also drill holes from inside attic through this board so the outside air could actually pass into attic and not be trapped in this blocked off area.
The attic space is about 600sq ft.
The only insulation is in the attic floor and on there walls, there is no insulation on the attic ceiling.
Bathroom fans are vented to outside the home (not into the attic or soffit)
I live in Massachusetts where winters get cold and summers are hot and humid.

My questions:

What should I do?
Why was the gable venting system in place good enough last year but not this year?
Why only one side of attic affected?

I recently beefed up the insulation and seal on the pull-down attic entrance as this could be an area where warm moist air was entering into the attic (the entrance is on same side as the attic problem area). Will that fix problem, or do you recommend installing more ventillation anyways?
Will a fan on the gable vents do the trick, or do I need to install soffit vents anyway?
Will soffits with the gables work, or will ridge or roof venting also be required?
Answer: In case you haven't noticed, weather varies ;) This alone could account for the different effects each winter. But I think you're right, other factors are at play here.
Ventilation. Your gross vent area is 1/100 the attic area, accounting for louvers, let's say about 1/150th of attic area. If you do not consider the gable ends as cross ventilated, it is barely adequate. But as a cross ventilated arrangement, it is more than adequate. Will more help? Yes. Will it be effective? Harder to say. More on this later.
Moisture. Frost on nails alone is not necessarily cause for alarm. Black mold growing where the ventilation is less effective is definitely cause for concern. I'm no mold expert, but you should at least spray some moldicide on it while you devise a more permanent solution. Since the attic is always warmer than outside air, for there to be enough moisture to condense in the attic, the moisture had to come from either inside the house or from a roof or plumbing leak. Running a humidifier frequently would significantly contribute to the amount of moisture migrating into the attic. You don't mention anything about a vapor barrier, you quite likely do not know.The amount of moisture you observe tells me you don't have an effective moisture or vapor barrier. Not only can this cause mold, but it will also diminish the effectiveness of the insulation.
Why frost on only one side? Most likely solar access. The nails are colder on one side because the roof angles are different. This has significant effect on roof surface temperature, even under a good layer of snow.
Not only can vapor migrate through the ceiling, it can be carried in through air leaking around openings in the ceiling, in particular the pull down steps. If the perimeter is not weatherstripped, much moisture (and heat!) can escape this way.
What to do. Your primary focus should be to limit moisture migration into the attic. This will not only solve the condensation problem, but also limit heat loss. Seal all ceiling penetrations. Not only the steps, but plumbing and electrical penetrations as well. Apply an effective vapor barrier. This is not easy. You don't mention your ceiling finishes, this can make it easy or difficult or expensive. You could simply sandwich plastic between the current ceiling and a thin new ceiling finish. If you have an expensive existing finish, you may need to pull up the attic insulation and spray a barrier down on the back surface.
Note that if your household generates a lot of moisture, a good vapor barrier could cause you to have problems with condensation in your ceiling finish. The only solution to this is reduce moisture generation and increase whole house ventilation, ideally through a heat exchanger of some sort.
Once you've reduced the moisture migration, you may not have a mold problem in the attic any more. You may not need any more ventilation at all. The areas near the eaves obviously are not well ventilated, so the addition of soffit vents is the best approach if more is needed. You will need to drill many holes in the separation board to gain free communication with added vents.
If that works out to be too much effort, adding ventilation elsewhere can still benefit the lower areas, though not as well as soffit vents. Anything that increases ventilation will help. More static vents, power vents, ridge vents, turbine vents, they all have their own pros and cons, but they will all increase ventilation. You can do just one measure or a combination of measures. There is no right solution, but there is something that will make more sense than the other options.


Wordpress jquery on footer

Question: In this file

wp-include/script-loader.php

Have this code:
$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.11.3');
$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.11.3');
$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.2.1');

How do I put the jquery in the footer?
I've tried adding a fifth parameter "true" or "1", but does not work.
...
 * Localizes some of them.
 * args order: $scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );
 * when last arg === 1 queues the script for the footer
...

I want to put the jquery at the bottom because it is blocking the correct page load (google page speed recommendation).
Comment: + google page speed insights recommendation
Answer: You have to dequeue it first and then enqueue it again.
The following code will do exactly what you need.
function jquery_mumbo_jumbo()
{
    wp_dequeue_script('jquery');
    wp_dequeue_script('jquery-core');
    wp_dequeue_script('jquery-migrate');
    wp_enqueue_script('jquery', false, array(), false, true);
    wp_enqueue_script('jquery-core', false, array(), false, true);
    wp_enqueue_script('jquery-migrate', false, array(), false, true);
}
add_action('wp_enqueue_scripts', 'jquery_mumbo_jumbo');

Comment: `Parse error: syntax error, unexpected 'public' (T_PUBLIC)`... Please remove the `public` part
Comment: @iautomation yeah, sorry, took it out class. Forgot to remove `public`
Answer: After experiencing all these problems and testing workarounds myself without any joy, I decided to just migrate all scripts in one go.
So how about going one better and having some code that loads all your script files, present and future into the footer. Preventing this ballache from repeating. Also handy for any plugins you may add.
Open your functions.php file and add this bad boy
// Script to move all Head scripts to the Footer

function remove_head_scripts() {
   remove_action('wp_head', 'wp_print_scripts');
   remove_action('wp_head', 'wp_print_head_scripts', 9);
   remove_action('wp_head', 'wp_enqueue_scripts', 1);

   add_action('wp_footer', 'wp_print_scripts', 5);
   add_action('wp_footer', 'wp_enqueue_scripts', 5);
   add_action('wp_footer', 'wp_print_head_scripts', 5);
}
add_action( 'wp_enqueue_scripts', 'remove_head_scripts' );

// END of ball ache

Answer: Cf docs: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
You have a hook: wp_enqueue_scripts
Use:
function themeslug_enqueue_script() {
    wp_enqueue_script( 'my-js', 'filename.js', false );
}

add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );

Comment: This doesn't answer the question.
Comment: This answer is off!

Wordpress jquery on footer


better way to process records, select and update lock

Question: I had a problem in my software that sometimes caused a lock on the SQL server.
This was caused by a process that selects a group of records and starts processing them.
Based on some values and a calculation the records get updated.
When a record is being updated the page where that record is on, is locked by the SQL server for select. Which results in a lock that never solves itself.
To solve the problem we have created a second table, from which we select, the main table is copied into it before the process starts, the table that is updated is not being selected in that way and no lock can appear.
What I am looking for is simple and better solution for this problem, because for me it is like a workaround for something I'm doing the wrong way and would really like to improve the processing.
Answer: Try to change TRANSACTION ISOLATION LEVEL on database. Here is link.
Comment: Thank you will read on that, but is this the regular way to deal with this kind of problem ?
Answer: I guess your default isolation level is set to repeatable read, which causes the select to set a shared lock on the returned records, deadlock happens when concurrent requests come in. To solve this you should take a locking select (to lock records with X lock rather than S lock).
Comment: The actual lock is LOCK_IX
Comment: Yes, before a transaction can acquire an X lock on a row, it must first acquire an IX lock on the table. take a look at http://dev.mysql.com/doc/refman/5.5/en/innodb-lock-modes.html


How to show that the ring $R= \mathbb Z_3[x]/\langle x^6-1\rangle$ is finite without using the concepts of vector space?

Question: I have understood that since $\mathbb Z_3$ is a finite field so $R$ has to be a finite dimensional vector space but is there any way of proving this from purely ring theoretic concepts ?
Comment: Hint: Prove that every polynomial in $\mathbb{Z}_3[x]$ is equivalent mod $x^6 - 1$ to one of degree $5$ or less...then clearly there are only finitely many of these.
Comment: I couldn't see any answer treating it without the approach of finite vector space. That was the reason for re framing the question.
Answer: $R= Z_3[x]/\langle x^6-1\rangle$ is $Z_3[x]$, the set of polynomials over $Z_3$, reduced by the equivalence relation that says that $x^6 - 1 \equiv 0$, or equivalently that $x^6 \equiv 1$.
If we have any polynomial we can reduce its higher-order terms via this equivalence, until the result has degree at most 5. For example, $x^7 + 2x^6 + 2x^2$ reduces to $x + 2 + 2x^2$, because $x^7\equiv x$ and $2x^6\equiv 2$.
Since a polynomial of degree at most 5 is completely determined by its 6 coefficients, and these coefficients are chosen from $Z_3$, there are at most $3^6$ such polynomials, and we are done.
Answer: Hint $\ $ Let $\,R = S[x]/f(x)$ where $\,f\,$ is not constant $\,f\not\in S,\,$ and $\,f\,$ is monic (lead coeff $= 1).\,$ By the Polynomial Division Algorithm, every $\,g\in S[x]\,$ is congruent mod $f$ to its remainder $r$, which has degree lower than $\,\deg f,\,$ i.e.
$$ g  = q f + r,\ \ \deg r< \deg f\ \Rightarrow\ g\equiv r \pmod f$$
If, further, the coefficient ring $\,S$ is finite then there are only finitely many polynomials of such bounded degree, so only finitely many elements in $\,S[x]/f(x).$
For example, if $\,f\,$ is a monic quadratic, then every element of $S[x]/f$ is congruent to a linear polynomial $\,ax+b,\,$ a fact familiar from $\,\Bbb C \cong \Bbb R[\,i\,]\cong \Bbb R[x]/(x^2\!+1),\,$ where every element has the form $\,a\,x+b\pmod{\!x^2\!+1},\,$ i.e. $\,a\,i+b\,$ where $\,i := x\pmod{\!x^2\!+1},\,$ i.e. $\ x + (x^2\!+1)\Bbb R[x].$
Remark $\, $ In your case the Polynomial Division Algorithm is slightly overkill, since we can use the Integer Division Algorithm on exponents $\, \color{#c00}{x^6\equiv 1}\ \Rightarrow\ x^n\! = x^{6j+k}\!\equiv (\color{#c00}{x^6})^j x^k\equiv x^k\ $ for $\,k\le 6$.


More Intuitive Search Icon - Maginfying Glass or Pair of Binoculars?

Question: I'm busy redesigning our main application's UI and we're adding a search feature. In your experience, between an icon of a magnifying glass and a pair of binoculars which icon is more intuitive?
I know/think that the user will get used to whichever icon is used, but it would be nice to get it "right" the first time.
Thanks
Answer: Go with what's common: the magnifying glass
http://www.bing.com/
EDIT: Its also the 'search' icon which is built into both IE and Firefox.
Answer: Apart from the icon, the position of the search box is also very important. Normally the search should be in the top right corner -- people tend to remember the position of an item better than the graphical representation of an icon, and they're used to this convention, so "muscle memory" will guide them to the top right.
See more on icon vs. position at UIE's Orbitz Can't Get A Date.
Answer: Oddly, neither really properly communicate the intent very well. They've just become the de-facto icon for it (like a floppy disk for 'save').
That's not to say we can't come up with a better icon though.
I think a magnifying glass is more common, thereby the default answer. Either one is likely OK to use as long as there isn't need for an icon for tasks such as 'find' or 'zoom' in which case things begin to fall apart metaphorically.
Answer: I'd recommend the magnifying glass. Its a simpler icon, easy to recognise at a variety of sizes, and consistent with the icon used on many leading websites.
Answer: Interestingly, the international standard ISO/IEC 18036, "Information technology - Icon symbols and functions for World Wide Web browser toolbars" defines a torch/flashlight with light rays as the appropriate icon.
Has anybody ever seen a flashlight used as a search icon?
Comment: Thanks for your reply Lisa.

Windows Grep uses it ( http://www.wingrep.com/ ), as well as other "old" programs that use "old fashioned" icons in their GUI.

The first time I saw it in WinGrep, I must admit, "WTF?" went through my mind. If it wasn't for the fact that I have previous experience with "old" and "outdated" GUI icons I think that I would have been seriously confused. I think that a magnifying glass would be better.
Comment: The flashlight used as a search icon is what the older versions of Windows use as a 'hunting for data / loading' icon when Windows gets a bit confused.
Answer: they both tell me "ZOOM" but i'd go with the magnifying glass because it's much more used as a search icon convention.
Answer: Thanks for your input guys.
I would have considered the pair of binoculars to be the more intuitive one as that is what has been used on the majority of programs that I have worked with (I've been on computers since about 1989.) To me the magnifying glass represents zooming in or giving more information on something since magnification is the process of enlarging the appearance of or giving more information about that something.
Oh, and to give you some more context, this is a WinForm application, not a web or Silverlight application (yet.)
And BTW - I'm a Google fan, I really don't like Bing ;-)
Comment: A meta-note: Editing your post is a better way for people to see your later thoughts, rather than replying with an answer. You could also add a comment to your original post. Answers are for...well...answers.
Comment: I've edited Andrew.

I think what's happened is the 'Web World' convention has won out over the Application Software World convention.
Comment: Yeah. On a personal level, I'm busy adding more web ideas and conventions into my head so that it's not just the "oldskool" offline app conventions that I"ve grown up with that are in there. :-)

Thanks.
Comment: Myth #14: You are like your users - http://uxmyths.com/post/715988395/myth-you-are-like-your-users
Comment: If your user base spend a lot of time on-line then the magnifying glass will be the most familiar icon for search. If you are searching content use a magnifying glass. If your search is different to content search, eg: searching files, consider binoculars.


Conditional rendering in react prop

Question: I want to ask if this possible in react while passing props or something similar. Eslint underlined the whole process in red.
Component A,
enter code here

<button style={{style:props.submit}}> Submit</button>
<button style={{style:props.loading}}> Loading</button>

Component B
import ComponentA from 'A',

export default class ComponentB extends Component {
constructor(props) {
super();
this.state = {
     load:false,
    }

  handleSubmit = (e) => {
   e.preventDefault();
   this.setState({
    load:true,
  })
 }

 render () {
 return (
 <ComponentA  {this.state.load ? (props.loading): (props.submit)}/>
  )

 }

Comment: ``
Comment: @Martin I don't think that would work. First if I'm correct I believe the order of operations would spread `load` before processing the ternary. Second I don't think it would be able to determine the prop names automatically.
Comment: I think you'd need to do: ``
Comment:
Comment: Thanks everyone for these.
While trying to implement these, the prop values needs to be assigned because they are style properties,
 and this is bringing out errors
Answer: You can use like that:
const newProps = this.state.load ? {loading: props.loading} : {submit: props.submit}

<ComponentA  {...newProps} />

Comment: Thanks for the answer, the props needs to be assigned values and it is not looking like it is possible.i am talking about something like

const newProps = this.state.load ? { loading : props . loading="none"} : {submit: props.submit="flex"}
Comment: What do you mean? `props . loading="none"`
Comment: props.loading is a style property. it needs a value. in Component A, i have something like this button style={{style:props.loading}}>Loading

Conditional rendering in react prop


Formally prove that every finite language is regular

Question: I know how to prove this informally, but don't know what the formal proof should look like.
Answer: One-line proof: A finite language can be accepted by a finite machine.
Detailed construction: Suppose the language $\mathcal L$ consists of strings $a_1 ,a_2, \ldots, a_n$.
Consider the following NFA to accept $\mathcal L$: It has a start state $S$ and an accepting state $A$.  In between $S$ and $A$ there are $n$ different paths of states, one for each $a_i$.  The machine can only get from the beginning of the i'th path to the end if it sees exactly the string $a_i$.
There are $\epsilon$-transitions from $S$ to the beginning of each path, and from the end of each path to $A$.
For example, suppose $\mathcal L$ consists of exactly the three strings "fish", "dog", and "carrot".  Then the NFA looks like this:
<code>  .-------- f - i - s - h --.
 /                           \
S---- d - o - g --------------A
 \                           /
  '- c - a - r - r - o - t -`
</code>
Comment: Love your ascii drawing :~).
Answer: If a language contains the strings $v_1, v_2, v_3,\dots, v_n$, one possible expression is $$ v_1\cup v_2\cup v_3 \cup ...\cup v_n=\bigcup_{i=1}^n v_i. $$ $\cup$ is also commonly written $|$, especially on computers. Since there is a regular expression for the language, the language is regular.
Answer: Another definition of a regular language is one generated by a regular grammar. If $L = \{v_1, v_2, \dots , v_n\}$ then
$$S \to v_1 \\ S \to v_2 \\ \vdots \\S \to v_n$$
is a regular grammar of $L$.


How to print or echo ACF repeater fields of a taxonomy in single template?

Question: This is my code to echo ACF fields if a taxonomy
<?php
    $terms = get_the_terms( $post->ID , 'agents' );
    $socials = get_field('ag_social', $terms);
    print_r($socials);
    ?>

the result is this: ( [0] => Array ( [ag_telegram] => https://t.me/+xx [ag_whatsapp] => https://wa.me/xxx [ag_insta] => https://instagram.com/x ) )
can anyone help me to print each field separately
for telegram ex: https://t.me/+xx
for whatsapp ex: https://wa.me/xxx
for instagram ex: https://instagram.com/x

Thanks
Answer: If you want it to be exactly like that, write this down.
<?php
$terms = get_the_terms( $post->ID , 'agents' );
$socials = get_field('ag_social', $terms);
foreach($array as $key => $value){
    echo "For : " . ucfirst(substr($key, 3)) . " ex : " . $value;
    echo "
";
}
?>

And if you just want to write links, write this down.
<?php
$terms = get_the_terms( $post->ID , 'agents' );
$socials = get_field('ag_social', $terms);
foreach($array as $value){
    echo $value;
    echo "
";
}
?>

Comment: Thanks for help Nashwan but the result prints Array word.


Why isn't this recessed light working?

Question: I have 9 HALO (HLBSL6099FS35-4PK) LED recessed lights on an Eaton Universal dimmer switch. When I turn the switch on, 8 of the 9 lights turn on. Power flows from the switch, through the 8 working lights, and the wiring ends at the 9th non-working light. I have used a voltage tester and confirmed that power is going to the non-working light. I have tried the non-working light in another location and it turns on. I have tried taking other lights out so that only 5 lights are connected to power, but the last light in the series still doesn't turn on.
Any idea what might be going on or other troubleshooting steps I should take?
Comment: If the problem is at this specific location, and the lights use separate drivers, (seems likely given visible cable)  and you are moving only the light, not the driver, you have a bad driver (or a bad connection TO the driver). Verify by swapping the drivers as well. Please [edit] to include the **specific model number** of HALO LED recessed light, which is an unfortunately non-specific description covering many different models.
Comment: @Ecnerwal the driver seems to have been the issue. I swapped it out and the light turned on, thanks!
Answer: Neutral Problem
The NCVT specifically checks the hot (or in this case, switched hot) wire. It does not know or care about neutral. But without neutral, you don't have a complete circuit.
So carefully check the neutral wire at both 8th (last working) and 9th (not working) junction boxes.
Comment: Visual inspection is good, @MarkW, but also, give each wire at each connection a good tug to make sure it doesn't come out of whatever connection device is being used. It's entirely possible for a wire to be in a wire nut, but not fully secured, and a tug will show that.
Comment: Good thought. I visually inspected both neutrals and the connections look sound. Is there a meter or some other way that I could detect if this was the issue?
Comment: Use a multimeter. Should show ~120V between hot (when on) and neutral. In addition, neutral to ground (actual ground wire or metal junction box if it is grounded) should be 0V/continuous (near 0 Ohms). You can't just "connect neutral to ground" if you have a bad neutral (that is only done in the main panel) but it is a good way to test if neutral is good or not.
Answer: Take one of the other lights and plug it into the end wiring. Looks like the power source or wiring for that end light might be bad. Forget about getting any meaningful information from those voltage testers, wonder sticks.
Comment: I've tried swapping out the lights to no avail. I can try swapping out the junction box, but I'll have to go to Home Depot before I can do that.

Why isn't this recessed light working?


Strange behaviour from system call creat

Question: I am creating a file as follows
 int fd  = creat(file_path.c_str() ,S_IRWXU|S_IRWXG|S_IRWXO);

Though i am providing all permissions to all three entities, it creates the files with the below permission.
-rwxr-xr-x

The directory i am creating this in has permissions set as
drwxrwxrwx

Umask
0022

Can you guys please suggest what could be wrong?
Edit : I can chmod the file to give it the permissions i plan to. I am curious why the above is failing.
Answer: You said it yourself, you have a umask of 022, so the write permission is omitted; From the creat man page:

The effective permissions are modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask).
Answer: You are likely running under a umask restriction
man umask

should get you onto the right track
Answer: The umask is combined with the file permissions you specify in the creat call in this way file_perms & ~umask to arrive at the permission bits that are actually set for the file. The umask basically specifies which bits should not be set even if you request they be set.
The chmod call ignores the umask. And your directory permissions are irrelevant here (well, not totally irrelevant, it would fail completely if you didn't have write permission to the directory you're creating the file in).
Comment: @Ricko M: You're welcome. A word of advice... you should wait for awhile before accepting an answer. The first person to give a halfway decent answer is not always the person who gives the best answer. I'm not saying mine is better. That's for you to judge. But if you accept within 5 minutes you might be missing out on a better answer.
Answer: Permissions in the umask are turned off from the mode argument to open and mkdir (and creat and friends, similarly). For example, if the mode argument is specified as:
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH (0666) when creating a file with the typical umask of 0022, the result will be
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH (0644)
So, you are correctly seeing write access not being given to the directory you're creating.


Using IMPORT RANGE on google sheets for multiple data sets (including blank cells)

Question: I want to import data from various google sheets. I am able to do this using the following formula (I realise this is probably a little clunky and could be improved)
=QUERY(
{
IMPORTRANGE(Summary!A26,"Challenges!A2:P");
IMPORTRANGE(Summary!A25,"Challenges!A2:P");
IMPORTRANGE(Summary!A27,"Challenges!A2:P");
IMPORTRANGE(Summary!A28,"Challenges!A2:P");
IMPORTRANGE(Summary!A29,"Challenges!A2:P");
IMPORTRANGE(Summary!A30,"Challenges!A2:P");
IMPORTRANGE(Summary!A31,"Challenges!A2:P");
IMPORTRANGE(Summary!A32,"Challenges!A2:P");
IMPORTRANGE(Summary!A33,"Challenges!A2:P");
IMPORTRANGE(Summary!A34,"Challenges!A2:P");
IMPORTRANGE(Summary!A35,"Challenges!A2:P")
},
"select * where Col1 is not null").

The range of cells with urls (Sumary!A25:A35) are for other users (who are not familiar with the formula) to copy and paste links to their sheets each time they are finished to stop me having to find this data each time. However, if any of these cells are left blank the formula does not work. Is there a way to ignore cell if empty, or importrange if filled?
I have tried using the IF function with no success
Shortended example of my attempt at using the IF function, returned a formula parse error
=QUERY(
{
IF(Summary!A26="","",IMPORTRANGE(Summary!A26,"Challenges!A10");
IF(Summary!A25="","",IMPORTRANGE(Summary!A25, "Challenges!A10")
},
"select * where Col1 is not null")))

Answer: You could try with REDUCE in order not to write again and again the IMPORTRANGE part, and there you can check if that range is empty or not. If it's not empty it will stack the new IMPORTRANGE:
=QUERY(REDUCE(INDEX(IFERROR(SEQUENCE(1,16)/0)),Summary!A25:A35,LAMBDA(a,v,
IF(v="",a,{a;IMPORTRANGE(v,"Challenges!A2:P")}))),
"select * where Col1 is not null")


Can I sell my own expensive cars?

Question: I have an apartment with a 10 car garage. I have purchased 6 expensive cars and stored them in my garage, 4 of them I need to sell!
I want to buy a different apartment and I don't want to lose the cars I have. How do I sell the expensive cars I have already bought? Is there a garage option for this? I know I can't sell them to Los Santos Customs.
Answer: If you can't sell the cars to Los Santos Customs because their individial worth exceeds 50k then you are out of luck. You will not be able to sell them anywhere. You will only be able to get rid of those cars when your garage has hit its limit and you will be asked to replace a car. This question and its answer are related to this problem.
On the topic of not loosing cars upon buying a new property, if you buy a property with the same amount of garage space it will not result in the loss of a car.If you buy yourself a property with less garage space than the one you had before you will loose every car that is in the last few slots. As an example: When currently owning a 10 garage space property the first 6 cars in your garage are important and the last four are the ones you will loose upon buying a 6 garage space property.
Answer: You can't sell premium super cars or anything over 50K.  The most expensive cars you can sell are like around 9K.
Comment: There are also cars worth 20K you can sell.
Answer: Yes you can sell cars I just sold one at Los santos customs but I think you can only do it if you are online

Can I sell my own expensive cars?


Evaluating Sum of Modified Bessel Functions

Question: In deriving some approximate solutions, I've come across the following sum I need to evaluate
$$S=\sum_{n=0}^\infty(-1)^nI_n(\alpha)e^{-n^2\beta},$$
where $I_n$ is the modified Bessel function of the first kind and $\alpha,\beta>0$ are arbitrary parameters. As far as I've found, there isn't a known closed form for this sum (please let me know if there is), so I've attempted to find a simplified form by expanding in power series:
$$I_n(\alpha)=\sum_{m=0}^\infty\frac{\left(\frac{\alpha}{2}\right)^{2m+n}}{m!(n+m)!}$$
$$e^{-n^2\beta}=\sum_{k=0}^\infty(-1)^k\frac{n^{2k}\beta^k}{k!}$$
So the sum above can be written as a triple sum of the form
$$S=\sum_{n=0}^\infty\sum_{m=0}^\infty\sum_{k=0}^\infty(-1)^n\frac{\left(\frac{\alpha}{2}\right)^{2m+n}}{m!(n+m)!}(-1)^k\frac{n^{2k}\beta^k}{k!}$$
In an effort to make some progress, I changed the order of summation to attempt to remove the summation over $n$:
$$S=\sum_{m=0}^\infty\sum_{k=0}^\infty(-1)^k\frac{\beta^k\left(\frac{\alpha}{2}\right)^{2m}}{m!k!}\sum_{n=0}^\infty(-1)^n\frac{\left(\frac{\alpha}{2}\right)^nn^{2k}}{(n+m)!}$$
The innermost sum here seems to be a power series of some function evaluated at some multiple of $\alpha$, but I can't seem to find anything that matches. I would appreciate any help on simplifying this sum. I am also interested in the sum
$$S_2=\sum_{n=0}^\infty(-1)^nn^2I_n(\alpha)e^{-n^2\beta},$$
which should be similar to the sum above. Thanks!
Answer: You can use this integral representation to derive a formula in terms of the Jacobi theta function:
\begin{align*}
\sum\limits_{n = 0}^\infty  {( - 1)^n \frac{1}{\pi }\int_0^\pi  {e^{\alpha \cos t} \cos (nt)dt} e^{ - n^2 \beta } } & = \frac{1}{\pi }\int_0^\pi  {e^{\alpha \cos t} \left( {\sum\limits_{n = 0}^\infty  {( - 1)^n \cos (nt)e^{ - n^2 \beta } } } \right)dt} \\ & = \frac{1}{{2\pi }}\int_0^\pi  {e^{\alpha \cos t} \left( {1 + \vartheta \left( {\frac{{t + \pi }}{{2\pi }};i\frac{\beta }{\pi }} \right)} \right)dt} .
\end{align*}
Does this help?
Comment: This is an interesting approach, but is there a method to evaluate this integral with high precision?  I am not familiar with the theta function.


wxpython print to tabbed panel

Question: I am trying to print to a specific tabbed panel in wxpython, but my below code just seems to print to the 3rd (Running Jobs) TAB panel window and I can't work out why. I want to print the 2nd (QueueList) TAB panel.
import wx
import sys
global queueList
queueList = []

class ScrolledWindow(wx.Frame):
    def __init__(self, parent, id, title):
        #global panel1
        wx.Frame.__init__(self, parent, id, title, size=(800, 700))
        self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP))
        self.panel1 = wx.Panel(self.tabbed, -1)
        self.panel2 = wx.Panel(self.tabbed, -1)
        self.panel3 = wx.Panel(self.tabbed, -1)
        self.tabbed.AddPage(self.panel1, "Submit Job")
        self.tabbed.AddPage(self.panel2, "Queue")
        self.tabbed.AddPage(self.panel3, "Running Jobs")
        self.CreateStatusBar()
        menuBar = wx.MenuBar()
        menu = wx.Menu()
        self.SetMenuBar(menuBar)
        self.Centre()
        self.submit(self)
        self.queue(self)
        self.running(self)

    def submit(self, event):
        self.Show()
        dt1 = MyFileDropTarget(self)
        self.tc_files = wx.TextCtrl(self.panel1, wx.ID_ANY, pos=(42, 120), size=(500, 25))
        self.tc_files.SetDropTarget(dt1)
        self.buttonGo = wx.Button(self.panel1, -1, "Submit", pos=(90,530))
        self.buttonGo.Bind(wx.EVT_BUTTON, self.submit1)
        self.buttonClose = wx.Button(self.panel1, -1, "Quit", pos=(195,530))
        self.buttonClose.Bind(wx.EVT_BUTTON, self.OnClose)
        outputtxt3 = '''Drag & Drop Folder of Packages to Verify'''
        wx.StaticText(self.panel1, -1, outputtxt3, (33, 64), style=wx.ALIGN_CENTRE)

    def notify(self, indir):
        """Update file in testcontrol after drag and drop"""
        self.tc_files.SetValue(indir[0])
        global indirTemp
        indirTemp = indir

    def submit1(self, edit):
        list1 = '\n'.join(indirTemp)
        queueList.append(list1)
        print queueList
        wx.MessageBox('Job Submitted')

    def queue(self, event):
        self.Show()
        self.buttonClose2 = wx.Button(self.panel2, -1, "Quit", pos=(195,170))
        self.buttonClose2.Bind(wx.EVT_BUTTON, self.OnClose)
        global log2
        log2 = wx.TextCtrl(self.panel2, -1, pos=(35, 210), size=(720,400),
                              style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        self.redir2=RedirectText(log2)
        sys.stdout=self.redir2

    def showQueue(self, edit):
        global queueList
        print queueList

    def running(self, event):
        self.Show()
        self.buttonClose3 = wx.Button(self.panel3, -1, "Quit", pos=(195,170))
        self.buttonClose3.Bind(wx.EVT_BUTTON, self.OnClose)

        global log3
        log3 = wx.TextCtrl(self.panel3, -1, pos=(35, 210), size=(720,400),
                              style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        self.redir3=RedirectText(log3)
        sys.stdout=self.redir3

    def go3(self, edit):
        print "do something"

    def OnClose(self, e):
        self.Close(True)

class MyFileDropTarget(wx.FileDropTarget):
    """"""
    def __init__(self, window):
        wx.FileDropTarget.__init__(self)
        self.window = window

    def OnDropFiles(self, x, y, filenames):
        self.window.notify(filenames)

class RedirectText:
    def __init__(self,aWxTextCtrl):
        self.out=aWxTextCtrl

    def write(self,string):
        self.out.WriteText(string)

app = wx.App()
ScrolledWindow(None, -1, 'Application')
app.MainLoop()

Comment: Out of curiosity, why are you declaring the TextCtrls to be global?
Comment: I dragged a folder to the drop target and hit "submit".  I did not get anything printed to tab3, I got an error message about queueList not being defined.
Comment: ... and (sorry for the diatribe) I would look hard for different way to do this than redirecting stdout.   I think that comandeering stdout as a path between two parts of your code is going to be a very fragile, hard to maintain, error prone thing to do...
Comment: ... pubsub might be a good alternative.
Comment: Sorry, I have amended the original question to show the example, which now runs as described, but still prints to the wrong window.
Comment: Another note (not related to the question) your `submit()` (and others) are taking an event as parameter, but not using it.   Which is just as well, because your `__init__` is calling them with `self` as the parameter - a wx.Frame is not an event.
Answer: As I mentioned in my other answer, the superficial reason why it's not working is because there was a bug :)    IE the logic written was not what was intended.    The deeper reason is because the app needs some better design.    Appended is an example of how that might be done.
The main feature of this design is that it separates the logic of each function (each of which is carried by the user on a separate tab of the notebook) into separate classes.   The classes communicate by method calls, and the connections are static at construction (for example, a reference to the queue manager is passed to the submission controller on construction).
This is by no means supposed to be "the best" design, it's just an example of possible improvement - the improvements reduce the chance of the types of hard to find logic errors in the original.
import wx

class MainWindow(wx.Frame):
    def __init__(self, parent, id, title):

        wx.Frame.__init__(self, parent, id, title, size=(800, 700))
        self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP))
        self.running = RunningPane(self.tabbed)
        self.queue = QueuePane(self.tabbed, self.running)
        self.submissions = SubmissionPane(self.tabbed, self.queue)

        self.tabbed.AddPage(self.submissions, "Submit Job")
        self.tabbed.AddPage(self.queue, "Queue")
        self.tabbed.AddPage(self.running, "Running Jobs")

        self.CreateStatusBar()
        menuBar = wx.MenuBar()
        menu = wx.Menu()
        self.SetMenuBar(menuBar)
        self.Centre()
        self.Show()

#---
#

class SubmissionPane(wx.Panel):
    def __init__(self, parent, queue_control):
        wx.Panel.__init__(self, parent, -1)
        self.parent = parent
        self.queue_control = queue_control
        self.selected_folder = None

        self.drop_target = MyFileDropTarget(self)
        self.tc_files = wx.TextCtrl(self, wx.ID_ANY, pos=(42, 120), size=(500, 25))
        self.tc_files.SetDropTarget(self.drop_target)
        self.buttonGo = wx.Button(self, -1, "Submit", pos=(90,530))
        self.buttonGo.Bind(wx.EVT_BUTTON, self.OnSubmit)

        self.buttonClose = wx.Button(self, -1, "Quit", pos=(195,530))
        self.buttonClose.Bind(wx.EVT_BUTTON, self.OnClose)

        outputtxt3 = '''Drag & Drop Folder of Packages to Verify'''
        wx.StaticText(self, -1, outputtxt3, (33, 64), style=wx.ALIGN_CENTRE)
        self.Show()

    def SetSubmissionFolders(self, folder_list):
        """Called by the FileDropTarget when files are dropped"""

        self.tc_files.SetValue(','.join(folder_list))
        self.selected_folders = folder_list

    def OnSubmit(self, event):
        self.queue_control.QueueFolders(self.selected_folders)
        wx.MessageBox('Job Submitted')

    def OnClose(self, e):
        self.Close(True)

class MyFileDropTarget(wx.FileDropTarget):
    """"""
    def __init__(self, window):
        wx.FileDropTarget.__init__(self)
        self.window = window

    def OnDropFiles(self, x, y, filenames):
        self.window.SetSubmissionFolders(filenames)

#---
#

class QueuePane(wx.Panel):
    def __init__(self, parent, run_control):
        wx.Panel.__init__(self, parent, -1)

        self.parent = parent
        self.run_control = run_control

        self.queue = []

        self.buttonClose2 = wx.Button(self, -1, "Quit", pos=(195,170))
        self.buttonClose2.Bind(wx.EVT_BUTTON, self.OnClose)

        self.log_text = wx.TextCtrl(self, -1, pos=(35, 210), size=(720,400),
                                    style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        self.Show()

    def QueueFolders(self, folder_list):
        """Called by anyone with a list of folders to queue.
            In this code, that is the submission pane."""
        self.queue.extend(folder_list)
        self.log_text.AppendText("\n".join(folder_list))

    def OnClose(self, e):
        self.Close(True)

#---
#

class RunningPane(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        self.parent = parent

        self.buttonClose3 = wx.Button(self, -1, "Quit", pos=(195,170))
        self.buttonClose3.Bind(wx.EVT_BUTTON, self.OnClose)

        self.running_log = wx.TextCtrl(self, -1, pos=(35, 210), size=(720,400),
                                       style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        self.Show()

    def OnClose(self, e):
        self.Close(True)
#
#---

app = wx.App()
MainWindow(None, -1, 'Application')
app.MainLoop()

Comment: I appreciate the time you have put into this GreenAsJade, I'm going to have to sit down and decipher this bit by bit. Many thanks again.
Comment: Adding back in the rest of the application, I am using quite a few global's, you mentioned this is bad practice?
Comment: It really really is, for very good reasons - not just "dogma". I think that I showed you how to communicate between sections of your code without globals in the above example.   The communication between the queue and the running list should be the same.   If there are other things that need to communicated, once again they should communicate by method calls (as above) or notifications (pubsub).
Comment: OK, I have been studying your code..... I now need to pass a few other variables into, lets say, the running class / function. To start I need to pass the self.queue value through to the running class / function, but am unsure of how to do that, could you point me in the right direction please?
Comment: I guess we're pushing the boundaries of what we're supposed to talk about in a question/answer/comment.   So I made a room:  http://chat.stackoverflow.com/rooms/47656/tips-for-good-design-in-python .    See you there.
Answer: The reason is because you call running() after you call queue() in __init__(), and this is the last thing that redirects stdout before you do some printing.
Here is a version of your code that makes this obvious when you run it, by outputting a trace of what it is doing as it does it...
import wx
import sys
global queueList
queueList = []

class ScrolledWindow(wx.Frame):
    def __init__(self, parent, id, title):
        #global panel1
        wx.Frame.__init__(self, parent, id, title, size=(800, 700))
        self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP))
        self.panel1 = wx.Panel(self.tabbed, -1)
        self.panel2 = wx.Panel(self.tabbed, -1)
        self.panel3 = wx.Panel(self.tabbed, -1)
        self.tabbed.AddPage(self.panel1, "Submit Job")
        self.tabbed.AddPage(self.panel2, "Queue")
        self.tabbed.AddPage(self.panel3, "Running Jobs")
        self.CreateStatusBar()
        menuBar = wx.MenuBar()
        menu = wx.Menu()
        self.SetMenuBar(menuBar)
        self.Centre()
        self.submit(self)
        self.queue(self)
        self.running(self)

    def submit(self, event):
        self.Show()
        dt1 = MyFileDropTarget(self)
        self.tc_files = wx.TextCtrl(self.panel1, wx.ID_ANY, pos=(42, 120), size=(500, 25))
        self.tc_files.SetDropTarget(dt1)
        self.buttonGo = wx.Button(self.panel1, -1, "Submit", pos=(90,530))
        self.buttonGo.Bind(wx.EVT_BUTTON, self.submit1)
        self.buttonClose = wx.Button(self.panel1, -1, "Quit", pos=(195,530))
        self.buttonClose.Bind(wx.EVT_BUTTON, self.OnClose)
        outputtxt3 = '''Drag & Drop Folder of Packages to Verify'''
        wx.StaticText(self.panel1, -1, outputtxt3, (33, 64), style=wx.ALIGN_CENTRE)

    def notify(self, indir):
        """Update file in testcontrol after drag and drop"""
        self.tc_files.SetValue(indir[0])
        global indirTemp
        indirTemp = indir

    def submit1(self, edit):
        list1 = '\n'.join(indirTemp)
        queueList.append(list1)
        sys.stderr.write("submit1 printing\n")
        print queueList
        wx.MessageBox('Job Submitted')

    def queue(self, event):
        self.Show()
        self.buttonClose2 = wx.Button(self.panel2, -1, "Quit", pos=(195,170))
        self.buttonClose2.Bind(wx.EVT_BUTTON, self.OnClose)
        global log2
        log2 = wx.TextCtrl(self.panel2, -1, pos=(35, 210), size=(720,400),
                              style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        sys.stderr.write("redirecting stdout to log2\n")
        self.redir2=RedirectText(log2)
        sys.stdout=self.redir2

    def showQueue(self, edit):
        sys.stderr.write("showQueue printing\n")
        global queueList
        print queueList

    def running(self, event):
        self.Show()
        self.buttonClose3 = wx.Button(self.panel3, -1, "Quit", pos=(195,170))
        self.buttonClose3.Bind(wx.EVT_BUTTON, self.OnClose)

        global log3
        log3 = wx.TextCtrl(self.panel3, -1, pos=(35, 210), size=(720,400),
                              style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        sys.stderr.write("redirecting stdout to log3\n")
        self.redir3=RedirectText(log3)
        sys.stdout=self.redir3

    def go3(self, edit):
        sys.stderr.write("go3 printing\n")
        print "do something"

    def OnClose(self, e):
        self.Close(True)

class MyFileDropTarget(wx.FileDropTarget):
    """"""
    def __init__(self, window):
        wx.FileDropTarget.__init__(self)
        self.window = window

    def OnDropFiles(self, x, y, filenames):
        self.window.notify(filenames)

class RedirectText:
    def __init__(self,aWxTextCtrl):
        self.out=aWxTextCtrl

    def write(self,string):
        self.out.WriteText(string)

app = wx.App()
ScrolledWindow(None, -1, 'Application')
app.MainLoop()

Note the trouble that you have to go to to do some simple debugging, because you have hijacked stdout.  I still strongly recommend you find a better way to do this, when you come to actually completing your application, once you have satisfied yourself with this experiment.   It is not robust or maintainable doing it the way that you are doing it.   Other evidence for this is the need for globals: a big warning sign that your code will become fragile and hard to maintain.
Comment: Thanks GreenAsJade, that makes sense, but i am unsure of how to go about using pubsub in this situation. could you point me in the right direction please?
Comment: OK pubsub is a good way to communicate between separate entities anonymously (IE without the sender needing to know where it's going and without the receiver knowing where it is coming from).   This is what you are achieving with your print.   But ... it might not be the right answer in your case.   You will only know when your overall app is structured better, which is the first thing to tackle. Ideally, you would restructure your app into the "Model/View/Controller" architecture, or something similar.   You will benefit from this as your app grows.
Comment: I'll think about how to do it within the your current structure, while you google MVC :)

wxpython print to tabbed panel


Undefined variable, unsure why

Question: <?php
$tid = $_GET['tid'];
$id = $_SESSION['userid'];
$sql1 = "SELECT * FROM topics WHERE id='$tid' LIMIT 1";
$res1 = mysqli_query($connect, $sql1) or die(mysqli_error($connect));
while ($row = mysqli_fetch_array($res1, MYSQLI_ASSOC)) {
    $title = $row['topic_title'];
    $creator = $row['topic_creator'];
}
$sql = "SELECT * FROM users WHERE id='$creator' LIMIT 1";
$user_query = mysqli_query($connect, $sql) or die(mysqli_error($connect));
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
    $name = $row["first"].$row["last"];
}
echo $name;
?>

I'm a little new to PHP, but I've done things exactly like this, but this time I'm getting an error. Everything here works except for $name. I checked my SQL tables and made sure users exist and that there's first and a last area. I don't see what else could be wrong.
Notice: Undefined variable: name in * on line **
Thank you.
Comment: If you get an error message, TELL US what it is. e.g. copy/paste it. Offhand I'd guess it's undefined indexes on your $_GET stuff, plus the gaping wide-open [SQL injection attack](http://bobby-tables.com) vulnerabilities.
Comment: Yes, I know it's vulnerable to SQL injection. I'm going to edit it later to prevent that, but I'll go ahead and add the full error. Thank you.
Comment: What is the exact error and what is the structure of your `users` table?
Comment: What is the error (and where does it occur)? Also, this is separate from your issue, but since `echo $name` is outside the `while` loop, it's only going to be echoed once, with the value from the last row.
Comment: `var_dump()` or `print_r()`
Comment: You are not entering the while, so mysqli_fetch_array($qy) is false.
Comment: If `$sql = "SELECT * FROM users WHERE id='$creator' LIMIT 1";` returns no rows your `$name` variable won't be set.
Comment: Your query is not yielding any results. You should test for `mysqli_result::$num_rows` http://us2.php.net/mysqli_num_rows
Comment: Thank you guys. I got it partially figured out. I don't see why I got a -1.
Answer: Try this code on for size:
<?php
$tid = $_GET['tid'];
$id = $_SESSION['userid'];
$tid = mysqli_escape_string($connect, $tid);
$sql1 = "SELECT * FROM topics WHERE id='{$tid}' LIMIT 1";
$res1 = mysqli_query($connect, $sql1) or die(mysqli_error($connect));
// Check for rows first.
if($res1 and mysqli_num_rows($res1)){
    // Use if as while is pointless on LIMIT 1
    if($row = mysqli_fetch_array($res1, MYSQLI_ASSOC)) {
        $title = $row['topic_title'];
        $creator = $row['topic_creator'];

        $creator = mysqli_escape_string($connect, $creator);
        $sql = "SELECT * FROM users WHERE id='{$creator}' LIMIT 1";
        $user_query = mysqli_query($connect, $sql) or die(mysqli_error($connect));
        // Check for rows first.
        if($user_query and mysqli_num_rows($user_query)){
            // Use if as while is pointless on LIMIT 1
            if ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
                $name = $row["first"].$row["last"]; // NO HIT!
            }
            echo $name;
        }else{
            echo 'no rows found (query 2).';
        }
    }
}else{
    echo 'no rows found (query 1).';
}
?>

Variable $name is undefined because the $name = ...; line is not reached. So make sure you $sql query actually returns results. It has to in order to define $name.
Comment: Thank you. I didn't get any errors with that, but what if I wanted to use $name outside of that? For example, I have a second PHP block that's inside of my main HTML. How could I use $name there?
Comment: @MichaelBlake You don't! Create functions. Feed `$name`, if exists to a function. Like `do_stuff($name);`. Easy! Or just `if(isset($name)){ /* Do stuff with $name. */ }`. I wouldn't choose the second one as, in a loop, some iterations might have a `$name` while others might not. But if you don't cleanup the `$name` between repeats, it will keep existing if created once.

Undefined variable, unsure why


Tagging symbols (eg. @, #) What are the others?

Question: I am creating a tagging system like Facebook. But unlike Facebook, where it would show all kinds of objects (eg. people, page, groups) under the '@' symbol, I want to separate things better. For example, I would like to use '@' to tag people only. And use another symbol to tag some other objects (eg. objects like page in FB).
I am thinking about to use '#' to do that, but '#' is now used in many sites as a symbol for hashtags, which is quite a different concept as it is not tagging an object but creating a metadata for people to find related conversations around it.
I am wondering if it is wise to use '#' in this case. I am afraid that it would create confusions to users. However, as the two objects on my site are quite different sort of things, I think using different symbols for them is still a nice idea. Is there any popular tagging symbol other than '@' or '#' that is being used? Or any other suggestions to let users understand the use of the symbols better? Thank you!
Comment: what is the point of showing different objects?
Comment: @Igor-G is right, is there a reason why you want to separate the two?
Comment: Why is a hashtag different to a tag? Both link to all entities hashtagged/tagged with this term.
Comment: @unor that's entirely not true. A `@` is directed at a user where they receive a notification of their mention. As for a hashtag, it doesn't alert the "other end" only because there isn't one (unless you count the list page). This, however, is pertaining to Facebook and Twitter.
Comment: @Majo0od: I mean a *hashtag* (as used by Twitter, prefixed with a `#`) and a *tag* (as used by blogs, on Stack Exchange, etc.). I'm not using Twitter, but AFAIK these don't have anything to do with linking user accounts or alerting users.
Comment: I see. Then you're on point!
Comment: stocktwits and some other sites use $STOCK to represent stock tickers. In case that's useful to know.
Answer: 1. Limit the different types of tags as much as possible
Make sure each of the different tag types in your system add value.  If different tag types add obvious value to the end user then they will use them.
2. Tags should be optional
Your system should work without requiring users to tag anything at all.  Tags are optional bits of data that enhance user experience not control it.  If you force people to tag things then it will most likely be more frustrating than it is helpful for them.
3. Design a system that is easy to learn
Say your system has 6 distinct object types that would be useful to tag.  Order these objects from most used to least used and then use tags based on the ordinal numbers of a keyboard.  The ordinal nature of these symbols would be true on most but not every keyboard so consider your user base when choosing your symbols.  Consistency is key here so choose a character that is typed with SHIFT + a number.  Keep the tagging characters together so they don't get fragmented by non-tagging characters.

! 1
@ 2
# 3
$ 4
% 5
^ 6

4. Automatically identify objects for your users
Don't require the user to type tags if you can identify objects automatically.  There is a fine line here so make sure it is easy to refuse any tags your program automatically assumes.  People are more likely to tag names of friends or places if your system recognizes them automatically.
Comment: I don't follow your reasoning in point 3 why those are most used to least used characters, nor why you would based tags on ordinal numbers on a keyboard, especially given that the symbols change between different keyboards.  Take a look at the Russian keyboard layout as an example: http://en.wikipedia.org/wiki/File:KB_Russian.svg
Comment: The order of the symbols chosen are more subliminal than anything else.  In reality `easy to learn` would be no more than 3 symbols and `!`, `@`, `#` (1,2,3) are right next to each other *on most keyboards* so there is less scanning when looking for the appropriate tagging character.
Comment: I think you may be assuming that most of the world use a standard US layout. Most keyboard layouts don't follow that format - not even within the UK, or mainland Europe.  I would also argue that `!` is in general a poor choice as it isn't visually distinct.  But if you were focusing on the US market, and left out the `!` I would agree with your reasoning.
Answer: If there is an input field for tags on your website I will suggest:

Tags with nothing before it = tags
Tags with @ = people

Users do not learn any other symbol, they learn the @-symbol on facebook and twitter. And all the other tags without any symbol are just tags.
Answer: Tags have all been learnt. There has been no tag symbols in common use (as a tag) for more than 10 years.  That shows that tag symbols will be learnt if your service is popular enough.  Of course the challenge is in getting your service to be popular in the first place.
Assuming you would like to go with what already makes sense (I'd recommend this route), my personal guide is:

@ person or place
# topic, code, or ordinal number
use a style for a generic tag

At some point in the future, I'm going to bet that + becomes a common tag for something, but it hasn't happened yet.
Edit: Savv pointed out that Google+ uses the + already, so clearly it's already happened.  I'm clearly not a big Google+ user :)
Comment: Google+ uses `+` instead of `@` for tagging people.
Comment: @Savv I haven't tagged anyone in G+ yet, but it seems you're correct.  My prediction turns out to be accurate for time travellers.


Cms database licenses Structure

Question: I'm currently building a big cms.
there is a table that called posts
her columns:
licenses_id post_id title
now what i want is that when user that has licenses id for example sSj1j221321
insert an new post it will search on posts table what is the last post_id that have the same licenses_id and insert it as post_id + 1.
how should i do it?
Answer: You can use a query to get the next post_id like this:

You can do a query to get the next post_id of the licenses_id like this:
SELECT `post_id`+1 AS `next_id` FROM `posts`
WHERE `licenses_id`='sSj1j221321' ORDER BY `post_id` DESC LIMIT 1

Fetch the next_id from above, then use it as the post_id in your insert query.

Cms database licenses Structure


Get GUI back from background application

Question: I started an app (minecraft server) with ssh like this:
nohup java -jar minecraftserver.jar &

and then logged out. Now that I am next to my computer I can't access the server's terminal.
How can I get it's GUI back? Or can it be accessed from the terminal in some way?
Answer: you can list all background jobs using jobs command:
$ jobs -l
[1]+ 15024 Running                 nohup firefox &

you can bring the process with fg command.
BUT
It's better to use screen other than nohup. It will detach your commands but you can resume your screen session easily and get the background processes easily.
Take a look for this screen tutorial in addition to the link above


Why is the destroyer disappearing when I summon him?

Question: My son is playing Terraria Mobile Edition. When he summons the destroyer, it breaks and disappears. How can he fight it?
UPDATE: We can get the Destroyer to spawn (by summoning him at night using the Mechanical Worm), BUT then he disappears and breaks into segments, and doesn't drop the expected items.
Any ideas?
Comment: To quote the wiki, "The Destroyer, unlike the Eater of Worlds, does not break apart when individual pieces lose all of their HP.". While I doubt that helps, it further supports my theory that you have hit a weird bug. There is even a listed bug for console, where the destroyer acts like the eater of worlds.
Comment: Could you explain your situation better? What does "but then he disappears" mean? Is it when it's killed? Randomly? When one segment breaks?
Comment: I'm passing on second hand info, here! As it's my son who's asking...! I'll get him to take a couple of screen shots when he plays later.
Comment: He says he hasn't killed it, because the Destroyer splits after just a few seconds.
Answer: The Destroyer is summonable from 7:30 p.m to 4:30 a.m. You can check the hour on a Grandfather Clock.
Be sure to use the Mechanical Worm at night.
Source
Answer: Aside from summoning him at night, there is a bug in which when the player summons the boss at too much of a height, the boss will fly off screen just disappear. I would suggest summoning him with the mechanical worm at a lower area and, if the attack pattern makes the boss go towards the sky, not to follow him with wings. Again, if the boss goes too high into the air, the entity simply disappears. (I believe this is a mobile only bug, as well.) If this is not the case, it could be a bug that the Terraria Devs would like to see. You may want to submit a bug report to them.
EDIT: I did do a little research on this, and besides the glitch above, where the boss despawns when too close to the border, I found this on the wikia:

On mobile version, if you fight The Destroyer near the edge of the world and his head goes out of the world, the head will be replaced with the nearest mob. The Destroyer's body will follow the "head" and after a little while, the Destroyer will die with no death message or drops.
  (Source)

There are a couple other bugs which cause the Destroyer to act oddly, you may want to check the behaviors of the bug.


Prokhorov theorem in locally compact Hausdorff space?

Question: Prokhorov theorem gives a compactness condition in the space of probability measures on a Polish space. I am wondering whether we have similar conditions for probability measures on more general spaces, say, locally compact Hausdorff spaces, which seems to me to be a more natural setting of measure theory.
However, since the proofs that I have seen for Prokhorov theorem depend heavily on the completeness and separability of the underlying space, they do not help much when one tries to extend the result to more general spaces. And to my best guess such an extension would rely on techniques from functional analysis.
So, do we actually have such a condition for more general spaces?
Thanks!
Comment: I should pose this as a question. My impression is that Prokhorov's is a statement about sequential compactness. The set of probability measures, as the dual of $C_0(X)$, is compact in the weak-$^*$ topology for any LCH $X$ by the Banach-Alaoglu theorem. To make the weak-$^*$ topology metrizable, one needs separability conditions on $X$ or imposes restrictions on the measures considered (like uniform tightness).
Comment: Regarding LCH spaces being more natural: one of the major realms of application for measure theory is probability.  In probability, Polish spaces are very useful.  A simple way to think of this is as soon as you are interested in stochastic processes (basically an old-fashioned term for "random functions"), you're doing measure theory in a function space --- which is typically not locally compact.  Many constructions of Brownian motion, for example, avail themselves of Prokhorov's Theorem.  Same for point processes (which can be analyzed as random measures).  See Billingsley's book for more.
Answer: There is a version of Prokhorov's theorem on locally compact Hausdorff spaces, but it seems surprisingly difficult to locate it in the literature.
One reference (that simultaneously gives both the LCH and Polish space versions) is Bourbaki's Intégration. Chapitre IX, Section 5.5, Théorème 1 + Théorème 2 (each theorem gives one implication). I'll summarize.
Definition (Prokhorov condition) Let $H$ be a collection of complex measures on a topological space $X$. $H$ is Prokhorov if

the total variations $|\mu|(X)$ of $\mu\in H$ are uniformly bounded, and

for every $\varepsilon >0$ there is a compact $K=K_{\varepsilon}\subseteq X$ such that $|\mu|(X-K)<\varepsilon$ for all $\mu\in H$.

Then:
Theorem 1 (Prokhorov $\Rightarrow$ compact) A Prokhorov set of complex measures on a completely regular space $X$ (in particular an LCH space or a metric space) is relatively compact in the weak$^*$ topology on complex measures relative to the bounded continuous functions on $X$.
Theorem 2 (compact $\Rightarrow$ Prokhorov) If $X$ is LCH or complete metric separable then a weak$^*$-compact set of positive finite measures on $X$ is Prokhorov.
Comment: This version can also be found as Theorem 8.6.7. in Bogachev's Measure Theory Volume 2.


CarbonServerManager Carbon initialization is delayed due to the following unsatisfied items

Question: Hi I am doing following steps from http://wso2.com/library/articles/2014/02/cloud-to-rdbms-using-wso2-esb/
the following issue happens after installation of Data Service Hosting 4.2.0  and restarted the ESB.
<code>[2017-03-15 11:58:30,385]  WARN - CarbonServerManager Carbon initialization is delayed due to the following unsatisfied items:
[2017-03-15 11:58:30,385]  WARN - CarbonServerManager Waiting for required OSGiAxis2Service: org.wso2.carbon.dataservices.task-4.4.0
</code>
how can I fix or revert it.
Answer: What is the ESB version you are using?
If you want to revert you can select it from installed features list and click uninstall
Comment: I wasn't able to reach the admin panel because Carbon UI not started yet.
I have ESB 5.0.0, issue solved just restart server with graceful mode. Issue happens when I have restart server with forcely restart after the  **Data Service Hosting 4.2.0**


Reference for information theory and bayesian inference

Question: I'm taking a course in Bayesian inference and Information Theory with application to physics. I have taken courses in Probability, Statistics, Measure Theory and Statistical Mechanics.
I would like a book mathematically rigorous but illustrated with physical examples if possible. In case it is not, what is a good book for learning about information theory and bayesian inference in more depth with the forementioned background?
Answer: 1. M. Jordan (ed.), Learning in Graphical Models , MIT Press, 1998

Overview of the book:

Graphical models, a marriage between probability theory and graph theory,
  provide a natural tool for dealing with two problems that occur
  throughout applied mathematics and engineering—uncertainty and
  complexity. In particular, they play an increasingly important role in
  the design and analysis of machine learning algorithms. Fundamental to
  the idea of a graphical model is the notion of modularity: a complex
  system is built by combining simpler parts. Probability theory serves
  as the glue whereby the parts are combined, ensuring that the system
  as a whole is consistent and providing ways to interface models to
  data. Graph theory provides both an intuitively appealing interface by
  which humans can model highly interacting sets of variables and a data
  structure that lends itself naturally to the design of efficient
  general-purpose algorithms.
This book presents an in-depth exploration of issues related to
  learning within the graphical model formalism. Four chapters are
  tutorial chapters—Robert Cowell on Inference for Bayesian Networks,
  David MacKay on Monte Carlo Methods, Michael I. Jordan et al. on
  Variational Methods, and David Heckerman on Learning with Bayesian
  Networks. The remaining chapters cover a wide range of topics of
  current research interest.

2. M. Mezard and A. Montanari, Information, Physics and Computation , Oxford University Press, 2009

Overview of this book:

This book presents a unified approach to a rich and rapidly evolving
  research domain at the interface between statistical physics,
  theoretical computer science/discrete mathematics, and
  coding/information theory. It is accessible to graduate students and
  researchers without a specific training in any of these fields. The
  selected topics include spin glasses, error correcting codes,
  satisfiability, and are central to each field. The approach focuses on
  large random instances and adopts a common probabilistic formulation
  in terms of graphical models. It presents message passing algorithms
  like belief propagation and survey propagation, and their use in
  decoding and constraint satisfaction solving. It also explains
  analysis techniques like density evolution and the cavity method, and
  uses them to study phase transitions.

3. C. Bishop, Pattern Recognition and Machine Learning (Information Science and Statistics), 2010

Overview of this book:

This is the first textbook on pattern recognition to present the
  Bayesian viewpoint. The book presents approximate inference algorithms
  that permit fast approximate answers in situations where exact answers
  are not feasible. It uses graphical models to describe probability
  distributions when no other books apply graphical models to machine
  learning. No previous knowledge of pattern recognition or machine
  learning concepts is assumed. Familiarity with multivariate calculus
  and basic linear algebra is required, and some experience in the use
  of probabilities would be helpful though not essential as the book
  includes a self-contained introduction to basic probability theory.

These books are self-contained and thus the prerequisites mentioned in the details are a add-on for research in these areas. Of course these are just the subset of many other content-rich books out there.
Hope this helps.