text:
Q: What is the correct way to move between pages like that? First of all, when the page is load I have a header div, home div and bottoom div. I have sidebar and If I click "about" for example it refer me to "#about" (this is a div).
I want that the "home" div will hide or something else, and instead of the "home" div, ill see the about div.
And of course to hide the about div when the page is in the home page (because when the page is load I want to see the home div).

A: What you should be doing is creating some connection between your links and the content to be displayed(div's). You may keep the id of each content div's in HTML 5 data attributes on each of the links.
Here i am going to keep the id of the corresponding content div in a data attribute called target

Header

Home
About
Contact

Home content

Abount content

Contact content

Footer

And when the links are clicked, get the target data attribute value and use that to get the content div and show it.
$(function(){

   $(".content").first().show();  //show the first div(Home content)

   $(".links").click(function(e){
     e.preventDefault();
     $(".content").hide();
     var target=$(this).data("target");
     $("#"+target).show();

   });

})

Here is a working sample.


text:
Q: Combination of numbers of multiplications I am currently coding in python a special program. I want to find out what combinations of numbers from a list gives me my answer, it is quite hard to explain so here are some examples:
Example 1
Number = 18
List = [2, 3]

I want the output to be: 3^2 * 2 = 18
Example 2
Number = 30
List = [2, 3, 5]

I want the output to be: 3 * 2 * 5 = 30
Example 3
Number = 20
List = [2, 5]

I want the output to be: 2^2 * 5 = 20
I have been at this problem for about 4 hours and I just can't seem to figure it out! Any help is appreciated! Thanks!

A: Try this one. Works for python 3.9+. I've also shared the workaround for versions less than 3.9 below.
from collections import Counter
from math import lcm

def get_repr(num, factors):
  factors = list(factors)
  f_lcm = lcm(*factors)

  if (num % f_lcm != 0):
    return "Could not be represented by given factors."

  factors.append(num // f_lcm)
  c = Counter(factors)
  string = []
  for k, v in c.items():
    if (k == 1):
      continue

    if (string):
      string.append(' * ')

    string.append(str(k))
    if (v > 1):
      string.append('^')
      string.append(str(v))
  return ''.join(string)

print(get_repr(20, [2, 5]))

# Output
# 2^2 * 5

For python version less than 3.9, here's the workaround for lcm function.
from math import gcd
from functools import reduce

def lcm(*factors):
  return reduce(lambda a, b: a * b // gcd(a, b), factors)

A: If you want to do it with just with standard python you can use this (which does not give you an error if the number can not be represented by your factors):
number = 20
factors = [2, 5]
for factor in factors:
    while number % factor == 0:
        print(factor)
        number = number / factor

Do you want to do prime factorization instead?

A: edit: Assuming you mean a countdown solver. It was pointed out by another user that you might just be looking for prime factorisation.
As mentioned above, this is called a "countdown solver".
You could try this approach (I also encourage others to improve upon this solution!)
In this example I'll be calling the numbers in your list 'option numbers'.

*

*Take target number, perform one of the mathematical functions on it using one of your option numbers. (Add a number, take a number, divide, multiply etc).

*Check to see if the result is a product, factor, or is reachable through addition/subtraction/powers of any of the other option numbers.

*If you can't reach it, recurse with your new number as the target.

This assumes you can reuse option numbers, which you have in your example above.

A: import math
def check_reach_mul(list, num):
    num_list = [math.prod(list)]
    for idx, item in enumerate(list):
        num_list.append(math.prod([i if i!=item else pow(item,2) for i in list ]))
    return num in num_list

print(check_reach_mul([2, 3], 18)) #True
print(check_reach_mul([2,3,5], 30)) #True
print(check_reach_mul([2, 5], 20)) #True

redpajama_set_name: RedPajamaStackExchange


text:
Q: TFS 2015 with SQL Server 2014. Best migration path to upgrade to Azure DevOps 2019? I am currently running TFS 2015 Update 3 with a SQL Server 2014 backend database environment.
It appears that SQL 2014 isn't supported with Azure DevOps 2019, so an in-place upgrade of TFS 2015 to 2019 may not be supported.
I have a separate SQL Server 2017 environment set up on a different server.   My initial thought was to migrate TFS 2015 databases from SQL 2014 to SQL 2017 and then perform the upgrade.   However, TFS 2015 doesn't support SQL 2017 (based on system requirements doc)
What would be the best migration path to upgrade from TFS 2015 to Azure DevOps 2019 while on SQL 2014 and only having SQL 2017 as an option?

A:
TFS 2015 with SQL Server 2014. Best migration path to upgrade to Azure DevOps 2019?

You could upgrade your TFS application and your SQL serverl separately, not necessarily as a whole.
According to the document Upgrade your deployment to the latest version of Azure DevOps Server, we could upgrade the TFS 2015 to Azure DevOps Server 2019:

So, we could:

*

*Upgrade from SQL Server 2014 to SQL Server 2017

*Migration from TFS 2015 to Azure DevOps Server 2019

*Select the SQL Server 2017 when you configure databases

Note: Do not forget to backup all your data before upgrading.
You could check this document and this doc for some more details.
Hope this helps.


text:
Q: Can't add ALAssets to NSOperationQueue from enumeration block I'm trying to enumerate through the ALAssetLibrary to retrieve all saved photos. From the enumeration block, I'm trying to to send each ALAsset for asynchronous processing by passing it to an NSInvocationOperation object, then adding that to an NSOperationQueue. However, only the first ALAsset object is properly passed to the processing method. All subsequent assets are just passed as nil.
Here is my code:
ViewDidLoad:
queue = [[NSOperationQueue alloc] init];
queue.maxConcurrentOperationCount = 1;

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
     [group setAssetsFilter:[ALAssetsFilter allPhotos]];
     [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
      {
          if (! result) {
              return;
          }

          NSInvocationOperation* operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(processAsset:) object:result];
          [queue addOperation:operation];

          return;
      }];

 } failureBlock:^(NSError *error) {
     NSLog(@"%@", error);
 }];

And the -processAsset method
- (void)processAsset:(ALAsset *)asset
{
    NSLog(@"Asset: %@", asset);
    // Asset is nil after the first iteration
}

Any help would be really appreciated, thanks!

A: All ALAssets objects are deallocated when the ALAssetsLibrary that obtained them goes out of scope.  If you want to do what you're doing, you'll need to keep a strong reference to library, and then deallocate library when you're done with it.
(In your case, they deallocate at the end of viewDidLoad.)


text:
Q: WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins I have multi-author website and I am not very comfortable for allowing all members to enter SEO details in the posts they are publishing. I would like this would be visible only to Administrator of the website. Any ideas?

A: Try pasting this in a plugin or theme functions.php file, as per the WordPress SEO plugin (API Docs), by Yoast.
if(function_exists('wpseo_use_page_analysis') && !current_user_can('administrator')){
    add_filter('wpseo_use_page_analysis', '__return_false');
}

To avoid any errors... This checks to make sure the function exists, before attempting to hide stuff, allowing you to deactivate the plugin, and not throw errors.
You may need to hook into init for this to properly work, which could be done so like this:
function wpse_init(){
    if(function_exists('wpseo_use_page_analysis') && !current_user_can('administrator')){
        add_filter('wpseo_use_page_analysis', '__return_false');
    }
}
add_action('init', 'wpse_init');

A: You can remove it using the remove_meta_box function.
if ( ! current_user_can( 'edit_pages' ) ) {
    add_action( 'add_meta_boxes', 'my_remove_wp_seo_meta_box', 100000 );
}

function my_remove_wp_seo_meta_box() {
    remove_meta_box( 'wpseo_meta', 'post', 'normal' );
}

Notice the 100000 in the add_action, this makes sure that this is done after the WP SEO metabox has been hooked in.

A: You can use the Adminimize plugin to hide items from users depending on their roles. Have used this myself to hide some Yoast SEO stuff from clients and simplifying the back end.
http://wordpress.org/extend/plugins/adminimize/
Pretty straight forward to use by adding the css selectors for the items you want to hide. Have used it to hide the SEO Page Analysis tabs (#linkdex)

A: It didn't say in the API docs on the Yoast SEO plugin site what the ID was and I don't have a copy of Yoast at installed at disposal, but according to yoas-plugin-dir/admin/class-metabox.php line 144, the meta_box registered is;
add_meta_box( 'wpseo_meta', ...etc ); ...

Which is hooked onto add_meta_boxes hook on line 32 of the same file,
add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );

