w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Using downcasting in real app life
I will probably go with the right datatype for right operations , long if I need long , int if int is enough for my requirements . Common sense would be to think using long for int probably will slow you down in general, but again this depends on the specific JVM implementation. You will have to decide based on the range which you want to target . Again , if there are lots of casting involved in your program , then better to go for a datatype like long which can accommodate a larger range than int and save you from casts and loss of data in that process . Having said that , long might be slower than intalthough in modern processors and JVMs I doubt that might affect much . May be , enlightened ones here can answer this question better. You can also read some nice SO Q&A here and h

Categories : Java

Tutorials and real-life applications of MVC .NET
Pluralsight mvc This is a really good set of tutorials to get you up to speed. Here is also a good tutorial on the web api just incase you want to use that too Pluralsight mvc web api These are free tutorials, but that sight has many brilliant tutorials for dot net dev. Hope its helpful to you.

Categories : Asp Net Mvc

Real life use and explanation of the AtomicLongFieldUpdate class
Atomics are usually used in parallel programming. Under the work-stealing mode, it only supports async, finish, forasync, isolated, and atomic variables. You can view atomic as a safe protection from data race and other problems that you need to concern in parallel programming.

Categories : Java

real examples using qunit and jstestrunner?
I've been running some QUnit tests using QUnit, phantomjs, ant and a modified version of a qunit-runner. The code itself is in a closed-source project, but the gist of it is that I invoke ant test on a build.xml file with only one target, the test target. The test target invokes phantomjs with the qunit-runner and some command line arguments. There was some magic involved, such as guessing that the qunit-runner wanted a package.json from which it injects the files that is to be tested. The tests themselves get passed using arguments in the ant build file. I have separate test files for each file that I want tested, and each test file has at least one module definition. The qunit-runner constructs configuration objects for qunit, injects the files to be tested and contains callback hook

Categories : Javascript

Basic WCF - how will the consumption of a WCF service translate to a 'real-life' deployment?
You will see that in your app.config file the url is saved. If you deploy your service to a live server you will only need to change the config to look at the new url. Hope I understood your question.

Categories : C#

Where are the Delphi Attributes Real World Examples?
I must say its not much clear to me what kind of example do you need. IMHO in http://docwiki.embarcadero.com/RADStudio/XE4/en/Overview_of_Attributes is everything you should need, perhaps providing that you have some basic knowledge of annotation and/or aspect programming resp. An example depends on the way/purpose an author of particular SW used attributes for. You mentioned ORM system: the typical usage here is to annotate member of class representing DB entity with additional information neccessary for DB operation in the backend of such framework. Let assume you have a DB entity having field COMPANY CHAR(32) NOT NULL and you want to represent it in Delphi class: TSomeDBEntity = class(...) FCDS: TClientDataset; ... constructor Create; ... [TCharColumn('COMPANY', 32, false)

Categories : Delphi

Using jFiddle examples ina real world environmnet?
Yeah, it's going to be a little difficult to port the examples over into a real-world production environment. It can be a real pain to integrate multiple frameworks javascript frameworks if you aren't already familiar with how each functions and how they can be configured to co-exist on a page. jsFiddle examples can each use a custom set of frameworks or even none at all. That site is simply for try-it-out types of examples. You just set up the environment you want (e.g. select the framework you are interested in etc) and then type in your code snippets. So there are no 'rules' that apply to all 'fiddles'. Each one is a custom example that isn't necessarily using the same set of frameworks and other configuration settings as any other. So think of each example as its own unique collectio

Categories : Jquery

Interfere in Jersey REST life cycle
There are 4 basic http methods in REST, namly GET, PUT, POST, DELETE. Your annotation tells Jersey what method to call when a http request occurs. Jersey looks up the target URI in the request and matches it against your model. If the request is a http get it will execute the method annotiated with @Get from the class with the correct @Path annotiaton. Usually you dont want to grant access to your resources in this annotated method directly. A common (may not perfect) way is to implement a DAO class that handles access to your resources, and of course does the validation before it returns the resource back to the @Get annotated method, which will itself only pass the resource to the client. So you will get another layer in your application between persisting (SQL, etc) and the client inter

