text:
Q: Widgets not displaying with macOS vibrancy (NSVisualEffectView) I have currently got a PyQt5 application which is quite simple (just one button). I'd like for it to have vibrancy, so I've ported ObjC vibrancy code to Python. My vibrancy code is as follows:
frame = NSMakeRect(0, 0, * self.get_screen_size())  # get_screen_size returns the resolution of the monitor
view = objc.objc_object(c_void_p=self.winId().__int__())  # returns NSView of current window

visualEffectView = NSVisualEffectView.new()
visualEffectView.setAutoresizingMask_(NSViewWidthSizable|NSViewHeightSizable)  # equivalent to: visualEffectView.autoresizingMask = NSViewW...
visualEffectView.setFrame_(frame)
visualEffectView.setState_(NSVisualEffectStateActive)
visualEffectView.setMaterial_(NSVisualEffectMaterialDark)
visualEffectView.setBlendingMode_(NSVisualEffectBlendingModeBehindWindow)

window = view.window()
window.contentView().addSubview_positioned_relativeTo_(visualEffectView, NSWindowBelow, None)
    # equal to: [window.contentView addSubview:visualEffectView positioned:NSWindowBelow relativeTo:nul]

window.setTitlebarAppearsTransparent_(True)
window.setStyleMask_(window.styleMask() | NSFullSizeContentViewWindowMask)  # so the title bar is also vibrant

self.repaint()

All I'm doing to draw a button is: btn = QPushButton("test", self)
self is a class inherited from QMainWindow and everything else should be fairly unimportant.
Behaviour with the window.contentView().addSubview... line commented out (no vibrancy)

Behaviour without it commented out (with vibrancy)

Thanks!

A: The UI elements are actually drawn, but the NSVisualEffectView is covering them.
I fixed that issue by adding another view QMacCocoaViewContainer to the window.
You'll also need to set the Window transparent, otherwise the widgets will have a slight background border.
If you use the dark vibrant window also make sure to set appearance correctly, so buttons, labels etc. are rendered correctly.
frame = NSMakeRect(0, 0, self.width(), self.height())
view = objc.objc_object(c_void_p=self.winId().__int__())

visualEffectView = NSVisualEffectView.new()
visualEffectView.setAutoresizingMask_(NSViewWidthSizable|NSViewHeightSizable)
visualEffectView.setWantsLayer_(True)
visualEffectView.setFrame_(frame)
visualEffectView.setState_(NSVisualEffectStateActive)
visualEffectView.setMaterial_(NSVisualEffectMaterialUltraDark)
visualEffectView.setBlendingMode_(NSVisualEffectBlendingModeBehindWindow)
visualEffectView.setWantsLayer_(True)

self.setAttribute(Qt.WA_TranslucentBackground, True)

window = view.window()
content = window.contentView()

container = QMacCocoaViewContainer(0, self)
content.addSubview_positioned_relativeTo_(visualEffectView, NSWindowBelow, container)

window.setTitlebarAppearsTransparent_(True)
window.setStyleMask_(window.styleMask() | NSFullSizeContentViewWindowMask)

appearance = NSAppearance.appearanceNamed_('NSAppearanceNameVibrantDark')
window.setAppearance_(appearance)

Result:


text:
Q: Error using CMake to build SFML for Fedora 23 [xcb-image not found] [FIRST ERROR FIXED, ANOTHER ONE AT END OF POST]
Hello and thanks in advance, I am having an issue trying to build SFML for my Fedora 23 system so I may continue work on my game I was developing in Linux Mint (I like fedora better, and I want it to work for both Debian and openSUSE distributions). The problem occurs when I am building SFML in the CMake GUI, it gives me the error:
Could NOT find LIBXCB_IMAGE (missing:  LIBXCB_IMAGE_LIBRARY)
CMake Error at cmake/Modules/FindXCB.cmake:93 (message):
  xcb-image not found
Call Stack (most recent call first):
  src/SFML/Window/CMakeLists.txt:202 (find_package)

Configuring incomplete, errors occurred!

I checked to see if xcb-image was there by using the "locate" keyword and it returned:
[hunter@localhost ~]$ locate xcb-image
/usr/lib/libxcb-image.so.0
/usr/lib/libxcb-image.so.0.0.0 /usr/lib64/libxcb-image.so.0
/usr/lib64/libxcb-image.so.0.0.0

I also tried reinstalling libxcb to see if that would fix it but no cigar.
And yes, I read the tutorial SFML gives and made sure everything was installed and I followed the correct steps as well. link
Any idea why it's giving me this error? Compiler is the normal Fedora 23 gcc-c++ install... I'll provide any more information if needed.

*

*EDIT 1

Fixed by installing 'xcb-util-image-devel'
I was able to fix it; but now get a new error:
UDev not found.
UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include
      currently found includes: UDEV_INCLUDE_DIR-NOTFOUND
UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib
      currently found libs: UDEV_LIBRARIES-NOTFOUND
CMake Error at cmake/Modules/FindUDev.cmake:49 (MESSAGE):
  Could not find UDev library
Call Stack (most recent call first):
  src/SFML/Window/CMakeLists.txt:215 (find_package)