Of course you could get the ID from the meta box itself on the post edit screen... Anyway.
You can do the following,
add_action('add_meta_boxes', 'yoast_is_toast', 99);
function yoast_is_toast(){
    //capability of 'manage_plugins' equals admin, therefore if NOT administrator
    //hide the meta box from all other roles on the following 'post_type'
    //such as post, page, custom_post_type, etc
    if (!current_user_can('activate_plugins')) {
        remove_meta_box('wpseo_meta', 'post_type', 'normal');
    }
}

...where post type is the post type you wish to apply this restriction too, such as post or a custom post type one or more!
Should do the trick.
update: manage_plugins should have been activate_plugins - ammended.

A: Well there is a setting option on the WordPress SEO by Yoast for disabling the advanced part of WordPress SEO settings for non admins. If you want to completely disable the box then you can use other plugins to remove post editor page elements for non admins, e.g. removing the WordPress SEO box from the post editor for non admins.


text:
Q: Optimizing execution of a CUDA kernel for Triangular Matrix calculation I am developing my first Cuda application, and I have a kernel with "below-expected throughput", which seems to be the biggest bottleneck at the moment.
The task of the kernel is to compute an N by N sized matrix (DD) containing squared distances between all elements on a data matrix. The data matrix (Y) is size N by D (to support multi dimensional data) and stored as row-major.
Source:
__global__ void computeSquaredEuclideanDistance(const float * __restrict__ Y, float * __restrict__ DD, const int N, const int D) {
    int index = blockIdx.x * blockDim.x + threadIdx.x;
    int stride = blockDim.x * gridDim.x;

    for (int i = index; i < N * N; i += stride) {
        const int m = i / N;
        const int n = i % N;
        float tmp = 0;
        for (int d = 0; d < D; ++d) {
            const float Ynd = Y[d + D * n];
            const float Ymd = Y[d + D * m];
            const float Ydiff = Ynd - Ymd;
            tmp += Ydiff * Ydiff;
        }
        DD[n + N * m] = tmp;
    }
}

This is being called with size_t blockSize = 256 and size_t numBlocks = (N*N + blockSize - 1)/blockSize.
How can I optimize this kernel? My initial thought is that the time-consuming part is reading data without exploiting some sort of shared memory, but can anyone give me pointers on how to approach this?
Remarks from the nvvc profiling tool:

*

*Latency analysis:

*

*Compute utilization at around 40%

*Memory (L2 cache) utilization at around 35%

*Occupancy is not an issue

*

*Active Warps at 57.59 of a theoretical 64

*Occupancy at 90% of a theoretical 100

For my application, typical values are:

*

*5k < N < 30k

*D is either 2 or 3

A: I typically disregard these types of optimization questions because they are on the verge of off-topic, in my opinion. Worst still, you provide no MCVE so anyone trying to answer would have to write all their own support code to compile and benchmark your kernel. And this sort of work does require benchmarking and code analysis. But because your problem is basically a linear algebra problem (and I like linear algebra), I answered it rather than close voting it as too broad......
With that off my chest. there are a couple of things which immediately jump out in the code which could be improved and which would probably have a material affect on the run time.
The first is that the trip count of the inner loop is known a priori. Anytime you have a situation like that, let the compiler know. Loop unrolling and code reordering is a very powerful compiler optimization and the NVIDIA compiler is extremely good at it. If you move D into a template parameter, you can do something like this:
template<int D>
__device__ float esum(const float *x, const float *y)
{
    float val = 0.f;
#pragma unroll
    for(int i=0; i<D; i++) {
        float diff = x[i] - y[i];
        val += diff * diff;
    }
    return val;
}

template<int D>
__global__
void vdistance0(const float * __restrict__ Y, float * __restrict__ DD, const int N)
{
    int index = blockIdx.x * blockDim.x + threadIdx.x;
    int stride = blockDim.x * gridDim.x;
    for (int i = index; i < N * N; i += stride) {
        const int m = i / N;
        const int n = i % N;
        DD[n + N * m] = esum<D>(Y + D * n, Y + D * m);
    }
}

template __global__ void vdistance0<2>(const float *, float *, const int);
template __global__ void vdistance0<3>(const float *, float *, const int);

The compiler will inline esum and unroll the inner loop and it can then use its reordering heuristics to better interleave loads and flops to improve throughput. The resulting code has a lower register footprint too. When I run this for N=10000 and D=2, I get about 35% speed up (7.1ms versus 4.5ms on a GTX 970 with CUDA 9.1).
But there is an even more glaringly obvious optimization than this. The calculation you are performing will produce a symmetric output matrix. You only need to do (N*N)/2 operations to compute the full matrix, rather than the N*N you are doing in your code [technically N(N/2 -1) because the diagonal entries are zero, but lets forget the diagonal for the purposes of this discussion].
So taking a different approach and using one block to calculate each row of the upper triangular output matrix, then you can do something like this:
struct udiag
{
    float *p;
    int m;

    __device__ __host__ udiag(float *_p, int _m) : p(_p), m(_m) {};
    __device__ __host__ float* get_row(int i) { return p + (i * (i + 1)) / 2; };
};

template<int D>
__global__
void vdistance2(const float * __restrict__ Y, float * __restrict__ DD, const int N)
{
     int rowid = blockIdx.x;
     int colid = threadIdx.x;
     udiag m(DD, N);

     for(; rowid < N; rowid += gridDim.x) {
         float* p = m.get_row(rowid);
         const float* y = Y + D * rowid;
         for(int i=colid; i < (N-rowid); i += blockDim.x) {
             p[i] = esum<D>(y, y + D * i);
         }
    }
}
template __global__ void vdistance2<2>(const float *, float *, const int);
template __global__ void vdistance2<3>(const float *, float *, const int);

This uses a little helper class to encapsulate the triangle numbers needed for the addressing scheme for the upper triangular output matrix. Doing this saves an enormous amount of memory and memory bandwidth as well as reducing the total FLOP count for the calculation. If you need to do other things afterwards BLAS (and CUBLAS) supports computations on upper or lower triangular matrices. Use them. When I run this I get about 75% speedup (7.1ms versus 1.6ms on the same GTX 970).
Huge disclaimer: All the code you see here was written during a 45 minute lunch break and as been very lightly tested. I make absolutely no claims that anything in this answer is actually correct. I have confirmed that it compiles and doesn't produce a runtime error when I run it to get profiling data. That is it. Cavaet Emptor and all that.


text:
Q: Vagrant plugin load order I am behind corporate proxy which is using self-sign certificate to intercept ssl trafic.
So I have installed vagrant-ca-certificates to have certificate in vm. I am also using vagrant-omnibus to update the Chef client. Issue is vagrant-omnibus runs before vagrant-ca-certificates and ssl error is raised.
Is it possible to order the load of the plugins or give priority to some plugin.
I have also tried shell provisioner but that also runs after omnibus.
    Bringing machine 'default' up with 'virtualbox' provider...
    default: The Berkshelf shelf is at "H:/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150930-8216-1au7gvy-default"
==> default: Sharing cookbooks with VM
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: test_default_1443594532782_74213
==> default: Clearing any previously set forwarded ports...
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'test' from source at chef/cookbooks/test
==> default: Using apache2 (3.1.0)
==> default: Using java (1.35.0)
==> default: Using test (0.1.0) from source at chef/cookbooks/test
==> default: Vendoring apache2 (3.1.0) to H:/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150930-8216-1au7gvy-default/apache2
==> default: Vendoring java (1.35.0) to H:/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150930-8216-1au7gvy-default/java
==> default: Vendoring test (0.1.0) to H:/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150930-8216-1au7gvy-default/test
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Configuring proxy for Apt...
==> default: Configuring proxy for Chef provisioners...
==> default: Configuring proxy environment variables...
GuestAdditions versions on your host (4.3.6) and guest (4.3.10) do not match.
stdin: is not a tty
 * Stopping VirtualBox Additions
   ...done.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  dkms fakeroot gcc gcc-4.8 libasan0 libatomic1 libc-dev-bin libc6-dev
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfakeroot libfontenc1
  libgcc-4.8-dev libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgomp1
  libice6 libitm1 libllvm3.4 libpciaccess0 libpixman-1-0 libquadmath0 libsm6
  libtsan0 libtxc-dxtn-s2tc0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-sync1 libxcomposite1 libxdamage1
  libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1
  libxshmfence1 libxt6 libxxf86vm1 linux-libc-dev manpages-dev x11-common
  x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common
  xserver-xorg-core
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  virtualbox-guest-dkms* virtualbox-guest-utils* virtualbox-guest-x11*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 12.1 MB disk space will be freed.
(Reading database ... 61001 files and directories currently installed.)
Removing virtualbox-guest-dkms (4.3.10-dfsg-1ubuntu5) ...

