w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Combining solve and dsolve to solve equation systems with differential and algebraic equations
Now I assumed that you wanted the code to be rather general, so I made it to be able to work with any given number of equations and any given number of variables, and I did no calculation by hand. Note that the way that the symbolic Toolbox works changes drastically from year to year, but hopefully this will work for you. Now one can add the equation Eq1 to the list of inputs of dSolve but there are two problems with that: One is that dSolve seems to prefer character inputs and the second is that dSolve doesn't seem to realize that there are 3 independent variables a, b, and c (it only sees 2 variables, b and c). To solve the second problem, I differentiated the original equation to get a new differential equation, there were three problems with that: the first is Matlab evaluated the d

Categories : Matlab

Knockout model binding technique
You don't need to create a new City object. Instead, just update the existing one. Any views that are data-bound to that EditingCity object should be automatically updated. So, instead of writing: self.EditingCity(new City({ CityId: cityid, CityName: cityname })); You should be writing: self.EditingCity().CityId(newCityId); self.EditingCity().CityName(newCityName);

Categories : Knockout Js

What is differential inheritance in JavaScript?
As the other commenters and the articles they've linked already suggested, differential inheritance is "just" the normal, known prototypical inheritance. Yet by using the term differential inheritance you focus on a more pure pattern than it is known in JavaScript (though quite common in other prototypical languages like Self, NewtonScript or Io). Unlike the pseudo-classical pattern, there are no constructors with new usage at all. Instead, by using Object.create you create a new object inheriting from the target object in one step, and then you create the necessary instance properties (only those that are different) manually (not with a constructor). It's not unusual to inherit from an object that you would consider to be an instance otherwise, instead of from a dedicated prototype obje

Categories : Javascript

Restoring differential backups from SQL Server
You should be setting the database to single user, if there is the potential for users to be connected (and if it is okay to kill their sessions). Since you are restoring the database, I would think that it is okay. You will need to specify the replace option on the full backup restoration. Also you only need to restore the latest differential backup (using with recovery), as it will contain all the changes since the last full backup. It should also be noted that this restore will not include transactions that have occurred since the last differential backup. I would think about using log backups every 3 hours. This will have less impact on your system and will allow the log to truncate (if you are in full recovery). In this restore scenario, you will need the full backup and all the

Categories : Sql Server

On ordinary differential equations (ODE) and optimization, in Python
Use scipy.integrate.odeint to handle your integration, and analyse the results afterward. import numpy as np from scipy.integrate import odeint ts = np.arange(0,3000,1) # time series - start, stop, step def rhs(y,t): return 0.01*y*(1-y) y0 = np.array([1]) # initial value ys = odeint(rhs,y0,ts) Then analyse the numpy array ys to find your answer (dimensions of array ts matches ys). (This may not work first time because I am constructing from memory). This might involve using the scipy interpolate function for the ys array, such that you get a result at time t. EDIT: I see that you wish to solve a spring in 3D. This should be fine with the above method; Odeint on the scipy website has examples for systems such as coupled springs that can be solved for, and these could be

Categories : Python

Fastest way to run a differential update on two collections of different types?
If you only have a Func<TSource, TTarget, bool> Equals function the only possible algorithm is to have two nested loops and compare each element with each other element. Performance is quadratic and quickly unacceptable. Knowledge of the key restricts the kind of possible "comparer functions" to the intuitive notion of equality by key. This enables the use of hashing. Therefore you need to base this on a Func<TItem, TKey> and use some kind of hashing (HashSet, ToDictionary or ToLookup). In database terms what you want is a full outer join. I suggest you keep a Dictionary<TKey, Tuple<List<TItem>, List<TItem>> which contains the set of items from both sources for a given key. First you add all items from both sources to the dictionary, then you iterate ove

Categories : C#

Matlab Differential Equations Euler’s method
After fixing the errors pointed out by Danil Asotsky and horchler in the comments: avoiding name conflict with built-in function 'diff' changing the order of arguments to t,y. decreasing the time-step dt to 0.1 converting ODE right-hand side to an anonymous function (and removing unnecessary parentheses in the function definition), your code could look like this: F = @(t,y) -3*y+t*exp(-3*t); tI = 0; yI = -0.1; tEnd = 5; dt = 0.1; t = tI:dt:tEnd; y = zeros(size(t)); y(1) = yI; for k = 2:numel(y) yPrime = F(t(k-1),y(k-1)); y(k) = y(k-1) + dt*yPrime; end plot(t,y) grid on title('Engr') xlabel('Time') ylabel('y(t)') legend(['dt = ' num2str(dt)]) which performs as expected:

Categories : Matlab

Any way to solve a system of coupled differential equations in python?
For the numerical solution of ODEs with scipy, see the function scipy.integrate.odeint or the class scipy.integrate.ode. Some examples are given in the SciPy Cookbook (scroll down to the section on "Ordinary Differential Equations").

Categories : Python

Looking for a specific C++ technique
There are some good answers in these previous questions: Having Public properties in c++ class C#-like properties in native C++? Portability of Native C++ properties Property like features in C++? dot property access in C++

Categories : C++

C# Impersonation technique
There are 2 problems with your approach: You are trying to impersonate a remote machine account on a local machine; this won't work. The credentials of a machine account can only be validated by that machine. In addition, that account has no rights on the local machine, so it doesn't really make sense to impersonate it. You need to impersonate a domain account. When you use a tool like putty, the credentials are sent to the remote machine and not validated by the local machine. This is why you can use a machine account of the remote machine. You need to give proper paths for the files. Nowhere do you indicate that these files are on the remote machine. Use something like "\machinec$path ofile". The details on what are going to work or not will depend on your network and OS, whic

Categories : C#

Does less have the "respond-to" technique like SCSS
This is how I do my media queries in LESS, utilising query bubbling as outlined in the article you linked to: @palm : ~"screen and (max-width: 40em)"; @lap : ~"screen and (min-width: 50em)"; @desk : ~"screen and (min-width: 60em)"; .some-class { color: red; @media @lap { color: blue; } } Unfortunately though there is no way to have it all compile down to one media query block. This may also be the case with SASS/SCSS. The only reason this could be a problem is that is increases file size. However you shouldn't worry about that. Why? The repetition of multiple media query blocks is negated by GZIP (more repetition == better compression). So providing your server is encoding with GZIP (most do, if not you should be able to enable it, it's worthwhile) you will not se

Categories : CSS