I used 'locate udev' and I found lots of stuff:
[hunter@localhost ~]$ locate udev
/etc/udev
/etc/udev/hwdb.bin
/etc/udev/hwdb.d
/etc/udev/rules.d
/etc/udev/udev.conf
/usr/bin/udevadm
/usr/lib/libudev.so.1
/usr/lib/libudev.so.1.6.4
/usr/lib/udev
/usr/lib/dracut/modules.d/95udev-rules
/usr/lib/dracut/modules.d/90dm/dm-pre-udev.sh
/usr/lib/dracut/modules.d/90mdraid/mdmon-pre-udev.sh
/usr/lib/dracut/modules.d/95udev-rules/59-persistent-storage.rules
/usr/lib/dracut/modules.d/95udev-rules/61-persistent-storage.rules
/usr/lib/dracut/modules.d/95udev-rules/load-modules.sh
/usr/lib/dracut/modules.d/95udev-rules/module-setup.sh
/usr/lib/dracut/modules.d/98dracut-systemd/dracut-pre-udev.service
/usr/lib/dracut/modules.d/98dracut-systemd/dracut-pre-udev.service.8
/usr/lib/dracut/modules.d/98dracut-systemd/dracut-pre-udev.service.8.asc
/usr/lib/dracut/modules.d/98dracut-systemd/dracut-pre-udev.sh
/usr/lib/python3.4/site-packages/pyudev
/usr/lib/python3.4/site-packages/pyudev-0.17-py3.4.egg-info
/usr/lib/python3.4/site-packages/blivet/udev.py
/usr/lib/python3.4/site-packages/blivet/__pycache__/udev.cpython-34.pyc
/usr/lib/python3.4/site-packages/blivet/__pycache__/udev.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__init__.py
/usr/lib/python3.4/site-packages/pyudev/__pycache__
/usr/lib/python3.4/site-packages/pyudev/_compat.py
/usr/lib/python3.4/site-packages/pyudev/_errorcheckers.py
/usr/lib/python3.4/site-packages/pyudev/_libc.py
/usr/lib/python3.4/site-packages/pyudev/_libudev.py
/usr/lib/python3.4/site-packages/pyudev/_qt_base.py
/usr/lib/python3.4/site-packages/pyudev/_util.py
/usr/lib/python3.4/site-packages/pyudev/core.py
/usr/lib/python3.4/site-packages/pyudev/device
/usr/lib/python3.4/site-packages/pyudev/glib.py
/usr/lib/python3.4/site-packages/pyudev/monitor.py
/usr/lib/python3.4/site-packages/pyudev/os.py
/usr/lib/python3.4/site-packages/pyudev/pyqt4.py
/usr/lib/python3.4/site-packages/pyudev/pyside.py
/usr/lib/python3.4/site-packages/pyudev/wx.py
/usr/lib/python3.4/site-packages/pyudev/__pycache__/__init__.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/__init__.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_compat.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_compat.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_errorcheckers.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_errorcheckers.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_libc.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_libc.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_libudev.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_libudev.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_qt_base.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_qt_base.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_util.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/_util.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/core.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/core.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/glib.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/glib.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/monitor.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/monitor.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/os.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/os.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/pyqt4.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/pyqt4.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/pyside.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/pyside.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/__pycache__/wx.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/__pycache__/wx.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/device/__init__.py
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__
/usr/lib/python3.4/site-packages/pyudev/device/_device.py
/usr/lib/python3.4/site-packages/pyudev/device/_errors.py
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__/__init__.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__/__init__.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__/_device.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__/_device.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__/_errors.cpython-34.pyc
/usr/lib/python3.4/site-packages/pyudev/device/__pycache__/_errors.cpython-34.pyo
/usr/lib/python3.4/site-packages/pyudev-0.17-py3.4.egg-info/PKG-INFO
/usr/lib/python3.4/site-packages/pyudev-0.17-py3.4.egg-info/SOURCES.txt
/usr/lib/python3.4/site-packages/pyudev-0.17-py3.4.egg-info/dependency_links.txt
/usr/lib/python3.4/site-packages/pyudev-0.17-py3.4.egg-info/top_level.txt
/usr/lib/python3.4/site-packages/sos/plugins/udev.py
/usr/lib/python3.4/site-packages/sos/plugins/__pycache__/udev.cpython-34.pyc
/usr/lib/python3.4/site-packages/sos/plugins/__pycache__/udev.cpython-34.pyo
/usr/lib/systemd/systemd-udevd
/usr/lib/systemd/system/dracut-pre-udev.service
/usr/lib/systemd/system/initrd-udevadm-cleanup-db.service
/usr/lib/systemd/system/systemd-udev-settle.service
/usr/lib/systemd/system/systemd-udev-trigger.service
/usr/lib/systemd/system/systemd-udevd-control.socket
/usr/lib/systemd/system/systemd-udevd-kernel.socket
/usr/lib/systemd/system/systemd-udevd.service
/usr/lib/systemd/system/initrd.target.wants/dracut-pre-udev.service
/usr/lib/systemd/system/sockets.target.wants/systemd-udevd-control.socket
/usr/lib/systemd/system/sockets.target.wants/systemd-udevd-kernel.socket
/usr/lib/systemd/system/sysinit.target.wants/systemd-udev-trigger.service
/usr/lib/systemd/system/sysinit.target.wants/systemd-udevd.service
/usr/lib/udev/ata_id
/usr/lib/udev/bcache-register
/usr/lib/udev/cdrom_id
/usr/lib/udev/check-ptp-camera
/usr/lib/udev/collect
/usr/lib/udev/hwdb.d
/usr/lib/udev/iphone-set-info
/usr/lib/udev/ipod-set-info
/usr/lib/udev/libinput-device-group
/usr/lib/udev/libinput-model-quirks
/usr/lib/udev/mtd_probe
/usr/lib/udev/mtp-probe
/usr/lib/udev/pcmcia-check-broken-cis
/usr/lib/udev/pcmcia-socket-startup
/usr/lib/udev/rename_device
/usr/lib/udev/rules.d
/usr/lib/udev/scsi_id
/usr/lib/udev/udev-add-printer
/usr/lib/udev/udev-configure-printer
/usr/lib/udev/usb_modeswitch
/usr/lib/udev/v4l_id
/usr/lib/udev/hwdb.d/20-OUI.hwdb
/usr/lib/udev/hwdb.d/20-acpi-vendor.hwdb
/usr/lib/udev/hwdb.d/20-bluetooth-vendor-product.hwdb
/usr/lib/udev/hwdb.d/20-net-ifname.hwdb
/usr/lib/udev/hwdb.d/20-pci-classes.hwdb
/usr/lib/udev/hwdb.d/20-pci-vendor-model.hwdb
/usr/lib/udev/hwdb.d/20-sane-backends.hwdb
/usr/lib/udev/hwdb.d/20-sdio-classes.hwdb
/usr/lib/udev/hwdb.d/20-sdio-vendor-model.hwdb
/usr/lib/udev/hwdb.d/20-usb-classes.hwdb
/usr/lib/udev/hwdb.d/20-usb-media-players.hwdb
/usr/lib/udev/hwdb.d/20-usb-vendor-model.hwdb
/usr/lib/udev/hwdb.d/60-evdev.hwdb
/usr/lib/udev/hwdb.d/60-keyboard.hwdb
/usr/lib/udev/hwdb.d/69-libmtp.hwdb
/usr/lib/udev/hwdb.d/70-mouse.hwdb
/usr/lib/udev/hwdb.d/70-pointingstick.hwdb
/usr/lib/udev/hwdb.d/90-libinput-model-quirks.hwdb
/usr/lib/udev/rules.d/10-dm.rules
/usr/lib/udev/rules.d/11-dm-lvm.rules
/usr/lib/udev/rules.d/11-dm-mpath.rules
/usr/lib/udev/rules.d/13-dm-disk.rules
/usr/lib/udev/rules.d/39-usbmuxd.rules
/usr/lib/udev/rules.d/40-iio-sensor-proxy.rules
/usr/lib/udev/rules.d/40-libgphoto2.rules
/usr/lib/udev/rules.d/40-usb-media-players.rules
/usr/lib/udev/rules.d/40-usb_modeswitch.rules
/usr/lib/udev/rules.d/50-udev-default.rules
/usr/lib/udev/rules.d/56-hp_conf_usb.rules
/usr/lib/udev/rules.d/56-hpmud.rules
/usr/lib/udev/rules.d/60-block.rules
/usr/lib/udev/rules.d/60-cdrom_id.rules
/usr/lib/udev/rules.d/60-drm.rules
/usr/lib/udev/rules.d/60-evdev.rules
/usr/lib/udev/rules.d/60-fprint-autosuspend.rules
/usr/lib/udev/rules.d/60-net.rules
/usr/lib/udev/rules.d/60-pcmcia.rules
/usr/lib/udev/rules.d/60-persistent-alsa.rules
/usr/lib/udev/rules.d/60-persistent-input.rules
/usr/lib/udev/rules.d/60-persistent-storage-tape.rules
/usr/lib/udev/rules.d/60-persistent-storage.rules
/usr/lib/udev/rules.d/60-persistent-v4l.rules
/usr/lib/udev/rules.d/60-raw.rules
/usr/lib/udev/rules.d/60-serial.rules
/usr/lib/udev/rules.d/61-gnome-bluetooth-rfkill.rules
/usr/lib/udev/rules.d/61-gnome-settings-daemon-rfkill.rules
/usr/lib/udev/rules.d/62-multipath.rules
/usr/lib/udev/rules.d/63-md-raid-arrays.rules
/usr/lib/udev/rules.d/64-btrfs.rules
/usr/lib/udev/rules.d/64-md-raid-assembly.rules
/usr/lib/udev/rules.d/65-libwacom.rules
/usr/lib/udev/rules.d/65-md-incremental.rules
/usr/lib/udev/rules.d/65-sane-backends.rules
/usr/lib/udev/rules.d/69-bcache.rules
/usr/lib/udev/rules.d/69-cd-sensors.rules
/usr/lib/udev/rules.d/69-dm-lvm-metad.rules
/usr/lib/udev/rules.d/69-libmtp.rules
/usr/lib/udev/rules.d/69-xorg-vmmouse.rules
/usr/lib/udev/rules.d/70-mouse.rules
/usr/lib/udev/rules.d/70-power-switch.rules
/usr/lib/udev/rules.d/70-printers.rules
/usr/lib/udev/rules.d/70-spice-vdagentd.rules
/usr/lib/udev/rules.d/70-touchpad-quirks.rules
/usr/lib/udev/rules.d/70-uaccess.rules
/usr/lib/udev/rules.d/70-wacom.rules
/usr/lib/udev/rules.d/71-seat.rules
/usr/lib/udev/rules.d/73-seat-late.rules
/usr/lib/udev/rules.d/75-net-description.rules
/usr/lib/udev/rules.d/75-probe_mtd.rules
/usr/lib/udev/rules.d/77-mm-cinterion-port-types.rules
/usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules
/usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules
/usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules
/usr/lib/udev/rules.d/77-mm-mtk-port-types.rules
/usr/lib/udev/rules.d/77-mm-nokia-port-types.rules
/usr/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
/usr/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules
/usr/lib/udev/rules.d/77-mm-simtech-port-types.rules
/usr/lib/udev/rules.d/77-mm-telit-port-types.rules
/usr/lib/udev/rules.d/77-mm-usb-device-blacklist.rules
/usr/lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
/usr/lib/udev/rules.d/77-mm-x22x-port-types.rules
/usr/lib/udev/rules.d/77-mm-zte-port-types.rules
/usr/lib/udev/rules.d/78-sound-card.rules
/usr/lib/udev/rules.d/80-drivers.rules
/usr/lib/udev/rules.d/80-kvm.rules
/usr/lib/udev/rules.d/80-libinput-device-groups.rules
/usr/lib/udev/rules.d/80-mm-candidate.rules
/usr/lib/udev/rules.d/80-net-setup-link.rules
/usr/lib/udev/rules.d/80-udisks2.rules
/usr/lib/udev/rules.d/85-nm-unmanaged.rules
/usr/lib/udev/rules.d/85-regulatory.rules
/usr/lib/udev/rules.d/90-alsa-restore.rules
/usr/lib/udev/rules.d/90-fwupd-devices.rules
/usr/lib/udev/rules.d/90-libgpod.rules
/usr/lib/udev/rules.d/90-libinput-model-quirks.rules
/usr/lib/udev/rules.d/90-pulseaudio.rules
/usr/lib/udev/rules.d/90-vconsole.rules
/usr/lib/udev/rules.d/91-drm-modeset.rules
/usr/lib/udev/rules.d/95-cd-devices.rules
/usr/lib/udev/rules.d/95-dm-notify.rules
/usr/lib/udev/rules.d/95-upower-csr.rules
/usr/lib/udev/rules.d/95-upower-hid.rules
/usr/lib/udev/rules.d/95-upower-wup.rules
/usr/lib/udev/rules.d/98-kexec.rules
/usr/lib/udev/rules.d/99-qemu-guest-agent.rules
/usr/lib/udev/rules.d/99-systemd.rules
/usr/lib64/libgudev-1.0.so.0
/usr/lib64/libgudev-1.0.so.0.2.0
/usr/lib64/libudev.so.1
/usr/lib64/libudev.so.1.6.4
/usr/lib64/pulse-7.0/modules/module-udev-detect.so
/usr/sbin/udevadm
/usr/share/bash-completion/completions/_udevadm
/usr/share/bash-completion/completions/udevadm
/usr/share/doc/libgudev
/usr/share/doc/python3-pyudev
/usr/share/doc/libgudev/NEWS
/usr/share/doc/python3-pyudev/CHANGES.rst
/usr/share/doc/python3-pyudev/README.rst
/usr/share/licenses/libgudev
/usr/share/licenses/python3-pyudev
/usr/share/licenses/libgudev/COPYING
/usr/share/licenses/python3-pyudev/COPYING
/usr/share/man/man5/udev.conf.5.gz
/usr/share/man/man7/udev.7.gz
/usr/share/man/man8/dracut-pre-udev.service.8.gz
/usr/share/man/man8/systemd-udevd-control.socket.8.gz
/usr/share/man/man8/systemd-udevd-kernel.socket.8.gz
/usr/share/man/man8/systemd-udevd.8.gz
/usr/share/man/man8/systemd-udevd.service.8.gz
/usr/share/man/man8/udevadm.8.gz
/usr/share/pkgconfig/udev.pc
/usr/share/vim/vim74/ftplugin/udevconf.vim
/usr/share/vim/vim74/ftplugin/udevperm.vim
/usr/share/vim/vim74/ftplugin/udevrules.vim
/usr/share/vim/vim74/syntax/udevconf.vim
/usr/share/vim/vim74/syntax/udevperm.vim
/usr/share/vim/vim74/syntax/udevrules.vim
/usr/share/zsh/site-functions/_udevadm
/var/cache/PackageKit/metadata/updates/packages/python3-pyudev-0.19.0-1.fc23.noarch.rpm

A: Same principle here : you should try to find the "-devel" package that contains the files that CMake is looking for (i.e the .so without a number appended at the end, and the header files)
Here the package you are looking for may be systemd-devel  (udev library is now part of systemd)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Using REST at web What is REST when using in WEB ?
Too many documentations, but is it just a simple attitude using existing html protocol, that may replace web-services.
Is it as following?
Like PAYPAL ...
Just using method from a specific server using http protocol: https://?
and on the server side using the value by get/post methods.
Entities:
Clients - every client that has access to server A (for the specific service).
Server A - Server (for the client use) that has an access to server (with an access key, like PAYPAL supports).
Server B - Server that has the API with some methods that returns to client.
Steps:
1. User ask from server A (server A uses the API) for a token.
2. Server A open a session with server B and send request for token (with the access key provided) to server B
3. Server B may reject or accept the request and send back the token to server A.
4. Server A may keep the token in session variable and send the token to the client.
5. Client use the token
6. Client send requests to server A, that send requests to server B with the token, keeping the same session.

Is the above correct?
Is that the concept of REST?
If not - need some guidelines, please.
Thanks :)

A: I think the concept of tokens is beyond the REST concept.
Rest (Representational state transfer) has more to do with the way you use the http methods to represent your desired action, like going to /users with get should give you back an arrays of users, then post in /users/1234 should create a user with id 1234 for example, or delete in /users/1234 should delete the user with 1234 id, etc.
It is an architecture where the http methods have a meaning.
Anyway there are more details of it, I would continue to read more with below;
http://en.wikipedia.org/wiki/Representational_state_transfer


text:
Q: Connecting to SQL Server from javascript properly, quickly I have a Javascript application that requires two queries to a MS SQL Server database. I need this done as simply and lightly as possible, because this is a high speed application, with data refreshing constantly. I've read that there is only one (improper) way to do it (using ActiveX) directly and only through IE, and I'd rather do it properly with a server side language and have it work in Chrome. I am a Java programmer, but I'd rather avoid starting with connecting to Java if possible. Is there any other framework/server side language that can quickly, easily, and lightly connect to my database? I don't want my users to need to download any software or adjust their browsers, so something that I can just add to the folder with the web pages would be optimal. If you know of a good system, can you include a link to whatever needs downloading, a basic explanation of how to use it - limiting it to exactly what I need to make a basic select query, and why you think this system is the simplest, fastest option?
Thanks!

A: You might need to write some backend code in Python, NodeJs, C# or Java to create a Web API. Web API is a wrapper around your MS SQL so that you can apply access control and error handling logics.
C# has scaffolding projects for quickly create a Web API, but it's going to use Entity Framework, which has known performance issues.
NodeJs has a package for connecting with MS SQL, but you'll need to write custom code to wire it up with an HTTP server package such as Express JS.

A: It is impossible to connect to a MS SQL database via JavaScript in a web browser. You would need back end code on a server to do that for you.

A: You can't directly query a database using JavaScript. Even if you found an ActiveX workaround, you shouldn't do this. If a web client was able to directly access the filesystem either locally or on the server it would be a security nightmare.
If you want a web based client to a backend database you'll have to use some kind of server side scripting. If you're already familiar with Java then why not use a CGI script written in Java?