-------- Uninstall Beginning --------
Module:  virtualbox-guest
Version: 4.3.10
Kernel:  3.13.0-63-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxguest.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-63-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxsf.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-63-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxvideo.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-63-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.

------------------------------
Deleting module version: 4.3.10
completely from the DKMS tree.
------------------------------
Done.
Removing virtualbox-guest-x11 (4.3.10-dfsg-1ubuntu5) ...
Purging configuration files for virtualbox-guest-x11 (4.3.10-dfsg-1ubuntu5) ...
Removing virtualbox-guest-utils (4.3.10-dfsg-1ubuntu5) ...
Purging configuration files for virtualbox-guest-utils (4.3.10-dfsg-1ubuntu5) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
dkms set to manually installed.
linux-headers-3.13.0-63-generic is already the newest version.
linux-headers-3.13.0-63-generic set to manually installed.
The following packages were automatically installed and are no longer required:
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgl1-mesa-dri
  libgl1-mesa-glx libglapi-mesa libice6 libllvm3.4 libpciaccess0 libpixman-1-0
  libsm6 libtxc-dxtn-s2tc0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-sync1 libxcomposite1 libxdamage1
  libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1
  libxshmfence1 libxt6 libxxf86vm1 x11-common x11-xkb-utils xfonts-base
  xfonts-encodings xfonts-utils xserver-common xserver-xorg-core
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
stdin: is not a tty
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting read-only
Installing Virtualbox Guest Additions 4.3.6 - guest version is 4.3.10
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.6 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers ...fail!
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.3.6. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
stdin: is not a tty
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /var/www => C:/jdp/baps/lamp/test
    default: /vagrant => C:/jdp/baps/lamp/test
    default: /tmp/vagrant-cache => C:/Users/pateljd/.vagrant.d/cache/ubuntu/trusty64
    default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => H:/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150930-8216-1au7gvy-default
==> default: Installing Chef 12.4.3 Omnibus package...
==> default: Downloading Chef 12.4.3 for ubuntu...
==> default: downloading https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default:   to file /tmp/install.sh.5643/metadata.txt
==> default: trying wget...
==> default: trying curl...
==> default: trying perl...
==> default: trying python...
==> default: Unable to retrieve a valid package!
==> default: Version: 12.4.3

==> default: Please file a Bug Report at https://github.com/opscode/opscode-omnitruck/issues/new
==> default: Alternatively, feel free to open a Support Ticket at https://www.getchef.com/support/tickets
==> default: More Chef support resources can be found at https://www.getchef.com/support

==> default: Please include as many details about the problem as possible i.e., how to reproduce
==> default: the problem (if possible), type of the Operating System and its version, etc.,
==> default: and any other relevant details that might help us with troubleshooting.

==> default: Metadata URL: https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default:
==> default: DEBUG OUTPUT FOLLOWS:
==> default:
==> default: STDERR from wget:
==> default:
==> default: --2015-09-30 06:31:17--  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Resolving www.getchef.com (www.getchef.com)... 103.245.222.65
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:33:30--  (try: 2)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:35:39--  (try: 3)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:37:50--  (try: 4)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:40:01--  (try: 5)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:42:13--  (try: 6)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:44:26--  (try: 7)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:46:41--  (try: 8)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:48:56--  (try: 9)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:51:12--  (try:10)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:53:29--  (try:11)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:55:47--  (try:12)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 06:58:04--  (try:13)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:00:21--  (try:14)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:02:38--  (try:15)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:04:56--  (try:16)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:07:13--  (try:17)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:09:30--  (try:18)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:11:47--  (try:19)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Retrying.
==> default:
==> default: --2015-09-30 07:14:04--  (try:20)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
==> default: Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
==> default: Giving up.
==> default:
==> default: STDERR from curl:
==> default:
==> default:
==> default:
==> default: STDERR from perl:
==> default:
==> default: Can't locate LWP/Simple.pm in @INC (you may need to install the LWP::Simple module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/s
hare/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at -e line 1.
==> default: BEGIN failed--compilation aborted at -e line 1.
==> default:
==> default: STDERR from python:
==> default:
==> default: Traceback (most recent call last):
==> default:   File "<string>", line 1, in <module>
==> default:   File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
==> default:     return _opener.open(url, data, timeout)
==> default:   File "/usr/lib/python2.7/urllib2.py", line 404, in open
==> default:     response = self._open(req, data)
==> default:   File "/usr/lib/python2.7/urllib2.py", line 422, in _open
==> default:     '_open', req)
==> default:   File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
==> default:     result = func(*args)
==> default:   File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open
==> default:     return self.do_open(httplib.HTTPSConnection, req)
==> default:   File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
==> default:     raise URLError(err)
==> default: urllib2.URLError: <urlopen error [Errno 110] Connection timed out>
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

sh install.sh -v 12.4.3 -d /tmp/vagrant-cache/vagrant_omnibus 2>&1

Stdout from the command:

Downloading Chef 12.4.3 for ubuntu...
downloading https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
  to file /tmp/install.sh.5643/metadata.txt
trying wget...
trying curl...
trying perl...
trying python...
Unable to retrieve a valid package!
Version: 12.4.3

Please file a Bug Report at https://github.com/opscode/opscode-omnitruck/issues/new
Alternatively, feel free to open a Support Ticket at https://www.getchef.com/support/tickets
More Chef support resources can be found at https://www.getchef.com/support

Please include as many details about the problem as possible i.e., how to reproduce
the problem (if possible), type of the Operating System and its version, etc.,
and any other relevant details that might help us with troubleshooting.

Metadata URL: https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64

DEBUG OUTPUT FOLLOWS:

STDERR from wget:

--2015-09-30 06:31:17--  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Resolving www.getchef.com (www.getchef.com)... 103.245.222.65
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:33:30--  (try: 2)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:35:39--  (try: 3)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:37:50--  (try: 4)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:40:01--  (try: 5)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:42:13--  (try: 6)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:44:26--  (try: 7)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:46:41--  (try: 8)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:48:56--  (try: 9)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:51:12--  (try:10)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:53:29--  (try:11)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:55:47--  (try:12)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 06:58:04--  (try:13)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:00:21--  (try:14)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:02:38--  (try:15)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:04:56--  (try:16)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:07:13--  (try:17)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:09:30--  (try:18)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:11:47--  (try:19)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Retrying.

--2015-09-30 07:14:04--  (try:20)  https://www.getchef.com/chef/metadata?v=12.4.3&prerelease=false&nightlies=false&p=ubuntu&pv=14.04&m=x86_64
Connecting to www.getchef.com (www.getchef.com)|103.245.222.65|:443... failed: Connection timed out.
Giving up.

STDERR from curl:

STDERR from perl:

Can't locate LWP/Simple.pm in @INC (you may need to install the LWP::Simple module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /u
sr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

STDERR from python:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>

Stderr from the command:


text:
Q: Do I have the right idea for my Multidimensional array search in C#? I'm new to Multidimensional arrays and just want to make sure I have the right idea for the search before start to code against it later today.
        public int[,] LocationXY = new int[5,5];

