w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I fall back to a high contrast color in WPF?
You can bind it to Tag property of textblock and use that in DataTrigger like below: <Style x:Key="MyTextBoxStyle" TargetType="{x:Type TextBlock}"> <Setter Property="Tag" Value="{DynamicResource {x:Static SystemParameters.HighContrastKey}}"/> <Style.Triggers> <DataTrigger Binding="{Binding Path=Tag , RelativeSource= {x:Static RelativeSource.Self}}" Value="True"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /> </DataTrigger> </Style.Triggers> </Style>

Categories : Wpf

HCM (High Contrast Mode) white vs black detection
http://www.w3.org/WAI/PF/aria-practices/#accessiblewidget Scroll down to 2.12 Compensate for Background Images when in High Contrast Mode

Categories : Javascript

Switching into (Linux) Kernel Mode
All switches to kernel mode are made via system calls. In the case of network protocols these system calls are socket, listen, accept, ioctl, read, write, recvmsg, etc. You write a Linux kernel module. There is already a SCTP protocol stack for Linux though. You would likely be better off modifying it to do what you want. Once you have written and compiled your module you can load it into the kernel using insmod and rmmod. In my experience you rarely get a chance to use rmmod because if you made a mistake the system crashes or freezes. So use a virtual machine for your testing. It is faster to reboot, you lose less data, and it is easier to hook up a virtual serial console for debugging. I am sure this question is a duplicate by the way. You can find a lot of questions on this topic.

Categories : Linux

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

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

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

Best Ways to reduce Disk IO On Linux Server
Your servers shouldn't crash due to disk IO. They stop, but don't crash, everything gets real slow, but crash?? Seems extreme. What time do they crash at? 8am? What happens if you reboot them? Did you say webapp? hmmm.. Dru You could reduce IO by using smaller drives, hehe I've got some, definitely reduced IO!!

Categories : Mysql

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

Write C++ on Windows but use Linux System calls through a Linux emulator
You've already tagged your question with Cygwin. That seems like the best solution for what you want. Cygwin is basically a collection of programs which emulate a GNU/LInux environment through the use of a DLL (cygwin1.dll) which acts as a Linux API layer providing substantial Linux API functionality. Here's the link to the documentation for its API Edit: Most of the Cygwin source code that I've looked at is written in C++ and makes system calls using MS Windows API to do provide the *nix emulation. The source is well written and very readable (even to to a non-C++ programmer such as myself). I think using Cygwin would be a good transition from programming on Windows to a GNU/Linux environment.

Categories : C++

C# switching windows in .net
SwitchToThisWindow is expecting a handle to the window that you want to switch to in that process. Try SwitchToThisWindow(proc.MainWindowHandle);

Categories : C#

Switching from Eclipse to IntelliJ: Is there a way to split tool windows?
Ok, by some more or less random combination of the "docked" , "pinned" , "view as tab" and "split mode" modifiers I got it to work. I wonder why they didn't simply implement dragging the window where you'd like it to appear...

Categories : Intellij Idea

EMACS find-grep command switching windows
There might be some options of grep behavior, that you might find if you dig in the lisp/progmodes/grep.el from the source, but I really think it might be better and easier to have a look of GrepPlus library which bring many enhancement of emacs grep. Otherwise you could also use occur and see how you could customize it. In occur, when you are in the match buffer, you can it C-o instead of Ret, which will show in the other buffer the match you selected, keeping your cursor in the match buffer. Difference with grep, is that it only works with opened buffer. I'm rather sure grep+ might have the equivalent. You should have a look

Categories : Function

WPF DocumentViewer: Switching between windows makes the window as if it has crashed
Dispatcher is here to run a delegate in the UI thread, Dispatcher.Invoke() will run a delegate synchronously on the thread the Dispatcher is associated with (see msdn). What you need may be Dispatcher.BeginInvoke(), or you should even use BackgroundWorker class to have a real background operation. I'd also recommend you using Application.Current.Dispatcher (see this question: Dispatcher.CurrentDispatcher vs. Application.Current.Dispatcher)

Categories : C#

Is it possible to query serial port tx pin status (signal low / high) in windows?
No. (at least not likely) If you are using the "16550" family of UARTs, then I am confident that you can not query the serial port tx pin status. Of course, if you are using some new version or other UART family, maybe. You can assume that the TX pin is in the SPACE state ('0', +Volts) whilst performing SetCommBreak(), but I suspect that is not enough for you. If you are look to debug your code to know if a break occurred, you can short pins 2 & 3 on a 9-pin D-sub, thus loop backing the transmit to the receive. A paper clip will do. Your receive code would detect the incoming BREAK. Shorting to the incorrect pin does not cause a lasting problem with a conforming serial port, but be careful. Try this first with simple data, before testing BREAK condition. If you have a "16

Categories : Windows