A: Disregard all answers telling you that's impossible. You can do it with javascript (however, it's really not recommended because of security matters) You should not connect to a database directly from the client browser, but if you need/want to do it, you can use ActiveXObject:
var conn = new ActiveXObject("ADODB.Connection"),
    cString="Data Source=yourServer;Initial Catalog=yourCatalog;User ID=yourUserId;Password=yourPass>;Provider=SQLOLEDB";

conn.Open(cString);
var rs = new ActiveXObject("ADODB.Recordset");

rs.Open("SELECT * FROM table WHERE id = 1", conn);
rs.MoveFirst
while(!rs.eof)
{
   document.write(rs.fields(1));
   rs.movenext;
}

rs.close;
conn.close;

In the connection string, replace all words starting with your with your real value.


text:
Q: Ansible playbook to fetch JSON file from an API via 'uri' I wrote an Ansible playbook intend to fetch the list from an API as JSON file using uri module as below.
- name: API check
  gather_facts: no

  tasks:

  - name : "Get the list as JSON"
    uri:
     url: http://sampleapitest.com/api
     user: test
     password: test
     force_basic_auth: yes
     status_code: 200
     body_format: json
     dest: "/home/peterw/list.json"

But when I am running the Playbook it is showing that the Playbook needs Hosts file. But I have access only to the URL, not to the SSH port 22.
ERROR! the field 'hosts' is required but was not set

I am new to Ansible. Can anyone please help me to fetch the details from the API as JSON file?

A: you have lot of ways to resolve your problem
either you have hosts defined, and you want to use an ansible module only on localhost, so you add delegate_to: localhost  and run_once: true  to signify i just want to play this task only one time.
- hosts:  listohhosts
  tasks:
    - name: what does the task
      moduleusing:
        param1:
         :
      delegate_to: localhost
      run_once: true

either you add hosts: localhost

A: It is possible to write tasks like
  - name: Gather stored entitlement from repository service
    local_action:
      module: uri
      url: "https://{{ REPOSITORY_URL }}/api/system/security/certificates"
      method: GET
      url_username: "{{ ansible_user }}"
      url_password: "{{ ansible_password }}"
      validate_certs: yes
      return_content: yes
      status_code: 200
      body_format: json
    check_mode: false
    register: result

  - name: Show result
    debug:
      msg: "{{ result.json }}"
    check_mode: false

which in example gather installed certificates from a JFrog Artifactory repository service via REST API call, as well
  - name: Gather stored entitlement from repository service
    action:
      module: uri
      ...

local_action
Same as action but also implies delegate_to: localhost

for Controlling where tasks run: delegation and local actions.


text:
Q: Oracle Query design I have two tables joining with left outer join
Employee
Employeed_Id    Employee_Name   Location_id

1               David           1
2               Andrew          2
3               Mike            3
4               steve           4

Employee_profile
profile_id     profile_name   location_id  profile_location
1              manager           1          NYC
2              accountant        2          Jersey
3              engineer          1          Mexico
4              trainer           3           Boston

This is the common query I have to retrieve the all employees based on location.here profile_location is unique.
Problem is, in some part of the application profile_location is not required. So Outer join between above tables is not required.
How to develop a query, so it should function normally in case of profile_location not have input value with outer join.
Below is my Query:
select e.Employee_Name
from Employee e,
     Employee_profile ep
 where e.location_id (+) = ep.location_id
 and ep.profile_location='xxxxx'

A: If you want to return those records that match your passed in profile_location but also want to return all records when the location does not exist, then you can use something like this:
select distinct e."Employee_Name"
from Employee e
left join Employee_profile ep
  on e."Location_id" = ep."location_id"
where ep."profile_location" = 'xxx'
    or not exists (select ep1."profile_location"
                   from Employee_profile ep1
                   where  ep1."profile_location" = 'xxx')

See SQL Fiddle with Demo
If you pass in a value that does not exist like 'xxx' the result is:
| EMPLOYEE_NAME |
-----------------
|         David |
|        Andrew |
|         steve |
|          Mike |

If you pass in 'NYC' the result is:
| EMPLOYEE_NAME |
-----------------
|         David |

A: select e.Employee_Name
from Employee e,
     Employee_profile ep
 where e.location_id (+) = ep.location_id
 and (ep.profile_location='xxxxx'
   Or ep.profile_location is null)


text:
Q: ARM carry flag on EOR/XOR and AND I was looking up some ARM assembly and i notice EOR/XOR and AND all set the C and O flag. How does that work? Are they always cleared? what conditions are they set?

A: I don't believe the normal AND/EOR set the carry and overflow flags at all. The ANDS and EORS variants (AND/EOR with set) can set carry but only if the right hand side is a shifted operand. Neither of these affect the overflow flag at all.
For example,
ANDS R0,R1,R2, LSR #1

will set carry depending on b0 of R2. If the bit was 1 (i.e., R2 was odd), carry will be set.
See here for the gory details (chapter 3, the instruction set).

A: If you decide to continue with ARM assembler you need a copy of the ARM ARM, which is the ARM Architecture Reference Manual.  There are many versions and each have their own "features".  I recommend collecting as many as you can but thats another story.  There are a number of ways to get an electronic copy for free.  Either way:
AND
you need the S bit set which for ARM means use ANDS instead of AND.  For thumb mode you are always using ANDS but gas for example refuses to accept ANDS in thumb mode (but always disassembles it as an ands).
If S==1 and Rd == R15 then
  CPSR=SPSR
else if S==1
  N Flag = Rd[31]
  Z Flag = if Rd == 0 then 1 else 0
  C Flag = shifter_carry_out
  V flag = unaffected

EOR is the same as AND when it comes to the flags

A: As other posters noted, the C flag is updated based on a shift that is optionally applied to one of the source registers before the operation.
The V (overflow) flag is unaffected by these instructions.
The Z flag is set if the result is exactly zero, and the N flag is set if the result is negative when viewed as a twos-complement integer (i.e. the high order bit is a one).

A: Recall that you can arbitrarily shift the result following the operation. The carry flag is set based on the carry out from the barrel shifter. The overflow flag is never affected.


text:
Q: When are database triggers bad?
Possible Duplicate:
Are database triggers evil?

There is lot of negative information on database triggers, just want to get the community's take on when is it good vs bad.

A: Database triggers are bad when they are used when other features are more appropriate.
Features which should be considered before attempting to use triggers:
Check constraints
Foreign key constraints
Unique indexes/constraints
(Persisted) computed columns
(Indexed) Views (if a trigger is attempting something like updating an aggregate, say)
Stored procedures (if direct table access can be prohibited)
After that point, triggers can be appropriately used without being "bad".  Triggers should always be designed to have a small footprint.

A: Because they're "magic". They aren't very visible and they can do lots of work.
I've seen good developers take a lot of time trying to track down issues that are trigger related because they just didn't think to look for them. Also, they are very rarely needed.

A: Here are a few articles that should help you figure out by yourself for your needs.

*

*Pros and Cons of Triggers vs. Stored Procedures for Denormalization (SO question) ;

*Choice Between Stored Procedures, Functions, Views, Triggers, Inline SQL.

In short, Triggers are useful for the processing of massive amount of data, when complex DML has to be conducted. To answer your question, if this is not the case, you got your answer as per when a trigger is bad.

A: I think they're OK when they are used to populate a separate, one-off set of tables for things like logging, aggregation etc. for security or creating metadata for example.
When you start altering your "live" data or "looping back" into your biz info tables, that's when they become evil and unwieldy. They are also utterly unnecessary for this. There is nothing that a trigger does that a stored proc cannot do.
I feel like they are SQL's evil equivalent to GOTOs in programming languages. Legal, but to be avoided unless absolutely necessary, and they are NEVER absolutely necessary.


text:
Q: Finding all natural $x$, $y$, $z$ satisfying $7^x+1=3^y+5^z$ The problem goes as follows:

Find all possible pairs of $x,y,z \in \mathbb{N}$ which satisfy the equation $7^x+1=3^y+5^z$

My first instinct was to continue by modding, but I don't think I can get anything out of it. The obvious solutions seem to be $x,y,z=1$ and $x,y,z=0$, but I am not really sure how to approach the problem.
Thanks in advance!

A: The two solutions you found are indeed all of them. In fact, we can solve this with a straight mod bash, which was surprising to me.
If any of $x,y,z$ are $0$, then we easily get $x=y=z=0$. If $y=1$, then $7^x=5^z+2$, and we readily get that $z=1$, so $x=1$ too. So now assume $y>1$ and $x,z>0$. Let the mod bash begin.
Taking mod $3$ implies that $z$ is odd. Taking mod $4$ implies that $x$ and $y$ have the same parity. Taking mod $5$ then implies that $x\equiv y\equiv 1\pmod 4$.
Now taking mod $7$, we get that either (a) $y\equiv1\pmod{12}$ and $z\equiv1\pmod{6}$ or (b) $y\equiv5\pmod{12}$ and $z\equiv5\pmod6$.
Now taking mod $9$, in case (a) we have $x\equiv5\pmod{12}$ and in case (b) we have $x\equiv9\pmod{12}$.
Consider case (a). If $z\equiv1\pmod{12}$, then taking mod $13$ gives $11+1\equiv3+5\pmod{13}$; if $z\equiv7\pmod{12}$ we still get a contradiction $11+1\equiv8+5\pmod{13}$.
Similarly in case (b), we get a contradiction in mod $13$, considering both cases $z\equiv 5\pmod{12}$ and $z\equiv11\pmod{12}$.


text:
Q: Android NFC in Embarcadero XE5 Trying to get NFC to work on Android in Embarcadero XE5.
Started with the following: https://forums.embarcadero.com/thread.jspa?threadID=97574
which seem to be working. Now would like to register callback for the NFC Intent
Java approach:
1. Register current activity as a listener
...
2. Receive Intent
@Override
protected void onNewIntent(Intent intent) {
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        NdefMessage[] msgs = NfcUtils.getNdefMessages(intent);
    }
}

Source: http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/
Delphi approach (as I would imagine):
1. Define methods available in Java interface

Source: https://forums.embarcadero.com/thread.jspa?messageID=634212
Question:
How do I register a listener for NFC intent messages and
how do I eventually get messages?

My guess would be to call enableForegroundDispatch method. Define it like:
procedure enableForegroundDispatch; cddcl;

to call it from Android API
But since I have never done this before, I do not know how to proceed

A: Edit : Seems I have missed a tag and the OP does not ask for Java code. Leaving this anyway for future reference
Your guess is correct, although it might be possible to define the intents you want to listen for in the AndroidManifest.xml, foreground dispatch really puts your app in the front, giving you the ability to capture all launched NFC intents.
The way it is described in the docs gives you a clue.
I assume you're familiar with the lifecycle of the Android Activities, Intent Dispatching and such.

Structure
Using the following structure, you'd have 4 fields :
private PendingIntent pendingIntent;
private IntentFilter[] mIntentFilters;
private String[][] mTechLists;
private NfcAdapter mNfcAdapter;

In the onCreate you'd get :
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    mIntentFilters = new IntentFilter[]{new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED)};
    mTechLists = new String[][]{new String[]{Ndef.class.getName()},
                new String[]{NdefFormatable.class.getName()}};
}

This does not actually enable the Foreground Dispatch yet, it is just the preparation.
The application would receive the Ndef and NdefFormatable technologies
Why do we subscribe for ACTION_NDEF_DISCOVERED ?
The order in which Android tries to handle the intent is as such :

*

*ACTION_NDEF_DISCOVERED

*ACTION_TECH_DISCOVERED

*ACTION_TAG_DISCOVERED

So we make sure our app is the first to be looked at by Android.

Enable FGD
Put the following line of code in the onResume method :
if (mNfcAdapter != null) {
        mNfcAdapter.enableForegroundDispatch(this, pendingIntent, mIntentFilters, mTechLists);
    }