Edit Array Search For Multi-dimensional Arrays:
Would the pseudocode for searching a multidimensional array of 5 by 5 be something like this?
The XNA code for moving the map:
            background.direction.X = background.position.X + 3000;
            background.direction.Normalize();
            background.position.X += background.direction.X *
            ball.speed;
            backgroundWest.direction.X = backgroundWest.position.X + 3000;
            backgroundWest.direction.Normalize();
            backgroundWest.position.X += background.direction.X * ball.speed;
            Map.ArraySearch(XSearch, YSearch);

            //if statement for changing background sprite.
            if(LocationXY[0,1])
              background01.LoadContent(this.content, "background01";

The Search Function:
public int [,] ArraySearch(XSearch, YSearch)

  {
            for(int X = 0; X < XSearch; X++)
                for(int Y = 0; Y < YSearch; Y++)
                   if(Y == YSearch && X == XSearch)
                    return LocationXY[XSearch, YSearch]
       }

The general idea is grabbing the array value for the if statement the background sits under.  I wish switch statements could take multidimensional arrays.

A: If you want a matrix, use: int[,]
If you want an array of array, in where all sub array can have a different length, use: int[][]. Remember (besides creating the main array) to always create a subarray before filling it, otherwise you get a NullReferenceException.
If you want a  list of X and Y coordinates, use: Point[].

A: I suggest you go to the MSDN and read about array, multidimensional arrays, and jagged arrays.
What you are doing in the code in your answer is kind of strange... the loops and the way you are returning the values contradict.
assuming an array int[,] a = new int[X,Y] ( the size does not matter),
This would get the cell at index m,n:
int value = a[m,n]

This will search the array for a the location of a cell that has the value five:
Tuple<int,int> search (int[,] arr, int value)
{
    for(int i=0; i < arr.GetLength(0);i++ )
        for(int j=0; j < arr.GetLength(1);j++)
            if(arr[i,j] == value)
                return Tuple.Create(i,j);
}


text:
Q: What does getch() really get? Scan codes? #include <conio.h>

int main (void)
{
    for (;;)
    {
        unsigned char ch = getch();
        printf ("0x%02X\n", ch);
    }
}

I want to get the scan code.
Here is the description from Wikipedia:
    Reads a character directly from the console without buffer, and without echo.

When I pressed Del, it shows 0xE0 0x53.
When I pressed Ctrl+PgUp, it shows 0xE0 0x86.
Though some are the same as the table, most of the values it shows are different from it.
So, does getch() really get scan codes?
Here is the scan code table (set 2, most commonly used)

A: I ran a console app in VS 2012 (C++) and got the same results as you.  It did say that getch() was deprecated and I should use _getch(), but that made no difference.
I then found a table here that matches it (right-most column).  For me, the "white" keys were using shift and the numeric keypad equivalents, the "grey" keys were the stand-alone page-up, page-down, etc.  The one discrepancy I found was enter on the numeric keypad is the same as the regular enter key.
http://www.itlnet.net/programming/program/Reference/msc/ng7d68f.html
I don't know where this table comes from, other than if you click on "About The Guide" it says "The Microsoft C Database,  Copyright (C) 1987,  by Peter Norton".  Where Peter got it, I don't know.


text:
Q: Error Running Batch Job in WildFly 8.2 Java EE 7 I am trying to run Batch Jobs through Servlet. When the following statement executes JobOperator jo = BatchRuntime.getJobOperator();, I am getting below error:
ERROR [io.undertow.request] (default task-8) UT005023: Exception handling request to /BatchProcessing/batchprocessing: java.util.ServiceConfigurationError: javax.batch.operations.JobOperator: Provider org.jberet.operations.JobOperatorImpl could not be instantiated: java.lang.IllegalStateException: JBAS020560: BeanManager service was not added on the deployment. Ensure the deployment has a META-INF/batch.xml file or the META-INF/batch-jobs directory contains batch configuration files.
    at java.util.ServiceLoader.fail(ServiceLoader.java:224) [rt.jar:1.7.0_51]
    at java.util.ServiceLoader.access$100(ServiceLoader.java:181) [rt.jar:1.7.0_51]
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:377) [rt.jar:1.7.0_51]
    at java.util.ServiceLoader$1.next(ServiceLoader.java:445) [rt.jar:1.7.0_51]
    at javax.batch.runtime.BatchRuntime.getJobOperator(BatchRuntime.java:57) [jboss-batch-api_1.0_spec-1.0.0.Final.jar:1.0.0.Final]
    at com.tcs.servlets.BatchServlets.doPost(BatchServlets.java:43) [classes:]
    at com.tcs.servlets.BatchServlets.doGet(BatchServlets.java:29) [classes:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.lang.IllegalStateException: JBAS020560: BeanManager service was not added on the deployment. Ensure the deployment has a META-INF/batch.xml file or the META-INF/batch-jobs directory contains batch configuration files.
    at org.wildfly.jberet.services.BatchEnvironmentService$WildFlyBatchEnvironment.getArtifactFactory(BatchEnvironmentService.java:131) [wildfly-jberet-8.2.0.Final.jar:8.2.0.Final]
    at org.wildfly.jberet.DelegatingBatchEnvironment.getArtifactFactory(DelegatingBatchEnvironment.java:51) [wildfly-jberet-8.2.0.Final.jar:8.2.0.Final]
    at org.jberet.operations.JobOperatorImpl.<init>(JobOperatorImpl.java:69) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_51]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_51]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_51]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_51]
    at java.lang.Class.newInstance(Class.java:374) [rt.jar:1.7.0_51]
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373) [rt.jar:1.7.0_51]
    ... 32 more

I have placed job.xml file in "WebContent/META-INF/batch-jobs/" folder.
Don't know what is wrong with the configuration. I also added the batch.xml file in META-INF folder but it still giving me the same error. Any help is appreciated.

A: To solve this issue there are multiple steps required. Firstly JPA needs to be enabled into the Dynamic Web Project. To enable JPA in your project follow these instructions:

*

*Right click on project and go to properties.

*Go to Project Facets.

*Click check box against JPA.

*Click Ok.

Eclipse will build project again and create META-INF folder inside src folder of the project. Secondly, The batch-jobs folder needs to be created inside this(src/META-INF) folder. Thirdly, beans.xml file needs to be created inside WEB-INF folder.  Following contents can be pasted inside this file:
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    bean-discovery-mode="all">
</beans>

Build and redeploy the project. These error will go away.


text:
Q: How do you handle multiple AJAX requests in PHP? My AJAX search program keeps asking PHP for results of a particular search term. The start of the PHP script reads thru a MySQL DB and initializes, so if the PHP keeps restarting, it will have to read the DB millions of times. If I can keep it alive and let multiple silly AJAX requests be served by a single running PHP script instance I'm sure performance would improve.
How do you do this typically? Use a service? Can this be done with services?

A: PHP has no concept of long-lived objects or shared state between threads or requests, every request always starts at zero (except for the session state, of course). You can emulate long-lived objects by caching to disk or memory (see memcached).
Do you have a particular reason to read the entire database when your script initializes?

A: If you know the results are the same every time, just move those results to a session variable.
PHP sessions are explained pretty well in their documentation:
http://us3.php.net/manual/en/book.session.php

A: How about storing the db results in a session variable? You'd check first if the keyword is not in the session (sessions allow to transport variable values between page refreshes), and if not, do a db query.
To store it:
$_SESSION['storedQueries']['keyword']= 'its definition, from the database';

To look for it:
  $index=  array_search('keyword',array_keys($_SESSION['storedQueries']));
  $result = ($index) ? $_SESSION['storedQueries'][$index] : 'nothing found, you should do a db query';

The ajax part is pretty easy if you use a javascript library, such as jquery:
$('#resultZone').load('find.php',{keyword: $('input.search').val() });

A: If the search result is something that would be similar to multiple users, I usually create a cache file and serialize the result set there. As a filename I might use md5sum of a string containing the search query and perhaps user group. Then when a Ajax needs the data I just need to check if the file is too old, if not I just need to send it to the client or maybe even just redirect the Ajax http-request to the file (assuming it is formatted properly). If the file is too old, I just refresh it with new content.
For very high volume sites memcached is usually a better option. And also some kind of php cache helps and SQL connection pooling lowers the overhead of opening SQL connections.

A: connecting to the DB is a very expensive operation and you can go around that by caching the results, take a look at Zend_Cache and see how it can save you allot headache.


text:
Q: Centring a Column inside another Column in Flutter I'm currently writing my first Flutter App and I got a little stuck here. Basically what I'm trying to do is display an image at the top of the screen (with 100px top-margin) and display a Column which contains some Text and a Button on the centre of the screen. I tried moving mainAxisAlignment crossAxisAlignment into the outer Column Widget but that centres everything.
Here's my code:
Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.white,
  body: Center(
    child: Column(
      children: [
        Opacity(
          opacity: 0.25,
          child: Container(
            child: Image.asset('assets/images/logo.png'),
            margin: EdgeInsets.only(top: 100),
            width: 75,
          ),
        ),

        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text('Please enter your first name:'),
            TextButton(onPressed: () {}, child: Text('Submit'))
          ],
        )
      ],
    ),
  ),
);

A: You actually only need to wrap the second column in an Expanded widget, "so that the child fills the available space", that's all:
Column(
    children: [
        Expanded(
            child: Column(
                children: [],
            ),
        )],
),

A: try, wrap your second Column inside a Center widget.
Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.white,
  body: Center(
    child: Column(
      children: [
        Opacity(
          opacity: 0.25,
          child: Container(
            child: Image.asset('assets/images/logo.png'),
            margin: EdgeInsets.only(top: 100),
            width: 75,
          ),
        ),

        Center(
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text('Please enter your first name:'),
            TextButton(onPressed: () {}, child: Text('Submit'))
          ],
        )
      ],
     ),
    ),
  ),
);

If this doesn't work you could also wrap it in an Align widget and add the alignment property to it.
Align(
            alignment: Alignment.center,
              child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text('Please enter your first name:'),
              TextButton(onPressed: () {}, child: Text('Submit'))
            ],
          ),
      ),

A: import 'package:flutter/material.dart';

