w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
TCP/UDP high-performance server under linux
Your basic approach is right. Start by studying the infamous C10K problem and how it was overcome. Once you understand the major bottlenecks in various implementations, you need to consider the following as part your design process : Minimise thread creation/deletion cycles. Always choose an "event-based" model over a blocking model. Basically the one-thread-per-request model is preferred for its simplicity of implementation. But it does NOT scale well with the number of concurrent requests. When designing systems required to support more than a few 1000 concurrent requests, one prefers the use of sockets over threads. The optimum number of "worker-threads" to instantiate depends upon : Load (number of concurrent requests) System (CPU, RAM) Since this is a very popular probl

Categories : Linux

Linux free shows high memory usage but top does not
Don't look at the "Mem" line, look at the one below it. The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free). The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.

Categories : Linux

Big array of size 1mega caused high CPU?
I just wrote this: #include <iostream> #include <cstdio> using namespace std; static __inline__ unsigned long long rdtsc(void) { unsigned hi, lo; __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); } const int M = 1024*1024; void bigstack() { FILE *f = fopen("test.txt", "r"); unsigned long long time; char buffer[M]; time = rdtsc(); fread(buffer, M, 1, f); time = rdtsc() - time; fclose(f); cout << "bs: Time = " << time / 1000 << endl; } void bigheap() { FILE *f = fopen("test.txt", "r"); unsigned long long time; char *buffer = new char[M]; time = rdtsc(); fread(buffer, M, 1, f); time = rdtsc() - time; delete [

Categories : C++

Take high supported picture size in android
it's solve and it's corrected method : public void GetHighResolutionForCamera(){ int Max = 0; Parameters params = mCamera.getParameters(); List<Camera.Size> resolution ; resolution = params.getSupportedPictureSizes(); Camera.Size MR = resolution.get(0); for (Camera.Size size : resolution) { if(Max < size.height){ MR = size ; Max = size.height; } } params.setPictureSize(MR.width, MR.height); mCamera.setParameters(params); } problem because MR was null

Categories : Android

Show items with high inventory first
Yes you can go throw this steps To do this a good post is Click on A more elegant solution is to make changes in .../Mage/Catalog/Model/Layer.php at line #102 $collection->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')->setOrder('inventory_in_stock', 'desc'); This will effect both the listing as well as the results page. Another things is to remember to copy this file from core to code/local/Mage/Catalog/Model/Layer.php so that the core files remain as it is. let me know if i can help you more.

Categories : Magento

Does a negative cross correlation show high or low similarity?
-1 is a sign of correlation, too. Only values around 0 are an indication that there is no correlation. Near +1 means, that the image is very similar to the other one. Near -1 means, that it's likely that one image is a negative and should be inverted, so the images are similar and get a correlation near +1.

Categories : Image

Different ways to show an image according to its size and window size
One way to do this is with simple CSS. Check this out: http://jsfiddle.net/panchroma/XBuGc/ I removed all your javascript and added some CSS .img-header{ width:100%; height:auto; min-width:450px; /* adjust as necessary */ } Hope this helps!

Categories : Jquery

How to create new VM using VMware VSphere API via PHP
why not try with Perl, its simple, vSphere SDK avail at free , http://www.vmware.com/support/developer/viperltoolkit/index.html here they gave how to connect to vsphere, we can use web services calls to connect to vsphere. all the need is to open https port.

Categories : PHP

python library which can be used for vSphere WS SDK
I don't know psphere or pysphere but I've used Suds to access the vSphere Web Services. Worked pretty well. The vSphere WS API is SOAP based and,to the best of my knowledge, exposes everything that's possible via vCenter. It's a bit tricky sometimes, but you can do it. I don't know what you try to achieve but you should be able to do it with Suds. Of course, you'd have to familiarize yourself with the API: vSphere Web Services SDK At the moment, we're playing around a bit with vCenter Orchestrator. It's a nice tool (since 5.0). Maybe that's an option for you, too.