Why is this in the onResume? As the docs state : enableForegroundDispatch() must be called from the main thread and only when the activity is in the foreground (calling in onResume() guarantees this)
This should enable your app to receive the intent, of course, when actually running.
If you want to receive intents while not running, you'd have to go to the AndroidManifest.


text:
Q: Specific WordPress permalinks link to wrong page I have a somewhat strange issue with WordPress today. This behaviour has only begun in the last week or so as far as I can ascertain.
Any page with the slug "downloads" links to it's parent page instead of to it's own page.
I have tried the following:

*

*Reset permalinks to default and then back to %postname%

*Disabled all plugins

*Physically cleared the cache

But none of the above fix the issue. The weird thing is that this behaviour is only happening for pages with the slug "downloads". For all other slugs it is fine.
For example there are multiple instances of the slug "get-involved" with different parents and all work fine. But when the same is done with "downloads" the links redirect to their parent. Is anyone else experiencing this issue?
I have also verified in fiddler that the pages are not redirecting, they are actually linking to the parent page with a response code of 200, there is no 301 or 302 thrown.

A: WordPress will automatically duplicate the same slug with a new name but you should check again, maybe you've re-writing slug manually before. And check your .htaccess.


text:
Q: Reportlab + SimpleDocTemplate + Table - create QR code with text - multiple pages I'm using Reportlab to create a pdf file that can span across multiple pages with the following format:
QR code + h1 paragraph + 2-3 lines of text
We need to support a dynamic number of elements with the format I described above.
I was thinking of using a Table inside a SimpleDocTemplate but couldn't find a way to support dynamic number of elements than can span over multiple pages.
How would you tackle this challenge?

A: This snippet is not fully working, but it could help you, for start
class StandardReport:

def __init__(self,):
    self.doc = BaseDocTemplate(destinationPath , showBoundary = 0, leftMargin=0.7*cm, rightMargin=0.7*cm, topMargin=0.7*cm, bottomMargin=0.7*cm, pagesize=A4)
    self.simpleFrame = Frame(self.doc.leftMargin, self.doc.bottomMargin, self.doc.width, self.doc.height - 5*cm, id='normal')

def createPdf(self):
    templates = [];
    self.doc.totalPages = 0;

    self.fill_sample();
    templates.append(SamplePageTempalte(self));
    self.doc.totalPages = self.doc.totalPages + 1;

    self.doc.addPageTemplates(templates);
    self.doc.build(self.Elements)

class SamplePageTempalte (PageTemplate):
    def __init__ (self, context):
        self.context = context
        self.largeur = self.context.doc.pagesize[0]
        self.hauteur = self.context.doc.pagesize[1]
        self.simpleFrame = Frame( self.context.doc.leftMargin, self.context.doc.bottomMargin, self.context.doc.width, self.context.doc.height - 3*cm, id='normal')
        PageTemplate.__init__ (self, id="GraphStatPageTemplateMonth", frames = [self.simpleFrame], pagesize=A4, onPage = self.context.footerAndHeader)


text:
Q: Type does not match the valueKind Microsoft.Win32.Win32RegistryApi.SetValue I have this code snippet where i am trying to write in the registry of windows so that i can expire a trail application.
    public RegistryKey rootKey;
    public RegistryKey regKey;
    public long expiry;
    // Use this for initialization
    void Start()
    {
        int period = 21; // trial period
        string keyName = "/Datefile.txt";
        long ticks = DateTime.Today.Ticks;

        rootKey = Registry.CurrentUser;
        regKey = rootKey.OpenSubKey(keyName);
        if (regKey == null) // first time app has been used
        {
            regKey = rootKey.CreateSubKey(keyName);
            expiry = DateTime.Today.AddDays(period).Ticks;
            regKey.SetValue("expiry", expiry, RegistryValueKind.QWord);
            regKey.Close();
        }
        else
        {
            expiry = (long)regKey.GetValue("expiry");
            regKey.Close();
            long today = DateTime.Today.Ticks;
            if (today > expiry)
            {
                Debug.Log("Application has expired.");
                Application.Quit();
            }

        }
    }

But it is giving me this error

ArgumentException: Type does not match the valueKind
Microsoft.Win32.Win32RegistryApi.SetValue . . .

Even i have tried to set Object in this line but it producing the same error
 regKey.SetValue("expiry", new Expiry(), RegistryValueKind.QWord);

A: This is only valid for DWord which is 32 bit.
You are trying to put long value into a 32-bit binary number. Which is not going to work.
You can cast the long to unsigned int.
regKey = rootKey.CreateSubKey(keyName);
expiry = DateTime.Today.AddDays(period).Ticks;
var uintVal = (uint)expiry;
regKey.SetValue("expiry", uintVal, RegistryValueKind.DWord);
regKey.Close();

Now when converting back you just:
long myTicks = Convert.ToInt64(myRegValue);

Edit:
Behind the scene QWord is stored as string, you can try to store it as string directly but I suspect this is not your problem
void Start()
{
    int period = 21; // trial period
    string keyName = "/Datefile.txt";
    long ticks = DateTime.Today.Ticks;

    rootKey = Registry.CurrentUser;
    regKey = rootKey.OpenSubKey(keyName);
    if (regKey == null) // first time app has been used
    {
        regKey = rootKey.CreateSubKey(keyName);
        expiry = DateTime.Today.AddDays(period).Ticks;
        regKey.SetValue("expiry", expiry.ToString(), RegistryValueKind.String);
        regKey.Close();
    }
    else
    {
        var s = regKey.GetValue("expiry").ToString();

        expiry = long.Parse(s);
        regKey.Close();
        long today = DateTime.Today.Ticks;
        if (today > expiry)
        {
            //Debug.Log("Application has expired.");
            //Application.Quit();
        }

    }
}


text:
Q: How to design bar chart on SSRS I want to create reports like below picture's report on SSRS.
Yellow parts mean SET_PHASE,
Green parts mean PROD_PHASE

And my query result like this:

I want to show for per line, all order and I want to show for per order, SETUP and PRODUCTION depends on duratıon time.
SET_PHASE's duration time is SET_DURATION,
PROD_PHASE's duration time is PROD_DURATION
I hope so my query is clear :) Could you help me about issue?

Answer:
Hello Alan,
Current situation I have just these data:
PROD100059335   SETUP   PRODUCTION  1   14  LINE 4
PROD100058991   SETUP   PRODUCTION  1   5   LINE 6
PROD100059259   SETUP   PRODUCTION  2   24  LINE 4
PROD100059188   SETUP   PRODUCTION  1   3   LINE 2
PROD100059248   SETUP   PRODUCTION  1   15  LINE 2
PROD100059055   SETUP   PRODUCTION  2   23  LINE 2
PROD100058754   SETUP   PRODUCTION  5   18  LINE 6

And If I use your query I just show "PROD100058754", "PROD100059259", "PROD100059055" these order. I don't understand why other data lost.
until "DECLARE @n TABLE(n int)" part I can show other data. but after that I can not show.
And I applied procedure on SSRS my report shows like this:

I couldn't do correctly and I don't know how can I fix them:(
for example "PROD100059259" this order normally has setup phase but on the report I don't have yellow field.
Do you have any suggestions for me?

A: OK, here is an attempt to give you what you want but there are a few caveats:

*

*The durations are scaled and no operation can take less than 1 time slot so the setup vs production duration is only approximate

*I haven't found a good way of labelling each bar so I've used tooltips

First the code... I've added lots of comments so hopefully you can follow it thru, it's based on your sample data.
NOTE: I've update the table as it now seems like you are using integer durations rather than the 00:00 format from your first example.
-- CREATE A TEST TABLE AND POPULATE IT
DECLARE @data TABLE(STR_ORDER_ID varchar(20), SET_DURATION varchar(10), PROD_DURATION varchar(10), Set_decimal int, Prod_Decimal int, Line varchar(10))

INSERT INTO @data
VALUES
('PROD100059335', NULL, NULL, 1, 14, 'LINE 4'),
('PROD100058991', NULL, NULL,1, 5, 'LINE 6'),
('PROD100059259', NULL, NULL,2, 24, 'LINE 4'),
('PROD100059188', NULL, NULL,1, 3, 'LINE 2'),
('PROD100059248', NULL, NULL,1, 15, 'LINE 2'),
('PROD100059055', NULL, NULL,2, 23, 'LINE 2'),
('PROD100058754', NULL, NULL,5, 18, 'LINE 6')

DECLARE @Gap int = 2 -- determines how many columns we use to separate each order

-- ASSUME durations are in hours/minutes or minutes/seconds and convert them to decimal minutes or decimal seconds respectively

-- COMMENTED THIS AS WE NO LONGER NEED IT. No longer required as durations are now integer values.
--UPDATE d
--    SET
--        Set_decimal = (CAST(LEFT(d.SET_DURATION, len(d.SET_DURATION)-3) AS INT) * 60) +  CAST(RIGHT(d.SET_DURATION, 2) AS INT)  ,
--        Prod_Decimal = (CAST(LEFT(d.PROD_DURATION, len(d.PROD_DURATION)-3) AS INT) * 60) +  CAST(RIGHT(d.PROD_DURATION, 2) AS INT)
--FROM @data d

-- CREATE A NORMALISED TABLE, this will just help to make the next steps simpler
DECLARE @normData TABLE(RowId INT IDENTITY (1,1), Line varchar(10), STR_ORDER_ID varchar(20), OperationOrder int, Operation varchar(10), Duration int)
INSERT INTO @normData (Line, STR_ORDER_ID, OperationOrder, Operation, Duration)
SELECT * FROM (
SELECT Line, STR_ORDER_ID, 1 as OperationOrder , 'SET' as Operation , Set_decimal FROM @data
UNION
SELECT Line, STR_ORDER_ID, 2 , 'PROD' , Prod_decimal FROM @data
UNION
SELECT Line, STR_ORDER_ID, 3 , 'GAP' , @Gap FROM @data )  u -- this adds dummy data that will act as gaps in hte timeline. Change 5 to whatever value suits you best
    ORDER BY Line, STR_ORDER_ID, OperationOrder

-- find the largest line running total duration per line and scale it to fit to 240 (so we dont go over 256 column limit in SSRS)
DECLARE @MaxDur INT = (SELECT MAX(rt) FROM (
                        select  *
                            , SUM(Duration) OVER(PARTITION BY Line ORDER BY Line, STR_ORDER_ID, OperationOrder) AS Rt
                         from @normData) mRt)

-- Now scale the values back so they fit but don't let any value become less than 1
IF @MaxDur > 240
    BEGIN
        UPDATE nd
            SET Duration = CASE WHEN nd.Duration / (@MaxDur/240) <1 THEN 1 ELSE nd.Duration / (@MaxDur/240) END
            FROM @normData nd
    END

/* check what we have so far by uncommenting this bit
select  *
    , SUM(Duration) OVER(PARTITION BY Line ORDER BY Line, STR_ORDER_ID, OperationOrder) AS Rt
 from @normData
--*/

-- ================================================================ --
-- At this point you 'may' have enough data to plot a bar chart. == --
-- ================================================================ --

-- CREATE A SIMPLE NUMBERS TABLE, we'll need this to act as our time series
DECLARE @n TABLE(n int)
DECLARE @i int  = 0
DECLARE @t int  = @MaxDur --(SELECT max(Duration) +5 FROM @normData) -- simple loop counter target set to slightly bigger than our highest duration
WHILE @i<@t
    BEGIN
        INSERT INTO @n SELECT @i
        SET @i = @i +1
    END

-- Join our numbers table to our real data
-- This will give us at least 1 row per time slot and associated activity during that time slot.
-- We can plot this driectly as a matrix.
SELECT *
    FROM @n n
        LEFT JOIN (
                -- Sub queries below give use a runnintg total, we then join this back to itself to get the previous
                -- running total and this will give us the 'time range' for each operation.
                SELECT
                    a.*
                    , ISNULL(b.Rt,0)+1 AS TimeStart
                    , a.RT AS TimeEnd
                    FROM
                    (SELECT *
                            , SUM(Duration) OVER(PARTITION BY Line ORDER BY Line, STR_ORDER_ID, OperationOrder) AS Rt
                         from @normData
                    ) a
                LEFT JOIN
                    (SELECT *
                            , SUM(Duration) OVER(PARTITION BY Line ORDER BY Line, STR_ORDER_ID, OperationOrder) AS Rt
                         from @normData
                    ) b
                    ON a.RowId = b.RowId + 1 and a.Line = b.Line
                ) d
            ON n.n between d.TimeStart and d.TimeEnd
    ORDER BY Line, STR_ORDER_ID, OperationOrder, n, TimeStart, TimeEnd

You can use the code above in your dataset.
The report design:
The report is very simple. It's a matrix with a single row group based on Line and a single column group based on n which is our time slot number.
I've added a blank row to act as a spacer between the 'bars'.

The expression of the cell background is
=SWITCH(
Fields!OperationOrder.Value = 1, "Yellow",
Fields!OperationOrder.Value = 2, "Green",
Fields!OperationOrder.Value = 3, Nothing,
True, Nothing
)

There is also a tooltip which displays STR_ORDER_ID and the operation name.
You get the following output.


text:
Q: get Image to encoded path to set image is not working? I am having  weird problem, I am having a user click button to choose an image. Then I am storing the encoded path in db and retreiving it later so I display the image in another activity but I am getting the following Exception
09-14 01:39:36.195: W/System.err(2241): java.io.FileNotFoundException: No content provider: /external/images/media/1113
09-14 01:39:36.195: W/System.err(2241):     at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:610)
09-14 01:39:36.195: W/System.err(2241):     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:542)
09-14 01:39:36.195: W/System.err(2241):     at android.content.ContentResolver.openInputStream(ContentResolver.java:377)