void main() {
  runApp(
  MaterialApp(
  home: Scaffold(
    appBar: AppBar(),
    body: Container(
      height: double.infinity,
      width: double.infinity,
      color: Colors.blue,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Container(
            height: 200,
            width: 200,
            color: Colors.pink,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
            ),
          ),
        ],
      ),
    ),
  ),
),
);
}

A: you have to use mainAxisAlignment property to set MainAxisAlignment.center.

A: In order to center align your second column,

*

*Make sure MainAxisAlignment of your Second Column is MainAxisAlignment.center

*Wrap your second column inside a Align Widget

*Now, wrap your Align widget with Expanded widget.

This should solve your issue.
Check this refrence.
 Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      const SizedBox(
        height: 18.0,
      ),
      const Padding(
        padding: EdgeInsets.only(left: 16.0),
        child: Text(
          'Recent Search(s)',
          style: TextStyle(
              color: Colors.black,
              fontSize: 16.0,
              fontWeight: FontWeight.bold),
        ),
      ),
      Expanded(
        child: Align(
          alignment: Alignment.center,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(
                MdiIcons.magnify,
                color: Colors.grey.shade600,
                size: 72.0,
              ),
              const SizedBox(
                height: 8.0,
              ),
              Text(
                'Search for places',
                style: TextStyle(
                    fontSize: 14.0,
                    color: Colors.grey.shade600,
                    fontWeight: FontWeight.w600),
              ),
              Text(
                'You haven\'t serached for any items yet...',
                style: TextStyle(
                    fontSize: 12.0,
                    color: Colors.grey.shade700,
                    fontWeight: FontWeight.w500),
              ),
              Text(
                'Try now - we will help you!',
                style: TextStyle(
                    fontSize: 12.0,
                    color: Colors.grey.shade700,
                    fontWeight: FontWeight.w500),
              )
            ],
          ),
        ),
      )
    ],


text:
Q: Function on another script not being called (AttributeError:) I have script1.py that is running/calling another script (script2.py).
script1.py
import sys
Wpath ='C:\PycharmProjects'
sys.path.insert(1, Wpath) # insert at 1, 0 is the script path (or '' in REPL)

import script2 as my_script
input_folder_name = 'TEST'
def run_Script():
    # todo

    if len(input_folder_name) != 0:
        my_script.SpecificFolders(outlook.Folders[user].Folders)
    else:
        my_script.AllFolders(outlook.Folders[user].Folders)

run_Script()

script2.py
if __name__ == "__main__":

    import win32com.client
    import os
    import glob
    import re
    import sys

    path = 'C:\PycharmProjects'
    os.chdir(path)

    outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
    user = outlook.Application.Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress

    def SpecificFolders(folders):
        my_list = []
        for folder in folders:
            if (folder.name == input_folder_name) and (input_folder_name != ""):
                print(folder.name)
            my_list.append(folder.name)
            my_list += SpecificFolders(folder.Folders)
        return my_list

When I run script1.py I get the message:

AttributeError: module 'script2' has no attribute 'SpecificFolders'

Can someone tell me why script1 is not "seeing" the function (SpecificFolders) inside script2?
And if possible, how to fix this error?


text:
Q: Python OpenCV - overlay an image with transparency What I'm trying to achieve is to place an image with transparency on top of another one. Something like this:

I haven't been able to find any solution, so I decided to go pixel by pixel and calculate the resulting color. That one worked for me, but its very slow.
I'm new to OpenCV and also to Python.
This is my code, I came up with:
import numpy as np
import cv2

img1 = cv2.imread("img1.png", -1)
img2 = cv2.imread("img2.png", -1) # this one has transparency
h, w, depth = img2.shape

result = np.zeros((h, w, 3), np.uint8)

for i in range(h):
    for j in range(w):
        color1 = img1[i, j]
        color2 = img2[i, j]
        alpha = color2[3] / 255.0
        new_color = [ (1 - alpha) * color1[0] + alpha * color2[0],
                      (1 - alpha) * color1[1] + alpha * color2[1],
                      (1 - alpha) * color1[2] + alpha * color2[2] ]
        result[i, j] = new_color

cv2.imshow("result", result)
cv2.waitKey(0)
cv2.destroyAllWindows()

Is there another way of doing this? Some faster way, much faster?
Thanks.

A: Answer :
import numpy as np
import cv2

from time import time

img1 = cv2.imread("./test_image/rgb.jpg", -1)
img2 = cv2.imread("./test_image/rgba.png", -1) # this one has transparency
h, w, c = img2.shape

img1 = cv2.resize(img1, (w, h), interpolation = cv2.INTER_CUBIC)
result = np.zeros((h, w, 3), np.uint8)

#slow
st = time()
for i in range(h):
for j in range(w):
        color1 = img1[i, j]
        color2 = img2[i, j]
        alpha = color2[3] / 255.0
        new_color = [ (1 - alpha) * color1[0] + alpha * color2[0],
                      (1 - alpha) * color1[1] + alpha * color2[1],
                      (1 - alpha) * color1[2] + alpha * color2[2] ]
        result[i, j] = new_color
end = time() - st
print(end)

#fast
st = time()
alpha = img2[:, :, 3] / 255.0
result[:, :, 0] = (1. - alpha) * img1[:, :, 0] + alpha * img2[:, :, 0]
result[:, :, 1] = (1. - alpha) * img1[:, :, 1] + alpha * img2[:, :, 1]
result[:, :, 2] = (1. - alpha) * img1[:, :, 2] + alpha * img2[:, :, 2]
end = time() - st
print(end)

cv2.imshow("result", result)
cv2.waitKey(0)
cv2.destroyAllWindows()


text:
Q: android app search button I've been trying to make my app implement the built in quick search, similar to how it is done in ApiDemos' "app/search/invoke search". I have tried everything from trying to follow different examples, to copying the code exactly as it is in ApiDemos.
All I've found for the former have been concerned with older versions of the SDK, and simply not worked. As for the stuff that I can actually run and see working in ApiDemos, I've tried copying the following
com.example.android.apis.app.SearchInvoke.java
com.example.android.apis.app.SearchQueryResults.java
com.example.android.apis.app.SearchSuggestionSampleProvider.java

res/layout/search_invoke.xml
res/layout/search_query_results.xml
res/values/arrays.xml
res/values/strings.xml
res/xml/searchable.xml

... and everything under "Search Samples" in AndroidManifest.xml

This copying gets me a view that looks exactly like the one I'm facing when running ApiDemos, but when I click the search button, in the quick search box, Android always just opens up a browser window, with Google search results for the given query. I simply cannot find the critical component in ApiDemos that tells android that I want to use my own custom code for handling the search request.
I would really appreciate some help in this matter. Both documentation and other online resources seem very lacking when it comes to this.
Thanks.

A: For reference, four months (and god knows how many attempts) later, I've found the part of the documentation I've missed out on, that had the whole search box behave fire up browser search results, instead of passing them to my own activity. It all comes down to a little notice found here:

Note that all user-visible strings must be provided in the form of "@string" references. Hard-coded strings, which cannot be localized, will not work properly in search metadata.

A: Try reading this first. If that does not help, you can try looking at the search example from one of my books -- that example integrates with the Quick Search Box, and perhaps it will give you more clues.

A: In addition to the examples provided by commonsware.com, you can look at the Searchable Dictionary in the samples directory of the 1.6 SDK.
http://developer.android.com/guide/samples/SearchableDictionary/index.html

A: I was wrong before... the SDK documentation has a thurough explanation in the docs for SearchManager that I suggest you take a look at. In addition, as CommonsWare mentioned, the blog entry is also a good resource.


text:
Q: How do you map a CultureInfo name to the CurrentLanguage of a SqlConnectionString? I am attempting to dynamically specify the CurrentLanguage of the SQL connection strings used by an application at runtime based on the current culture information of the application.
My initial attempt was the following:
foreach (ConnectionStringSettings item in ConfigurationManager.ConnectionStrings)
{
    if (!this.ConnectionStrings.ContainsKey(item.Name))
    {
        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(item.ConnectionString);
        if (String.IsNullOrEmpty(builder.CurrentLanguage))
        {
            var culture = Thread.CurrentThread.CurrentUICulture ?? Thread.CurrentThread.CurrentCulture;
            builder.CurrentLanguage = culture.Name;
        }

        this.ConnectionStrings.Add(item.Name, builder.ToString());
    }
}

This however fails, as the Name of the CultureInfo does not map the the name in the sys.syslanguages of SQL server.
Is there a way to map one of the CultureInfo name properties to a SQL server language name, or am I stuck calling a user defined function that accepts an LCID and maps that to the appropriate name to pass to SET LANGUAGE?

