Kubuntu 16.10 - VirtualBox not working correctly

Question: Since I upgraded from 16.04 to 16.10 VirtualBox is not working properly.  I followed a few other suggestions online and made baby step progress.  When I try to run a VM I get an error for any of them usually containing message to run:
/sbin/vboxconfig

When I run that it gives me an error of:
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.

Here is what's in vbox-install.log (some of content here):
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
make KBUILD_VERBOSE=1 SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 CONFIG_MODULE_SIG= -C /lib/modules/4.8.0-27-generic/build -j4 modules
make[1]: warning: -jN forced in submake: disabling jobserver mode.
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \
echo >&2;                           \
echo >&2 "  ERROR: Kernel configuration is invalid.";       \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
echo >&2 ;                          \
/bin/false)
mkdir -p /tmp/vbox.0/.tmp_versions ; rm -f /tmp/vbox.0/.tmp_versions/*
make -f ./scripts/Makefile.build obj=/tmp/vbox.0
  gcc -Wp,-MD,/tmp/vbox.0/linux/.SUPDrv-linux.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/6/include  -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -D__KERNEL__ -fno-pie -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-pie -no-pie -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -DCC_HAVE_ASM_GOTO -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -I/lib/modules/4.8.0-27-generic/build/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxdrv/ -I/tmp/vbox.0/vboxdrv/include -I/tmp/vbox.0/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -fno-omit-frame-pointer -fno-pie  -DMODULE  -DKBUILD_BASENAME='"SUPDrv_linux"'  -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/linux/.tmp_SUPDrv-linux.o /tmp/vbox.0/linux/SUPDrv-linux.c
  gcc -Wp,-MD,/tmp/vbox.0/.SUPDrv.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/6/include  -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -D__KERNEL__ -fno-pie -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-pie -no-pie -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -DCC_HAVE_ASM_GOTO -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -I/lib/modules/4.8.0-27-generic/build/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxdrv/ -I/tmp/vbox.0/vboxdrv/include -I/tmp/vbox.0/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -fno-omit-frame-pointer -fno-pie  -DMODULE  -DKBUILD_BASENAME='"SUPDrv"'  -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/.tmp_SUPDrv.o /tmp/vbox.0/SUPDrv.c
  gcc -Wp,-MD,/tmp/vbox.0/.SUPDrvGip.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/6/include  -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -D__KERNEL__ -fno-pie -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-pie -no-pie -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -DCC_HAVE_ASM_GOTO -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -I/lib/modules/4.8.0-27-generic/build/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxdrv/ -I/tmp/vbox.0/vboxdrv/include -I/tmp/vbox.0/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -fno-omit-frame-pointer -fno-pie  -DMODULE  -DKBUILD_BASENAME='"SUPDrvGip"'  -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/.tmp_SUPDrvGip.o /tmp/vbox.0/SUPDrvGip.c

EDIT: ADDITIONAL INFO (requested)
Output of dkms status
rtl8812au, 18.104.22.16875.20140902+dfsg: added
virtualbox, 5.1.6, 4.8.0-27-generic, x86_64: installed

Output of dpkg -l linux-|grep ii
ii  linux-base                         4.0ubuntu1           all          Linux image base package
ii  linux-firmware                     1.161                all          Firmware for Linux kernel drivers
ii  linux-generic                      126.96.36.199.36          amd64        Complete Generic Linux kernel and headers
ii  linux-headers-4.8.0-27             4.8.0-27.29          all          Header files related to Linux kernel version 4.8.0
ii  linux-headers-4.8.0-27-generic     4.8.0-27.29          amd64        Linux kernel headers for version 4.8.0 on 64 bit x86 SMP
ii  linux-headers-generic              18.104.22.168.36          amd64        Generic Linux kernel headers
ii  linux-image-4.4.0-21-generic       4.4.0-21.37          amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.8.0-27-generic       4.8.0-27.29          amd64        Linux kernel image for version 4.8.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-21-generic 4.4.0-21.37          amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.8.0-27-generic 4.8.0-27.29          amd64        Linux kernel extra modules for version 4.8.0 on 64 bit x86 SMP
ii  linux-image-generic                188.8.131.52.36          amd64        Generic Linux kernel image
ii  linux-libc-dev:amd64               4.8.0-27.29          amd64        Linux Kernel Headers for development
ii  linux-sound-base                   1.0.25+dfsg-0ubuntu5 all          base package for ALSA and OSS sound systems
ii  syslinux-common                    3:6.03+dfsg-14       all          collection of bootloaders (common)
ii  syslinux-utils                     3:6.03+dfsg-14       amd64        collection of bootloaders (utilities)

Answer: before you run this again, run:
sudo apt-get install build-essential linux-headers-`uname -r` dkms

This will install all kernel headers or dependencies you need.
Comment: Says everything is installed or newest version.
Answer: The command needs to be run as root, so type this:
sudo /sbin/vboxconfig

The latest version of Virtualbox is 5.1. If you're running with version 4.3 or older, you should get at least version 5.0.
Lastly, if you're running with any dkms kernel modules, you will have to turn off secure boot in your BIOS so that unsigned kernel modules will load properly in 16.10.
Comment: Version is 5.1.  I did run /sbin/vboxconfig as root.  Cant I sign the modules?
Comment: Yes, you *could* sign the modules, but it is kind of a pain. Search AskUbuntu for signing kernel modules for info on how to do that. Are you still having problems with the vboxconfig command? If so, edit your question to include the `terminal` output of `dkms status` and `dpkg -l *linux-*|grep ii`.
Comment: Ok updated post..
Comment: Everything looks ok there. There is one partially installed dkms module for rtl8812au. And you **will** have to have `secure boot` turned off in your BIOS. Virtualbox is at 5.1.10, so you might wish to update to see if that helps you. Otherwise it looks like you've got some other kernel configuration problem that's over my head.
Answer: It turns out the problem was that my PATH environment variable was malformed.  Correcting this and re-installing VirtualBox solved the problem.


Smalltalk Windows application works in debug mode; .exe hangs

Question: I am working with a Windows application developed in Smalltalk 3.1, and here's something really weird that I just found and I'm not sure how many detail I should include, so I'll try to start a conversation with the main scenario:
The program opens a project from a remote machine, which makes the interface hang for a long time (~10 minutes) before it becomes responsive again.
Now, if I launch the program from within Smalltalk and add a self halt. just anywhere near the relevant operations that deal with opening a project, the issue does not happen. Now, if I don't add any halts and launch it from Smalltalk then the problem shows up again.
I wonder if this is something common in Smalltalk apps, since I don't know much about the language.
Comment: Are you running these "tests" from the same development image? Also, if you add the `halt` and then remove it, does the problem persist?
Comment: What "Smalltalk" are you referring to? Squeak, Pharo, Dolphin, VisualWorks, VisualAge...? And how to you launch the program? Do you click on some button or do you evaluate code? In the latter case you could try running the code forked at a lower priority (Squeak/Pharo dialect): `[  ] forkAt: Processor userBackgroundPriority`. If the "unresponsiveness" is due to something blocking the UI process then this should help.
Comment: Yes all tests are in the same dev image,and  the problem comes back if I add the `halt` and then remove it. It's one of the Visual SmallTalks, not sure which one really! Doesn't look like VisualWorks though...

`RqReqBrowserDlg reinitializeChoices.    "mpwAdded"
self halt.
    App explorerPane initItems; redisplay.`

That's the part of the code where the magic happens. The interface elements show up after `initItems` evaluates and then hangs -not so with that halt in there.
Comment: By the way, do you know what happens if I compile the application with that `halt` in there?
Comment: Packaging a runtime image with a halt in it will result in the program writing a walkback.log file either onto stderr or a file and the program terminating.
Answer: Sounds like a timing issue to me.
When you add the self halt your program will wait for you to press the "resume button", thereby adding a delay prior to the App explorerPane initItems; redisplay code
Comment: Thanks for the response. In the end I wasn't able to solve the mystery but did solve the original issue with the application.


How to customize desktop

Question: I'm very new to Linux and am having trouble understanding how to customize my desktop. I would love to have my desktop look like an image provided below, but I'm confused how to do so. Is that icon bar a desklet? What is it that is needed to add this to my desktop?
Comment: What's your Ubuntu  version and flavour (Xubuntu, Lubuntu, Ubuntu MATE etc.)?
Comment: Ubuntu 18.04 Unity
Comment: Have you installed Unity separately? Ubuntu 18.04 comes with GNOME by default. Could you add a screenshot of your desktop as it looks right now?
Comment: Sorry, I didn't mean Unity. I meant Gnome. Everything is a fresh install of Ubuntu 18.04
Comment: @pomsky Unity 7.5 is automatically installed when you upgrade Ubuntu 16.04 (Unity 7) to Ubuntu 18.04. Not sure about 17.04 or 17.10 though.
Answer: Here are some things you can do to get a desktop similar to the one in the screenshot.

Move Ubuntu dock to bottom from left: follow this Q&A
Make the dock flexible instead of fixed-length: Run the following command in Terminal
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false

(source)
Install and use Arc theme: The application theme in the screenshot looks like the popular Arc theme. Install it first by running
sudo apt install arc-theme

Then install (GNOME) Tweaks by running
sudo apt install gnome-tweak-tool

Finally, launch Tweaks and select Arc for application theme in Appearance section.

How to customize desktop


Can I dismiss all the specialists after having developed everything?

Question: I was wondering whether it would interfere with the game. I've developed all weapons.
Comment: As an alternative if you want a higher ranked researcher in that spot once you have a higher heroism rank you can redo the mission you get the specialist in and they may be a higher rank.
Answer: They're only required when starting development of an item, so if you've already developed everything that requires specialists, you can safely get rid of them.
It's worth noting that some specialists have unique appearances, if you care about that.
Comment: To know those,  I guess I could see the mission details for the obtainable skills. It helped a lot. Thanks. I am getting rid of them now.


Proper Use of Products in Link Token Request

Question: Folks,
<code>LinkTokenCreateRequest request = new LinkTokenCreateRequest()
        .user(user)
        .clientName("Plaid Test App")
        .products(Arrays.asList(Products.fromValue("auth")))
</code>
That Products enum has more options, and I tried providing one and a few more combinations into that method. However, most of the combinations retun 400 bad request response.
How exactly are we supposed to use "Products"? I want to make sure my users are able to connect any available product and/or bank. So looks like there' some gap (in my understanding). Fill it!
Answer: The Products field indicates the specific Plaid API(s) you want to use. You can't allow users to connect "any product" because you have to actively integrate and pay for every Plaid API you're incorporating. For example, some Plaid APIs are specifically used for transferring money. If your app doesn't have funds transfer functionality, there's no reason to enable users for those APIs. Other Plaid APIs are used to verify users' income or assets for loan underwriting -- if you're not in the business of lending money, your app shouldn't use those APIs.
I'd recommend checking out Explore by Use Case to see which products might map to your use case, and then reading more about the individual products for your use case to see which ones apply to you.
Comment: Thanks for your reply. My platform uses many of the products auth, investments, transactions, liabilities,.... Sure I could ask the user to input the type of account, and create the token link accordingly but that would be a bad customer experience. I just tried this: If I init link with liabilities, transactions and investments, some institutions eg fidelity become deactivated from the link flow.
Comment: @ZiCode check out https://plaid.com/docs/link/initializing-products/ for details on why this is happening and some recommendations on how/when to initialize link. The short version is that you should only initialize Link with products you absolutely, definitely need for all users.


compiz --replace not finishing

Question: I read online, to check if your compiz is running correctly, you should type compiz --replace. I typed the command, and  after it started, my screen flashed then disappeared then came back, and here is what the terminal is saying.

alexander@Alexander:~$ compiz --replace
Checking if settings need to be migrated ...no
Checking if internal files need to be migrated ...no
Backend     : gconf
Integration : true
Profile     : unity
Adding plugins
Initializing core options...done
Initializing composite options...done
Initializing opengl options...done
Initializing decor options...done
Initializing vpswitch options...done
Initializing snap options...done
Initializing mousepoll options...done
Initializing resize options...done
Initializing place options...done
Initializing move options...done
Initializing wall options...done
Initializing grid options...done
Initializing session options...done
Initializing gnomecompat options...done
Initializing animation options...done
Initializing fade options...done
Initializing unitymtgrabhandles options...done
Initializing workarounds options...done
Initializing scale options...done
compiz (expo) - Warn: failed to bind image to texture
Initializing expo options...done
Initializing ezoom options...done

(compiz:10806): GConf-CRITICAL **: gconf_client_add_dir: assertion `gconf_valid_key (dirname, NULL)' failed
Initializing unityshell options...done
WARN  2012-07-26 18:16:07 unity.libindicator :0 Desktop file '/usr/share/applications/libreoffice-writer.desktop' is using a deprecated format for its actions that will be dropped soon.
WARN  2012-07-26 18:16:07 unity.libindicator :0 Desktop file '/usr/share/applications/libreoffice-calc.desktop' is using a deprecated format for its actions that will be dropped soon.
WARN  2012-07-26 18:16:07 unity.libindicator :0 Desktop file '/usr/share/applications/libreoffice-impress.desktop' is using a deprecated format for its actions that will be dropped soon.
ERROR 2012-07-26 18:16:08 unity.glib-gobject :0 g_object_unref: assertion `G_IS_OBJECT (object)' failed
Setting Update "run_command_terminal_key"
Setting Update "fullscreen_visual_bell"
Setting Update "num_launchers"
Setting Update "launcher_capture_mouse"

It will not continue past that, and I have let it keep running for about 10 minutes.
Answer: compiz --replace kills and replaces the current running compiz with a new process, that's why the screen flashes. It doesn't gives the command prompt back because it runs in foreground. If you have problems with compiz, run compiz --replace & so it goes background and you get the prompt back.
Answer: That process is not supposed to end, because:
compiz --replace commands replaces the current process of compiz running in background, (compiz is the program which provide you the window decorations, effects and much more) and creates another process, which is running from your terminal. The process will continue to run, unless you deliberately stop or kill it or you exit the terminal. But, whenever you exit the terminal, the child process (currently running compiz) will exit, and guess what will happen. You may loss window manager or compiz may restart automatically itself.
If you want to replace current compiz process, the safe way to do so is,:

Pressing Alt+F2 to bring dash command prompt.
Type compiz --replace there and hit Enter.

For your information, You can stop a running process in terminal by using Ctrl+C keyboard shortcut, But I am not recommending it.
Comment: @visoft I wrote this answer 5 years ago. It may not be working now, but it worked before. Try setting display by `DISPLAY=:0` before the command. Should work
Comment: Running compiz in ALT+F2 console does not work. It gives up with an error. Running it from GUI terminal and setting it in the background with &, does the trick. That is, you can close the terminal and not loose the compiz.

compiz --replace not finishing


Blender 2.70 not installed, but can open it, yet can't find it in dash or add it to launcher

Question: I have downloaded Blender 2.7 and moved it to folder /opt and yet I can't find it in dash or place it in launcher. I have searched for solutions on the net, but I don't quite understand those.
Comment: I'd say that Blender is not really a command-line application
Comment: You may also want to read [this question](http://askubuntu.com/questions/253448/how-to-install-and-keep-updated-most-recent-versions-of-blender-in-ubuntu)
Answer: Unless you absolutely need features or bug fixes only present in Blender 2.70 I'd use the version available in the Ubuntu repositories (2.69 for 14.04).
You can easily install it from the Terminal (Ctrl+Alt+t):
sudo apt-get install blender

Properly packaged for Ubuntu, Blender comes with a .desktop file (see the package list) allowing the dash to find it (and can also be used as a launcher icon).
UPDATE:
I assume that you installed blender in /opt/blender-2.70a-linux-glibc211-x86_64.
So the only thing missing to enable dash search and a launcher icon is a .desktop file like this one:
[Desktop Entry]
Version=2.70a
Name=Blender
GenericName=3D modeller
GenericName[es]=modelador 3D
GenericName[de]=3D-Modellierer
GenericName[fr]=modeleur 3D
GenericName[ru]=Редактор 3D-моделей
Comment=3D modeling, animation, rendering and post-production
Comment[es]=modelado 3D, animación, renderizado y post-producción
Comment[de]=3D-Modellierung, Animation, Rendering und Nachbearbeitung
Exec=/opt/blender-2.70a-linux-glibc211-x86_64/blender
Icon=/opt/blender-2.70a-linux-glibc211-x86_64/icons/256x256/apps/blender.png
Terminal=false
Type=Application
Categories=Graphics;3DGraphics;
MimeType=application/x-blender;

After you've created this blender.desktop file, just drag and drop it somewhere onto your launcher.
Note: You may have to change the path to the blender exe/icon if you downloaded the i386 tar.bz2.
Comment: I really want the latest version
Comment: Excellent it worked But blender doesn't appear in dash.
Comment: it worked for me, i used the following Blender.desktop - [Desktop Entry]
Name=Blender
Comment=To place in /usr/share/applications/ or $HOME/.local/share/applications/
Exec=/home/vikrant/Documents/softwares/multimedia/blender/install/blender %U
Terminal=false
Type=Application
Encoding=UTF-8
Icon=/home/vikrant/Documents/softwares/multimedia/blender/install/icons/scalable/apps/blender.svg
StartupNotify=true
StartupWMClass=Blender
Categories=Graphics;3DGraphics;
MimeType=application/x-blender;


jquery ui autocomplete custom display if no results returned

Question: how can I display a custom popup if no results are returned ?
I have managed to display a "no results" response if the term returned no results
    response:function(event, ui){

        if(!ui.content.length){

            var noResult = {value:'',label:'No results'};
            ui.content.push(noResult);

        }
    }

but how can I display a custom popup. I am trying to display a window with necessary fields to add the item if it doesn't exist.
Comment: So instead of modifying the `ui.content`, you can just show your own popup normally, if you mean to show the popup right at the position of the autocomplete dropdown (replace the dropdown), then it may be more complicated.
Comment: yep, that's what I'm trying to do, to alter the ui popup
Answer: so actually it was very easy...
$('#search').autocomplete({
    .....
}).data("ui-autocomplete")._renderItem = function (ul, item) {
    //customizeaza selection list-ul
    return $("
")
        .data("item.autocomplete", item)
        .append("<input type='text' maxlength='3' size='3' />" + item.label + "
" + item.den_prod + "")
        .appendTo(ul)
};


AltBeacon results in Unable to instantiate activity ComponentInfo RuntimeException

Question: I created a new Android project in Android Studio 1.4 beta 4. I just added the org.altbeacon:android-beacon-library:2.5.1 to Gradle, and added the line:
private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);

to the onCreate() as follow:
public class MainActivity extends AppCompatActivity {
    protected static final String TAG = "BeaconActivity";
    private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }
}

After adding this and Run, the following RuntimeException has occurred and the App has crashed:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.test/com.example.test.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference

I didn't use the above codes obviously. How can I resolve the issue?
Answer: your mistake are here :
 private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);

you tried to make a object from BeaconManager by  "this" , but this activity is not created by the system but by you. So this InstalledApp object does not have Context object bounded to system.
just try this :
private BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    beaconManager = BeaconManager.getInstanceForApplication(this);
    beaconManager.bind(this);
}


New sink plumbing advice

Question: We have decided to get rid of our dual sink and go for a single large sink with a center drain.
Before we get started I wanted to just double check to see if it can be plumbed successfully without having to do a lot of cutting.  The black PVC pipe is not moveable, and I'd rather not cut that and adjust it.
I took the pipes off and did a rough fitment, just trying to get some advice if it looks correct and or acceptable.
This is how  it looks with the dual sink :

And I'm hoping I can plumb it so it fits like the next pictures.

At this point in time, as I mentioned, this is just a  rough dry fit to see what I'm dealing with, and only using the white pipes as reference.
(so things are not straight or lined up 100%)
Comment: Are you asking if it's OK to have the horizontal run from the center drain of the new sink before you get to the trap?
Comment: FYI, the "black PVC" is almost certainly ABS, not PVC. If you need to work on it, you'd want the correct glue for ABS. You'll have some degree of adjustment from the threaded union on the trap allowing the loop of the **P** to be rotated. The input leg does need to be higher than the output leg (not true in your mock-up pictures.)
Comment: Yes, that is correct.
Comment: The P-trap has a threaded fitting which you can loosen and swivel to adjust the angle too, if it helps shorten runs or reduce clutter.
Comment: Great ,thanks for the help,,
Actually have another related question....Our new sink is deeper  than what we have now, only by 1 inch.. if i need to ,can i cut that  PVC vent  pipe at the back and move the Horizontal PVC pipe down a inch or so to accommodate the new sink?..( just thinking ahead )
Answer: In your current setup, you've got a horizontal run from one bowl to the other, then it drains into the trap. In your mock-up, you're using the exact same horizontal piece to show where the new single, center drain will go. You're wondering if it's OK to have a horizontal run before you get to the trap...
So long as it's not truly horizontal, but has the appropriate 1/4" drop per foot of run, you'll be just fine.

New sink plumbing advice


converting cutoff frequency of lowpass filter for 2D images

Question: If we want to lowpass filter an image by 0.3xpi rad/sample by using h = fspecial('average', size), how shall we determine size parameter corresponding to 0.3xpi rad/sample in the following code?
lp_filter = fspecial('average', size);
img = imfilter(original,lp_filter,'replicate');

Answer: Filter size is the inverse of the cut-off.  So, for a simple filter like average, if you had a size of 1 pixel (i.e. no averaging), the cut-off would be at pi rad/sample.  So, the nearest integer to 0.3 pi rad/sample would be a size of 3 pixels.
The maths is a bit more complicated than that, but this is a useful rule of thumb in this case.
Comment: Is there any reference that you suggest for the math?
Comment: Any good textbook on signal or image processing will include information on the Fourier transform.  There are two key aspects to the problem (if you want the detail), and that is (i) it is a sampled data system, so the averaging filter is periodic in the frequency domain, and (ii) you are looking at a very non-ideal filter.  A quick search brings up [link](http://zimmer.fresnostate.edu/~pkinman/pdfs/Sampling.pdf) which shows the time-frequency dual relationship.
Comment: You can test out what the frequency response of any function in Matlab is pretty quickly.  For example, the averaging by 3: `x=ones(1,3); X=fft(x,1024); plot(20*log10(abs(X)));` will plot, on a dB scale, the magnitude of the frequency response.  (You'll need to normalise the x-axis to be able to work out the frequency, but in this case, 1024 corresponds to 2pi).  By increasing the length of x, you'll readily see the relationship I was talking about.


Fullscreen tearing in Firefox Flash video with AMD Catalyst drivers

Question: Since upgrading to Linux Mint 17, every time I put a flash video into fullscreen it starts tearing up, then freezes after a couple seconds. This only happens when I have the proprietary AMD drivers installed. I am currently running fglrx-updates from the driver manager, and have also tested this with fglrx and also the drivers from the AMD homepage.
I have also manually installed flash player from Adobe, to no avail.
Any ideas?
Comment: What graphics card are you using? Try upgrading to the latest AMD Catalyst drivers, and if it still tears, file a bug with AMD.
Answer: I had the same issue when I updated the kernel to 3.13.0-27.
So I booted back into old 3.13.0-24 and removed the -27 in the update manager > view > Linux Kernels.
No tearing/freezing full screen flash videos with proprietary AMD drivers in Firefox again.
Hope it works for U too.


Show all numbers from the fibonacci calculation

Question: this is part of my online class module and I need to write a program where the user inputs a number(n) and the program then prints the first n numbers in the fibonacci series.
I currently wrote the program so that it prints out the fibonacci number at a certain position.
for example, if I enter "7", it will print "13".
n = int(input("Enter a number:"))
fibonacciSeries = ((1+sqrt(5))**n-(1-sqrt(5))**n) /(2**n*sqrt(5))
print (fibonacciSeries)

How can I modify this code so that it prints out all the numbers leading up to the 7th number in the series?
Comment: Do you know the recursive form as well as the closed for for Fibonacci? Or stick the closed form in a loop?
Answer: If you need to repeat an operation you'll need loops, if you also need to store the result of the repeated operation you need a list. So, use a list comprehension to create a list of all numbers until i (renamed in order to use in range).
Then, you can unpack in the print call to view all the numbers produced. Also, / is floating point division; you're probably after floor division // here so I modified that for you:
i = int(input("Enter a number:"))
fibonacciSeries = [((1+sqrt(5))**n-(1-sqrt(5))**n)//(2**n*sqrt(5)) for n in range(1, i+1)]
print ("Fibonacci Nums: ", *fibonacciSeries)

The expression:
[(...) for n in range(1, 1+1)]

will repeat the operations in (...) for i times.
This results in:
Enter a number:7
Fibonacci Nums:  1.0 1.0 2.0 3.0 5.0 8.0 13.0

Answer: You can put it on a cycle, like this:
n = int(input("Enter a number:"))
for i in range(n + 1):
  fib = ((1+sqrt(5))**n-(1-sqrt(5))**n) /(2**n*sqrt(5))
  print(fib)

Answer: If you've already calculated the first n-1 values of the Fibonacci sequence, then there's no reason not to use them to determine the nth term.
a, b = 0, 1 #set a=0, b=1
for _ in range(n): #do the following n times
    print(a) #print one term each loop, for a total of n terms
    a, b = b, a+b #advance the sequence one step

Answer: Well... assuming your calculation is correct (It may be, I've just never seen that before)
n = int(input("Enter a number:"))
for i in range(1,n+1):
   fibonacciSeries = ((1+sqrt(5))**i-(1-sqrt(5))**i) /(2**i*sqrt(5))
   print (fibonacciSeries)

Answer: def fibonacci(z):
   a,b = 0,1
   while True:
   for y in xrange(z):
       yield a
       a,b = b, a+b

for i in fibonacci(5):
    print i

The fibonacci generator will pop out the numbers you want.  I don't know if you have eventually you will have anything else to do besides print them, but anytime you are outputting a series, generators are highly recommended.
Answer: This should do it.
def fibonacci():
    x,y = 1,1
    n=int(input("Enter number: "))
    n_int=int(n-2)
    for i in range (n_int):
        x,y=y,x+y
        print(x)
    print(y)


Need Cost Minimization Algorithm for USPS Flat Rate Boxes

Question: I have a client who ships fluids in USPS flat rate boxes. If you are unfamiliar with USPS flat rate boxes, they are boxes of a certain volume that ship regardless of weight. Anything that fits in the box, ships for one low price. My client uses two box sizes: the medium flat rate boxes, and the large flat rate boxes. Additionally, my client ships their fluids in the three bottle sizes: 200ml, 375ml, and 750ml. Moreover, due to the shape of the bottles only a certain number of bottles can fit in each box, and due to their shape the cost minimization cannot be detemined by computing using the volume of each box and the bottle volumes. Thus, there are different arrangements of the bottles in each box which can work. For example, a medium box can hold 3 200ml and 2 375ml bottles or it can hold 4 200 ml bottles and 1 375ml bottle, and there are many other possible arrangements depending on the number of each size bottle. The table below, which I will call the configurations table lists the possible arrangements of each bottle in each size of box. Also, the large box costs $14.50 and the medium box costs $10.70 to ship (http://www.usps.com/prices/priority-mail-prices.htm).
SQL Table Configurations
Box Type, 200ml, 375ml, 750ml, Cost
Medium Flat Box, 5, 0, 0, 10.70
Medium Flat Box, 4, 1, 0, 10.70
Medium Flat Box, 3, 2, 0, 10.70
Medium Flat Box, 0, 3, 0, 10.70
Medium Flat Box, 4, 0, 0, 10.70
Medium Flat Box, 3, 0, 0, 10.70
Medium Flat Box, 2, 0, 0, 10.70
Medium Flat Box, 1, 0, 0, 10.70
Medium Flat Box, 0, 2, 0, 10.70
Medium Flat Box, 0, 1, 0, 10.70
Large Flat Box, 0, 0, 2, 14.50
Large Flat Box, 0, 0, 1, 14.50
Large Flat Box, 4, 3, 0, 14.50
Large Flat Box, 0, 6, 0, 14.50
Large Flat Box, 0, 5, 0, 14.50
Large Flat Box, 0, 4, 0, 14.50
Large Flat Box, 8, 0, 0, 14.50
Large Flat Box, 7, 0, 0, 14.50
Large Flat Box, 6, 0, 0, 14.50

For example, the first row in the table says 5,0,0 and indicates that the medium box can hold 5 200 ml bottles, and no other bottles. Using the table of the arrangements above, find an algorithm for computing the optimal arrangement with respect to the shipping cost for shipping a set of x 200ml bottles, y 375 ml bottles, and z 750 ml bottles. Your algorithm should not only compute the minimal cost but it should return the optimal arrangment of bottles among the different size boxes. I would be particularly interested in seeing your algorithm expressed in SQL, but solutions in a procedural language such as Java, PHP, or C will definitely be useful also.
Comment: Can you answer your own question in a way that would help others? If you do, you can select yours as the correct answer. It may seem strange, but it is the preferred way of dealing with situations like this.
Comment: http://en.wikipedia.org/wiki/Knapsack_problem
Comment: I believe I have a working solution. While my solution may not provide the absolute optimal arrangment of the bottles within the boxes, my intuition tells me that it must get very close. I have posted the code on SNIPPLR - http://3.ly/QS3U - I plan to post it here also with an explanation.
Comment: @jerryvig - Glad you got a solution :-). Agreed with @Will: please post your answer here and mark it as answered. This will help others searching for similar answers. Thank you! :)
Comment: lookup up 'knapsack packing' algorithms
Comment: Thanks very much for that link. After reading a little more, I think I have a "Bin Packing Problem" here. Although wikipedia says bin packing problems are NP-hard, I think my simple case should be soluble.
Answer: select min(Cost)
from mytable
where 200ml<=x
and 375ml<=y
and 750ml<=z

if you want the rows back to determine the configurations you would need to add a primary key to the table to make it easier to write a subquery.


How could I find something in an array that I know only parts of

Question: Lets say I have these two values how could I match and see all possible combinations that word could be in the array. For this example how could I find apple in the array?
const fruit = ["apple", "banana", "strawberry", "grape"];
var word = "a__ple"

Answer: You can use Regex to match partial strings -

const fruit = ["apple", "banana", "strawberry", "grape"];
var regex = "^a.ple$";

var result = fruit.filter(f => f.match(regex));
console.log(result);
Answer: You can create a regex from your word and then using array#filter look up in the array.

const fruit = ["apple", "banana", "strawberry", "grape"],
      word = "a__ple",
      pattern = word.split("_").filter(Boolean).join('(.*?)'),
      result = fruit.filter(name => new RegExp(pattern, 'i').test(name));
console.log(result);
Answer:
Example for solution

fruit = ["apple", "banana", "strawberry", "grape"];
var word = "a_ple";

const searchQuery = word.replace(/[_]/g, '.');
const regex = new RegExp(searchQuery);

for (let i = 0; i < fruit.length; i++) {
    if (regex.test(fruit[i])) {
        // Word is founded
        console.log(fruit[i]);
    }

}

but it must use the "_" sign as same as the count of missing characters
also, you can use an index with words instead of search about strings I will try to do another example for this way thanks and I hope this helps you


Winning of game

Question: Given a game, where we pay x dollars (say 10 dollars), if we loss, we will loss 100% (we loss 10 dollars), if we win we got 37.5% (we win 3.75 dollars).
Given a strategy with 70% winning percentage.
Is anyway we place our bid that is able to win the game?
Answer: Omitting units, you pay $x$. You expect to receive back $(0.7)1.375x = 0.9625x < x$.
Since you expect to get back less than you pay, no: You should not play using the 70% strategy.

Winning of game


Create limit posting for users

Question: I want to make users only can create maximum 10 post per day.
Here is my controller:
$id_user=$this->session->userdata('id');
$sql ="SELECT COUNT(id_post) as max_post FROM post
WHERE post.id_user=$id_user
AND DATE(post.time)=DATE(NOW())";
$result = $this->db->query($sql);
if ($result > 10) //line number 17
{
  //redirect to home
} elseif($result <= 10 ) //line number 20
{
  //then do post

Then is getting error like this:
A PHP Error was encountered
Severity: Notice

Message: Object of class CI_DB_mysql_result could not be converted to int

Line Number: 17

A PHP Error was encountered
Severity: Notice

Message: Object of class CI_DB_mysql_result could not be converted to int

Line Number: 20

Any answer?
Many thanks...
Comment: have made echo query?
Comment: What does `print_r($result)` give you? (*just after `$result = $this->db....`*)
Comment: try this one  if( $result[0]['max_post'] > 10)   {then your code here}
Comment: it showing error like this `Cannot use object of type CI_DB_mysql_result as array  `
Answer: if ($result > 10)

$result Is the resource itself, you have to fetch data from it. $result itself is not what you are looking for. Fetch the required field from result.
For example
$row = $result->row();
if ($row->max_post > 10)

Comment: Thats some other problem then :)
Comment: i'm trying your code, it success in the first, but when i'm trying to upload in second time, it always redirect to home..
Answer: if(mysql_num_rows($result)>10)
{

}

try using this
Comment: `$result` is class `CI_DB_mysql_result` object from Codeigniter active records. `mysql_num_rows($result)` over the `$result` will not work.
Comment: when i use '$q = mysql_query("select * from table");' and mysql_num_rows($q) then it works... what special in this case

Create limit posting for users


I'm trying to count how many sales men are in a text file c++

Question: struct ventasType
{
    string iD;
    double quarterSales, totalSales;
};

void readingID(int counter) {

    ventasType sales;
    ifstream inFileID;
    counter = 0;

    inFileID.open("id.txt");

    inFileID >> sales.iD;

    while (!inFileID.eof())
    {
        inFileID >> sales.iD;
        counter++;
    }

    cout << "Total de vendedores:" << counter;
}

int main()
{
    ventasType sales;
    int count;
    readingID(count);
    cout << count;

    return 0;
}

When I try to print count it prints a memory location. I'm i doing this right? I'm trying to count hoy many sales people are in the text file. Did this code but its not running correctly. it prints a memory location. The programming language is c++.
Comment: `readingID` takes `count` by value, there's no way it can change the variable in `main`. *That* `count` will always remain an uninitialised variable with indeterminate value.
Comment: Count is uninitialized garbage when you print it. As @Jesper mentioned, its passed by value, not by reference. Give this a read [pass by reference](https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.cbclx01/cplr233.htm)
Comment: @Jesper is trying to tell you that within the scope of `ReadingID(){}`, it cannot change the value of Main's `count` because they are not the same `int`
Comment: what do you mean there's no way it can change the variable in main?
Comment: Didn't I say? It is taking the argument by value (copy). It cannot modify the original. Did you mean to pass by reference or pointer?
Comment: The question could be made easier to understand with a little more attention to formatting of the code.  There is no indentation of lines within readingID, for instance.  Then there is mixed indentation in main.
Comment: You probably should change this `void readingID(int counter) {` to `int readingID()`. In addition I don't like the naming but I will leave that up to you.
Comment: Unrelated: Recommended reading: [Why is iostream::eof inside a loop condition (i.e. while (!stream.eof())) considered wrong?](https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-i-e-while-stream-eof-cons)
Answer: You have to pass variable count by pointer or reference.
The easiest way to do it is to change
void readingID(int& counter)

This way you pass reference to variable without making a copy
Also I would like to suggest to initialize variable firstly before using it:
int count{0};
Answer: The following code cout << "Total de vendedores:" << counter; should be printing correctly. However, if you want your code cout << count; to print correctly, you need to pass the variable by reference or have your function return the value.
To pass the variable by reference, change void readingID(int counter) to void readingID(int& counter).
To change your function to return the total number salesmen, change to int readingID(), add return counter; at the end of your function, and set your counter variable in main to the value counter = readingID();


Why won't hp print driver print past a test page?

Question: Why won't hp dj1000j110 printer print more than the test page? Job goes to print queue, flashes for a moment, then disappears and the printer does not print anything. Printer driver is hplip-3.11.3a.run. Install telemetry available upon request.
Answer: Disabling bi-directional printing on your printer will fix this problem. Take a look at this: How to send print to Windows XP?
Even when this answer refers to Windows XP acting like a print server, the same rules applies to HP printers when connected to a Linux machine. Give it a try and please inform.
Good luck!
Edit:
Additionally, take a look at HPLIP (The HP Linux Imaging and Printing). This can help you but the majority of the HP's are working perfectly right out of the box, I insist that you may be experiencing bi-directional printing issues. Unfortunately I don't have an HP physically connected to my computer at this very moment in order to run a test. HPLIP can, however, help you.
Comment: I erased all of Windows on purpose while installing Ubuntu 9.10. So, Windows XP, or any other Windows distro does not exit.
Comment: Currently, I run Ubuntu 10.04, trying to get my HP printer to work. HP driver hplip-3.11.3a.run is installed. It printed a test page, but the system will not print anything else. The job shows up on job queue for all of 2 sec then flashes off the screen.
Comment: I have edited my answer to provide you with a link. I hope this help you.
Comment: Further tests of the software reveals that the printer is trying real hard to print but for some reason it just can't or won't.
Comment: The Document Print Status sheet shows jobs "Processing", "Completed", or "Aborted", --- yet,the computer does not print anything. The power cord and liaison cable hooking the printer to the computer are hooked in there solidly.
Comment: well, ken1943... as I mentioned in the past (probably in a different answer), I have faced this kind of behavior in HP printers, several models that includes lasers and inkjets. The job goes to the queue, and the printer shows a bit of activity which stops suddenly leaving the printer stuck and the only way to make it work again is disconnecting from the mains. The test page in certain models is something that can be achieved by a portion of code inserted in the firmware.
Comment: (continued...) the problem comes when the printer -as you mention- is trying to understand what the printing queue and service is trying to say. And you should look for a way to override the bi-directional printing in your hardware via a software or HPLIP. I feel bad because of I can't provide you with screenshots and a more detailed "how-to" because of I don't have an HP printer to connect in my computer. But tomorrow I will try to continue a research in order to provide you with a good tip. Meanwhile look forward to override the bi-directional printing and let's see what happen. Good luck!
Comment: new problem: machine prints now but keeps giving the following error msg: "/usr/lib/cups/filter/pdftoraster failed"
Comment: What are you using for printing your PDF? evince? web browser? which? If you are using google-chrome and/or chromium-browser try Firefox. chrome/chromium seems to have known problems to print PDF files. Addittionally, take a look into this anwer provided by @Ragnar123: http://askubuntu.com/questions/20642/whats-the-response-to-error-message-usr-lib-cups-filter-pdftoraster-failed, please inform.
Comment: machine does not function now, not even for a test page. I do not know what program prints my PDF file. Ragnar123 poses some interesting questions ... .


Can I move an attic furnace downstairs

Question: I love the single unit HVACs. I hate the unit in the attic - it has leaked so many times. Now that I am ready to replace the attic unit, I was wondering if I could have the same setup as my 1st floor DualFuel Heat Pump (single unit)
Houses are so badly designed when the downstairs unit has more power than the upstairs one, which gets hotter.
I understand there will be hell with duct replacements, but isnt there an easy way, instead of replacing all ducts and registers to just have a duct going to the place where the upstairs duct starts ? I really want a single unit and one which I dont have to bother with in the stupid attic.
I came across the reverse in this post:
Should I move the furnace upstairs to help cool the 2nd story?
Answer: No, not really. The work you're describing doesn't sound remotely cost-effective, or effective at all for that matter. Running a huge duct from the basement to the attic will choke off the airflow. Not to mention that if you're going to to that, you're already doing half the work necessary to redo the ductwork properly to connect the two zones.
It sounds like the real solution would be to abandon the attic unit (possibly selling it for some quick cash if it still works), and then integrate the second floor ductwork with the first floor ductwork such that the basement-mounted unit can service the whole house adequately.
If your second floor gets really really hot, the first and probably most consequential step is to air-seal and super-insulate the attic floor, and possibly adding a radiant barrier under the roof rafters if you can perform the work yourself (don't hire that part out; the payback time will be on the order of a hundred years). Low-E storm windows can help too if your house's windows are old and crappy.
Comment: Thanks for the detailed answer. Integrating the ductwork sounds like a great plan, I will now have to research that option, as well as make sure my downstairs unit can service both levels. (14 SEER 2 ton should be good enough for heat & cold for a 2k sqft house correct ?)
Comment: SEER tells you how efficiently it runs, not how much house it can cool; the BTU rating is what you'd need to know. But it's probably fine; most AC units are grossly oversized. You can more or less ensure it'll be fine by performing the attic air-sealing-and-insulation work, since that's where a lot of the heat gain comes from.
Comment: this combining ductwork stuff - is it something that needs to be done by a certified professional and be inspected ? Is it something that can be easily reversed if things dont work out ? Is it something that can be done without messing around with the structure and be seen outside the walls ? I know it depends on the house, lets say a 'standard' house. Thanks again !
Comment: A pro would probably be best unless you want to learn all about duct design. Which you can and should! A lot depends on the condition of the house: where the ducts are located, what they're made out of, their current layout, etc. Impossible to be more specific without knowing that info. I'd recommend either hiring a pro or becoming an expert in duct design and doing it yourself, if you reasonably feel like it's within your capacity to do.
Comment: @killjoy: in what region is your house? A 2 ton unit for 2k sf would be grossly _undersized_ for most homes in a southern climate (like Texas) but could be sufficient if you are in a cool enough climate or if your house is sealed well enough.
Comment: Ductwork - can anyone give me a rough idea of how the U & D ducts will be merged in a situation like this - I know the D one is in the crawlspace and U one starts at furnace - and no, I am not all confident of doing the job myself.

@RyanSmith - it is in the south, Charlotte.
Comment: On the same lines, is it worth going for a "$49 Complete Attic Energy and Ventilation Inspection" or is it enough if I just make sure openings are sealed well ?

Can I move an attic furnace downstairs


Create rewrite rule on IIS to redirect to subdirectory on same server

Question: I have a website structure like this:
https://example.org/
                    october-2018/
                                 index.html
                                 css/...
                                 js/...
                    november-2019/
                                 index.html
                                 css/...
                                 js/...
                    march-2020/
                                 index.html
                                 css/...
                                 js/...
                    ...

I would like to create a IIS Rewrite rule that will rewrite a request for just the bare domain URL (https://example.org/) to serve the contents of, say, the november-2019/ directory. I cannot find any examples and I'm not IIS-savvy enough to get my head around this (much easier for me if it were Apache or nginx ...).
In case it matters: As I'm in a corporate environment, I don't think the Application Request Routing (ARR) extension is available on the platform I have to use.
Comment: is your issue resolved?
Comment: Yes, thanks for reminding. I will add my own answer as yours wasn't clear to me; and I didn't have time to ask for clarifications. Thanks for your input though!
Answer: You could use below url rewrite rule:
    <rule name="ReverseProxyInboundRule5" stopProcessing="true">
           <match url="^$" />
           <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
           <action type="Rewrite" url="http://www.sample1.com/november-2019/" logRewrittenUrl="true" />
     </rule>

   <outboundRules>
    <rule name="rule5" preCondition="ResponseIsHtml1" stopProcessing="true">
            <match filterByTags="Link, Script" pattern="(.*)" />
            <conditions>
            <add input="{HTTPS}" pattern="on" />
            <add input="{HTTP_HOST}" pattern="www.sample1.com" />
            </conditions>
            <action type="Rewrite" value="/november-2019{R:1}" />
            </rule>
   <preConditions>
          <preCondition name="ResponseIsHtml1" logicalGrouping="MatchAny">
           <add input="{RESPONSE_CONTENT_TYPE}" pattern="text/html" />
           </preCondition>

    </outboundRules>

Answer: In the end, after a lot of trial and error, I was able to create the following rule:
<rule name="Redirect to specific local subdirectory" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
   <match url="^$" />
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
   <action type="Rewrite" url="november-2019/" />
</rule>

This works for the parent directory in the same way as for the child directory. However, all assets (fonts, images, css, etc.) need to use the absolute URL to the november-2019/ directory.
Unfortunately, I couldn't use @Jalpha's rules as I wasn't sure how to use them. I appreciate the effort though.


Linux Kernel task_struct void *stack

Question: What is the void *stack declaration in task_struct in sched.h?
Is it the pointer to the process image (stack, heap, .bss, data, text) stack? If so, where are the pointers to the rest of the process image?
Answer: In Linux kernel source code you can see the macros task_thread_info():
#define task_thread_info(task)  ((struct thread_info *)(task)->stack)

The void *stack pointer of task_struct points to thread_info.
Since 2.6 version Linux uses part of a task's kernel-stack page-frame to store "thread information" (thread_info). The thread_info in its turn includes a pointer to the task_struct:
struct task_struct *task = info->task;

F.e. (for platforms where the stack grows in the direction of decreasing the value of the memory address):

Useful links: 1, 2

where are the pointers to the rest of the process image?

Such info is contained in memory descriptor mm_struct. F.e.:
struct mm_struct {
    //...
    unsigned long start_code, end_code, start_data, end_data;
    unsigned long start_brk, brk, start_stack;
    //...
}

Must-read: How The Kernel Manages Your Memory

Linux Kernel task_struct void *stack


Perl merging 2 csv files line by line with a primary key

Question: Edit: solution added.
Hi, I currently have some working albeit slow code.
It merges 2 CSV files line by line using a primary key.
For example, if file 1 has the line:
"one,two,,four,42"

and file 2 has this line;
"one,,three,,42"

where in 0 indexed $position = 4 has the primary key = 42;
then the sub: merge_file($file1,$file2,$outputfile,$position);
will output a file with the line:
"one,two,three,four,42";

Every primary key is unique in each file, and a key might exist in one file but not in the other (and vice versa)
There are about 1 million lines in each file.
Going through every line in the first file, I am using a hash to store the primary key, and storing the line number as the value. The line number corresponds to an array[line num] which stores every line in the first file.
Then I go through every line in the second file, and check if the primary key is in the hash, and if it is, get the line from the file1array and then add the columns I need from the first array to the second array, and then concat. to the end. Then delete the hash, and then at the very end, dump the entire thing to file. (I am using a SSD so I want to minimise file writes.)
It is probably best explained with a code:
sub merge_file2{
 my ($file1,$file2,$out,$position) = ($_[0],$_[1],$_[2],$_[3]);
 print "merging: \n$file1 and \n$file2, to: \n$out\n";
 my $OUTSTRING = undef;

 my %line_for;
 my @file1array;
 open FILE1, "<$file1";
 print "$file1 opened\n";
 while (<FILE1>){
      chomp;
      $line_for{read_csv_string($_,$position)}=$.; #reads csv line at current position (of key)
      $file1array[$.] = $_; #store line in file1array.
 }
 close FILE1;
 print "$file2 opened - merging..\n";
 open FILE2, "<", $file2;
 my @from1to2 = qw( 2 4 8 17 18 19); #which columns from file 1 to be added into cols. of file 2.
 while (<FILE2>){
      print "$.\n" if ($.%1000) == 0;
      chomp;
      my @array1 = ();
      my @array2 = ();
      my @array2 = split /,/, $_; #split 2nd csv line by commas

      my @array1 = split /,/, $file1array[$line_for{$array2[$position]}];
      #                            ^         ^                  ^
      # prev line  lookup line in 1st file,lookup hash,     pos of key
      #my @output = &merge_string(\@array1,\@array2); #merge 2 csv strings (old fn.)

      foreach(@from1to2){
           $array2[$_] = $array1[$_];
      }
      my $outstring = join ",", @array2;
      $OUTSTRING.=$outstring."\n";
      delete $line_for{$array2[$position]};
 }
 close FILE2;
 print "adding rest of lines\n";
 foreach my $key (sort { $a <=> $b } keys %line_for){
      $OUTSTRING.= $file1array[$line_for{$key}]."\n";
 }

 print "writing file $out\n\n\n";
 write_line($out,$OUTSTRING);
}

The first while is fine, takes less than 1 minute, however the second while loop takes about 1 hour to run, and I am wondering if I have taken the right approach. I think it is possible for a lot of speedup? :) Thanks in advance.

Solution:
sub merge_file3{
my ($file1,$file2,$out,$position,$hsize) = ($_[0],$_[1],$_[2],$_[3],$_[4]);
print "merging: \n$file1 and \n$file2, to: \n$out\n";
my $OUTSTRING = undef;
my $header;

my (@file1,@file2);
open FILE1, "<$file1" or die;
while (<FILE1>){
    if ($.==1){
        $header = $_;
        next;
    }
    print "$.\n" if ($.%100000) == 0;
    chomp;
    push @file1, [split ',', $_];
}
close FILE1;

open FILE2, "<$file2" or die;
while (<FILE2>){
    next if $.==1;
    print "$.\n" if ($.%100000) == 0;
    chomp;
    push @file2, [split ',', $_];
}
close FILE2;

print "sorting files\n";
my @sortedf1 = sort {$a->[$position] <=> $b->[$position]} @file1;
my @sortedf2 = sort {$a->[$position] <=> $b->[$position]} @file2;
print "sorted\n";
@file1 = undef;
@file2 = undef;
#foreach my $line (@file1){print "\t [ @$line ],\n";    }

my ($i,$j) = (0,0);
while ($i < $#sortedf1 and $j < $#sortedf2){
    my $key1 = $sortedf1[$i][$position];
    my $key2 = $sortedf2[$j][$position];
    if ($key1 eq $key2){
        foreach(0..$hsize){ #header size.
            $sortedf2[$j][$_] = $sortedf1[$i][$_] if $sortedf1[$i][$_] ne undef;
        }
        $i++;
        $j++;
    }
    elsif ( $key1 < $key2){
        push(@sortedf2,[@{$sortedf1[$i]}]);
        $i++;
    }
    elsif ( $key1 > $key2){
        $j++;
    }
}

#foreach my $line (@sortedf2){print "\t [ @$line ],\n"; }

print "outputting to file\n";
open OUT, ">$out";
print OUT $header;
foreach(@sortedf2){
    print OUT (join ",", @{$_})."\n";
}
close OUT;

}

Thanks everyone, the solution is posted above. It now takes about 1 minute to merge the whole thing! :)
Comment: (for reference (arrays of arrays): http://sunsite.ualberta.ca/Documentation/Misc/perl-5.6.1/pod/perllol.html )
Comment: I think there is still enough space for optimizations but if it is fast enough go with it.
Answer: Two techniques come to mind.

Read the data from the CSV files into two tables in a DBMS (SQLite would work just fine), and then use the DB to do a join and write the data back out to CSV. The database will use indexes to optimize the join.
First, sort each file by primary key (using perl or unix sort), then do a linear scan over each file in parallel (read a record from each file; if the keys are equal then output a joined row and advance both files; if the keys are unequal then advance the file with the lesser key and try again). This step is O(n + m) time instead of O(n * m), and O(1) memory.
Comment: What do you mean by O(n*m) ?  He's not doing anything O(n*m) here.  He's looping once over one file, and once over the second, and not doing anything silly like a sequential scan of the array inside the second loop.
Comment: @Daniel: If you think that hash lookup is O(1) then you are naive. It is only in books but in reality it is not true. First, hash map lookup is proportional to hash computation it is proportional to length of key multiplied to length of hash and length of hash is typically logN of key space. So lookup is in reality at least O(logN). (Yes, Perl uses adaptive hash length.) Second, there are some additional effects as CPU cache hits and so and so. In reality it is much more O(N) than O(logN) and O(1) never.
Comment: My original hash got slower and slower, the intial 20,000 lines were done in under a few seconds, but the final 1000s of lines took about 5 seconds for each 1000.
Answer: What's killing the performance is this code, which is concatenating millions of times.
$OUTSTRING.=$outstring."\n";

....

foreach my $key (sort { $a <=> $b } keys %line_for){
    $OUTSTRING.= $file1array[$line_for{$key}]."\n";
}

If you want to write to the output file only once, accumulate your results in an array, and then print them at the very end, using join. Or, even better perhaps, include the newlines in the results and write the array directly.
To see how concatenation does not scale when crunching big data, experiment with this demo script. When you run it in concat mode, things start slowing down considerably after a couple hundred thousand concatenations -- I gave up and killed the script. By contrast, simply printing an array of a million lines took less than a than a minute on my machine.
# Usage: perl demo.pl 50 999999 concat|join|direct
use strict;
use warnings;

my ($line_len, $n_lines, $method) = @ARGV;
my @data = map { '_' x $line_len . "\n" } 1 .. $n_lines;

open my $fh, '>', 'output.txt' or die $!;

if ($method eq 'concat'){         # Dog slow. Gets slower as @data gets big.
    my $outstring;
    for my $i (0 .. $#data){
        print STDERR $i, "\n" if $i % 1000 == 0;
        $outstring .= $data[$i];
    }
    print $fh $outstring;
}
elsif ($method eq 'join'){        # Fast
    print $fh join('', @data);
}
else {                            # Fast
    print $fh @data;
}

Comment: @Ether No, `join` is very fast -- orders of magnitude faster than building up a giant string through repeated concatenation. Try it out: I modified my demo script.
Comment: `join` would be just as slow, I think... but this would get around that: `foreach my $line (@outputarray) { print $line, "\n"; }`
Comment: Thanks, in my solution I posted, the file is output from the array.
Comment: I ran this test `time ./test.pl 100 10000000` for all three methods, and it completed in between 20 to 26 seconds in all cases. What do I have to do to see it be slow? Maybe you are running on a computer with little enough memory to force paging?
Answer: I can't see anything that strikes me as obviously slow, but I would make these changes:

First, I'd eliminate the @file1array variable.  You don't need it; just store the line itself in the hash:
while (<FILE1>){
     chomp;
     $line_for{read_csv_string($_,$position)}=$_;
}

Secondly, although this shouldn't really make much of a difference with perl, I wouldn't add to $OUTSTRING all the time.  Instead, keep an array of output lines and push onto it each time.  If for some reason you still need to call write_line with a massive string you can always use join('', @OUTLINES) at the end.
If write_line doesn't use syswrite or something low-level like that, but rather uses print or other stdio-based calls, then you aren't saving any disk writes by building up the output file in memory.  Therefore, you might as well not build your output up in memory at all, and instead just write it out as you create it. Of course if you are using syswrite, forget this.
Since nothing is obviously slow, try throwing Devel::SmallProf at your code.  I've found that to be the best perl profiler for producing those "Oh!  That's the slow line!" insights.
Comment: 1. Initially I stored the line in a hash, but I thought it was slowing it down, so I tried to minimise the key-values size to just the key and the line number to see if it would help. (obviously it didn't)

2. yes, the point is made. I will use arrays instead of concatenating everything into a big string.

3. Not using syswrite, advice taken.
4. yep, will look into using SmallProf for future code.
Comment: 3. Btw, I found that if I write line by line with a print OUT, $_ statement in a foreach() loop, it will crash/disconnect my SSD drive. Whereas, if I use a single print OUT $OUTSTRING; then this will work fine. (maybe the controller for the SSD drive is bad).

  When I run the program on a mechanical rotating hard drive, then I can do both no problem.
Answer: If you want merge you should really merge. First of all you have to sort your data by key and than merge! You will beat even MySQL in performance. I have a lot of experience with it.
You can write something along those lines:
#!/usr/bin/env perl
use strict;
use warnings;

use Text::CSV_XS;
use autodie;

use constant KEYPOS => 4;

die "Insufficient number of parameters" if @ARGV < 2;
my $csv = Text::CSV_XS->new( { eol => $/ } );
my $sortpos = KEYPOS + 1;
open my $file1, "sort -n -k$sortpos -t, $ARGV[0] |";
open my $file2, "sort -n -k$sortpos -t, $ARGV[1] |";
my $row1 = $csv->getline($file1);
my $row2 = $csv->getline($file2);
while ( $row1 and $row2 ) {
    my $row;
    if ( $row1->[KEYPOS] == $row2->[KEYPOS] ) {    # merge rows
        $row  = [ map { $row1->[$_] || $row2->[$_] } 0 .. $#$row1 ];
        $row1 = $csv->getline($file1);
        $row2 = $csv->getline($file2);
    }
    elsif ( $row1->[KEYPOS] < $row2->[KEYPOS] ) {
        $row  = $row1;
        $row1 = $csv->getline($file1);
    }
    else {
        $row  = $row2;
        $row2 = $csv->getline($file2);
    }
    $csv->print( *STDOUT, $row );
}

# flush possible tail
while ( $row1 ) {
    $csv->print( *STDOUT, $row1 );
    $row1 = $csv->getline($file1);
}
while ( $row2 ) {
    $csv->print( *STDOUT, $row2 );
    $row2 = $csv->getline($file1);
}
close $file1;
close $file2;

Redirect output to file and measure.
If you like more sanity around sort arguments you can replace file opening part with
(open my $file1, '-|') || exec('sort',  '-n',  "-k$sortpos",  '-t,',  $ARGV[0]);
(open my $file2, '-|') || exec('sort',  '-n',  "-k$sortpos",  '-t,',  $ARGV[1]);

Answer: Assuming around 20 bytes lines each of your file would amount to about 20 MB, which isn't too big.
Since you are using hash your time complexity doesn't seem to be a problem.
In your second loop, you are printing to the console for each line, this bit is slow. Try removing that should help a lot.
You can also avoid the delete in the second loop.
Reading multiple lines at a time should also help. But not too much I think, there is always going to be a read ahead behind the scenes.
Comment: Um, he's printing to the console only once every 1000 lines, and the "delete" is very important for what he does in the loop following that while statement.
Comment: 20 bytes per line. LOL. You don't know Perl memory efficiency a lot. If you parse it and store in hash it takes more.
Answer: I'd store each record in a hash whose keys are the primary keys. A given primary key's value is a reference to an array of CSV values, where undef represents an unknown value.
use 5.10.0;  # for // ("defined-or")
use Carp;
use Text::CSV;

sub merge_csv {
  my($path,$record) = @_;

  open my $fh, "<", $path or croak "$0: open $path: $!";

  my $csv = Text::CSV->new;
  local $_;
  while (<$fh>) {
    if ($csv->parse($_)) {
      my @f = map length($_) ? $_ : undef, $csv->fields;
      next unless @f >= 1;

      my $primary = pop @f;
      if ($record->{$primary}) {
        $record->{$primary}[$_] //= $f[$_]
          for 0 .. $#{ $record->{$primary} };
      }
      else {
        $record->{$primary} = \@f;
      }
    }
    else {
      warn "$0: $path:$.: parse failed; skipping...\n";
      next;
    }
  }
}

Your main program will resemble
my %rec;
merge_csv $_, \%rec for qw/ file1 file2 /;

The Data::Dumper module shows that the resulting hash given the simple inputs from your question is
$VAR1 = {
  '42' => [
    'one',
    'two',
    'three',
    'four'
  ]
};


Github and private channel

Question: i tried to execute this bash command:
verweb=`sudo wget -q -O- 'https://github.com/Kitware/CMake/releases/latest' | grep -o 'https[^\"]*' | grep tag | grep -o -P '(?<=tag/v).*(?=",)' | uniq` ; echo $verweb

and the output is correct: 3.23.4
But when I execute this command there is no output:
url=`sudo wget -q -O- 'https://github.com/meetfranz/franz/releases/latest' | grep -o 'meetfranz[^\"]*' | grep amd64.deb | head -1` ; echo $url

this is because the github channel have private assets, can you help me to solve this problem? i know exists some API to fix this problem, but i don't know how use it:
https://github.com/wyozi/download-gh-release-asset/blob/master/download-asset
https://gist.github.com/maxim/6e15aa45ba010ab030c4#file-gh-dl-release
THANKS
Answer: I don't think this has anything to do with a "private channel" (whatever that is).  I think it's just that this project has many artifacts per release so sometimes it doesn't inline all the release the HTML response and instead the list of release artifacts is getting lazily loaded via another request.
If you're trying to get the version latest release you can use something like:
gh release view -R meetfranz/franz --json name -q .name
5.9.2

Or using curl + jq:
curl -sSH "Accept: application/json" \
    -L https://github.com/meetfranz/franz/releases/latest \
  | jq -r .tag_name \
  | tail -c '+2'
5.9.2

Or if you're looking to get the download URL for the amd64 deb associated with the most recent release:
gh release view \
  -R meetfranz/franz \
  --json assets \
  -q '.assets[] | select( .url | contains("amd64.deb") ) | .url'
https://github.com/meetfranz/franz/releases/download/v5.9.2/franz_5.9.2_amd64.deb

Github and private channel


Is it possible to get a shiny Honedge without breeding?

Question: I have already looked at many articles on the subject but all of them just say it's possible to find on route 6, or you can breed 'till the cows come home trying to get a shiny. I'm not real big on breeding and was wondering, is there a way to get a shiny honedge that does not involve breeding or the pokemon radar (because it does not work on rout 6 due to the tall grass)?
Comment: You can get a shiny of everything: Starters, gifts, fossils, even Legendaries (only exceptions are trades and event Pokémon). The problem with shiny Pokémon is that they're extremely rare. Breeding and Pokémon Radar are only supposed to *increase your chances* at getting a shiny Pokémon.
Comment: @Nolonar I think since Gen5 or so some in-game legendaries have been flagged so that they can't be shiny outside of event distribution.
Comment: Note that breeding doesn't actually increase the chances for a shiny, but ensures the shiny will have the Nature and attacks (and to some degree stats) you want it to have once it appears. Using the Masuda method does increase the chances while breeding, but the breeding itself doesn't.
Answer: Yes, any wild pokémon (with the exception of some legendaries) you encounter can be shiny.
However, keep in mind that without any tricks available to increase the shiny rate (Radar, horde battles, etc), your chances are low. Even with the item for 'finishing' the national dex, you are still looking at 1 in 2,000 or so. Also, Honedge aren't the only pokémon in the grass; even if we assume the chance of a Honedge is equal to the other five (It isn't; Bulbapedia lists it as 'rare'), that would take your chances to 1 in 24,000 (assuming a base rate of 1 in 4,000 or so).
Compare this with breeding: You can put an ordinary Honedge in the daycare with another opposite gendered Honedge, 1 in 4,000 (Again, roughly, assuming this is the base rate) chance of each egg being shiny. Take out one of those Honedge and stick in a Ditto (or any pokémon from the Mineral egg group) that was caught in a different region, like Japan, and your chance doubles to 1 in 2,000.
Breeding repeatedly might get a little dull, but if you have to breed "'till the cows come home" to get a shiny, you'll be wading through the grass until the cows came home 6-12 times by comparison.
Answer: Im kind of late to this sorry, but the fastest method I found was to use a pokemon with Magnet pull on Route 6. Magnet Pull increases the chance of encountering a steel pokemon to 150% of the usual chance. And as Honedge is the only steel type there, you will encounter more of them.
Other pokemon will still show up, but honedge will be the most common, so the chances of it being the shiny you encounter are a bit higher.
Answer: Also, if you have some good pokemon with you, I would look on the GTS. There may be some unreasonable offers but if you are persistent, you may be able to get one.


Changing the amount of a 'Coin Pack' IAP

Question: I have an IAP set up for an iOS game, that gives the player in-game currency for real money.  Right now I have the amount of in-game coins saved in the game, while the price is saved in the information Apple collected for the IAP.
The problem is, sometimes we might want to run special deals where instead of, say, 1000 coins the IAP would give the player 1500 coins if they bought it on a certain weekend.  If the amount of coins for the IAP is saved in the game, we're relying on the fact that players will update their app at the proper times to get the weekend deal and not everyone updates right away. On the other hand, we can change the IAP information given to Apple at any time so I was wondering:
Could I add a coin amount in the IAP 'description' field and use that to determine how much to give players?  Does it take time to get the IAP reviewed if the description gets changed?  Or is there a better way to set up an IAP so it is possible to change the amount of in-game coins it gives players?
Answer: The best option is to just change the price of the purchase during your deal time. That's what the app store is setup to do, it will be simple for you to do and 100% reliable.
Your hacky option of using the description will work (assuming you code it correctly). And technically, the user will see the updated description in the store while the deal is on. But you'll have much less control over the timing (as you say, due to the review time for each change).


What drainage should I install under concrete slab in garage?

Question: I have a concrete garage which is halfway inside the hill. Essentially the surface behind the garage is at garage's roof level. Garage's floor is concrete slab 3"-4" thick (at least it's best I could figure). I suspect that the base under the slab is in poor condition.
Some bright minds, presumably about 50 years ago, terminated drain holes inside the garage. So now I have water along garage sides year round. Also a bit of water sips through some cracks in the slab.
I don't want to dig around garage to install drainage because there is a large tree behind it which I don't want to kill. Plus it's very close to property line.
So what can I do to minimize the moisture inside the garage? I was thinking of removing the slab and putting drain pipes along garage walls. Then re-pouring the slab with proper base under it. The holes would then just drip directly into the drain pipe. Drain pipes can be terminated in sewer, then.
Does it make sense? Can someone recommend better option?
Answer: You can install an interior weeping system similar to what you would normally do on the outside, but without the waterproofing.
Start by jackhammering out about two feet of floor around the edges of your garage, as close to the walls as you can get. Dig down until you reach dirt, and if that's not at least two feet down, keep going. Now, put down a couple inches of 3/4" crushed gravel, and then install weeping tile (it's not tile anymore; it's 4-6" corrugated plastic drain pipe with a nylon mesh sock over it). Make sure the sock is continuous across any joins you make in the weeping tile for corners etc. This is a good time to direct those drain holes down into this trench, where the water they drain will flow into the weeping tile. You'll also need a sump, or a connection to a downhill storm sewer; direct the weeping tile to this sump pit or the storm drain. While you're doing all this a center drain can't hurt too much; you can tie it into the weeper wherever it's convenient, just make sure the garage floor and the drain flange are level, or that the garage floor slopes slightly to the drain.
Now, you can install waterproof sheathing on the interior walls contacting the concrete. Normally this product is designed to go outside the foundation walls, but in cases where that's infeasible it can work this way too. The idea is to trap moisture that weeps through the wall behind the sheathing, where it will then be directed down the wall and under the slab to the weeper. So, you'll install the sheathing, which should have an air space between wall and most of the layer, and make sure the end is down in the trench by the weeper.
Backfill the rest of the trench with 3/4" crushed gravel up to the slab footing, then patch the slab with new concrete. Your garage should stay much drier.


Scrape 2 inner texts within div as one value

Question: I have the following html

102,
99

I want to print the price of this html without comma, so
print price should result in:
102.99
I have the following code
pricea = page_soup.find("div", {"class":"price-block__highlight"})
price = str(pricea.text.replace('-','').replace(',','.').strip())
print price

This however results in:
 102.
  99

When writing in a csv it creates multiple rows. How to get both numbers in one value?
Answer: i think you are using bs4
from bs4 import BeautifulSoup

html_doc = """

102,
99

"""

soup = BeautifulSoup(html_doc, 'html.parser')

price_div = soup.find("div", {"class": 'price-block__highlight'})

texts = [x.strip() for x in price_div.text.split(',')]

print('.'.join(texts))

Output
102.99


"No executable" when using dotnet add

Question: I'm trying to add a Nuget .core package using
dotnet add package [package name]

but get "No executable found matching command dotnet-add".  I've installed Nuget and can use "dotnet" to create applications, restore, build, run, etc.
What am I doing wrong?  Thanks.
Comment: what does `dotnet --version` return? you need at least 1.0.0 (no 1.0.0-preview)
Comment: Yep, I was running preview.  Many thanks!
Answer: The dotnet add family of verbs was released in version 1.0.0 of the dotnet cli tooling and is not part of the 1.0.0-preview2-* range of versions previously used for project.json projects.
This means that dotnet add verbs are only available for msbuild based projects (=> .csproj).

"No executable" when using dotnet add


What is the proper preparation to re-apply silicone caulk?

Question: We have a Swan Stone shower surround that consists of 3 solid surface panels caulked at the corners with a corner molding them applied and caulked.
The previous owners weren't great at things like caulking so it's a mess and I've pulled off the corner mouldings and scrapped off all the existing caulk to get it ready to re-apply.
I was about to wipe it all down with mineral spirits to remove any remaining caulk residue, but then notice in the product literature is specifically says NOT to use mineral spirits as it will prevent the caulk from adhering and that I should instead use denatured alcohol to prep the surface.
So now I'm confused. Should I used mineral spirits to clean off the old caulk, then denatured alcohol to clean off the mineral spirits? Is there some other product I should be using?
Comment: Well whatever you do don't dump the mineral spirits out in your yard when you're done... ;)
Answer: By all means, use denatured or isopropyl alcohol to remove all mineral spirits. Go over the entire area a few times with the alcohol on a clean micro fiber cloth, turning the cloth each time to be sure no spirits are being reintroduced to the surface. The surface should be squeaky clean.


How do I check if the list contains empty elements?

Question: Suppose I have a empty string, it will be split:
>>>''.split(',')
['']

The result of the split is ['']. I use bool to check it whether or not it's empty. It will return True.
>>>bool([''])
True

How do I check the split result is empty?
Comment: I see. it's not a empty list. I hope I would exclude the situation. I am thinking how to do.
Comment: Ultimately, what are you trying to do? There's no point in trying to split an empty list in the first place, you could gate this code with an if-statement or if-expression in a list comprehension: `if s1: s2 = s1.split(',') ...`
Answer: With bool(['']) you're checking if the list [''] has any contents, which it does, the contents just happen to be the empty string ''.
If you want to check whether all the elements in the list aren't 'empty' (so if the list contains the string '' it will return False) you can use the built-in function all():
all(v for v in l)

This takes every element v in list l and checks if it has a True value; if all elements do it returns True if at least one doesn't it returns False. As an example:
l = ''.split(',')

all(v for v in l)
Out[75]: False

You can substitute this with any() to perform a partial check and  see if any of the items in the list l have a value of True.
A more comprehensive example* with both uses:
l = [1, 2, 3, '']

all(l)
# '' doesn't have a True value
Out[82]: False

# 1, 2, 3 have a True value
any(l)
Out[83]: True

*As @ShadowRanger pointed out in the comments, the same exact thing can be done with all(l) or any(l) since they both just accept an iterable in the end.
Comment: Also, you inverted `all` and `any`; `all` tells you if all the results were non-empty, not if it has non-empty elements,and `any` says if it has non-empty elements (it could still have empty, but if `any` returns `True`, at least one was non-empty). `any` is probably more useful here.
Comment: Simplification: Change `all(v for v in l)` to just `all(l)`; no need to make a special generator expression when `all` can process the `list` directly.
Comment: It does not work if the elements contains value `False`, sample `all([1, 2, 3, False])`, False returns as result.
Comment: @Ivan that does what it is supposed to do. Since they *all* don't have a Truthy value it returns `False`.
Answer: If emptiness is the important result, probably best to test the original string first:
x = ''
if x:
    # Original string was non-empty, split it
    splitx = x.split(',')
    if any(splitx):
        # There was at least one character in the original string that wasn't a comma

The first test rules out empty initial strings, the second one using any rules out strings that were nothing but the split character, and therefore returned a whole bunch of empty strings, but no non-empty strings. As long as you got one non-empty string, it passes.
Note: In case you're trying to parse CSV files, don't use .split(','); there is a csv module that handles this correctly (including escapes, quoting, etc.), and should ALWAYS be used for parsing CSV, never roll your own parser. Added bonus: csv will convert '' inputs to [] rows, which you can test for truthiness directly, not to [''] like str.split does. Example:
>>> import csv, io

>>> f = io.StringIO('\n\na,b,c\n1,2,3\n\n')
>>> [row for row in csv.reader(f) if row]  # Stripping easily
[['a', 'b', 'c'], ['1', '2', '3']]

vs. the same approach with str.split(',') which still doesn't handle quoting, escaping, etc.:
>>> f = io.StringIO('\n\na,b,c\n1,2,3\n\n')
>>> stripped = (line.rstrip('\r\n') for line in f)  # Must manually strip line endings first
>>> [line.split(',') for line in stripped if line]
[['a', 'b', 'c'], ['1', '2', '3']]

Answer: The split result isn't empty. The sense of "emptiness" you're looking for is best checked by looking at the original, unsplit string:
if not original_string:
    # It's empty.

But if you really want to look at the split result for this:
if len(split_result) == 1 and not split_result[0]:
    # It's "empty".

Answer: In your case it truly isnt empty
If you want to check if the element within that list is empty you can do:
string = ''.split(',')

if not string[0]:
    print "empty"

Answer: According to the str.split() documentation, "Splitting an empty string with a specified separator returns ['']."
To check for this case, when you are using an explicit delimiter (like your use of split(",")), do something like this:
l = s.split(",")

if len(l) == 1 and l[0] == '':
    print("string was empty")


Improper Integral, show that $\int_0^\infty \frac{x^2}{\theta^2}f(\frac{x}{\theta})\,d\theta=x$.

Question: Let $f$ be a function, $x>0$ and $\theta>0$, and suppose $\int_{0}^{\infty}tf(t)\,dt=1$
How could I show that $\int_0^\infty \frac{x^2}{\theta^2}f(\frac{x}{\theta}) \, d\theta =x$?
I try substituting with $u=\frac{x}{\theta}$ and then $du=-\frac{x}{\theta^2} \, d\theta$, and the integral becomes:
$\int_0^\infty \frac{x^2}{\theta^2}f(\frac{x}{\theta}) \, d\theta=\int_\infty^0 -xf(u)\,du=\int_0^\infty xf(u) \, du$...
but then I don't seem to be getting anywhere and I don't know how to use that $\int_0^\infty tf(t) \,dt=1$
...
Thanks.
Comment: are you sure that the condition is not $\int_0^{\infty} f(t)=1$  instead ?
Comment: your integral is = $\theta$.
Comment: It's false as stated.
Comment: @Chilango That's the variable of integration.
Comment: As tired alluded to above you need to start with the condition $\int_0^\infty f(t) dt = 1$ to get the desired conclusion. From your condition you only get $\int_0^\infty f\left(\frac{x}{\theta}\right)\frac{x^3}{\theta^3}d\theta = x$
Comment: zhw, some counterexample?
Comment: Counter-example: $f(x) = 4e^{-2x}$. Then $\int_0^\infty tf(t)dt = 1$, but your integral with $x=1$ gives $2 \not= 1$.
Comment: @zhw. of course you're right., I misread the problem. Looking again, I don't think the problem is well-posed.
Comment: Since the only thing you know about $f$ is $\int_0^\infty t f(t)\; dt$, the only integrals of the form $\int_a^b g(\theta) f(u(\theta))\; d\theta$ that you can evaluate are those that transform to a multiple of $\int_0^\infty t f(t)\; dt$ by substitution $t = u(\theta)$.
Comment: Thanks. I've already found another counterexample (With a normal curve). So, it's false.
Answer: $$
\int_0^\infty \frac{x^2}{\theta^2} f\left(\frac x \theta \right)\,d\theta= \int_\infty^0 x f(u)\,(-du) = \overbrace{\int_0^\infty xf(u)\,du = x \int_0^\infty f(u)\,du}
$$
The step under the $\overbrace{\text{overbrace}}$ is valid because $x$ is a constant, i.e. it does not change as $u$ goes from $0$ to $\infty$, or as $\theta$ goes from $0$ to $\infty$.
To finish this off, you would have to know that $\int_0^\infty f(u)\,du=1$.


ggbiplot - change the axes value

Question: The current ggbiplot  (code below) shows  X axis values from -5 to 5 and Y axis from -4 to 4. How can I change it so it will be X axis values from -6 to 6 and Y axis from -6 to 6?
Thanks.
Code:
library(devtools)
install_github("ggbiplot", "vqv")
library(ggbiplot)
data(wine)

ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
         varname.size = 8, labels.size=10,
         ellipse = TRUE, circle = TRUE) +
  scale_color_discrete(name = '') +
  geom_point(aes(colour=wine.class), size = 8) +
  theme(legend.direction ='horizontal',
        legend.position = 'top')

Answer: One possibility: Use xlim and ylim fuctnions
library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
p <-
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
         varname.size = 8, labels.size=10,
         ellipse = TRUE, circle = TRUE) +
  scale_color_discrete(name = '') +
  geom_point(aes(colour=wine.class), size = 8) +
  theme(legend.direction ='horizontal',
        legend.position = 'top')
p <- p + xlim(-6, 6) + ylim(-6, 6)
print(p)

ggbiplot - change the axes value


knockoutjs - html in textarea

Question: I am using knockoutjs and need a way to display raw html inside a text area. Is is stored in my database as encoded html e.g.
<object width="640" .....

But I want it to be displayed as
<object width="640"
for the user to edit.
Answer: I guess you are using text or value binding in textarea if you change it to html it will work as you needed:
<textarea data-bind="html: data"></textarea>

Here is an example: http://jsfiddle.net/vyshniakov/qTRSX/
Comment: This will display the html properly within the textarea when reading from ko observable to textarea but not the other way.
Comment: displaying the data is fine but capturing it using html does not work
Comment: its does not show this mark up `` how can i do it. thanks
Answer: If your html is already escaped then you're all set, see demo

knockoutjs - html in textarea


Is there any reason to target the defensive riders?

Question: There are some riders on the road (they always seem to be neutral as well) who have little icons floating over their heads.  Most of them give easily identifiable bonuses for killing them.  For example, the $ guy gives you cash, the + guy gives you health.
One of these riders has what looks like a little shield over his head.  Additionally, these defensive riders will parry 100% of your melee attacks, so they have to be killed either with explosives, firearms, or via environmental kill.  Critical strikes also seem to work, as they are unblockable.
Is there any reason for me to go after these guys like for the other bonus riders, or are they just more dangerous agents that should be avoided?
Answer: There is no reason to target defensive riders specifically in terms of reward like there is for money or health riders. However, there may still be reasons to take them out:

they're in the way of you killing someone specific, e.g. there's a money rider next to them and they'll block your attacks
you're being attacked by a group and don't have nitro to boost out
every kill gives you money and experience, including of defensive riders

I'd also like to add that there's another way to kill them: block one of their attacks and strike back, they can't block your counterattack. Still, if you meet one alone on the road like in your screenshot, it's fine to just avoid them.
Comment: It's possible, the window to attack after blocking isn't too long. Next time you find a solitary defensive rider again, test it by staying besides them until they attack, block and immediately counter. If it works, it's just your timing that's off. In my experience, while you don't have to attack instantly to the point that it's a test of reflexes, if you just sway to the side a bit before you come back into range and strike, that's already too slow.
Comment: I've found they block my counterattacks as well.  Is it possible I'm just not attacking fast enough?