My button OnClick & store in db code:
                Uri selectedImage = imageReturnedIntent.getData();
                InputStream imageStream;
                try {
                    imageStream = getContentResolver().openInputStream(selectedImage);
                    BitmapFactory.Options options=new BitmapFactory.Options();
                    options.inSampleSize = 8;
                    Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream, null, options );
                    ivPictureChosen.setImageBitmap(yourSelectedImage);
                    storeEncodedImageInDb(selectedImage.getEncodedPath());
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Toast.makeText(this, "Couldn't pick image", Toast.LENGTH_SHORT).show();
                }

My retreival & showing image code:
            String imagePath = db.getEncodedImage();
            if(imagePath.length()>0){
                Uri mainImgeUri = Uri.parse(imagePath);
                InputStream imageStream;
                try {
                    imageStream = getContentResolver().openInputStream(mainImgeUri);
                    BitmapFactory.Options options=new BitmapFactory.Options();
                    options.inSampleSize = 8;
                    Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream, null, options );
                    mainImage.setImageBitmap(yourSelectedImage);
                } catch (FileNotFoundException e) {

                    e.printStackTrace();
                }
            }

How come the file is not found although thats the encoded path I got in the first place?

A: You will not only need the path but also scheme etc.
An Uri looks like so: http://www.stackoverflow.com or file://foo/bar/image.jpg.
encodedPath is only the path part of this, e.g. stackoverflow.com or /foo/bar/image.jpg.
Try to store the result of yourUri.toString() in the database and retrieve Uri.parse(theStringFromDatabase)

A: This is the way that encode and decode it to base64 string and return from base64 string, please have a look.
public static String encodeTobase64(String Path)
{
    Bitmap immagex=Bitmap.createScaledBitmap(BitmapFactory.decodeFile(Path), 140, 120, false);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    immagex.compress(Bitmap.CompressFormat.JPEG, 75, baos);
    byte[] b = baos.toByteArray();
    String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);

    Log.e("LOOK", imageEncoded);
    return imageEncoded;
}
public static Bitmap decodeBase64(String input)
{
    byte[] decodedByte = Base64.decode(input, 0);
    return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}


text:
Q: How I can get an img tag from string I have html string in variable in php. I want to get  tag from it. For example :
  $str ='

text
';

how can I get  (or any img tag plus its content) from this string?

A: All answers seem a bit messy and include regex.
You dont need it.
$str ='

text
';
echo strip_tags($str, '');

Will work nicely.
Strip_tags Ref

A: You can either use regular expressions, but you have to be careful to cater for any attributes that could be inside, or you can use the DOMDocument::loadHTML functionality along with DOMDocument::getElementsByTagName
$doc = new DOMDocument();

$doc->loadHTML($str);

// gets all img tags in the string
$imgs = $doc->getElementsByTagName('img');

foreach ($imgs as $img) {
    $img_strings[] = $doc->saveHTML($img);
}

You then have all your img tags in the $img_strings variable.
In the foreach loop you can also get attributes within the tag:
$img->getAttribute('src');

A: If I understand what you want to do correctly:
I would suggest something like
what is described here.
They created a function to select the string contained between two particular strings. Here is their function:
function getInnerSubstring($string,$delim){
    // "foo a foo" becomes: array(""," a ","")
    $string = explode($delim, $string, 3); // also, we only need 2 items at most
    // we check whether the 2nd is set and return it, otherwise we return an empty string
    return isset($string[1]) ? $string[1] : '';
}

So long as there is not another set of "" in your HTML then this should work for you.
If you use this you could search for what is only between those two "

A: User Regex in php. You should write regular expression for it
http://php.net/manual/en/function.preg-match.php
<img\s[^<>]*>


text:
Q: Segmentation Fault in template operator overload I am currently trying to get to grips with templates and operator overloading in C++. I've written a class which is basically a wrapper of a vector. I am trying to add operator overloading to the template class so I can iterate over the list but I keep receiving a segmentation fault with the overloaded operator.
Here is the template code.
template <class T> class List {
private:
    std::list<T *> *objects;
    int count;
    uint currentIndex;
    typename std::list<T*>::iterator item_iter;

public:
    T *currentItem;
    T *get(int idx);
    void add(T *obj);
    void start();
    bool empty();
    void next();
    List<T>& operator++();

    List() {
        this->currentItem = NULL;
        this->currentIndex = 0;
        this->count = 0;
        this->objects = new std::list<T *>;
    }

    ~List() {
        delete this->objects;
    }
};

template <class T>
void List<T>::add(T *obj) {
    this->objects->push_back(obj);
}

template <class T>
T *List<T>::get(int idx) {
    if (idx < this->objects->size()) {
      typename std::list<T*>::iterator it = this->objects->begin();
      std::advance(it, idx);
      return *it;
    } else {
      return NULL;
    }
}

template <class T>
void List<T>::start() {
    this->currentIndex = 0;
    if (this->objects->size() > 0) {
      this->item_iter = this->objects->begin();
      this->currentItem = *(this->item_iter);
    } else {
      this->currentItem = NULL;
    }
}

template <class T>
void List<T>::next() {
     if (!this->empty() && (this->currentIndex == 0) && (this->currentItem == NULL)) {
      this->start();
    } else if (this->currentIndex < this->objects->size() - 1) {
      this->currentIndex++;
      std::advance(item_iter, 1);
      this->currentItem = *item_iter;
    } else {
      this->currentItem = NULL;
    }
}

template <class T>
bool List<T>::empty() {
    return !this->objects->size();
}

template <class T>
List<T>& List<T>::operator++() {
    // Note: We don't get this far
    this->next();
    return *this;
}

The following code works.
List<Item> *items = new List<Item>();
items->addItem(new Item(20));

for(items->start(); items->currentItem != NULL; items->next()) {
    // Can work with items->currentItem;
}

The following code causes the segmentation fault.
List<Item> *items = new List<Item>();
items->addItem(new Item(20));

for(items->start(); items->currentItem != NULL; items++) {
    // Segmentation fault occurs before we get inside
}

A: @FrançoisAndrieux was correct.
I needed to dereference the items pointer.
for(items.start(); items.currentItem != NULL; ++items) {
    // Can now use current item
}

I also changed the return type.
template <class T>
List<T> List<T>::operator++() {
    this->next();
    return *this;
}


text:
Q: Esper / NEsper EPL event statement I'm pretty new in NEsper/Esper. I want to catch the event when two event occur less than 3 seconds, in other words when the timestamp difference between two events is smaller than 3 seconds. How can I define the EPL statement?
For example, the event is a Tick (which contains attributes- symbol, price and timestamp). When a Tick occurs after previous Tick less than 3 seconds, the second Tick should be captured. How can I write the EPL statement "select * from StockTick(symbol='anySymbol')...."?
Thanks in advance.
Narsu

A: There are quite a few ways. Lets use match-recognize. It seems to do what you want.
select * from SymbolTick
match_recognize (
  partition by symbol
  measures E1 as e1, E2 as e2
  pattern (E1 E2)
  define
    E2 as E1.timestamp.before(E2.timestamp, 3)
)

You can read up on "before" and "after". I think maybe I didn't get it right so please check and test.
For numeric timestamps one could instead do "E2.timestamp - E1.timestamp <= 3000".


text:
Q: Jane and Mark's and my house When an object belongs to three people, how do you write the possessive noun forms? If a house belongs to Jane, Mark, and myself, do I say 'Jane and Mark's and my house?'
Thank you.

A: When you are talking about ownership between multiple people, the possessive is indicated for each person if they each own something individually:

Jane's and Mark's and Taylor's houses.

Here, they each own a house of their own.
But if something is owned by all of them collectively, then you apply the possessive only to the final person in the list:

Jane and Mark and Taylor's house.

Here, it's a single house of which they share joint ownership.
Of course, things can get tricky when trying to express certain things, and you may need to rewrite the sentence in order to avoid confusion.
For example, what if Jane and Mark jointly own a house, while Taylor owns a different one?

Jane and Mark's and Taylor's houses.

This would be technically correct, but it leads to confusion. It would be clearer written as:

Jane and Mark's house and Taylor's house.

This makes it obvious who owns what. (Although the meaning is now clear, it still sounds a bit awkward and could perhaps be further rewritten.)
In your example sentence, however, you've used a pronoun. When you use pronouns it makes things even more difficult.

Mark and her house.
  Mark's and her houses.

Here, what I'm trying to express is either the house collectively owned by Mark and Jane or the houses owned by each. Neither works well.

His and her houses.

This is also ambiguous. It's not even clear if the pronouns are being used as possessive adjectives; I could be referring to houses that are meant to be used by two genders. (In other words, not a possessive at all but a simple noun phrase.)
Where does that leave your example sentence? Despite whatever technically correct rule there is, you will want to rephrase it.
Try:

The house that belongs to Jane, Mark, and me.

Of course, most people in conversation will understand who the owners are anyway and specifying them wouldn't be needed:

It's our house.
  It belongs to all of us.

A: You can, although it might be better to use the possessive for each of the owners:

It is Jane's and Mark's and my house.

However, this is still relatively unclear.  In such situations, I would choose to be a little more explicit:

The house belongs to all three of us -- Jane and Mark and me.

or

The house is all three of ours -- Jane's and Mark's and mine.


text:
Q: Assert and Verify both fail Please see the code below:
[TestClass]
public class UnitTest1
{
    Moq.Mock<ISayGoodMorning> GoodMorningMock;

    [TestInitialize]
    public void init()
    {
        GoodMorningMock = new Moq.Mock<ISayGoodMorning>();
        GoodMorningMock.Setup(x => x.GoodMorning()).Returns(Test());
    }