Which sorting technique is this code?
It's most similar to bubble sort. Read more here: http://en.wikipedia.org/wiki/Bubble_sort. Your loops are different, but it still works because you iterate from j to i in each pass, instead of iterating over the entire collection. For example: First iteration: i = 0. Second loop doesn't execute. {4,2,1,3,5,7,5,6,8} Second iteration: i = 1. Second loop comapres 4 and 2, switches them. {2,4,1,3,5,7,5,6,8} Third iteration: i = 2. Second loop compares 2 and 1, switches. Compares 4 and 1, makes a switch. {1,2,4,3,5,7,5,6,8} Fourth iteration: i = 3. Second loop compares 1 and 3, no switch. Compares 2 and 3, no switch. Compares 4 and 3, switches. {1,2,3,4,5,7,5,6,8} Fifth iteration: i = 4. Second loop compares 1 and 5, no switch. Compares 2 and 5, 3 and 5, 4 and 5, no switches. {1,2,

Categories : C

Sorting Technique Python
The sorting algorithm you're describing actually is called Combsort. In fact, the simpler bubblesort is a special case of combsort where the gap is always 1 and doesn't change. Since you're stuck on how to start this, here's what I recommend: Implement the bubblesort algorithm first. The logic is simpler and makes it much easier to reason about as you write it. Once you've done that you have the important algorithmic structure in place and from there it's just a matter of adding gap length calculation into the mix. This means, computing the gap length with your particular formula. You'll then modifying the loop control index and the inner comparison index to use the calculated gap length. After each iteration of the loop you decrease the gap length(in effect making the comb shorter) by

Categories : Python

What is the best technique to render circles in iOS?
Personally, I think you are over-thinking the problem. If you're only drawing a few circles, there is going to be very very little performance/maintenance impact whichever you decide on, and even if you optimize it to hell your users aren't getting any benefits from it. Do whatever you're doing now; focus on making the app's content great, and come back to performance later on if you really need to. With that being said, I would recommend using drawing libraries. Rounding corners is slow and rather non-intuitive Using image files will be a problem if you decide to do stuff like change colors. Also, sometimes images don't look that great after you scale them.

Categories : IOS

Soft Shadow Technique using XNA 3.0
Simplest way would be use Percentage Closer Filtering. Basically it works by taking a few shadow map samples. You can start from an article in GPU Gems.

Categories : C#

Technique for smaller Qt setups of C++ apps
When you create a Qt application, you only include needed module (QtCore, QtGui, etc, ..) The more modules you will included, bigger will be the weight of library. 15 MB is not so big compare to other frameworks..

Categories : C++

Better Technique: Reading Data in a Thread
I think you're going about the multithreading part the wrong way. I can't really explain it, but threads should cooperate and not compete for resources, but that's exactly what's bothering you here a bit. Another problem is that your timeout is too long (so that it annoys users) and at the same time too short (if the AD server is a bit slow, but still there and serving). Your goal should be to let the thread run in the background and when it is finished, it updates the list. In the meantime, you present some fallbacks to the user and the notification that the user list is still being populated. A few more notes on your code above: You have a variable m_thread that is only used locally. Further, your code contains a redundant check whether that variable is null. If you create a user list

Categories : C#

Interpolation technique inpainting Opencv
The very link that you gave to the OpenCV docs tells what algorithms are used: INPAINT_NS Navier-Stokes based method. INPAINT_TELEA Method by Alexandru Telea [Telea04]. Here are links to papers on the two methods used http://iwi.eldoc.ub.rug.nl/FILES/root/2004/JGraphToolsTelea/2004JGraphToolsTelea.pdf http://www.math.ucla.edu/~bertozzi/papers/cvpr01.pdf

Categories : Opencv

what's wrong with my sensor monitoring technique?
Change variable declaration: List<float[][]> array = Collections.synchronizedList(new ArrayList<float[][]>()); Inside the runnable: Iterator<float[][]> values = array.iterator(); while (values.hasNext()) { float[][] result = values.next(); //calculating. //after calculating remove the items. values.remove(); }

Categories : Java

Super-aggressive 'caching' technique
This idea will have issues with dynamic web sites... how will you treat dynamically generated web pages? Another idea would be to save each page into a static html file on the server, and then serve the static page, which will be regenerated when needed. You should also cache the static parts of your website, i.e. images, scripts, CSS, and store these in the cache of your visitors' browsers. In Apache, you could use mod_expires, and then set up an .htaccess file like this: ### turn on the Expires engine ExpiresActive On <FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|swf)(.gz)?$"> ExpiresDefault "access plus 1 month" FileETag None </FilesMatch> This will basically cache all of the static parts of your website in your visitors' browser cache, so they will stop refetching

Categories : Javascript

How to use public and private key encryption technique in C#
Code example: private static string _privateKey; private static string _publicKey; private static UnicodeEncoding _encoder = new UnicodeEncoding(); private static void RSA() { var rsa = new RSACryptoServiceProvider(); _privateKey = rsa.ToXmlString(true); _publicKey = rsa.ToXmlString(false); var text = "Test1"; Console.WriteLine("RSA // Text to encrypt: " + text); var enc = Encrypt(text); Console.WriteLine("RSA // Encrypted Text: " + enc); var dec = Decrypt(enc); Console.WriteLine("RSA // Decrypted Text: " + dec); } public static string Decrypt(string data) { var rsa = new RSACryptoServiceProvider(); var dataArray = data.Split(new char[] { ',' }); byte[] dataByte = new byte[dataArray.Length]; for (int i = 0; i < dataArray.Length; i++) { dataByte[i] = C

Categories : C#

MySQL string searching technique?
I think the wild card will help you a little bit. Check it out here: http://www.w3schools.com/sql/sql_wildcards.asp My suggestion is try adding a column named FULLNAME for example, then can use something like this: select id from members where fullname='%Jack%' or fullname="%Daniel%" or email="%jack%" or email="%daniel%"

Categories : Java

Efficient thread synchronization technique for STL map
First question: how efficient should grading students be? Second question: is multithreading really needed? If it is for efficiency, maybe it isn't even helping. After that, you can consider Reader/Writer lock, where Reader locks aren't exclusive. But watch out, because the actual grading is writing, so you probably need another lock per student to avoid contention.

Categories : C++

Fast integration technique in matlab?
If your integrand doesn't change (variables not a function of x) then I see no reason why you couldn't take the output of the symbolic integration and use it numerically without performing the integration: kmp = K.*m.*period/2 L = exp(-1i*(ax.*t+kmp)).*sin(kmp)./kmp Otherwise, yes, you should look into Matlab's quadrature integration methods – they work vary similary to sym/int, but are for numerical values and functions. In newer versions of Matab try integral or use quadgk. Something like this: fun = @(x)exp(-1i*(ax*t+(m*K*x))); L = (1/period)*integral(fun,0,period); Note that for highly oscillatory functions, most quadrature methods have difficulty. You should check that your results are actually correct in such cases. If Matlab's built-in quadrature routines have trouble, y

Categories : Matlab

How to evaluate dimensionality reduction technique?
You could use SOM technique to be able to see several dims in two dimensions. There are other techniques also, I will update the answer if I can remember their name, but I am used to SOM. You can find one good SOM toolbox for matlab clicking here. This helps you to visualize, but the evaluation should use an efficiency meter that measure what is important for your dimension reduction (the SOM itself may be used as a dimension reduction technique). What is important, to compress data with minimal loss? To compress data as most as possible? To represent data in a visible way? You can probably measure the techniques efficiency without needing to see how did them changed the data space representation, all you need is a good function to measure how good your technique is.

Categories : Matlab

assistance with technique for htaccess debugging
Your current rule will allow you to debug. Try opening this URL: http://mydomain.com/contacts?foo=bar then it will show you original and modified query in your browser. It will show http://mydomain.com/contacts?vardump&reqhost=foo=bar&foo=bar in your browser. However if you are loading http://mydomain.com as per your rule it will indeed become http://mydomain.com/?vardump&reqhost= as both $1 and %{QUERY_STRING} will be empty. Also better not to use R=301 for testing, make it R=302. Clear you browser cache once before you test. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.

Categories : Htaccess

Progressive Image Loading Technique
It seems to me that there is no actual progressive loading going on in Google Images. When you click on an image thumbnail, there is a quick animation "unveiling" the full resolution image. While the animation is happening, the image that is partly displayed is actually just the thumbnail (size 251x201), but upscaled to the resolution of the larger image (1280X1024). The way to do this upscaling in HTML should be something like this: <img src="thumbnail.jpg" width="251" height="201"> The full resolution image is then displayed when the animation is completed, replacing the upscaled thumbnail. So this is not a progressive loading after all. Still, you might want to read about Progressive JPEG: http://en.wikipedia.org/wiki/JPEG#JPEG_compression.

Categories : C#

Technique to prevent accidental re-enumeration of IEnumerable?
For this specific issue, I'd say that the solution is "don't write incorrect code". Especially when results can be generated without altering any state (like when you enumerate elements from a list), I think it should be okay to create multiple enumerators from any enumerable. You could create an IEnumerable wrapper that would ensure GetEnumerator is called only once, but what if you actually legitimately need to call it twice? What you really want is to catch mistakes, not to catch enumerables being enumerated multiple times, and that's not something you can easily put in a software solution. Maybe the issue was that clickBatch and clicks have the same type, so the compiler couldn't distinguish between either.

Categories : C#

Why use Perl OO simply as a data encapsulation technique?
Every situation is diffferent, and whether you choose to use Moose or another object framework (or none at all) really comes down to what you're planning to do and what your requirements are. There might not be any immediate advantage to writing the system in question with Moose, but consider these: You get free access to Moose's metaobject system, so you can interrogate the objects for useful information in a well-defined way You can extend the provided classes using Moose's inheritance system; so even if they don't use inheritance themselves, the framework is already in place for you to do so if needed You have peace-of-mind because you know the system was built on the most widely-deployed and well-tested object framework for Perl. People know Moose, meaning there is a higher probabil

Categories : Perl

Is there any technique or plugin to illuminate an element(button)?
Glowing buttons (HTML & CSS): HTML: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Glowing buttons</title> </head> <body> <!-- Blue --> <a href="#" class="button blue">Hello World</a> <!-- Yellow --> <a href="#" class="button yellow">Hello World</a> <!-- White --> <a href="#" class="button white">Hello World</a> </body> </html> COMPASS (SCSS): @import "compass/css3/images"; @import "compass/css3/border-radius"; @import "compass/css3/box-shadow"; @import "compass/css3/animation"; body { background: #000 url('http://subtlepatterns.com/patterns/office.png'); padding: 30px; font-family: "Helvetica Neue

Categories : Javascript

is using this technique for android request/response safe?
You will have to use a thread or Asynctask for network related operation. HttpResponse http_response = http.execute(http_get); Post Honeycomb you will get NetworkOnMainThreadException. Use AsyncTask or use a thread`. http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html For Asynctask http://developer.android.com/reference/android/os/AsyncTask.html Note: You cannot update ui from the background thread. You can update ui on the ui thread.

Categories : Android

best technique for saving CSV logs in Azure Blob
I suggest your work objects by using the BlobStream, as in the following example. _container.CreateIfNotExist(); CloudBlob inputBlob = _container.GetBlobReference(outputBlobUri); CloudBlob outputBlob = _container.GetBlobReference(inputBlobUri); using (BlobStream input = inputBlob.OpenRead()) using (BlobStream output = outputBlob.OpenWrite()) { ProcessImage(input, output); output.Commit(); outputBlob.Properties.ContentType = "image/jpeg"; outputBlob.SetProperties(); FunnyAppRepository<Post> postRepository = new FunnyAppRepository<Post>(); Post post = postRepository.Find(partitionKey, rowkey); post.PostImage = outputBlobUri; post.State = true; postRepository.Update(post); postRepository.SubmitChange(); _queue.DeleteMessage(message); }

Categories : C#

click-through is not working - is SetWindowLong the proper technique?
The right way to set additional window styles is by overriding the CreateParams getter. That way the styles will be present from creation. SetWindowLong may set them too late to be 100% effective.

Categories : C#

Why is this so slow to load? Is there any technique to make this faster?
Classic example of the N + 1 problem. You retrieve @messages = current_user.mailbox.inbox.page, which will retrieve records from the messages table. In the view, you loop through them and check each message's recipients list (a has_many relationship, probably based on the receipts table, as can be seen here). So, for each message, you end up sending another query to the database. You can correct this by retrieving the recipients together with the messages (and the last_message association as well, since you're using it): @messages = current_user.mailbox.inbox. includes(:receipt, :last_message).page Also, you may have a different problem compounding this, as 25 queries should execute pretty quickly on a modern computer. I'd recommend using something like the RailsPanel tool to t

Categories : Ruby On Rails

Best technique to store gender in MySQL Database
Personally (because this is a somewhat subjective question) I'd go with ENUM. MySQL doesn't support CHECK constraints, so the ENUM is the only way to really make sure the value is M or F (or m or f). To me, that's the most important point. In addition, the ENUM should only need one byte of storage space (according to the docs), so it's just as efficient storage-wise as CHAR(1) or TINYINT. I don't understand the TINYINT approach at all because you end up with queries like this: SELECT * FROM myTable WHERE gender = 1; Is 1 male or female? And if it's male, is female 0? Or is it 2? Or maybe 16? You already have to remember a pile of things to write (and maintain) an application; no need to add to that pile.

Categories : Mysql

Better technique to send mail if new record inserted
You don't give any details, but I guess you're looking for something like a database trigger. I don't know which DBMS you're using, but take a look at this post: C# / SQL Listener to tell me if a row has been inserted into a table

Categories : C#

Reshaping data frame using a custom technique
Your thinking wasn't too far off. The next step would have been to aggregate your output. Consider the following: aggregate(CrimeNew ~ Month + Crime, crimeData3, length) # Month Crime CrimeNew # 1 2010-12 Anti-social-behaviour 3 # 2 2011-01 Anti-social-behaviour 4 # 3 2011-01 Arson 2 # 4 2010-12 Robbery 2 # 5 2010-12 Theft 1 # 6 2011-01 Theft 5 # 7 2010-12 Violent-Crime 2 As to improving your code, there's no need for the for loop: myseqFinal <- rep(LETTERS[seq_along(instances)], times = instances) However, as mentioned in the comments, you can just use table on the two columns of your data, and wrap that in data.frame. Since you seem to be c

Categories : R

Technique to make a canvas drawLine() clickable?
Use a path to draw the line: Path linePath; Paint p; RectF rectF; float point1X, point1Y, point2X, point2Y; // initialize components // draw the line linePath.moveTo(point1X, point1Y); linePath.lineTo(point2X, point2Y); canvas.drawPath(linePath, p); linePath.computeBounds(rectF, true); Override onTouchEvent(MotionEvent): @Override public boolean onTouchEvent(MotionEvent event) { float touchX = event.getX(); float touchY = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (rectF.contains(touchX, touchY)) { // line has been clicked } break; } return true; }

Categories : Android

Technique used in java to make string immutable?
String class in Java is already immutable. For reference, see the documentation at http://docs.oracle.com/javase/7/docs/api/java/lang/String.html If you want to see how Java String class is implemented, please visit http://docjar.com/html/api/java/lang/String.java.html

Categories : Java

Can closure compiler use chaining as a minification technique?
There is a compiler pass for this: https://code.google.com/p/closure-compiler/source/browse/src/com/google/javascript/jscomp/ChainCalls.java It isn't enabled by default, however. It didn't provide any saving for the projects that we tested it with but you could try enabling it. It is controlled by the "CompilerOptions#setChainCalls" method in the Compiler's Java API.

Categories : Javascript



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