A: After reviewing the sys.syslanguages documentation, it appears that there are 33 supported languages. Given such a small subset of languages, the final solution I ended up using was to create a SqlConnectionLanguage class that is used by a factory class to dynamically specify the SQL Server language name based on the LCID of the current culture.
Given the difficulty in mapping a CultureInfo to the SQL Server language name or alias, creating a utility class that encapsulated the 33 supported languages appears to be the simplest approach.
Factory class specifies connection language by doing the following:
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(this.ConnectionStrings[name]);
if (String.IsNullOrEmpty(builder.CurrentLanguage))
{
    var culture = Thread.CurrentThread.CurrentUICulture ?? Thread.CurrentThread.CurrentCulture;

    if (culture != null)
    {
        var language = SqlConnectionLanguage.Create(culture);

        if (language != null)
        {
            builder.CurrentLanguage = language.Name;
        }
    }
}

return new SqlConnection(builder.ToString());

Implementation of the SqlConnectionLanguage class:
///
/// Represents a language supported by SQL Server.
///
/// <remarks>
/// See sys.syslanguages (Transact-SQL)
/// for more information about culture support in SQL Server.
/// </remarks>
[Serializable()]
public class SqlConnectionLanguage : INotifyPropertyChanged, INotifyPropertyChanging
{
    //=======================================================================================================
    //  Constructors
    //=======================================================================================================
    #region SqlConnectionLanguage()
    ///
    /// Initializes a new instance of the <see cref="SqlConnectionLanguage"/> class.
    ///
    public SqlConnectionLanguage()
    {

    }
    #endregion

    #region SqlConnectionLanguage(int id, int localeId, string name, string alias)
    ///
    /// Initializes a new instance of the <see cref="SqlConnectionLanguage"/> class
    /// using the specified unique identifier, locale identifier, name, and alias.
    ///
    /// <param name="id">The unique identifier for the language.</param>
    /// <param name="localeId">The  Microsoft Windows locale ID for the language.</param>
    /// <param name="name">The official name for the language.</param>
    /// <param name="alias">The alternative name for the language.</param>
    public SqlConnectionLanguage(int id, int localeId, string name, string alias) : this()
    {
        this.Id         = id;
        this.LocaleId   = localeId;
        this.Name       = name;
        this.Alias      = alias;
    }
    #endregion

    //=======================================================================================================
    //  Public Properties
    //=======================================================================================================
    #region Alias
    ///
    /// Gets or sets the alternative name for this language.
    ///
    /// <value>
    /// The alternative name for this language.
    /// The default value is an <see cref="String.Empty"/> string.
    /// </value>
    public string Alias
    {
        get
        {
            return _languageAlias;
        }

        set
        {
            if (PropertyChangeNotifier.AreNotEqual(_languageAlias, value))
            {
                using (new PropertyChangeNotifier(OnPropertyChanging, OnPropertyChanged))
                {
                    _languageAlias = !String.IsNullOrEmpty(value) ? value : String.Empty;
                }
            }
        }
    }
    private string _languageAlias = String.Empty;
    #endregion

    #region Id
    ///
    /// Gets or sets the unique identifier for this language.
    ///
    /// <value>
    /// A <see cref="Int32"/> value that represents the  unique identifier for this language.
    /// The default value is zero.
    /// </value>
    public int Id
    {
        get
        {
            return _languageId;
        }

        set
        {
            if (PropertyChangeNotifier.AreNotEqual(value, _languageId))
            {
                using (new PropertyChangeNotifier(OnPropertyChanging, OnPropertyChanged))
                {
                    _languageId = value;
                }
            }
        }
    }
    private int _languageId;
    #endregion

    #region InstalledLanguages
    ///
    /// Gets the installed languages for the SQL Server database engine.
    ///
    /// <value>
    /// A <see cref="ConcurrentDictionary{Int32, SqlConnectionLanguage}"/> collection that contains
    /// the installed languages for the SQL Server database engine.
    /// </value>
    /// <remarks>
    /// The collection is keyed by the <see cref="SqlConnectionLanguage.Id"/> of the
    /// contained <see cref="SqlConnectionLanguage"/> elements.
    /// </remarks>
    public static ConcurrentDictionary<int, SqlConnectionLanguage> InstalledLanguages
    {
        get
        {
            if (_languageInstalledLanguages == null)
            {
                _languageInstalledLanguages = new ConcurrentDictionary<int, SqlConnectionLanguage>();

                _languageInstalledLanguages.TryAdd(0, new SqlConnectionLanguage(0, 1033, "us_english", "English"));
                _languageInstalledLanguages.TryAdd(1, new SqlConnectionLanguage(1, 1031, "Deutsch", "German"));
                _languageInstalledLanguages.TryAdd(2, new SqlConnectionLanguage(2, 1036, "Français", "French"));
                _languageInstalledLanguages.TryAdd(3, new SqlConnectionLanguage(3, 1041, "日本語", "Japanese"));
                _languageInstalledLanguages.TryAdd(4, new SqlConnectionLanguage(4, 1030, "Dansk", "Danish"));
                _languageInstalledLanguages.TryAdd(5, new SqlConnectionLanguage(5, 3082, "Español", "Spanish"));
                _languageInstalledLanguages.TryAdd(6, new SqlConnectionLanguage(6, 1040, "Italiano", "Italian"));
                _languageInstalledLanguages.TryAdd(7, new SqlConnectionLanguage(7, 1043, "Nederlands", "Dutch"));
                _languageInstalledLanguages.TryAdd(8, new SqlConnectionLanguage(8, 2068, "Norsk", "Norwegian"));
                _languageInstalledLanguages.TryAdd(9, new SqlConnectionLanguage(9, 2070, "Português", "Portuguese"));
                _languageInstalledLanguages.TryAdd(10, new SqlConnectionLanguage(10, 1035, "Suomi", "Finnish"));
                _languageInstalledLanguages.TryAdd(11, new SqlConnectionLanguage(11, 1053, "Svenska", "Swedish"));
                _languageInstalledLanguages.TryAdd(12, new SqlConnectionLanguage(12, 1029, "čeština", "Czech"));
                _languageInstalledLanguages.TryAdd(13, new SqlConnectionLanguage(13, 1038, "magyar", "Hungarian"));
                _languageInstalledLanguages.TryAdd(14, new SqlConnectionLanguage(14, 1045, "polski", "Polish"));
                _languageInstalledLanguages.TryAdd(15, new SqlConnectionLanguage(15, 1048, "română", "Romanian"));
                _languageInstalledLanguages.TryAdd(16, new SqlConnectionLanguage(16, 1050, "hrvatski", "Croatian"));
                _languageInstalledLanguages.TryAdd(17, new SqlConnectionLanguage(17, 1051, "slovenčina", "Slovak"));
                _languageInstalledLanguages.TryAdd(18, new SqlConnectionLanguage(18, 1060, "slovenski", "Slovenian"));
                _languageInstalledLanguages.TryAdd(19, new SqlConnectionLanguage(19, 1032, "ελληνικά", "Greek"));
                _languageInstalledLanguages.TryAdd(20, new SqlConnectionLanguage(20, 1026, "български", "Bulgarian"));
                _languageInstalledLanguages.TryAdd(21, new SqlConnectionLanguage(21, 1049, "русский", "Russian"));
                _languageInstalledLanguages.TryAdd(22, new SqlConnectionLanguage(22, 1055, "Türkçe", "Turkish"));
                _languageInstalledLanguages.TryAdd(23, new SqlConnectionLanguage(23, 2057, "British", "British English"));
                _languageInstalledLanguages.TryAdd(24, new SqlConnectionLanguage(24, 1061, "eesti", "Estonian"));
                _languageInstalledLanguages.TryAdd(25, new SqlConnectionLanguage(25, 1062, "latviešu", "Latvian"));
                _languageInstalledLanguages.TryAdd(26, new SqlConnectionLanguage(26, 1063, "lietuvių", "Lithuanian"));
                _languageInstalledLanguages.TryAdd(27, new SqlConnectionLanguage(27, 1046, "Português (Brasil)", "Brazilian"));
                _languageInstalledLanguages.TryAdd(28, new SqlConnectionLanguage(28, 1028, "繁體中文", "Traditional Chinese"));
                _languageInstalledLanguages.TryAdd(29, new SqlConnectionLanguage(29, 1042, "한국어", "Korean"));
                _languageInstalledLanguages.TryAdd(30, new SqlConnectionLanguage(30, 2052, "简体中文", "Simplified Chinese"));
                _languageInstalledLanguages.TryAdd(31, new SqlConnectionLanguage(31, 1025, "Arabic", "Arabic"));
                _languageInstalledLanguages.TryAdd(32, new SqlConnectionLanguage(32, 1054, "ไทย", "Thai"));
            }
            return _languageInstalledLanguages;
        }
    }
    private static ConcurrentDictionary<int, SqlConnectionLanguage> _languageInstalledLanguages;
    #endregion