    [TestMethod]
    public void TestMethod1()
    {
        GoodMorningMock.Verify(x => x.GoodMorning(), Times.Once());
        Assert.AreEqual(g.SayGreeting(), "Hola");
    }

    public string Test()
    {
        return "Hola";
    }
}

The assert and the verify fail.  Why is that? Here is the code that is tested:
namespace ClassLibrary1
{
    public class SayGoodMorning : ISayGoodMorning
    {
        public string GoodMorning()
        {
            return "Good Morning";
        }
    }

    public interface ISayGoodMorning
    {
        string GoodMorning();
    }
}

namespace ClassLibrary2
{
    public class Greeting
    {
        public string SayGreeting()
        {
            ISayGoodMorning s = new SayGoodMorning();
            return s.GoodMorning();
        }
    }
}

A: First the subject under test needs to be refactored to inject the dependency to allow a mock to be used when testing. Either via constructor or method injection. (Explicit Dependencies Principle)
This example uses constructor injection
namespace ClassLibrary2 {
    public class Greeting {
        private readonly ISayGoodMorning speaker;

        public Greeting(ISayGoodMorning speaker) {
            this.speaker = speaker;
        }

        public string SayGreeting() {
            return speaker.GoodMorning();
        }
    }
}

Next the test needs to be restructured so that the Verify is done after exercising the method under test;
[TestClass]
public class UnitTest1 {
    Mock<ISayGoodMorning> GoodMorningMock;

    [TestInitialize]
    public void init() {
        //Arrange
        GoodMorningMock = new Mock<ISayGoodMorning>();
        GoodMorningMock.Setup(_ => _.GoodMorning()).Returns(Test());
    }

    [TestMethod]
    public void TestMethod1() {
        //Arrange cont'd
        var g = new ClassLibrary2.Greeting(GoodMorningMock.Object);
        var expected = "Hola";

        //Act
        var actual = g.SayGreeting();

        //Assert
        GoodMorningMock.Verify(_ => _.GoodMorning(), Times.Once());
        Assert.AreEqual(expected, actual);
    }

    public string Test() {
        return "Hola";
    }
}


text:
Q: How to work with DynamicNode in Umbraco I see some examples about DynamicNode's in Umbraco. But i don't see how i can use these.
Can anyone tell me which reference do i have to make to be able to use DynamicNode?
I'm using C#, ASP.NET webforms and Umbraco 4.7.

A: Have a look at:
Razor DynamicNode Cheat Sheet
You can see the references (using) at the bottom right of the page:
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContex

pehaps you need to add uComponents library (part of it it's now on umbraco core, but I think it's from 4.8.0 on).


text:
Q: How to test for a skin? I know I'll be asked to give context so I'll do so. I'm editing an .swf Mario game. I'm replacing the Mario fireball with a hammer but for some reason it only shoots right. Here is the code for the if statement (when you hit the space bar)
  if(Key_off == 0 && crouch == 0 && slide == 0)
  {
     if(_root.Fireball < 2)
     {
        _loc3_ = _root.level.getNextHighestDepth();
        var _loc3_ = _root.level.attachMovie("hammer","Enemy" + _loc3_,_loc3_);
        _loc3_._y = _Y;
        _loc3_._x = _X + (lr >= 0?17:-7);
        _loc3_.dir = lr * 3;
        _loc3_.vit = -19;
        _loc3_.lr = -1;
        _root.throw_hammerfx.start(0,0);
        Key_off = 1;
     }
  }