Categories : Java

How i use amazon s3 in python to use REST examples
In boto, you could create a similar request like this: import boto s3 = boto.connect_s3() bucket = s3.lookup('example-bucket') for key in bucket.list(prefix='photos/2006/', delimiter='/'): print k.name What boto does is parse the XML output from S3 and turn it into Python objects. So, listing a bucket will return a bunch of Key objects, each object representing an object in S3. There isn't anything in boto or in S3 that would automatically turn the data into JSON but you could certainly write some Python to translate the information in the Key objects into JSON.

Categories : Python

Cannot get REST API usage records examples to work
The API documentation is wrong on the site. # twilio-ruby install docs at twilio.com/docs/ruby/install require 'rubygems' # This line not needed for ruby > 1.8 require 'twilio-ruby' # Get your Account Sid and Auth Token from twilio.com/user/account account_sid = 'AC32a3c49700934481addd5ce1659f04d2' auth_token = '{{ auth_token }}' @client = Twilio::REST::Client.new account_sid, auth_token # Loop over records and print out a property for each one @client.account.usage.records.today.list.each do |record| puts record.category + ' : ' + record.usage end For reference: https://github.com/twilio/twilio-ruby/issues/52

Categories : Ruby

In Java 7, how to crete a real life example to demonstrate the difference between Files.exists and Files.notExists?
Following code will work. In your case your were getting denying permissions issue you may check the folder in operating system installation partition. (C:). Following will work. Path path = Paths.get("D:\TestFolder"); if (Files.exists(path)) { System.out.println("exist"); } if (Files.notExists(path)) { System.out.println("not exist"); } javadoc says about Files.notExists() Tests whether the file located by this path does not exist. This method is intended for cases where it is required to take action when it can be confirmed that a file does not exist. Note that this method is not the complement of the exists method. Where it is not possible to determine if a file exists or not then both methods return false. As with the exists method,

Categories : Java

Real life scenarios for calling a constructor from another constructor
ArrayList is a nice example. The default constructor calls the constructor that takes the initial capacity of the underlying array. This looks like this: public ArrayList() { this(10); } public ArrayList(int capacity) { objects = new Object[capacity]; }

Categories : Java

How to use REST API PATCH command with Google Apps Script UrlFetchApp
UPDATE This is now supported. See Chris Raynor's answer. OLD ANSWER We don't currently support X-HTTP-Method-Override though we are considering it. For now you'll likely have to do a PUT with the whole record. Give us an email at support@firebase.com if this is significantly blocking you.

Categories : Google Apps Script

Update records using Salesforce REST API - Patch method not working
As I think you're aware, commons httpclient 3.1 does not have the PATCH method, and the library has been end-of-lifed. In your code above, you're trying to add the HTTP method as a query parameter, which doesn't really make sense. As seen on SalesForce Developer Board, you can do something like this instead: HttpClient httpclient = new HttpClient(); PostMethod patch = new PostMethod(url) { @Override public String getName() { return "PATCH"; } }; ObjectMapper mapper = new ObjectMapper(); StringRequestEntity sre = new StringRequestEntity(mapper.writeValueAsString(data), "application/json", "UTF-8"); patch.setRequestEntity(sre); httpclient.executeMethod(patch); This allows you to PATCH without switching out your httpclient library.

Categories : Rest

WEKA training examples and testing examples do not match
For any preprocessing task you should use the 'FilteredClassifier'. Thereby, the actual preprocessing operation is determined based on the training set only and then applied to the testing data. For instance: If you do discretization this way, the actual bins will only depend on the attribute values within the training data. Yet, the discretization using those bins will be applied to the testing data.

Categories : String