XML File Input Map/Reduce Hadoop Windows Server
Your first task would be to find a way to read in xml files and feed them to your MR job, as there is no builtin InputFormat available for xml files. See this and this if you need some help(Haven't tested them personally but they look OK to me). You'll get the content within the start and end tag provided by you during the job configuration as values in your mapper. Extract the values you need and generate the output. HTH

Categories : Xml

How to retain Listbox visualization with high resolution images in windows phone 8
In my current project (winrt) I have similar problem and solved it by resizing images during binding (in getter of nested field) get { return new BitmapImage(new Uri(url)) { DecodePixelWidth = 200 }; } Hope it's help you too.

Categories : Windows Phone 8

Switching to assigning functions to objects on windows.onload rather than explicitly. Experiencing difficulties
You are missing the function keyword. You'll also want to use the ClientID which is the ID that is used on the HTML element for the browser client. window.onload = function() { document.getElementById('<%= NewQuestionTopbtn.ClientID %>').addEventListener("click",NewQuestion); }

Categories : Javascript

Linux server: Would a cache scheme help reduce hits to 3rd-party server?
I think memcached is a good choice. You can set timeout when you store content to memcached server, if key-value missed, retrieve data from 3rd-part server and store again. There is memcached extension for PHP, check doc here.

Categories : PHP

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

After switching Views, I want my label text to remain what it was before switching
Put the same code in "viewDidAppear" as well. viewDidLoad is called only once when the view is created, not every time it appears. In viewDidLoad, make sure to call [super viewDidLoad]; in be beginning. Do the similar in viewDidAppear.

Categories : Misc

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

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

Why is the result of a reduce function fed back into reduce using mongodb mapreduce
I figured out the situation. When putting the output of a map reduce job into a collection that already exists, mongo will pass both the newly reduced document and the document that was already in the output collection with the same key back through the reduce function. This works seamlessly IF you have a consistent format for the value that you emit from map and the value that you return from reduce. This is not well documented at all, but now that I have figured it out my frustration has transubstantiated into a feeling of smarts. Painful lesson learned. Good times ahead.

Categories : Mongodb

LESS contrast() function
The square brackets denote optional arguments and shouldn't appear in your code. Check out the LESS function reference and its documentation on contrast, it has an example on how to use contrast correctly: Example: contrast(#aaaaaa) contrast(#222222, #101010) contrast(#222222, #101010, #dddddd) Output: #000000 // black #ffffff // white #dddddd So your code should read: color: contrast(@popupBg, black, white, 43%); On the other hand, are you sure that @popupBg is defined? Check out this jsfiddle for a demo.

Categories : CSS

Reduce function on Map Reduce showing incorrect results -- why?
This happens because MongoDB can invoke the reduce function multiple times for the same key. Here's a simple worked example: Lets say you have just three documents in your database, each with same 'city' of 'Seattle'. After the emit phase, you will have a set of emitted objects which look like {'Seattle' : 1}. {'Seattle' : 1}. {'Seattle' : 1} After the emit phase has completed, the reduce phase starts. In the simplest case, the reduce function will be called as reduce('Seattle', [1,1,1]). In this case, your first function would work correctly. However, the reduce function may be called multiple times: reduce('Seattle', [1,1]) -> {'Seattle' : 2}, {'Seattle', 1} reduce('Seattle', [2,1]) In this case, your first reduce function would return 2 after the second reduce call as there ar

Categories : Mongodb

Same-machine-as-data processing on reduce side of map reduce
Inputs to the Reducers can reside on any node(local or remote) and not necessarily on the same machine where they are running. As Mappers complete their output gets written onto the local FS of the machine where they are running. Once this is done the intermediate output is needed by the machines that are about to run the reduce task. One thing to note here is that all the values corresponding to a particular key go the same reducer. So, it's not always possible that the input to Reducers is local, since different sets of key/value pairs are processed by different Mappers running on different machines. Now, before the Mapper output is sent to Reducers for further processing, the data is partitioned based on keys and each partition goes to a Reducer and all the key/value pairs in that part

Categories : Hadoop

Increasing Contrast Matlab
Your ifs needs ends. You assigned properly in the first part of your code, then moved to set for some reason? set is not used for what you are using it. if div(x,Y) < 100 %X being 100 in this circumstance myimage(x,Y)=0; end if div(x,Y) > 100 myimage(x,Y)=255; end I took the liberty of changing your high contrast value to 255, which sounds like what you are looking for.

Categories : Matlab

How to contrast two sets of variables (in SAS)
Not next to sas right now, but this should be roughly what you are after: data test; set temp; array arrx{*} x:; array arrz{*} z:; arriter = max(dim(arrx), dim(arrz)); do _i = 1 to arriter; if arrx{_i} ne arrz{_i} then do; arrx{_i} = .; arrz{_i} = .; end; end; run; I'm not sure what you want to do with cases where there are more elements in x than in z or vice versa, so this code will leave as they are.

Categories : Sas

Three.js: how to make a contrast sphere?
An easy solution is to use a multi-material, wireframe material combined with your original material, for an example check out: http://stemkoski.github.io/Three.js/Wireframe.html A slightly trickier (but perhaps more aesthetically pleasing) solution is to create a second object with the same geometry as the first, at the same position, scaled up by a small amount, with a solid color material, and most importantly, set the "side" parameter to THREE.BackSide. This will ensure that your second mesh does not obscure the first. For an example, check out: http://stemkoski.github.io/Three.js/Outline.html And finally, most trickily, you could do some sort of "halo" glow style effect; this solution involves a bit of coding using shaders. For an example, check out: http://stemkoski.github.io/Th

Categories : Javascript

Switching backgrounds, while switching text
Why do you want to change the id of the element if you are so keen to set the color. You can just the class on the body element which should get the work done for you. Secondly it's a bad practice to bind events inline. Use javascript to bind the events as well. <body id="color1" class="color1"> This is one way of writing the code. Code var header = document.getElementsByTagName('header')[0]; header.addEventListener('click', function () { var body = document.getElementById('color1'); document.getElementById('click').innerHTML = flip("text"); body.className = flip("color"); }); var flip = (function () { var flip = ['_addText1', '_addText2', '_addText3'], colors = ["color1", "color2", "color3"]; var count = -1, colorCount = -1; return

Categories : Javascript

Hadoop Map Reduce CustomRecordReader Reduce Phase
Just add the empty constructor, apparently Hadoop needs the class to have a default constructor, so just add it. public class Allineamento { public Allineamento() { } } And it should work.

Categories : Java

"Map Reduce" reduce function finds value undefined
You have an error in your reduceFunc2 function: var reduceFunc2 = function reduce(key,values){ var val = values[0]; //values is an array!!! // ... } Reduce function meant to reduce an array of elements, emitted with the same key, to a single document. So, it accepts an array. You're emitting each key only once, so it's an array with a single element with it. Now you'll be able to call your MapReduce normally: db.orders.mapReduce(map, reduceFunc2, {out: {inline: 1}}); The way you overridden emit function is broken, so you shouldn't use it. Update. Mongo may skip reduce operation if there is only one document associated with the given key, because there is no point in reducing a single document. The idea of MapReduce is that you maps each document into an array of key-value pair

Categories : Mongodb

increasing contrast of ggplot2 scale_colour_gradient in R?
It seems black-to-red or red-to-darkred gives you very little color space to work with. You can use hex code to assign more specific colors to your low and high settings, and add a black background to improve contrast. For instance: + scale_colour_gradient2(low="#22FF00", mid="white", high="#FF0000", midpoint=median(iris$Sepal.Length)) + theme(panel.grid=element_blank(), panel.background=element_rect(fill="black")) gives you much more contrast. Note that I am using scale_color_gradient2, which allows you to set a midpoint color and ascribe it to a summary statistic of the data (here, I used the median). I also used two colors at relatively opposite ends of the spectrum. Adding the above to your code produces: But aside from playing around with the specific colors until you're satisfi

Categories : R

How to set colors to a specific contrast ratio?
Use SASS to accomplish this. Simply install ruby and then run: gem install SASS sass --watch /path/to/sass path/to/css This will watch and convert any SASS files in the first directory to CSS in the second directory. You can then use functions in the SASS to handle lightening and darkening of colors with variables. A quick example: @black: #000; footer { background-color: lighten(@black, 20%); } and it will render completely valid CSS using ruby to handle the variables and lightening of the background by 20%

Categories : CSS

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

getaddrinfo() - Linux VS Windows
There are these magical things called man pages. For example, man 3 getaddrinfo clearly says that If the AI_PASSIVE flag is specified in hints.ai_flags, and node is NULL, then the returned socket addresses will be suitable for bind()ing a socket that will accept() connections. The returned socket address will contain the "wildcard address" (INADDR_ANY for IPv4 addresses, IN6ADDR_ANY_INIT for IPv6 address). The wildcard address is used by applications (typically servers) that intend to accept connections on any of the hosts's network addresses. If node is not NULL, then the AI_PASSIVE flag is ignored. The purpose of the getaddrinfo() function is simple: it tries its best to convert user-specified strings into numeric data an application can use to create a socket, eit

Categories : C

Native windows Linux
As wine demonstrates, the PE format isn't really the problem with compatibility. PE only defines how the program is pieced together at load time. Under windows, RUNDLL interprets it, loads all the program sections to memory, loads all the supporting dlls to memory and patches up the function pointers so that there is a program sitting in memory ready to go. (See http://msdn.microsoft.com/en-us/library/ms809762.aspx for more details. Its a good read!) There is little stopping you writing a kernel module to do all of this. With the details in the page linked above it may not be to hard and someone may already have done it. The real issue is the fundamentals of the operating system. Even if linux could load a PE, there would be problems around the fundamental difference in file names

Categories : Linux

XOR Crypt with Linux & Windows different
I'd guess this is an encoding issue: the charset might be different on windows and linux. I'd suggest byte[] bytes = s.getBytes(charset); ... return new String(bytes, charset) , where charset is some explicit charset.

Categories : Java

Windows and linux max threads
Linux, it's pretty easy. cat /proc/sys/kernel/threads-max Windows, less so. Basically it depends on how much ram you have / how much you allocate on each thread's stack - see What's the maximum number of threads in Windows Server 2003?; but basically <1000

Categories : C++

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



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