Note: I don't know a lot of these variables as I did not design this. Don't ask me what they mean. (although I've noticed that the height the hammer is thrown at is affected by how low 'vit' is)
So I plan to change the 'root.fireball' if statement to also check if the image of Mario facing right is shown. and make an elif statement to test for mario facing right. For mario facing  left, the data will be multiplied by -1. Failing that I think the hammer's motion is decided in its own actionscript. So I'll test for mario's image their instead.

A: Add a variable to player pressing left. Make it = 1 and for mario facing right make it =2. Check for what that variable = in your if mario presses 32.


text:
Q: Extending RestfulController for a base SubClassRestfulController is not working on grails 3.0.4 According to Extending Restful Controller
I Can create a SubClass of this RestfulController to become a Base controller class for every rest Controller I want.
Its OK subclassing this to a DIRECT resource controller.
Class BooksController extends RestfulController {
BooksController() {super(Book)}

But if instead I follow the grails DOC to create a base controller like this:
class MyRestController<T> extends RestfulController<T> {
static responseFormats = ['json', 'xml']
MyRestController(Class<T> domainClass) {this(domainClass, false)}
MyRestController(Class<T> domainClass, boolean readOnly) {
    super(domainClass, readOnly)
}

I got an error:
Failed to instantiate [clash.MyRestController]: No default constructor found;

I tried putting this controller inside controllers folder or src folder.
Only works if I create a default constructor but it is not what I want. I don want this class to serve API for any domain class but instead I want to create new controllers extending this class.
class BooksController extends MyRestController {
BooksController() {super(Book)}

A: The problem is that the class is being recognized as a controller and the framework is attempting to create an instance of the controller. One of the criteria we use to identify if that should happen is we check to see if the class is abstract. The class in question should be marked abstract
One way to make it work is to move it out of the grails-app/controllers directory and define it under src/main/groovy/.

A: Sorry. Just clean and run-app solved the problem. My fault


text:
Q: Why don't most NoSQL DBMSs have "pointers"? What is the objective reason fo why don't most NoSQL storage solutions have some kind of "pointers" for ultra-efficient joins, like the pre-relational DBMSs had?
I mean, I partially understand the theoretical reasons for why classical RDBMSs have ditched pointers (need to update them and double sync them for memory and disk, no "disks" fast enough to be treatable like random-access for some use cases, like modern SSDs can, etc.).
But of the many NoSQL solutions out there, why do just so few of them realize that this model would be awesome (exception I know of would be OrientDB and Neo4j) for many practical cases, not only ones that need graph traversals. I mean, when you need things like multi-joins, you need to ping pong Mongo and do N queries instead of one.
Isn't the use case of a NoSQL document-db overlapping enough with the one of graph DBs that such a feature would make sense and would just provide all the practical features of SQL-joins to the NoSQL solutions with not much extra cost, and for most queries would make indexes useless, and take up much less space for huge datasets?
(...and as a bonus any NoSQL solution would be ready to use as a graph db, and doing a ~100 nodes path length traversal of a graph stored in Mongo would just automagically work fast enough)

A: I believe the key problem is data locality and horizontal scalability. A premise of NoSQL is that the read-heavy models of RBDMSs, i.e. those that require joins, lead to bottlenecks.
Think of Twitter: the original data model was read-heavy, but the joins you need to make are insanely large (billions of tweets x hundreds of millions of users x tens of billions of follower-followee relations that are wildly varying in size [1-10M, or whatever aplusk has these days]).
When even the ids you'll want to join don't fit in a reasonable machine's RAM, calculating the overlap of ids becomes terribly expensive. If you take the actual data into account, horizontal scalability becomes next to impossible because there's no a priori knowledge which shards / machines will need to be hit. Storing all follower pointers in every follower-list would require insane bookkeeping for trivial changes, while not exploiting creation-time locality (or at least, creation-time locality per feed).
In a multi-tenant application, you can always shard by the tenants, or by the sales region or by agents or maybe even by time: You can find some locality criterion that is good for like > 95% of the cases.
With graphs, that becomes a lot more complicated, especially those which have certain connection properties (scale-free networks with small diameter / small world phenomenon): A simple post, say by a celebrity, can quickly spread through a large portion of the entire network, meaning that practically every query must hit the one node that holds the post.
Sure, the post itself would be cached by the web servers, but add likes and comments, or favorites and retweets and the story becomes a nightmare (writes!) Add in notification emails, content ranking and filtering and you're in true horror.

doing a ~100 nodes path length traversal of a graph stored in Mongo would just automagically work fast enough

If that data happens to be on 100 different nodes, the sheer network overhead will be in the range of 50ms, even in a single datacenter with no congestion and idle machines. If this spreads across the world or individual queries take a little longer, you'll quickly end up at 5000ms. Also, the query would fail if only one machine is down.
This depends too much on the details of the network, which is why the problem should be solved by application code, not by the data store.

when you need things like multi-joins, you need to ping pong Mongo and do N queries instead of one

When you need multi-joins in MongoDB, you're using the wrong tool for your data model, or vice versa. Multi-Join means normalized means read-heavy which battles the key concept of MongoDB. However, you can store quite large association lists even in MongoDB. But the tool becomes almost irrelevant here: If you look at Facebook TAO, for instance, there's little technology dependence in that.


text:
Q: Realizar serie de Fibonacci mediante un bucle 'dowhile()' hola me pueden ayudar donde tengo el error, tengo que hacer un función  fibonacci mediante un bucle 'dowhile
function fibonacci(numero)
var i =2;
    {
        var numeros=[0,1];
        do ( i < numero; i++) {
            numeros[i] = numeros[i - 2] + numeros[i - 1];
        }
        return numeros;
    }

    while(document.write(fibonacci(6)) );

A: Tienes varios errores en tu código:

*

*La variable var i=2 la has declarado fuera de la función. Fíjate que la has dejado fuera de las llaves de la función.

*En un bucle do-while la condición va en el while, no el do.

*La condición del while la has sacado fuera de la función y tendría que estar dentro, junto a las llaves del bucle. Además, estas intentando escribir el resultado desde ahí, pero la parte del while es para escribir la condición por lo que no vas a poder escribr desde ella.

*Desde fuera de la función puedes escribir el resultado de la función, pero sin tener que llamar a la parte while del bucle.

Tu código corregido:

function fibonacci(numero)
{
    var i=2;
    var numeros=[0,1];
    do{
        numeros[i] = numeros[i - 2] + numeros[i - 1];
        i++;
    }while(i < numero)
    return numeros;
}

document.write(fibonacci(6));


text:
Q: Homework - combinatorics How many solutions does this inequality have in non negative integers $x_i$:
$n \leq x_1+x_2+x_3+ \dots +x_n \le 2n$ ? Im stumped
I know I should add another variable but...I don't know.

A: Using generating functions,
The number of solutions of $x_1 + x_2 + x_3 + \dots + x_n = m$ is given by the coefficient of $x^m$ in $(1+x+x^2+...)^n = \dfrac1{(1-x)^n}$
So the number of solutions of $x_1 + x_2 + x_3 + \dots + x_n \le m$ is given by the coefficient of $x^m$ in $\dfrac1{(1-x)^{n+1}}$.  Say this is $f(m)$.  Then you need $f(2n)-f(n-1)$.
By the extended binomial theorem, $f(m) = \dfrac{(n+1)(n+2)(n+3)\dots(n+m)}{m!} = \binom{n+m}{m}$, so you can work out that
$$f(2n)-f(n-1) = \binom{3n}{n}-\binom{2n-1}{n}$$ is what you seek.

A: Hint: The number of (non-negative integer) solutions to
$$ x_1 + x_2 + \ldots + x_n \leq k, $$
is equal to the number of solutions to
$$x_1 + x_2 + \ldots + x_n + x_{n+1} = k, $$
which by stars and bars is ${ n+1 + k -1  \choose n}.$ $_\square$
Hence, conclude that the number of ways is ${3n \choose n } - { 2n-1  \choose n}$.

A: Suppose $s$ is  positive integer.  Now create a row of $n + s - 1$ blanks, and imagine you have $s-1$ $o$s and $n-1$ $x$s  .  There are ${n+s-1 \choose n-1}$ ways to position the $x$s in the blanks.  There is one way to position the $o$s.  Each of these permutations represents a solution to the equation
$$\sum_{k=1}^n x_k = s, \qquad x_k \ge 0, 1\le k \le n.$$
This correspondence is achieved by letting $x_1$ be the number of $o$s as the beginning, $x_2$, be the number of $o$s between $x_1$ and $x_2$, etc.
So this equation has ${n+s-1\choose n-1}$ solutions.
Now do some summation to get the solution to your problem.


text:
Q: SQL Server ogr2ogr batch unable to access ogr_MSSQLSpatial.dll I have an ogr2ogr batch file that reprojects SQL data into a new SQL Server table.
It works fine when I run the bat file manually but it fails if I run the bat file via a SQL Server stored procedure. I have given the gdal folders SQL Service permissions and xp_CommandShell is also enabled. I'm using
EXECUTE xp_CMDShell 'blah'

in the T-SQL script.
For some reason the ogr_MSSQLSpatial.dll causes it to fail.

ERROR 1: Can't load requested DLL: Z:\BroadSpectrumSQLTreeExtract\ogr2ogr\gdalplugins\ogr_MSSQLSpatial.dll

If I remove this dll the script runs via SQL but it means I need to add extra commands that the dll must take care of, such as setting source coordinate system. I haven't managed to get it working 100%. The furthest I got to was producing the reprojected table but the  geometry field is empty.
The DLL does contain SQL commands to the system tables. Could this be a SQL Server security issue stopping it from working?

A: I again had this problem with another ogr2ogr bat while executing with SQL. If I put the bat in the same folder as the dll's it works fine.


text:
Q: Scheffe Test in R I have 3 groups: Control, Experimental 1, Experimental 2. I am trying to run a Scheffe Test comparing the means of Experimental Groups 1 & 2 compared to the mean of the Control group.
I have tried a regular ScheffeTest(x=model), but that gives me the comparisons of each group (i.e. Control/Exp1; Control/Exp2; Exp1;Exp2).
How would I be able to compare the means of both experimental groups together with that of the control group?

ScheffeTest(x=model)

  Posthoc multiple comparisons of means : Scheffe Test
    95% family-wise confidence level

$Morality
                      diff     lwr.ci     upr.ci    pval
Exp 1-Control     -18.955128 -29.029235 -8.8810211 3.3e-05 ***
Exp 2-Control     -9.908715 -20.352044  0.5346142  0.0672 .
Exp 1-Exp 2        9.046414  -1.741866 19.8346927  0.1208

---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

As you can see, it is comparing each group, but I would like to only compare both experimental groups together versus the control

A: You can specify the comparison by using an appropriate contrast, specified with the contrast parameter. For example, contrasts=matrix(c(-1, 0.5, 0.5), ncol=1) should result in a comparison of Controls in your example against the two remaining groups.


text:
Q: Random points in spherical shell I have a sphere of radius $R_1$, and a smaller, concentric sphere of radius $R_2$. Let them be centered at the origin $(0,0,0)$. I need to generate random points with uniform density in the volume between the two sphere surfaces.
Here I found a solution for picking random points in a sphere volume, using
$$\frac{R_s U^{1/3}}{\sqrt{X_1^2 + X_2^2 + X_3^2}} (X_1, X_2, X_3)$$
where $X_1,X_2,X_3$ are independent normal random variables with mean 0 and variance 1, and $U$ is uniformly distributed between 0 and 1.
That strategy could be used for my problem as well, combining it with a rejection method:

*

*Generate a random point $(x,y,z)$ within $R_1$, using the abovementioned solution

*If $x^2 + y^2 + z^2 \leq R_2^2$, go back to step 1

But this is quite inefficient when the spherical shell is small. I guess it is possible to use a transformation method to generate points between $R_1$ and $R_2$. Can this be done?

A: No need to use accept-reject methods here.
First generate a point on the unit sphere ($r=1$). There are several ways, for example:
$$\theta \sim U[0,2\pi]$$
$$Z_0 \sim U[-1,1]$$
$$X_0=\sqrt{1-Z_0^2} \cos(\theta)$$
$$Y_0=\sqrt{1-Z_0^2} \sin(\theta)$$
Then generate a random radius $R$ in $[r_1,r_2]$ with density proportional to $r^2$ : first generate  $T \sim U[r_1^3,r_2^3]$ and then
$$R= T^{1/3}$$
(so that $f_R(r)=\frac{3}{r_2-r_1}{r^2}$ as desired)
Finally scale: $X=X_0 R$, $Y=Y_0 R$, $Z=Z_0  R$
It's also possible to generate the random point in the unit sphere volume, like in the question body, and then traslate+rescale radially.

A: A very good way to generate normal variables is to start with pairs of uniform variables
and apply a rejection method.  If you're considering these normal variables as input
to a rejection method, then, why not start with uniform variables so you only have
to do one level of rejection?
You could generate a random point uniformly distributed within the volume of the
sphere of radius $R_1$ (using three uniform variables and a rejection method)
and then move that point further from the origin
by applying a transformation of the form $r' = f(r)$
($r$ the original distance from the origin, $r'$ the distance after moving the point)
so that the result is uniformly distributed in the spherical shell.
The transformation function $f$ should satisfy
$$\int_r^{R_1} t^2 dt = k \int_{f(r)}^{R_1} t^2 dt$$
where $k = \dfrac{R_1^3}{R_1^3-R_2^3}$
is the ratio of the volume of the entire sphere to the volume of the spherical shell.
I get the relationship
$$(f(r))^3 = \frac 1k r^3 + \frac{k-1}{k} R_1^3
= \frac{R_1^3-R_2^3}{R_1^3} r^3 +  R_2^3 $$
by computing both integrals and rearranging terms.
Note that $f(0) = R_2$ and $f(R_1) = R_1$, as desired.
Another way of writing this is
$$\frac{f(r)}{r} = \left(\frac{R_1^3-R_2^3}{R_1^3} + \frac{R_2^3}{r^3} \right)^{\frac13}.$$
So the procedure is to generate three uniform variables, $U_1$, $U_2$, and $U_3$ (between $-R_1$ and $R_1$),
and compute $r = \sqrt{U_1^2 + U_2^2 + U_3^2}.$
If $r \leq R_1$, the desired point within the spherical shell is
$$(x,y,z) =
 \left(\frac{R_1^3-R_2^3}{R_1^3} + \frac{R_2^3}{r^3} \right)^{\frac13} (U_1, U_2, U_3).$$
If $r > R_1$ you reject the three variables and try again.
You will be able to use $\frac\pi6$ of the triples you generate,
which is worse than the $\frac\pi4$ of pairs of uniform variables
that you would be able to use when generating pairs of normal variables
by the usual rejection method, but a lot better than rejecting everything inside
the shell if the shell is thin.


text:
Q: Why does my WP_Query pagination on a custom page.php only loads the homepage? What I am looking to do:
Setup WP_Query pagination in a custom php template file with a custom WP_Query query (It's not originally mine, I'm just fixing it). The file loops through posts (category "Publishing") and adds them to the page (5 at once).
My code should work it seems to be very well done and follows the WP documentation. I wonder what bug is stopping it from working.
What I have done

*

*Tried to add the pagination myself with paginate_links(array). I did get the pagination bar but every time I clicked a link it just jumped back to the homepage. But there was a /page/2/ etc. added to the url.

*Tried the WP-PageNavi plugin added:
$custom_query->query(array('category_name' => 'Publishing', 'page' => get_query_var('paged')));

and used the shortcode:
wp_pagenavi(array( 'query' => $custom_query ) );

Result is the same like in 1). It always jumps back to the homepage but adds the slug to the URL.
What I am trying to do
Add a pagination at the bottom of the page that works. I guess there might be some problem with how the loop is working in my template?
My current code with the WP-PageNavi plugin:
<?php

$args = array(

    "category_name"    => "Publishing",
    "orderby"          => "post_date",
    "order"            => "DESC",
    "post_type"        => "post",
    "post_status"      => "publish",
    );

$custom_query = new WP_Query($args);
$custom_query->query(array('category_name' => 'Publishing', 'page' => get_query_var('paged')));

if ( $custom_query->have_posts() ) :
    while ( $custom_query->have_posts() ) : $custom_query->the_post();

        { $id=$post->ID; $image=get_the_post_thumbnail($id, 'full');
            if( class_exists('Dynamic_Featured_Image') ) {
                global $dynamic_featured_image;

                $featured_images = $dynamic_featured_image->get_featured_images($id );

            }

                echo "
".get_the_date( 'd F Y', $post->ID )."ID)."?kat=publishing> [Direct Link]
";
                ?>

                                            <?php echo $image; ?>

                                        <?php foreach($featured_images as $featured_image): ?>

                                                <img src="<?php echo $featured_image['full']; ?>"
                                                data-splide-lazy="<?php echo $featured_image['full']; ?>"
                                                loading="lazy"
                                                >

                                        <?php endforeach; ?>

            <?php

            echo "
";
                the_title();
            echo "
";
            echo "
";
                the_content();
            echo "
";
            echo "

";
        }

    endwhile;

    wp_pagenavi(array( 'query' => $custom_query ) );

    wp_reset_postdata();
endif;

?>

The method I tried before the plugin:
<?php

$published_posts = wp_count_posts()->publish;
$posts_per_page = get_option('posts_per_page');
$page_number_max = ceil($published_posts / $posts_per_page);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(

    "category_name"    => "Publishing",
    "orderby"          => "post_date",
    "order"            => "DESC",
    "post_type"        => "post",
    "post_status"      => "publish",
    );

$custom_query = new WP_Query($args);

if ( $custom_query->have_posts() ) :
    while ( $custom_query->have_posts() ) : $custom_query->the_post();

        { $id=$post->ID; $image=get_the_post_thumbnail($id, 'full');
            if( class_exists('Dynamic_Featured_Image') ) {
                global $dynamic_featured_image;

                $featured_images = $dynamic_featured_image->get_featured_images($id );

            }

                echo "
".get_the_date( 'd F Y', $post->ID )."ID)."?kat=publishing> [Direct Link]
";
                ?>

                                            <?php echo $image; ?>

                                        <?php foreach($featured_images as $featured_image): ?>

                                                <img src="<?php echo $featured_image['full']; ?>"
                                                data-splide-lazy="<?php echo $featured_image['full']; ?>"
                                                loading="lazy"
                                                >

                                        <?php endforeach; ?>

            <?php

            echo "
";
                the_title();
            echo "
";
            echo "
";
                the_content();
            echo "
";
            echo "

";
        }

    endwhile;

    $total_pages = $page_number_max;

    if ($total_pages > 1){
        $current_page = max(1, get_query_var('paged'));

        echo paginate_links(array(
            'base' => get_pagenum_link(1) . '%_%',
            'format' => 'page/%#%',
            'current' => $current_page,
            'total' => $total_pages,
            'prev_text'    => __('« prev'),
            'next_text'    => __('next »'),
        ));
    };

    wp_reset_postdata();
endif;

?>

Any help would be appreciated. I'm trying to get the pagination to work for hours now.

A: You can paginate your custom loop on a page created inside WordPress, the issue with your code is that your are using "page" parameter instead of "paged" parameter; the former is used to paginate a single post parts, while the later is used to paginate post archives or multiple posts.
So a paginated query on your page template should be something like that:
$args = array(

    "category_name"    => "Publishing",
    "orderby"          => "post_date",
    "order"            => "DESC",
    "post_type"        => "post",
    "post_status"      => "publish",
    'paged' => get_query_var('paged'), // This is the correct parameter for pagination
);

$custom_query = new WP_Query($args);

if ( $custom_query->have_posts() ) :
    while ( $custom_query->have_posts() ) : $custom_query->the_post();

        echo '
' . get_the_title() . '
';
        // The remaining of your code here
    endwhile;

    wp_pagenavi(array( 'query' => $custom_query ) );

    wp_reset_postdata();
endif;

Also, I see in your code that you are using "$post" variable without being defined. If you are trying to access the current post in your custom loop, it is better to use the template tags -- helper methods-- e.g. get_the_ID(), get_the_title(),...etc those methods can access the global $post object by default without passing it as a parameter because you have already set it using $custom_query->the_post();


text:
Q: How to remove all characters before the final \ I have a variable called dllName that grabs the name of a dll that has been executed. Sometimes this dll is returned in the format of "kernel32.dll" and sometimes as "C:\Windows\system32\kernel32.dll".
The path can vary, what I am trying to achieve is the stripping of the "C:\Windows\system32\".
EDIT: Extract file name from path, no matter what the os/path format
My question is not the same as this question, as os.path.basename and os.path.split do not work in this situation.
For os.path.split the head is empty and the tail contains the whole path?

A: You could use :
path = 'C:\\Windows\\system32\\kernel32.dll'
print path.split('\\')[-1]
#=>  kernel32.dll

or
import os.path
print os.path.basename(path)

or
import re

def extract_basename(path):
  """Extracts basename of a given path. Should Work with any OS Path on any OS"""
  basename = re.search(r'[^\\/]+(?=[\\/]?$)', path)
  if basename:
    return basename.group(0)

print extract_basename(path)

This last example should work for any OS, any Path.
Here are some tests.


text:
Q: Optimize OS X for performance of single app? I'm going to be using my computer to run an real-time video display application at an event. This application is processor intensive, and runs well, except for occasional stutters. I'm thinking the stutters might be from other applications/processes using computer resources (proc/drive/etc.) For this event, this application deserves priority and everything else can wait.
Does anyone have some general tips for giving a single application priority and keeping the computer from doing any other housekeeping (such as spotlight indexing)?

A: If it's CPU intensive, use renice to assign a higher scheduling priority.
You can use top -o cpu to observe other processes' CPU usage and kill them if necessary, but Spotlight indexing is more I/O bound anyway.


text:
Q: 'this' in constructor and objects creation I read some articles when it is said that you should not use the 'this' keyword in constructor and others saying the exact opposite....
Now my main question is : Is it safe and is it a good practice to use 'this' in a constructor ?
This question lead to others :

*

*How an object creation is proceed ?

*When are the members of a class created ? Before the constructor is called ?

Here is some examples working with VS2012 on windows 7 :
class FirstClass
{
    int m_A;
public:
    FirstClass( int a ) : m_A( a )
    {
        std::cout << this->m_A << std::endl;
        //           ^^^^
    }
};

and :
class ThirdClass; // forward decl
class SecondClass
{
public:
    SecondClass( ThirdClass* iTC )
    {
        // ...
    }
};

class ThirdClass
{
    SecondClass* m_SC;
public:
    ThirdClass():
        m_SC( new SecondClass( this ) )
    //                         ^^^^
    {
        //...
    }
};

Those examples are working but is there a probability to have an undefined behavior ?

A: Since the memory for the object and its members is allocated before the call of the constructor, the value of this pointer itself is not the issue: it's the members that you might dereference off of it that may be an issue.
Your first code fragment is valid, because this->m_A is identical to m_A, which is a valid expression.
Your second code fragment may or may not be OK, depending on what the constructor of SecondClass does:

*

*If SecondClass constructor simply stores the pointer to FirstClass for future use, this is OK

*If SecondClass constructor calls methods off of the pointer to FirstClass passed into it, this is not OK, because the instance to which the this pointer is pointing has not been initialized.

A: First, yes it is totally safe to use the 'this' keyword,
In case of all those members which are on stack the 'this' keyword will work fine
and those which are pointer type you must assign them memory first then use them using the 'this' keyword. if you don't assign memory and try to use them then it will create an issue.
Secondly you asked that how object creation takes place and when members of class are created they are created when you make the object of the class either in main or in any function.


text:
Q: Vote to delete answers Why aren't answers held to the same rules as questions?
Answers can only be flagged, or voted upon. We see many examples of new-to-Stack Overflow-users posting comments, questions, and follow-ups as answers to their own questions. Why can't we vote to delete as "Not a valid Answer," or other reasons?
I don't think downvotes should be the solution here, as I'm not a fan of punishing the many new-to-Stack Overflow-users who unknowingly do these types of things.
Possible Restrictions:

*

*You must have 3k rep to vote for answer-deletion.

*You cannot delete an answer that has +2 upvotes.

A: I think this is kind of completed,
since users with 20k+ user can vote to delete answers with score of -1 or lower
https://stackoverflow.com/privileges/trusted-user

A: NO
Downvote, post a comment saying "this is a comment, not an answer" and instruct the user to edit their Question or whatever needs to be done.  A downvote is not punishment.  Deleting their content would be punishment.

A: Wouldn't this just open up the site to abuse? You could find a really good answer, copy it and then vote to close the "duplicate" original in favour of your own? I don't see the value in this feature. Downvoting an answer rather than voting to close it allows people to see good and bad answers in an argument, if you close all the bad answers, you have no contrast to learn from.
Also, closing a question means closing it for further answers, and in some cases, results in the question being deleted (if it's not real or not programming related for example - SO-wise). What does closing an answer do? Stop it being edited?

A: Downvotes are the way to get rid of answers.
The reason that questions need close/delete votes and systems is that they occupy clog up the front page and they are the basis of the site. It makes sense that there would be systems in place for this. For answers, you just downvote the person into oblivion.

A: *

*It's not as common for answers to be off-topic.

*When answers are off-topic, spam flags, downvotes and moderator attention whinings are good enough.

*This is pretty much what downvotes are for.

*Vampires (filling in my bold quota for this answer to guarantee acceptance)

Picture of a vampire, as the commenters required it:


text:
Q: Can a function know the names of the variables it takes as arguments?
Possible Duplicate:
Inspect the names/values of arguments in the definition/execution of a JavaScript function

When debugging javascript, I often have code like this:
function doSomething(a,b,c) {
    console.log(a,b,c);

    //function contents here
    //...
}

This results in a line in the console like this:
0.0010719847172334315 0.002392010391772366 -2.764548758273147e-7

Which is hard to read. I want to have output like this:
a: 0.0010719847172334315, b: 0.002392010391772366, c: -2.764548758273147e-7

Is this possible to do? I don't think it is possible to do in many languages. However, I don't know javascript very well, and it seems like a language where it is possible to do clever things like this.

A: You can do something like this by taking in a parameter object and iterating over it:
function doSomething(options) {
    var i, parameterString = [];
    for (i in options) {
        if (!options.hasOwnProperty(i)) continue;
        parameterString.push(i + ': ' + options[i]);
    }
    console.log(parameterString.join(', '));

    //function contents here
    //...
}

// Invoke like this:
var result = doSomething({a: 'a', b: 'b', c: 'c'});

Note that most of the cruft is due to you wanting to log the parameters on one line; in some other cases (such as logging one per line), you can simply call console.log on each of the individual strings and not bother with the array or the string join.


text:
Q: Java Removing/Adding JPanel Currently I have a client that contains two panels... one is the main game and the other is a side panel containing tools.  The side panel can be shown/hid (thus making the frame only show the game).
            activateSidePanel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (sp) {
                    frame.remove(enhancedPanel);
                    frame.repaint();
                    frame.pack();
                    sp = false;
                } else if (!sp) {
                    frame.add(enhancedPanel);
                    frame.repaint();
                    frame.pack();
                    sp = true;
                }
            }
        });