why git format-patch generates a patch older than the timestamps of reveision range
A range of commits can contain commits that are older than the first commit due to rebasing. A range of commits created using <rev1>..<rev2> is defined as the commits that are reachable from <rev2> but excluding those that are reachable from <rev1>. "Reachable" means that a commit can be navigated to using the parent reference that each commit has embedded. So, strictly speaking, a range has nothing to do with dates. See the Git revisions man page for more details. During a rebase, the changes made in commits are used to create "copies" of those commits. Those "copies" will have the same author and date as the original commits. Let's say someone develops something for a long time on a local feature branch, then rebases that feature branch on master and pushes. Then the

Categories : GIT

svn patch error: patch: **** misordered hunks! output would be garbled
Don't use OS patch for applying patch from svn diff, you have svn patch (with resolving merge-conflicts in process, if they will appear) If both WCs are binded to the same repo, why you don't want to use "commit"-"update" procedure?

Categories : Svn

C# Auto-Patch to Patch all Files in a Game Folder
You will need to check the current version of the product, then check a database/web server to see if a new version is available. If there is, pull the new version down, store it to the local file system. Preferably it will be some type of archive. Drop it in the root directory and extract it. You can double check the Process list to see if the game is running, and either shut it down or throw an error when they try to update, so that you don't run into any file permission errors. I know this is a very broad overview, but the question you have asked is a bit broad in scope of Stack Overflow. We don't write your entire solution for you.

Categories : C#

Can I patch 'random' using unittest.mock.patch?
patch.function doesn't seem to exist. You can use patch itself instead: with patch('random.choice', return_value=3) as mock_random: choice = my_code_that_uses_random() assert choice == 3

Categories : Python

Are there any free compression utilities that zip in real time like Xceed Real-Time Zip?
What you are looking for is stream compression approach. Good news is you have quite a lot of options. Please also note you have to think about memory because some solutions (dictionary-based) might require a lot of memory, so test and tune. In order to keep my answer short I would suggest to give LZ4 a try. LZ4 - http://code.google.com/p/lz4/ LZ4 is a very fast lossless compression algorithm, providing compression speed at 300 MB/s per core, scalable with multi-cores CPU. It also features an extremely fast decoder, with speed in GB/s per core, typically reaching RAM speed limits on multi-core systems. Benchmark: Name Ratio C.speed D.speed MB/s MB/s LZ4 (r97) 2.084 410 1810 LZO 2.06 2.106 409 600 QuickLZ 1.5.

Categories : Dotnet

Does a thread run on the same CPU/core throughout its life?
does a thread change the CPU/core during its lifetime? It can. It doesn't necessarily change, but there is nothing preventing the operating system from moving a thread between cores. The Windows API does provide some control over this via SetThreadIdealProcessor or SetThreadAffinityMask and SetProcessAffinityMask, if you need to control a thread's operation.

Categories : Windows