Categories : Python

show only one series data in High charts in start of drawing/load
I think I found solution visible: false in series, updated my jsfiddle series: [{ name: 'MyHiddenLine', data: [1,2,3], visible: false },

Categories : Javascript

vsphere api to change ip address of VirtualMachine
VMware API don’t have a setting to set IP address on virtual machine guest OS, because the IP address setting depends on version guest OS. You could use two ways to do it: 1) You could use GuestOperationsManager from VMware vSphere API to launch the script of IP address setting on guest OS. Prerequisites: You should write scripts of IP address setting for each supported OS (Linux, Windows, etc.) VMware Tools must be installed on each supported VM (for use GuestOperationsManager). Update2. The following simplified example of running a script on the guest OS. This example does not include error handling, getting logs of the script, VM power on, etc. using System; using System.IO; using System.Net; using Vim25Api; namespace RunScriptOnGuestOsTest { class Program { st

Categories : C#

How to use the vSphere SDK for Perl with IPV6 hosts
You have two issues here. IPv6 literal addresses in a URL need to be in brackets. Your link-local address is missing an interface identifier. Specify the link-local address in brackets with the correct interface identifier. For example: https://[fe80::b6b5:2fff:fe5a:c5d8%eth0]:443/sdk

Categories : Perl

Show 'more' option to show after window size is 480px
Use .is(':visible') to decide what to hide/show and then just append the ...more to the end of the displayed element. See demo $(function () { $('.more').click(function () { if ($('.mobile-1').is(":visible")) { $('.mobile-1').hide(); $('.mobile-2').show(); $(this).appendTo($('.mobile-2')); } else { $('.mobile-1').show(); $('.mobile-2').hide(); $(this).appendTo($('.mobile-1')); } }); $(window).resize(function () { if ($(window).height() > 480) { $('.mobile-1').show(); $('.mobile-2').show(); $('.more').hide(); } else { $('.mobile-1').show(); $('.mobile-2').hide(); $('.more').show().appendTo($

Categories : Jquery

Perl vSphere SDK adding multiple disks soap error:
I found the solution. Apparently you need to give each virtual machine config spec its own key, even if it is negative. For posterity set $disk->key = UNIQUE NEGATIVE NUMBER and then set your config spec $devSpec = VirtualDeviceConfigSpec->new( operation => $devSpec->operation, fileOperation => $devSpec->fileOperation, device => $disk, );

Categories : Perl

Azure Could Computing high availoability vs NEO4J high availability?
The short answer is probably yes. Windows Azure provide you infrastructure that allow you to build high availability system, it won't make any system high available by magic. As NEO4J is state-full, each node (with only one node Azure don't give you any SLA, you instance will be down) will need to share some state and the way to do it will be dependent on how NEO4J is working. So you will need to rely on NEO4J mechanism to do it. I don't know how NEO4J is working but you won't be able to skip designing an high available architecture around NEO4J using Windows Azure infra. Cloud may be a magic buzz word that can make things append on management level, but when we are on hard real world level Harry magic wand doesn't exist.

Categories : Neo4j

How to get windows size from Linux
The issue has nothing to do with PuTTY per se, and everything to do with SSH clients and pseudoterminals in general. To avoid this issue, configure your PuTTY to use a pseudoterminal. (In the TTY panel, there is a "Don't allocate a pseudoterminal" checkbox. Make sure it is not checked.) With ssh, you need to use the -t option to tell ssh to use a pseudoterminal. Here is a simple example program you can use in Linux to obtain the terminal size. It does not require curses: #include <unistd.h> #include <sys/ioctl.h> #include <errno.h> #include <stdio.h> static int get_size(const int fd, int *const rows, int *const cols) { struct winsize sz; int result; do { result = ioctl(fd, TIOCGWINSZ, &sz); } while (result == -1 &&

Categories : C

quicksand sorting price values low to high / high to low
val() gives you a string, so > and < comparisons are lexographical (not numeric). Try wrapping the values in parseInt() or parseFloat(). Make sure to add appropriate error handling as well.

Categories : Jquery

How to reduce the size of mp3s in linux?
It depends on what you want to achieve. avconv (formerly ffmpeg) is a good tool, but there's no one size fits all solution pertaining the parameters, since it depends heavily on the type of audio data (music, speech, etc) and the original bitrate, etc. Try the different settings, maybe convert it to mono, see what produces still acceptable results for you. As a general rule of thumb: Speech compresses really well, downsampling it to 11kHz may still give acceptable results, but music can also be downsized by decreasing the bitrate or switching to mono.

Categories : Linux

How to set max file size in Linux CeNTOS to server.log
You can use logrotate to deal with log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large. It has a size option, so you can configure it to stay under 500MB for your "server.log"

Categories : Linux

Varnish High DB Connections In High Traffic
Mostly spiking backend connections has little to do with your varnish configuration but alot to do with the cachability of your site. Are there cookies that prevents you from caching efficiently? You can chose to strip them or remove all but chosen ones, there are examples for both on the varnish site. Do a varnishstat and check your hit rates during peaks. Is it a good cache hitratio? Is it the same as during low load? If it's the same or higher in low load it's easy to work on improving it at any time. Do a varnishtop -i txurl to see what requests are the most frequently sent to backend servers. Maybe it's some URLs that are just not cached due to faulty headers? Maybe some pages can be cached longer? Maybe some parts of the pages can be cached with ESI? Make sure your varnish is not

Categories : Mysql

Finding Memory Size in Boot without DOS, Windows, Linux
You will need to read the ACPI tables on a PC (or other machines that support ACPI). Note that this will not give you the total size as one number, but give you the memory size of each region of memory - on a simple machine, that may just be two or three regions (there are holes of "not real memory" at the 0xA0000-0xFFFFF and wherever the BIOS decides to put the "PCI-hole"). I suspect it won't be entirely trivial to fit the ACPI reader into a single sector, considering some of the boot sector only has around 400 bytes of space available (although if you completely skip the partition table, I suppose you can use almost all of the 512 bytes). As to "how to call C/C++", you will not be able to fit any meaningful C or C++ program in less than several sectors. You will need to take a look

Categories : C++

How do you get the total size of all files of a certain type within a directory in linux?
Found it. ls -lR | grep .jpg | awk '{sum = sum + $5} END {print sum}' As I understand it: ls says list all the files in the directory. Adding in the -l flag says show me more details like owner, permissions, and file size. tacking on R to that flag says 'do this recursively'. Piping that to grep .jpg allows only the output from ls that contains '.jpg' to continue on to the next phase. Piping that output to awk '{sum = sum + $5} END {print sum}' says take each line and pull its fifth column element (file size in this case) and add that value to our variable sum. If we reach the end of the list, print that variables value.

Categories : Osx

Return value size or type of a system call in Linux
On x86, the return value is put in the eax register, so it cannot be bigger than 32 bit; similarly, on x86-64 it is stored on rax (the 64-bit extension of eax). In general, the trend seems to be to always use a register for the return value (which seems reasonable for system calls), so you are limited to the size of the "native integer" of the current platform. If you needed to return bigger stuff, you'd have to resort to passing the location for the output via a pointer.

Categories : C

Reduce TCP maximum segment size (MSS) in Linux on a socket
Unless otherwise noted, optval is a pointer to an int. but you're using a u_int16. I don't see anything saying that this parameter isn't an int. edit: Yeah, here is the source code and you can see: 637 if (optlen < sizeof(int)) 638 return -EINVAL;

Categories : Linux

how to change read buffer size of linux serial line?
in a desperate attempt at my office, we modified the host application (running on windows, build on MS Visual Studio, as a .net application). So we created a small C++ serial port control application to just bypass the .net and voila! Without altering the code on the embedded system side, I can now read the full data I expect (from the embedded device side)! I am not going to blame .net since the problem started showing up after I ported the embedded sytem's code from an older device ARM9TDMI-ARMv4T (running linux with kernel 2.4), to the newer freescale cortex A9 imx6q sabrelite. However, I will note here that moving away from .net code, the C++ serial port control that we wrote worked both with the old device and the new one. So the code above should work for reading from the serial

Categories : Linux

When to use low < high or low + 1 < high for loop invariant
If your invariant is that the target must lie in low <= i <= high, then you use while (low < high); if your invariant is that the target must lie in low <= i < high then you use while (low + 1 < high). [Thanks to David Eisenstat for confirming this.]

Categories : Algorithm

Nesta CMS on linux not show latest articles
If you are fetching the articles with latest_articles helper method then try calling it with some number that is larger than 8, for example 30 latest_articles(30), because by default it returns only 8 documents.

Categories : Ruby

Does Iostat show the correct output for linux md raid
The zeros are actually the correct result (in a way) considering the values of the virtual layer itself. Hopefully, your virtual layers (mdadm arrays) are fast enough that they are always zero. For example, avgqu-sz is number of requests in queue, but it passes the request to the disk almost immediately.

Categories : Linux

linux-watch command: show time remaining
I think there is no way unless the COMMAND creates some information (e. g. a timestamp after its execution or similar). The reason for this is simple: The watch simple enters a nanosleep() system call to wait for the 50 seconds. (You can find this out using strace.) This nanosleep() does nothing else but wait for 50 seconds. It does not provide any information anywhere on how long the sleep already has been going on or how long it still will take. That information is buried deep inside the kernel who will, eventually, wake up the process again. So, your only way is making the COMMAND render that information, e. g. by letting it touch a timestamp file (e. g. touch /tmp/COMMAND.timestamp) whose time then can be used to determine indirectly when the next sleep will probably be finished

Categories : Python

CentralWidget adjust size to show all the content
Given example, depending on Pixmap size, QMainWindow will resize. Generally this is not the ideal case, as a user MainWindow need to display on the desktop, It should not be more that your desktop screen size. I am not sure you are actually looking for this. Copied fromSO Ans #include "mainwindow.h" #include <QLabel> #include <QHBoxLayout> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindowClass) { ui->setupUi(this); QPixmap pix; pix.load("C:\Users\user\Desktop\Uninstallation failure2.png"); //Replace with ImageLabel2 QLabel* image = new QLabel(this); image->setPixmap(pix); QHBoxLayout* hbox = new QHBoxLayout(this); hbox->addWidget(image); QWidget* centreWidget = new QWidget(); //QM

Categories : Qt

How can i get/show the file size in real time?
Once possibility would be to make ffmpeg write its output to stdout rather than to a file. Then you can capture the output by setting the RedirectStandardOutput property. It will then be up to you to read the redirected output and save it to disk yourself. Of course you'll then know exactly how much data you've saved as you're saving it.

Categories : C#

Show/hide buttons depending on screen size
You can't get the physical size of the screen, but you can get its resolution. The 4" iPhone 5 and the new iPod touch have 320×568 points, while the other iPhones have 320×480. You can get these dimensions using [[UIScreen mainScreen] bounds].size. It's of course possible that Apple releases a new phone that has the same pixel dimensions as the 4" iPhone 5, but uses a 5" (or whatever) screen, or that they release a device that has completely different dimensions. Your code should ideally be prepared for that, and not make the assumption that these dimensions are set in stone. On the other hand, this kind of change typically doesn't happen overnight. So, if you want to hide a button on devices with "small" screens, you could do something like this: - (void)viewDidLoad { self.myButt

Categories : IOS

Adjusting a function to show a specific size of image
<img class="ImageBorder" src="<?php echo get_resource_path($home_collectionx["home_page_image"],false,"thm",false) ?>" width="<?php echo $home_collectionx["thumb_width"] ?>" height="<?php echo $home_collectionx["thumb_height"] ?>" /> Why not edit this to set your desired size in pixels, like <img class="ImageBorder" src="<?php echo get_resource_path($home_collectionx["home_page_image"],false,"thm",false) ?>" width="1000" height="800" />

Categories : Function

Show image in a div tag with it's real size using jquery/css/html
instead of using height and width attributes use a class and use jquery to remove/hide the class .thumbimage { height:300px; width:300px; } $('.thumb-image').click(function(){ $(this).toggleClass('thumbimage'); });

Categories : Javascript

sizeof wont show real size, trying to implement ip
This is because your structure gets padded to overcome this you could use a #pragma pack compiler directive like so: #pragma pack(push) #pragma pack(1) struct IPHDR // the ip header { unsigned char VER : 4; unsigned char IHL : 4; unsigned char DSCP : 6; unsigned char ECN : 2; unsigned short len; unsigned short id; u_char Reserved:1; //Zeroes u_char DF:1; //Dont Fragment u_char MF:1; //More Fragment unsigned short FragOffset : 13; u_char ttl; u_char protocol; u_short checksum; struct in_addr src; struct in_addr dst; } ; #pragma pack(pop) Read more about padding and alignment: Data structure alignment

Categories : C++

Show different adsense block based on screen size?
A less efficient, but simple way would be to use javascript to dynamically load your adverts. On page load, check which class tag is visible and then load the appropriate ad. You lose on SEO, but since 99.99% adverts are also loaded in runtime by JS anyway, this won't affect you at all. + You probably don't want SEO from adverts anyway, so no problem there.

Categories : Javascript

CSS3 : how to show heading only all the time even re-size window
You can do it by using media queries: /*iPads -----------*/ @media only screen and (min-width : 768px) and (max-width : 1024px) { strong{ display: none; } } FIDDLE

Categories : HTML

Java Out of Memory Error(Native memory), the process size limit was hit(32-bit linux)
print the memory size every minute, and found that the VmSize was 2924700 kB before the process died. AFAIK On Linux the OS uses about 1 GB. You need virtual memory for thread stacks, shared libraries, Perm Gen, memory mapped files, and any native resources. If you are getting anywhere near this limit (or if you just have a 64-bit processor) you really should be using a 64-bit OS and JVM. I would use Java 6 update 45, which is end of free support, if not Java 7 update 25.

Categories : Java

How to show different number of items in slider based on screen size in PHP?
Short answer: you cannot. Long answer: since PHP runs on the server, it has absolutely no way of knowing where it will be displayed, or if it actually will be displayed; let alone what is the size of that display. The server has no access to that information. There are some workarounds involving AJAX and sending parameters and reloading the page, and various other hacks; but in the end, you should accept that PHP is an unsuitable tool for the task, and use something like JavaScript to update the styles.

Categories : PHP

How to show Listbox selected item (Image) in an another Control with larger size
In your code add a selection changed event handler for the listbox: lv.SelectionChanged += lv_SelectionChanged; private void lv_SelectionChanged(object sender, SelectionChangedEventArgs e) { //Get selected item and do what you want with it here. } EDITS, want do in XAML only can use a CollectionViewSource <Window.Resources> <CollectionViewSource x:Key="myViewSource" d:DesignSource="{d:DesignInstance {x:Type YOUR_DATA_TYPE}, CreateList=True}"/> <CollectionViewSource x:Key="myPath_ViewSource" Source="{Binding Image, Source={StaticResource myViewSource}}"/> </Window.Resources> THen <Grid DataContext="{StaticResource myViewSource}"> //SOME LIST BOUND TO MAIN CONTEXT </Grid> // LIST BOUND TO SELECTED PATH &

Categories : Wpf



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.