That is my action listener for the button.  The button hides correctly, however it doesn't show.  When I click the button again it just makes the frame smaller and does not bring back the side panel.  Confused on this one.

A: } else if (!sp) {

Why do test for !sp? A boolean can only have two values, so all you need is an if/else statement (without the test on the else.
Instead of removing/adding the panel I would try invoking the setVisible(false/true) method first.
If that doesn't work then then general code for removing/adding components is:
panel.add(...)
panel.revalidate();
panel.repaint();

You should not need to invoke pack() because you don't want the frame to keep resizing, you only want the main panel to become bigger/smaller.


text:
Q: Writing my first Dynamic Business Rule I've been working with Endeca at arms length for three years. Now I need to write my first dynamic business Rule.
I have records with a property, say "ActiveField", as a business Rule I need to take the value of "ActiveField" and return the records that match it. I'll restrict it to 20 with the Style.
I've read about writing Dynamic Business Rules, and I've gone through the dialogue box. I can't find where I'd need to write the logic that makes the matches. If it was SQL I expect I'd type in:
SELECT record.name record.id Where record.ActiveField = @ActiveField

I appreciate Endeca might not work like this, or convey this functionality in drop-down boxes which are written to XML config files.
But I can't find any hint of this level of complexity in the documentation; I'm probably missing something since this is fundamental.

A: Business rules are triggered by search / navigation states, not by records.
Rules can be created in several places depending on your deployment:
1 Developer studio
2 Merchandising Workbench (page builder or rule manager)
3 Experience Manager (which has replaced Merchandising
    workbench in the most recent releases).
In any of these locations you can set a trigger for your rule which can be either a search term or a dimension value(s), or combination of the two.
The actual records returned do not effect whether or not the rule is triggered. At that point your application has to take over a do something with the rule.
Best of luck.


text:
Q: Java email parser I have to parse the email message like this and figure out the body,date etc.Any help would be appreciated.
Date:        XXXXX
Reply-To:     XXXXX
Sender:       XXXXX
From:        XXXX
Subject:     Test
In-Reply-To:  XXXX
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="=__Part416ABDAE.0__="
=__Part416ABDAE.0__=
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: quoted-printable
Test

A: Here's a regex solution:
import java.util.regex.*;

class Test {

    public static void main(String[] args) {

        String input = "Date:        XXXXX\n"
                     + "Reply-To:     XXXXX\n"
                     + "Sender:       XXXXX\n"
                     + "From:        XXXX\n"
                     + "Subject:     Test\n"
                     + "In-Reply-To:  XXXX\n"
                     + "Mime-Version: 1.0\n"
                     + "Content-Type: multipart/alternative; " +
                                 "boundary=\"=__Part416ABDAE.0__=\"";

        Pattern p = Pattern.compile("(.*?):\\s+(.*)");
        Matcher m = p.matcher(input);
        while (m.find()) {
            System.out.println("Key: " + m.group(1));
            System.out.println("Val: " + m.group(2));
            System.out.println();
        }
    }
}

Output:
Key: Date
Val: XXXXX

Key: Reply-To
Val: XXXXX

Key: Sender
Val: XXXXX

Key: From
Val: XXXX

Key: Subject
Val: Test

Key: In-Reply-To
Val: XXXX

Key: Mime-Version
Val: 1.0

Key: Content-Type
Val: multipart/alternative; boundary="=__Part416ABDAE.0__="

A: If your serious about parsing email (and this is not a home work parsing assignment) you should look at Mime4J.


text:
Q: How can I set a text as a label instead of opening a new page? I am using a newsletter script from a predefined solution:
<?php

# SUBJECT
$subject = '';
if (isset($_POST['s1'])) $subject = $_POST['s1'];
if ($subject=='')
{
$subject='Remove';
}
else
{
$subject='Subscribe';
}

# LIST EMAIL ADDRESS
$recipient = 'email@domain.com';

# VERIFY SYNTAX
if(!preg_match('/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i', $_POST['f16']))
{
die ('Please enter a valid email.');
}

# FORM VALUES
$body = '';
$body .= "Email: ".$_POST['f16']." \n";

# SEND MESSGAE
mail( $recipient, $subject, $body, "From: $recipient") or die ('Error message');

# SHOW RESULT PAGE
header('Location: http://google.com');
?>

How can I display a label underneath my input instead of opening a new window?