w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Implementing RAID-i using RAID-0 and FUSE
FUSE is not really an appropriate way to do this. It's intended to be used to implement a filesystem, and that isn't really what you're trying to do here -- FUSE will pass you events like "get me all files in this directory", which is considerably higher-level than you're after. (You'd probably rather have simple events like "read this block".) There is a project to allow a block device to be implemented in userspace (BUSE), but it's pretty preliminary. I'm not sure how well it'll work for this.

Categories : Misc

In win32 C++ programming how can I duplicate a window style?
DWORD existingStyle = (DWORD)GetWindowLongPtr(hWnd, GWL_STYLE); DWORD existingExStyle = (DWORD)GetWindowLongPtr(hWnd, GWL_EXSTYLE); This gets the existing styles (dwStyle parameter to CreateWindowEx) and extended styles (dwExStyle parameter CreateWindowEx). Note also that you should pretty much not call GetWindowLong directly. Although in this case it's harmless it's not a good habit to get into, because it doesn't work with pointers on 64-bit Windows. GetWindowLongPtr is documented as what you should call instead.

Categories : C++

Setting Up a linux raid from dd images
Well "mdadm --assemble" would have been a better choice before running "mdadm --create" Running --create should be your last resort. With your --create command the problem is you most likely specified the wrong drive order or the wrong raid parameters. With --assemble mdadm does all that work so the easiest way forward is probably to create new images and try... mdadm -v --assemble /dev/md0 /dev/loop0p1 /dev/loop1p1 /dev/loop2p1 /dev/loop3p1

Categories : Linux

False Sharing only became noticeable on certain machines
False sharing only occurs with blocks of 64 bytes. You need to be accessing the same 64-byte block in all four threads. I suggest you create an object or an array with long[8] and update different cells of this array in all four threads and compare with the four threads accessing independent arrays.

Categories : Java

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

Spring Data JPA and MySQL: How to avoid "duplicate entry" error in multithreaded environment?
duplicate entry error would occur when two records of the same entity are attempted to be inserted . things to check would be : is the same JPA/Hibernate session shared across the threads doing the updating at time of the error . how is the unique record id generated ? ( myqsl auto-increment ; id generator code . etc ) and if there's an id column does it differ from the actual Primary Key ( the constraint ) of the table .

Categories : Mysql

IBM Worklight 6.0 - Gets a noticeable blip in hybrid application(used Dojo toolkit 1.9) while loading the framework libraries and css?
Did you put "visibility: hidden" on your body element? You need to put it (and remove the "display: none" that some worklight versions are adding) and Dojo Mobile will make sure to remove it when it is ready to display the screen.

Categories : Android

A good programming language is a conceptual universe for thinking about programming
The meaning of this quote is: What we need is not just another programming language but a conceptual universe for thinking about software development, embodied in a kind of language that is new to computer science -- a language that will bridge the gap between programming and software development at large.

Categories : Misc

Is it good programming practice to use shell scripts in systems programming
You're running the shell script from within code in another language? In that case using a shell script is almost certainly unnecessary. Virtually all languages allow you to run an arbitrary command and capture the output. For example, C and friends have popen() and Perl, Ruby and such have backticks (`lpstat -a` returns the output of that command as a string). This kind of approach makes it unnecessary to have an extra shell script or a temporary file.

Categories : Bash

Copying a WF4 instance store database from production environment to development environment?
Jesús López gave me the answer at this MSDN thread, where I asked exactly the same question as in this StackOverflow’s thread. First, he asked: “Is the [IIS] path to the workflow service (the xalmx file) the same in production than in development? If the path is different because the virtual directory is different then is also different the WorkflowHostType column and that might cause problems.” After letting him know that IIS site names were actually different in production and in development environment, even though the rest of the paths to workflow services were the same, he replied: “Both [IIS sites] must have the same name. I've just tested it. I changed the site name in IIS and suddenly WorkflowHostType changed. So idle persisted workflows won't load any more.” Then he

Categories : Dotnet

Using MySQL on development environment and SQL server on the live environment
While on the development environment, I have installed the commercial system with the default MYSQL that comes with the product. Due to licenses & resource restrictions. Can't you use SQL Express? But yes, you can use Entity Framework with MySQL, and it should be possible to accomplish by just changing the connection string. Beware that the MySQL-EF connector seems not to support all possiblities of Linq to Entities.

Categories : Asp Net Mvc

What is the difference between the C programming language and C programming under linux?
The C language is governed by the ISO approved C standard and it does not take in to account the underlying platform on which you use C. So from the perspective of the language standard there is no difference, and a standard compliant program shall work correctly on both. However in practical usage one needs to do platform specific things for ex: IPC mechanisms, multithreading, file access and so on which are specific to the platform, such functionality will vary from platform to platform because each will provide functionality specific to itself. Note that such functionality is not covered by the C language standard, so using it makes the program non portable across other platforms.

Categories : C

Java Programming : Dynamic Programming on stairs example
why and how she employs the function map here? The book shows a dynamic programming technique called memoization. It is used to avoid calculating the same number again: if the element is not -1, then it has been computed again, and re-calculating it would mean wasting lots of CPU cycles. DP computes the value once, and then returns it every time the value is needed. map here is array right? Correct, map is of an array type. I do not see any line to save an input to the map array but how would it return something? That would be the assignment on the third line from the bottom: map[n] = countDP(n-1, map) + countDP(n-2, map) + countDP(n-3, map); Anybody has an idea of C++ or C version of this code? It is hard to understand this code. Maybe not because of the JAVA gramma

Categories : Java

Natural Language Programming vs. Literate Programming
Natural language programming is a system for expressing instructions to a computer in a form approximating a language humans write or speak. NLP syntax structure usually resembles human-language sentence structure, in a form that might sound stilted to a native speaker, but which tends to read almost like the real language. Many NLP implementations are focused on querying data stores rather than writing programs, but actual programming implementations also exist. Literate programming is a system for simultaneously writing programs and writing about programs. Unlike NLP, the code portions of a literate program are written in traditional programming languages. The classic examples, for which the name was coined, are Donald Knuth's writings on the TeX typesetting system. Published as h

Categories : Misc

How to convert Text-based programming code (stored in DB) into actual programming code?
The hard way is to interpret the code within the database, the easier way is to store c# code and runtime compile it with CodeDOM http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx Or take a look at Iron Python. http://ironpython.net/

Categories : C#

How to combine two multidimensional arrays with showing duplicate keys or if duplicate, must add the values
$array1 = array( 'a1' => array(200,300,300), 'a2' => array(100,600,200)); $array2 = array( 'a1' => array('gen','gen2','gen'), 'a2' => array('gen2','gen3','gen3')); $result = array('a1' => array(), 'a2' => array()); foreach($array2 as $k => $v) { foreach ($v as $k2 => $v2){ if (array_key_exists($v2, $result[$k])){ $result[$k][$v2] += $array1[$k][$k2]; } else { $result[$k][$v2] = $array1[$k][$k2]; } } } Output: Array ( [a1] => Array ( [gen] => 500 [gen2] => 300 ) [a2] => Array ( [gen2] => 100 [gen3] => 800 ) )

Categories : PHP

Hudson server running app engine, duplicate shell script executions result in duplicate property errors
It might be the case that the dev_appserver is already running and then you run it again with hudson job. The best way will be to stop the dev_appserver instance first and then pump it up again.

Categories : Python

For iOS, what is the difference of the Concurrency Programming Guide and the Threading Programming Guide?
This is written in a warning box inside of the Threading Programming Guide Important: If you are developing a new application, you are encouraged to investigate the alternative OS X technologies for implementing concurrency. This is especially true if you are not already familiar with the design techniques needed to implement a threaded application. These alternative technologies simplify the amount of work you have to do to implement concurrent paths of execution and offer much better performance than traditional threads. For information about these technologies, see Concurrency Programming Guide. So, really the difference is that the Threading Programming Guide is older and discouraged from being used in modern Objective-C. HOWEVER, as noted in the comments, for operations that ne

Categories : IOS

Differences between wpf xaml/programming and metro xaml/programming
The short answer is yes, you will run into various nuance differences it will take some time to get used to. If for example, you're coming from more of a Silverlight background, you may find it a bit easier of a transition than if you've been strictly WPF. However most of the time the concepts will remain the same and the differences will be trivial. Like for example more reliance on VisualStateManager rather than Style Triggers, or newly introduced available controls at your disposal like VariableSizeWrapGrid and newly available gesture functionality targeted more towards the touch enabled devices, etc, etc... Howevever this topic can be found covered in length and in detail with a quick trip to your favorite search engine results, so I wouldn't be surprised if you find your question dow

Categories : Wpf

Good programming etiquette/ good programming practices
Val is a left over Legacy function. I would recommend switching to type specific converters. This also provides protection for values that are not convertible like letters. Remember to convert types. Turn Option Strict On and you will see. Integer.TryParse Dim result As integer = 0 Dim numberA, numberB as Integer If Integer.TryParse(TextBoxNumbA.Text, numberA) Then If Integer.TryParse(TextBoxNumbB.Text, numberB) Then result = numberA + numberB End If End If TextBoxResult.Text = result.ToString("n2")

Categories : Vb.Net

Find duplicate values in an array which creates a new array with key as duplicate keys and values as the dupes
This should do what you want. Loop over the array, and see if the value was already in there. If so, add it to the result. $arr_duplicates = array(); foreach($array as $k=>$v){ // array_search returns the 1st location of the element $first_index = array_search($v, $array); // if our current index is past the "original" index, then it's a dupe if($k != $first_index){ $arr_duplicates[$k] = $first_index; } } DEMO: http://ideone.com/Kj0dUV

Categories : PHP

TCP/IP Programming in C
Maybe you can try to look at Network Socket on the web. You can easily find a lot of good tutorial that can answer your question. You can use the compiler you want on your system, depending on what are you using now.

Categories : C

Thread Programming in C++/CLR
Be Aware that you leave the Main function and therefor all threads will be terminated... so place an Console.ReadLine() in the last line of your "main"... Also: Your source code is C# and not C++/CLI...

Categories : Multithreading

Exercise6-4 programming in c
Here is your C code. #include <stdio.h> #include <conio.h> int main (void) { int loop; float value, acc = 0; char o; printf ("Simple Printing Calculator Program "); printf (" KEY: + Add - Subtract * Multiply / Divide "); printf ("S Set Accumulator E End Program "); printf ("Enter a number and an operator, then press enter "); printf ("Type in your expression: "); for ( loop=0 ; loop>-1; ++loop) { { scanf ("%f %c", &value, &o); if ( o == '+' ) { acc = acc + value; printf (" %.2f ",acc); } else if ( o == '-' ) { acc = acc - value; printf (" %.2f ",acc); } else if ( o == '*' ) { acc = acc

Categories : C

Combining VB and C/C++ programming?
Creating a class library in VB.net is not much different from any other Visual Studio library. You can see a general know how here: http://www.csunit.org/tutorials/tutorial6/#createclasslibrary Once you have your gui library, you can easily create a vb.net application that will show your gui. If you want a C backend, you won't be able to use COM interfaces, so you'll have to use pipes manually to do IPC. If you do a C# or C++ backend (which you might want to do), then you can create a COM+ interface in those languages that the VB.NET frontend can interact with to send messages. http://www.codeproject.com/Articles/4732/COM-Interface-Basics

Categories : C

comet programming using JS or PHP
For comet programming you can use node.js you can also use meteor. Server side javascript can run using node.js and meteor runs in Node.js container on server-side.

Categories : PHP

Bayesian R Programming
Here is your code after clean-up: binomial <- function(nmax = 100, thr = 0.95, alpha = 1, beta = 1, p_true = 0.5, p_0 = 0.5){ targetatnmax <- 0 for(j in seq.int(0,nmax)){ if(pbeta(q = p_0, shape1 = alpha + j, shape2 = beta + nmax - j, lower.tail = FALSE) < thr){ targetatnmax <- j + 1 } else { break } } result <- list(targeratnmax = targetatnmax) return(result) } res = binomial() res #$targeratnmax #[1] 59 The main problem (other than the syntax errors and not existent objects) was that your loop ran from nmax to 0 instead of the other way arround. There is probably potential for optimi

Categories : R

MIDI Programming for web
It looks like it's possible. There is a browser plugin by Jazz-soft which adds low level MIDI support. http://jazz-soft.net/ WebMIDI is an API supporting the MIDI protocol, enabling web applications to enumerate and select MIDI input and output devices on the client system and send and receive MIDI messages. http://www.w3.org/TR/webmidi/ A bit of web searching also turned up something called Web MIDI API Polyfill.

Categories : Windows

MVC programming best practise
It is perfectly OK to have a ViewModel object which encapsulates multiple model objects. You did right. It depends on what's logically "correct" to your applications. For some purposes you should create an IEnumerable object and iterate it in the view, while in other cases it would make more sense to simply have to model objects in the ViewModel.

Categories : Asp Net Mvc

How to do looping in C# programming?
There are varying ways.. the most obvious being instead of this: Image ball1; Image ball2; Image ball3; // .. etc ... You would put those in an array also: Image[] balls = new Image[20]; ..same with your speeds. Then you can change your update method to this: private void OnUpdate(object sender, object e) { for (int i = 0; i < balls.Length; i++) { Canvas.SetLeft(balls[i], ballSpeedXAxis[i] + Canvas.GetLeft(balls[i])); Canvas.SetTop(balls[i], ballSpeedYAxis[i] + Canvas.GetTop(balls[i])); } } Others include putting the already created images into a List<Image>.. but that's a bit yuck.

Categories : C#

RPG inventory in C programming
You need to move the struct definition to be outside of your function. Your specification for how long the line should be is wrong. You need to specify a number of bytes that is long enough to take in an entire line. When you use fgets() to get a line, you should not use fscanf() to read from the file. You are already using fgets() to read from the file. You use sscanf() to read data from the string that is contained within line. The above is enough to get your program to do something nominally useful. To return a list of items, you will need to actually call malloc() (or some other similar function) to create the memory for your "dynamically created list" that you have specified as a requirement. Since you don't know how many items you have up front, you either need a way to discover

Categories : C

C Programming under Windows
cxCaps=(tm.tmPitchAndFamily & 1?3:2)*cxChar/2; and if (tm.tmPitchAndFamily & 1) { cxCaps=3*cxChar/2; } else { cxCaps=2*cxChar/2; } are the same On the other hand, & is bitwise operator AND In this case means: if bit 1 is set in tm.tmPitchAndFamily Bitwise AND The bitwise AND operator is a single ampersand: &. A handy mnemonic is that the small version of the boolean AND, &&, works on smaller pieces (bits instead of bytes, chars, integers, etc). In essence, a binary AND simply takes the logical AND of the bits in each position of a number in binary form. For instance, working with a byte (the char type): 01001000 & 10111000 = -------- 00001000 The most significant bit of the first number is 0, so we know the most signi

Categories : C

C Programming - Struct
Yes, they do, until you reassign p1.a1, then of course they don't. You could just print them out to prove it. Example code: #include <stdio.h> struct s { char *a1; int a; }; int main(void) { struct s p = { "asdv", 11 }; struct s p1 = p; printf("They're the same: %p %p ", p.a1, p1.a1); p1.a1 = "vshaj"; printf("%d %s ",p.a,p.a1); printf("They're different: %p %p ", p.a1, p1.a1); return 0; } Example run: $ make example cc example.c -o example $ ./example They're the same: 0x10e258f2a 0x10e258f2a 11 asdv They're different: 0x10e258f2a 0x10e258f48

Categories : C

Server programming in C++
For first part, have a look over TCP. It provides a ordered and reliable packet transfer. Plus you can have lot of customizations in it by implementing it yourself using UDP. Broadly, what it does is, Server: 1. Numbers each packet and sends it 2. Waits for acknowledge of a specific packet number. And then re-transmits the lost packets. Client: 1. Receives a packet and maintains a buffer (sliding window) 2. It keeps on collecting packets in buffer until the buffer overflows or a wrong sequenced packet arrives. As soon as it happens, the packets with right sequence are 'delivered', and the sequence number of last correct packet is send with acknowledgement. For second part: I would use HTTP for it. With some modifications. Like you should have some very unique indicator to tell c

Categories : C++

Functional programming in C/C++?
Edit: I'm not sure why this answer gets so much hate. The question asks specifically about function pointers, and whether their presence means that C++ supports "functional programming in general". In a sort of technical, not-very useful way: yes*. The real essence of "functional" programming is that functions are values. C and C++ won't give you any help in terms of things like the easy creation and destruction of lexical closures, nor will it do you any favors in terms of partial application. The fact that you can simulate the appearance of functions behaving kinda like values using function pointers is really just a consequence of the equivalent expressivity languages. Trying to conflate this with "functional programming" is really wading deep into the Turing tarpit. *For a reall

Categories : C++

When should I use parallel-programming?
There are very few problems which can't be solved more quickly by a parallel program than by a serial program. There are very few computers which do not have multiple processing units. I conclude, therefore, that you should use parallel programming all the time.

Categories : Algorithm

use of

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