Nested life times
enum Source<'self> { String(&'self str), ReaderUtil(&'self ReaderUtil) } pub struct Matrix<'self> { source: &'self Source<'self> } fn main() { } You declared your enum Source with a lifetime parameter, enum Source<'self>. That means you also have to declare the lifetime for Source in Matrix.

Categories : Misc

Life of a Static class in ASP.Net
But, when is the static class 'born' and 'killed'? You don't need a reference of the class in order to access a static member. So there's never a birth or a death. Is it per session of a user? No, it is global for your entire application and shared between all users. I want it to be limited to the current user. Then forget about static members and use the session.

Categories : C#

OracleConnection life cycle
The important question under this is: does the ODP OracleConnection implement connection-pooling? If it does (and many ADO.NET providers do), then the "best practice" code is absolutely fine; it might look like you are opening a connection, but with connection pooling that Open() is actually "get an underlying connection from the pool, or connect if there isn't one available". The Dispose() (at the end of using) releases the underlying connection back to the pool. With this approach, then, there is no need to track the state of the connection - you let the pool worry about that. It looks like connection pooling is enabled in ODP by default, with connection-string parameters to tweak it (source)

Categories : C#

How to save the life of my process?
As @Peter said, screen is one good solution. A brief tutorial: Connect to server screen -S SectionName matlab -nosplash -nodesktop or -nodisplay or -nojvm depending if you have allowed X11 forwarding on putty (you can check this by simply open a figure and check if you can see it with -nodesktop option) Ctrl+a d to detach Log out Reconnect to server If you are using X11 forwarding, you may need to update your display on the screen, so: echo $DISPLAY, copy its result screen -rd SectionName If you are using X11 forward, update display on screen export DISPLAY="value echoed outside screen" (I think the opposite also works, you set the log display into the screen display) Finish Screen Exit matlab and type exit List open screens screen -ls Terminate unresponsive screen Ctr

Categories : Matlab

Game of Life Segmentation Fault in C
In main scanf("%i %i ", &HEIGHT, &WIDTH); ==> scanf("%i %i", &HEIGHT, &WIDTH); ^ because of that you need to enter one more input.avoid it and segmentation fault in askUser tableA[height][width] = LIFE_YES; Program received signal SIGSEGV, Segmentation fault. 0x00000000004007c1 in askUser (tableA=0x603010) at seg3.c:49 49 tableA[height][width] = LIFE_YES; (gdb) bt #0 0x00000000004007c1 in askUser (tableA=0x603010) at seg3.c:49 #1 0x0000000000400bf3 in main () at seg3.c:142 (gdb) and here you did not allocate memory but you are accessing.allocate memory first

Categories : C

MVC4 and page life cycle?
No, there is no page life cycle per se (because there is no 'page' object), but there is a request processing pipeline, which usually goes something like this: Incoming request is picked up by the System.Web.Routing.UrlRoutingModule which uses the request url to map the request to a controller action method. The appropriate controller is instantiated The OnActionExecuting-methods of action filters on the controller and/or action are invoked Model binding and input validation may occur The action method itself is invoked Any OnActionExecuted and OnResultExecuting-methods of action filters are invoked The ActionResult returned by the action method (typically, a ViewResult which renders HTML) is executed. Any OnResultExecuted-methods of action filters are invoked. The list above is just a

Categories : Asp Net Mvc

Draining battery life by using the radio too much
I figured it out! I found where the battery consumption was via socket tagging and commenting out potentially draining behaviors. I make some heavy client optimizations and the huge drain is gone. It was mainly a CPU drain due to constantly reading from the socket when it shouldn't have been.

Categories : Android

Optimising conways game of life
I believe that the Hashlife algorithm could help you. It gives the idea of using a quadtree (tree data structure in which each internal node has exactly four children) to keep the data, and then it uses hash tables to store the nodes of the quadtree. For further reading, this post, written by Eric Burnett, gives a great insight about how Hashlife works, it's performance and implementation (although in Python). It's worth a read.

Categories : Java

Different broadcastreceiver depending on activity life
I found my own answer, so I give the response for those who can be interested in. I have two BroadcastReceiver class, one used when application is wake up, with : ActivityBroadcastReceiver myReceiver = new ActivityBroadcastReceiver(); @Override protected void onResume() { LocalBroadcastManager.getInstance(this).registerReceiver(myReceiver, new IntentFilter("com.mybroadcast")); super.onResume(); } and @Override protected void onPause() { LocalBroadcastManager.getInstance(this).unregisterReceiver(myReceiver); super.onPause(); } and in my manifest file : <receiver android:name="com.broadcastreceiver.NotificationBroadcastReceiver" android:enabled="true" > <intent-filter> <action android:name="com.mybroadcast

Categories : Android

Laggy Code in Game of Life 3D
Make sure that this piece of code is actually the performance bottle neck. Even though you are using xxxGL, drawing may be time consuming. Review the list types you are using and make sure they are efficient for the operations you are performing on them. For example, depending on the type of the cell list, for (int i = 0; i < cell.Count(); i++) { if (cell[i].dies) { if (animated && delay == 50) { cell.RemoveAt(i); cellsdied += 1; i--; } else { cell[i].willdie = true; } } } this code may be really slow because of the RemoveAt(i), i-- style you are using to iterate. 3.Consider keeping some of your data

Categories : C#

ASP.Net life of threads and spawned tasks
IIS can recycle your application at any time so the web server is not the best thing to use for this. Your best bet would be to run a windows service on a separate server and either self host the WebApi in that or use MSMQ to send a message from the web server to the "app" server to initiate the processing.

Categories : C#

life time of object associated with signal
According to the Qt documentation All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. And no, Qt doesn't "magically" keep the object in memory. An object that doesn't exist anymore can't send signals. You should allocate memory for this object and keep a reference to it. Remember that if you gave your QObject a parent, then this parent will automatically handle the deletion of their child (but if you don't provide a parent, you'll have to delete it manually or use the deleteLater() slot of QObject)

Categories : C++

Some Examples From Ben-Gan Why need "AS"
First code: the inline select returns a result set = requires an alias Second code the EXISTS is a correlated subquery to do a semi-join. No result set it returns a scalar value (not a result set) - no alias needed (but no column name then) Third code: Uses ROW_NUMBER() which did not exist before SQL server 2005 alias needed because it returns a result set Not sure what you mean after that...

Categories : Sql Server

Android activity life cycle with asynctask
For me is not actually clear what is question about. For a reference two important points if some newbee comes here and read. it takes some time list to load because it is long operation. Purpose of AsyncTask is to keep UI not blocked. It's purpose is not to magicaly speed up things to infinity (btw even if it is light speed is a limit). onStop() in this code is useless, it does nothing. super.onStop() would be called even if you delete completely your overriden onStop method because base class ListActivity is extended from Activity which has this method and it will be called. You didn't add anything by just calling super.onStop() Just for records onPreExecuting and onPostExecute are executing on main (UI) thread..doInBackground is running in separate thread but Android wrapped everythin

Categories : Android

activity's life cycle is beyond its application process?
If you reopen the app via the activities list, it will attempt to restart via the last open activity. It's a "feature" of Android that can be incredibly annoying (and frequently just wrong)- Android assumes every app can serialize its entire state when exited for later reopening. You either need to do that (via onSaveInstanceState and onRestoreInstanceState) or you need to catch when you're relaunched and explicity launch your main activity. This shouldn't happen if you're relaunched via the app launcher, as that should always launch your specified activity.

Categories : Android

Data member and rvalue life-time
what is different in Paul Preney' code in Expression templates and C++11 that permits the temporary vectors to exist as long as the rvalue-references members exist? Nothing permits such a thing. The temporary vectors there exist until the end of the full expression, as any other temporary that isn't bound to a local reference variable. That is enough in Paul's code because the code immediately materialises the expression tree into an actual math_vector, and the temporaries are not needed anymore after that. Paul's code does not store any expression template node (math_vector_expr) anywhere, while your code stores one (X) as x2. That's a known issue with auto: it does the wrong thing when you are using expression templates because it results in storing the expression tree, which is l

Categories : C++

Conway's Game of Life logic error
Your problem is very simple - you're resetting count in the wrong place. Put it inside the loop and it will (probably) work. Regarding the rest of the code, if you want to make it significantly easier to follow just give your game area a one-element border. You'll need to pad the file you read in (blank line above and below, blank characters to the left and right), and alter your loops to: for (int i = 1; i < gen0.Length - 1; i++) and for (int j = 1; j < gen0[i].Length - 1; j++) but your central count calculation can then be reduced down to a single calculation: count = (gen0[i - 1][j - 1] == alive) ? 1 : 0 + (gen0[i - 1][j] == alive) ? 1 : 0 + ... etc ... which should make for cleaner code and ensure that any other errors you may make are signi

Categories : C#

Android Service : What happen at the end of Activity life?
If You start service through startService() it will keep remaining after Activity finishes. If You start service through bindService() it will live until last Activity unbounds from it. Also if service is already started and you call startService() no new instance of service will be created, but in living service method onStartCommand() will be executed. Almost same when you bind to living service, methon onBind() will be executed.

Categories : Android

life of an object created with copy constructor
Will it be destroyed only when arrnode is destroyed? Yes. That is exactly the point of std::vector (and all other containers in the Standard Library) which destroys the elements it contains when container itself gets destructed.

Categories : C++



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