    #region LocaleId
    ///
    /// Gets or sets the Microsoft Windows locale ID for this language.
    ///
    /// <value>
    /// A <see cref="Int32"/> value that represents the Microsoft Windows locale ID for this language.
    /// The default value is zero.
    /// </value>
    public int LocaleId
    {
        get
        {
            return _languageLocaleId;
        }

        set
        {
            if (PropertyChangeNotifier.AreNotEqual(value, _languageLocaleId))
            {
                using (new PropertyChangeNotifier(OnPropertyChanging, OnPropertyChanged))
                {
                    _languageLocaleId = value;
                }
            }
        }
    }
    private int _languageLocaleId;
    #endregion

    #region Name
    ///
    /// Gets or sets the official name for this language.
    ///
    /// <value>
    /// The official name for this language.
    /// The default value is an <see cref="String.Empty"/> string.
    /// </value>
    public string Name
    {
        get
        {
            return _languageName;
        }

        set
        {
            if (PropertyChangeNotifier.AreNotEqual(_languageName, value))
            {
                using (new PropertyChangeNotifier(OnPropertyChanging, OnPropertyChanged))
                {
                    _languageName = !String.IsNullOrEmpty(value) ? value : String.Empty;
                }
            }
        }
    }
    private string _languageName = String.Empty;
    #endregion

    //=======================================================================================================
    //  Public Methods
    //=======================================================================================================
    #region Create(CultureInfo culture)
    ///
    /// Creates a new <see cref="SqlConnectionLanguage"/> using the specified <paramref name="culture"/>.
    ///
    /// <param name="culture">The <see cref="CultureInfo"/> to create</param>
    /// <returns>
    /// A new <see cref="SqlConnectionLanguage"/> using the specified <paramref name="culture"/>.
    /// If no SQL Server language exists for the specified <paramref name="culture"/>,
    /// returns a <see langword="null"/> reference (Nothing in Visual Basic).
    /// </returns>
    /// <exception cref="ArgumentNullException">The <paramref name="culture"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</exception>
    public static SqlConnectionLanguage Create(CultureInfo culture)
    {
        Guard.AgainstNullReference(culture, "culture");

        return InstalledLanguages.Values.FirstOrDefault(language => language.LocaleId == culture.LCID);
    }
    #endregion

    #region ToString()
    ///
    /// Returns a string that represents the current <see cref="SqlConnectionLanguage"/>.
    ///
    /// <returns>
    /// A string that represents the current <see cref="SqlConnectionLanguage"/>.
    /// </returns>
    public override string ToString()
    {
        return this.Alias;
    }
    #endregion

    //=======================================================================================================
    //  INotifyPropertyChanged Implementation
    //=======================================================================================================
    #region PropertyChanged
    ///
    /// Occurs when a property value changes.
    ///
    /// <remarks>
    /// The <see cref="PropertyChanged"/> event can indicate all properties on the object have changed
    /// by using either a null reference (Nothing in Visual Basic) or <see cref="String.Empty"/>
    /// as the property name in the <see cref="PropertyChangedEventArgs"/>.
    /// </remarks>
    public event PropertyChangedEventHandler PropertyChanged;
    #endregion

    #region OnPropertyChanged(string propertyName)
    ///
    /// Raises the <see cref="PropertyChanged"/> event.
    ///
    /// <param name="propertyName">The name of the property that changed.</param>
    protected void OnPropertyChanged(string propertyName)
    {
        this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
    }
    #endregion

    #region OnPropertyChanged(PropertyChangedEventArgs e)
    ///
    /// Raises the <see cref="PropertyChanged"/> event.
    ///
    /// <param name="e">A <see cref="PropertyChangedEventArgs"/> that contains the event data.</param>
    protected void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        PropertyChangedEventHandler handler = this.PropertyChanged;

        if (handler != null)
        {
            handler(this, e);
        }
    }
    #endregion

    //=======================================================================================================
    //  INotifyPropertyChanging Implementation
    //=======================================================================================================
    #region PropertyChanging
    ///
    /// Occurs when a property value is changing.
    ///
    /// <remarks>
    /// The <see cref="PropertyChanging"/> event can indicate all properties on the object are changing
    /// by using either a null reference (Nothing in Visual Basic) or <see cref="String.Empty"/>
    /// as the property name in the <see cref="PropertyChangingEventArgs"/>.
    /// </remarks>
    public event PropertyChangingEventHandler PropertyChanging;
    #endregion

    #region OnPropertyChanging(string propertyName)
    ///
    /// Raises the <see cref="PropertyChanging"/> event.
    ///
    /// <param name="propertyName">The name of the property that is changing.</param>
    protected void OnPropertyChanging(string propertyName)
    {
        this.OnPropertyChanging(new PropertyChangingEventArgs(propertyName));
    }
    #endregion

    #region OnPropertyChanging(PropertyChangingEventArgs e)
    ///
    /// Raises the <see cref="PropertyChanging"/> event.
    ///
    /// <param name="e">A <see cref="PropertyChangingEventArgs"/> that contains the event data.</param>
    protected void OnPropertyChanging(PropertyChangingEventArgs e)
    {
        PropertyChangingEventHandler handler = this.PropertyChanging;

        if (handler != null)
        {
            handler(this, e);
        }
    }
    #endregion
}

A: I think that CultureInfo has a LCID property. This should map to the LCID column in the sys.syslanguages table. So you should probably query the sys.syslanguages table with this LCID to get the value from the Name column, and then pass this string to your ConnectionStringBuilder. For example: SELECT name FROM sys.syslanguages WHERE lcid = 1033 will return "us_english".
I realize you need a connection to the DB to do this and therefore a connectionstring, so I might be giving an useless answer here. But you can query the languages without specifying the CurrentLanguage.

A: Maybe this is very ugly... but you could to smth like this:
 builder.CurrentLanguage = culture.EnglishName.Substring(0, culture.EnglishName.IndexOf(" "))

Also, perhaps you could make use of an Windows API function like here
How to convert Microsoft Locale ID (LCID) into language code or Locale object in Java
and then maybe play around with it until it suits you. Either way, good luck:)


text:
Q: GreaseMonkey - Prevent online script I have an HTML website which returns some HTML like this:

Content ...

 ...

With GreaseMonkey for Firefox is it possibile to prevent that badscript is executed?


text:
Q: How to render responsive and blurred images on load with Next.js I am trying to blur my images when they are loading, but I am unable to find a comprehensive and understandable solution. Currently, in Next.js, I am using the <img/> tag to define how my image looks. However, after looking into Next's built-in <Image/> tag, I think that it is more performant and feature rich than the simple <img/> tag.
In trying to convert my old code to the next Next tag, I have run into a few issues:

*

*I loose control over the styling of the image

*The blurring still does not appear

This is my original code:
<img
  src={images[0].url}
  alt={images[0].altText}
  className="object-cover w-full h-64 rounded-md"
/>

And the Next Image tag code
<Image
  src={images[0].url}
  alt={images[0].atlText}
  width={300} // I want a 100% width, not fixed
  height={200}
  placeholder="blur"
  blurDataURL="https://abstackwp.khingars.com/wp-content/uploads/2021/09/image-blur-placeholder.png"
/>

As you can tell, I am loading images from an external API.
In short, how can I both style my images to be responsive and blurred while loading?


text:
Q: Highlight ListBox items based on value from class Is it possible to loop through items in a ListBox and highlight or indicate item unavailability somehow by checking a class for a value?
Basically, got a Game class and within stored info whether Game is Available so I need to check this class when looping through the ListBox Items and somehow indicate on the ListBox if GameAvailable = false.
Got to this point and not sure how to carry on:
private void HighlightUnavailable()
    {
        foreach(string item in listbox_consoles.Items)
        {
            foreach (Products.Game game in GameService.AllGames())
            {
                if (item == game.GameName.ToString())
                {
                    if (game.GameAvailable)
                    {

                    }
                }
            }
        }
    }

A: Yes that's possible in such a way as:

*

*Bind the ListBox to the GameService.AllGames() which returns I believe a list or an array of the Game objects.

*Set the ListBox.DrawMode to DrawMode.OwnerDrawFixed and handle the ListBox.DrawItem event to draw the items according to their GameAvailable properties.
Assuming the controls names are Form1 and listBox1, add in Form1 constructor:
public Form1()
{
    InitializeComponent();
    //...

    listBox1.DrawMode = DrawMode.OwnerDrawFixed;
    listBox1.DrawItem += (s, e) => OnListBoxDrawItem(s, e);
    listBox1.DataSource = GameService.AllGames();
}

Say you want to display the available games with green and the rest with red foreground colors.
private void OnListBoxDrawItem(object sender, DrawItemEventArgs e)
{
    //Comment if you don't need to show the selected item(s)...
    e.DrawBackground();

    if (e.Index == -1) return;

    var game = listBox1.Items[e.Index] as Game;
    var foreColor = game.GameAvailable ? Color.Green : Color.Red;

    //Pass the listBox1.BackColor instead of the e.BackColor
    //if you don't need to show the selection...
    TextRenderer.DrawText(e.Graphics, game.GameName, e.Font,
        e.Bounds, foreColor, e.BackColor,
        TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
}

... or with different background colors:
private void OnListBoxDrawItem(object sender, DrawItemEventArgs e)
{
    if (e.Index == -1) return;

    var game = listBox1.Items[e.Index] as Game;

    var backColor = e.State.HasFlag(DrawItemState.Selected)
        ? e.BackColor
        : game.GameAvailable
        ? Color.LightGreen
        : listBox1.BackColor;

    //Or this if you don't need to show the selection ...
    //var backColor = game.GameAvailable
    //  ? Color.LightGreen
    //  : listBox1.BackColor;

    using (var br = new SolidBrush(backColor))
        e.Graphics.FillRectangle(br, e.Bounds);

    TextRenderer.DrawText(e.Graphics, game.GameName, e.Font,
        e.Bounds, Color.Black, backColor,
        TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
}

... or with a couple of yes  and no  images from your resources:
Bitmap YesImage, NoImage;

public Form1()
{
    InitializeComponent();
    //...

    YesImage = Properties.Resources.YesImage;
    NoImage = Properties.Resources.NoImage;

    listBox1.DrawMode = DrawMode.OwnerDrawFixed;
    listBox1.DrawItem += (s, e) => OnListBoxDrawItem(s, e);
    listBox1.DataSource = GameService.AllGames();
    this.FormClosed += (s, e) => { YesImage.Dispose(); NoImage.Dispose(); };
}

private void OnListBoxDrawItem(object sender, DrawItemEventArgs e)
{
    if (e.Index == -1) return;

    var game = listBox1.Items[e.Index] as Game;
    var backColor = e.State.HasFlag(DrawItemState.Selected)
        ? e.BackColor
        : listBox1.BackColor;
    var bmp = game.GameAvailable ? YesImage : NoImage;
    var rectImage = new Rectangle(
        3, e.Bounds.Y + ((e.Bounds.Height - bmp.Height) / 2),
        bmp.Width, bmp.Height
        );
    var rectTxt = new Rectangle(
        rectImage.Right + 3, e.Bounds.Y,
        e.Bounds.Right - rectImage.Right - 3,
        e.Bounds.Height
        );

    using (var br = new SolidBrush(backColor))
        e.Graphics.FillRectangle(br, e.Bounds);

    e.Graphics.DrawImage(bmp, rectImage);

    TextRenderer.DrawText(e.Graphics, game.GameName, e.Font,
            rectTxt, Color.Black, backColor,
            TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
}


text:
Q: How to sequentially write a stream in Node in a loop with writeable Streams? I want to append lines to a file, which is a writeable stream, in Node, in a specific order, through a loop.
Here is a simplified version of what I am talking about:
var fs = require('fs');
var outfile = fs.createWriteStream('outfile.txt');

for (var i = 0; i < 200; i++) {
    outfile.write('i', function (err, len) {
        console.log('written');
    });
}

I need the file to be written sequentially meaning that it would write, 12345...etc in order.  My understanding is that outfile.write is async, meaning that it is possible for the file to be written out of order - is this correct?
I see from the node docs

Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended.

So I believe that using a stream is best, however, I am not sure hot to guarantee that the data chunk was written succesfully before moving on to the next iteration in the loop.  How should I go about doing that? Thanks.

A: I think with both the current streams and the streams you had in 2015 the write was never async parallel. Write streams have a buffer in memory and you write to that buffer not to the hard disk directly. The buffer will keep your sequence in the right order.

A: You can avoid using fs.createWriteStream by using fs.writeSync which doesn't have a callback problem like fs.write


text:
Q: Directive: ngModel not change ng-hide I started build a directive calendar and I have a problem:
I'm putting dynamic tables and want to filter by a ngModel that is parent controller, but I can not take the change of ngModel using dynamic tables and attr.
Here is the code:
HTML

   <input type="checkbox" ng-model="confirm.is_true" checked class="checked-blue">
   Confirm

JS
function createBar(kind) {
    var _span = document.createElement("div");
    switch(kind){
      case "initial":
        var _img = document.createElement("img");
        var _text = document.createTextNode("Test");
        _img.src = "/uploads/photo/27/sq135_DSC_0011.JPG";
        _span.appendChild(_img);
        _span.appendChild(_text);
        _span.className = "bar-init";
        _span.setAttribute("ng-hide", "confirm.is_true");
        break;
      case "middle":
        _span.className = "bar-middle";
        break;
      case "end":
        _span.className = "bar-end";
        break;
    }
    return _span;
  }

Thanks

A: The problem is, I think that angular is not aware of the fact that you are creating this element. You should definitely have a look into $compile method. Instead of using document.createElement use angular.element. After creating desired element, use $compile(_span)($scope).


text:
Q: Authenticating an Android or iPhone app to a Django backend I have a webapp that is built with Django.  It works fine for use on the web, but now I am building a Android app.  I am not sure how to go about authenticating the Android app the the Django backend, securely.
This webapp has user profiles.  A user can register/login/logout using the web interface.  The relevant part of urls.py looks like this:
urlpatterns += patterns('',
  url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login'),
  url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name="logout"),
)

My understanding is that after the user successfully completes accounts/login there is some cookie deposited on the browser which is used for the rest of the connections.  Is this correct?
When on an Android device, given a username and password, what is the proper or best way authenticate the user to the Django backend?  Do I need to get the cookie like in the browser or is there a better way?

A: There's a couple of ways you could do authentication, but using the existing Django session support and the cookies it uses is probably the best way.
When you connect to a Django page with the Session Middleware enabled (which you need for login) it'll set a session cookie (generally called 'sessionid', although you can customise that). The users (not) logged in state is stored server-side in a session linked by this session id (unless you're using the cookie-based sessions but's that's an item for another post).
So your Android app can just get the login page, fish out the sessionid (and csrftoken) cookies and then make a post with the username, password, sessionid and csrftoken.
That's the easy way. There's more complex options, which mostly involve making a custom view that spits back JSON and generally starts providing an API for your mobile apps as opposed to make them pretend they're browsers, but that's somewhat more complex on the Django side.


text:
Q: how to convert an image into base64 string in android? Bitmap bm = BitmapFactory.decodeResource(getResources(),R.drawable.image);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object
    final String encodedImage = Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);

This is my code. It uploads the image onto the server. However, All I can see is a box. Where am I going wrong?

A: Make sure you convert back to bitmap at the End, ie Server side
1, convert your imageview to bitmap.
 imageView.buildDrawingCache();
 Bitmap bmap = imageView.getDrawingCache();

2, convert bitmap to base64 String and pass to server
public String getEncoded64ImageStringFromBitmap(Bitmap bitmap) {
  ByteArrayOutputStream stream = new ByteArrayOutputStream();
  bitmap.compress(CompressFormat.JPEG, 70, stream);
  byte[] byteFormat = stream.toByteArray();
  // get the base 64 string
  String imgString = Base64.encodeToString(byteFormat, Base64.NO_WRAP);
  return imgString;
}

3, At server side convert base64 to bitmap.
(this is java code, do it in your server side language)
byte[] decodedString = Base64.decode(Base64String.getBytes(), Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);

set this bitmap to display image

A: convert your image to bitmap.
 File imagefile = new File(Environment.getExternalStorageDirectory(),"/image/test.jpg" );
    FileInputStream fis = null;
                try {
                    fis = new FileInputStream(imagefile);
                    } catch (FileNotFoundException e) {
                        logger.error(Log.getStackTraceString(e));
                    e.printStackTrace();
                }

  Bitmap bm = BitmapFactory.decodeStream(fis);

Bitmap to Byte[]
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
                bm.compress(Bitmap.CompressFormat.PNG, 10 , baos);
                byte[] img = baos.toByteArray();

Byte[] to String:
String s= Base64.encodeToString(img , Base64.DEFAULT)