w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
basic javascript object and mime regarding a basic web-server code
Expanding on Jared's comments above. Using the single quotes in both the HttpServlet constructor and the MimeMap initializer is likely just the original authors style preference. There are times when this is necessary. For example when using a name that isn't a valid per the syntax rules or is a reserved javascript keyword. From A Survey of the JavaScript Programming Language: In the object literal notation, an object description is a set of comma-separated name/value pairs inside curly braces. The names can be identifiers or strings followed by a colon. Because of an error in the language definition, reserved words cannot be used in the identifier form, but they can be used in the string form. For example: { 'my name here': 'bob', '0': '', 'ne

Categories : Javascript

Basic delay command for Visual Basic
Since sleeping and busy waiting are generally frowned upon, you could do something with an AutoResetEvent: Private ReadOnly _resetEvent As AutoResetEvent = New AutoResetEvent(False) Sub Pause(ByVal milliseconds As Long) Dim waitInterval As TimeSpan = TimeSpan.FromMilliseconds(milliseconds) While Not _resetEvent.WaitOne(waitInterval) ' Waiting! End While End Sub This is not recommended, but here's an example using the System.Diagnostics.Stopwatch class: Sub Pause(ByVal milliseconds As Long) If milliseconds <= 0 Then Return Dim sw As New Stopwatch() sw.Start() Dim i As Long = 0 Do If i Mod 50000 = 0 Then ' Check the timer every 50,000th iteration sw.Stop() If sw.ElapsedMilliseconds >= milliseconds Then

Categories : Vb.Net

Basic RMI Example
It looks like your RMI registry is not running, which is causing the bind call to fail. You are also not binding to a URL but just to a name. Usually you'd call bind like so: Naming.bind("//registryHost:port/remote", service); where registryHost points at the machine that is running your RMI registry. For a simple local test you'd make the URL "//localhost:port/remote" and run the rmiregistry service on your local machine. How to do this is explained for example here: http://www.javacoffeebreak.com/articles/javarmi/javarmi.html Excerpt: To start the registry, Windows users should do the following (assuming that your javain directory is in the current path):- start rmiregistry To start the registry, Unix users should do the following:- rmiregistry &

Categories : Java

Really basic AJAX
It should be echo not return. return is used in function to return the data. <?php $mytext = $_REQUEST['textbox']; echo $mytext; ?> Also you have to send the parameter to php file xmlhttp.open("GET","scripts/handle_feedback.php?textbox=your_value",true);

Categories : PHP

Basic example for PCA with matplotlib
I don't think the mlab.PCA class is appropriate for what you want to do. In particular, the PCA class rescales the data before finding the eigenvectors: a = self.center(a) U, s, Vh = np.linalg.svd(a, full_matrices=False) The center method divides by sigma: def center(self, x): 'center the data using the mean and sigma from training set a' return (x - self.mu)/self.sigma This results in eigenvectors, pca.Wt, like this: [[-0.70710678 -0.70710678] [-0.70710678 0.70710678]] They are perpendicular, but not directly relevant to the principal axes of your original data. They are principal axes with respect to massaged data. Perhaps it might be easier to code what you want directly (without the use of the mlab.PCA class): import numpy as np import matplotlib.pyplot as

Categories : Python

How to use Lib like Visual Basic in C#
It sounds like the library is a native library (i.e. unmanaged code, not .NET). You will need to P/Invoke to call into it. You can find a basic introduction to this here. You will need some additional information (perhaps from your colleague's VB project) to correctly declare the library functions you want to invoke.

Categories : C#

Basic JavaScript if vs. else if
If you are checking for different conditions of the same variable (or something like that) then else if is faster. If it matches a condition, it executes and then you are done in the statement. A whole bunch of if statements means the code has to run through every one of those no matter if it finds the first one true or not. Be aware though, with 'else if' you must be only looking for one of the conditions to match. If you want it still to check anything after that, it will have to be another 'if' statement.

Categories : Javascript

Basic RESTful API example using PHP
In my opinion this URL is against REST principles www.mysite.com/api/myAPI.php?request=get If one mentions in the url request=get then the purpose of using HTTP GET dies. A RESTful url should be something like www.mysite.com/api/myAPI.php and a HTTP GET request to this url should do the work.

Categories : PHP

C# Basic Calculator
You should be doing something like: button_plus_Click{ //code from your method that need to be refactored button_equal_Click(){ if(there is operando 1, and lblpantalla and operando) switch (operando) { case '+': //suma operador1 = (operador1 + lblpantalla); } } You are getting too many negative points as this is not technical question, its almost you are asking someone to do programming for you. Think about States your calculator can be in: https://www.clear.rice.edu/comp212/06-spring/labs/13/ This should be fun part of the programming, trying to resolve something on your own :) Good Luck

Categories : C#

WCF & Basic Authentication
You can configure IIS7 for basic authentication, however this would authenticate against Local Users and Groups rather than the web.config configuration file. I would not recommend putting them in the configuration file as then you would have to go to the effort of encrypting the passwords and you would also have to modify your code to use a custom authentication method.

Categories : Wcf

basic XSD importing and xsd.exe?
My bad, it seems that xsd.exe does not resolve schema imports. From this article : Now that the type has been defined in another file, the xsd.exe will generate this error if you attempt to create the create the Request XML: C:SolutionProject>xsd.exe Request.xsd /c Schema validation warning: Type 'http://www.Example.com/Types:Meeting' is not declared. Warning: Schema could not be validated. Class generation may fail or may produce incorrect results. Error: Error generating classes for schema 'C:SolutionProjectsRequest'. The datatype 'http://www.Example.com/Types:Meeting' is missing. If you would like more help, please type "xsd /?". This is due to the fact that the xsd.exe does not use the schemaLocation hint to find the imported schema. You’ve got to inclu

Categories : Visual Studio 2012

Basic C / C++ explanation
The answer here is that the exact timing varies. When I run this code on my machine, it comes up with 1000 for the first loop sometimes, and 1000 for the second loop at other times. It's just "luck" when the timer ticks over. If you have a more accurate timer, it may show differences based on how long it takes to read the timer, or some such. $ ./a.out k = 1000000 k = 1000000 Simple: 0 Double: 1000 $ ./a.out k = 1000000 k = 1000000 Simple: 1000 Double: 0 $ ./a.out k = 1000000 k = 1000000 Simple: 1000 Double: 0 $ ./a.out k = 1000000 k = 1000000 Simple: 1000 Double: 0 It is easy to see that BOTH loops are optimized out: main: .LFB1474: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 subq $8, %rsp .cfi_def_cf

Categories : C++

New to SAX Parser so need this BASIC
To parse an entry named MyResource that contains multiple entry of Item you can do something like that : At first, initialize your variables inside the startDocument method to allow the reuse of your Handler : private List<MyResource> resources; private MyResource currentResource; private StringBuilder stringBuilder; public void startDocument() throws SAXException { map = null; employees = new ArrayList<Employee>(); stringBuilder = new StringBuilder(); } Detect inside of startElement when a MyResource is starting. The tag name will usually be stored inside the qName argument. When a MyResource is starting, you may want to create an instance of MyResource as a temporary variable. You will feed it until its end tag is reached. public void startElement(String uri

Categories : Android

Basic C++ calculator
Literal strings in C++ use double quotes, not single quotes. That is, "Addition" instead of 'Addition'. A single-quoted string is something called a "multi-character constant" which is valid but definitely not what you want here.

Categories : C++

a basic keystroke map
Firstly, install autohotkey on your system. Once installed, create a text file and save it as .ahk (rather than .txt). Within the file, at the end, type the following code: F2::Send +^s Save the file then double click it to run the program. This will change F2 to your shift-control-s in ALL applications. To make it application-specific, when running, right click on the icon in the taskbar and choose "Windows Spy". Click into the application you want to use the F2 shortcut in and make a note of the line just below >>>>>>>>>>( Window Title & Class )<<<<<<<<<<< Now, change your script to this: #IfWinActive INSERTWindowsSpyWindowTitleHERE F2::Send +^s #IfWinActive Obviously making sure to change INSERTWindowsSpyWindo

Categories : Windows

Basic require.js example
AMD support (which is required by RequireJS) has been added to jQuery 1.7, and you are trying to use jQuery 1.6. In order to use jQuery 1.6 with RequireJS, try adding shim configuration: requirejs.config({ paths: { jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min' }, shim: { jquery: {exports: '$'} } }); Alternatively, you can use newer version of jQuery (at least 1.7): requirejs.config({ paths: { jquery: 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min' } });

Categories : Javascript

Basic C# about the "using" keyword
This form of using (the statement, not the directive) works with the IDisposable interface, to reclaim unmanaged resources. Unmanaged resources are things like database connections, which cannot be simply allowed to be reclaimed by the garbage collector. Rather, they need to be closed, in an orderly fashion. When the using code block goes out of scope, the Dispose() method is called on the database connection object, closing the connection and releasing the resource. As an example, check out the SQLConnection class. Note that it inherits from the DBConnection class, which in turn implements the IDisposable interface. The SQLConnection object implements the Dispose method, which closes the connection when scope leaves the using block. Note that you can abuse the using statement and ID

Categories : C#

Need Help on basic Windows C
case WM_CLOSE:DestroyWindow(hwnd); break; case WM_DESTROY:PostQuitMessage(0); break; deafult: return DefWindowProc(hwnd, msg, wParam, lParam); It might be hard to see, and it's cruel that it compiles because of it being a normal label (though I get a warning from -Wunused-label), but you misspelled default. This causes WM_NCCREATE to not be handled, which causes your window creation to fail. It's worth noting that you handle WM_CLOSE in the same way as DefWindowProc, just calling DestroyWindow. You can leave out that case and still end up with the same thing happening when your window is closed.

Categories : C++

XSS Basic Understanding
Content Security Policy solves the problem of injected javascript by banning any inline javascript and validating content sources. Info: https://developer.mozilla.org/en-US/docs/Security/CSP/Using_Content_Security_Policy Browser support: http://caniuse.com/contentsecuritypolicy

Categories : PHP

Basic Auth example
// Authentication delegate methods - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { #pragma mark unused (connection) assert(connection == connect); assert(protectionSpace != nil); BOOL retVal; retVal = [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; return YES; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { // Tries to connect 3 times, after the 3 attempts it cancels. if ([challenge previousFailureCount] < 3) { // Create credentials from the user name and password and save them, for this // specific authentication challenge. N

Categories : IOS

.Net web api, SSL + basic auth
Basic authentication is about sending the user name and password in the HTTP authorization header as plain text (base64 encoded but not encrypted). For this reason, you need to use HTTPS with basic authn so that folks in the middle do not get to see the user name and password that a client sends. When it comes to HTTPS, there is a server certificate and a client certificate. Server sends the server certificate to the client so that client can determine it is the right server it is connecting to. Similarly, a client can send a client certificate to the server so that a server can determine if an authentic client is talking to it. The client certificate part is optional in HTTPS. So, you can use basic authentication without using the client certificate. If you use client certificate, it is

Categories : Ssl

what is the basic difference between jobconf and job?
In short: JobConf and everything else in the org.apache.hadoop.mapred package is part of the old API used to write hadoop jobs, Job and everything in the org.apache.hadoop.mapreduce package is part of the new and preferred API to write hadoop jobs. Both APIs generally provide equivalent core functionality. If you're new to hadoop just start using the new API (i.e. Job and Configuration instead of JobConf). Make sure to not import anything from the mapred package. When you find examples on the internet using the old API you can use this presentation or this guide to translate it to the new API.

Categories : Hadoop

basic python with Django
Person.objects.get_or_create returns two values, which are assigned into obj and created respectively. obj is the actual object that was gotten or created, and created is a flag that tells you if it was created (or gotten).

Categories : Python

Basic JSON syntax?
[ { "UserJSONImpl": { "id": 26136358, "name": "BryanConnor", "screenName": "thewhyaxis", "location": null, "description": "TheWhyAxisisacollectionofindepthwritingaboutthevisualizationsthatdeserveyourattention.", "isContributorsEnabled": false } } ] Following http://json.org/ [ elements ] with elements as value, value as object, object as { members }, members as pair pair as string : value value as object ...

Categories : Json

Basic age asker program in C++
This loop is never executed: while (error = false) It's equivalent to while(false), because it sets error equal to false and then doesn't execute the loop. It should say while(error == false) As people have pointed out the input is not inside the loop so you'll see an infinite loop after you make the above fix. I think the bug will be obvious at that point -- the message will be repeated forever.

Categories : C++

Basic auth iOS 6 - Not working
Change NSURLRequest to NSMutableURLRequest to access it's setValue:forHTTPHeaderField method, and add a HOST header as well if it's a shared web host. At the end, you have to start the connection: [connection start]; Also, make sure you've set up your NSURLConnectionDelegate delegate methods for the call backs.

Categories : IOS

Basic OOP PHP form class
You call instance methods with $this: $this->show_options(); You don't need to copy-paste the whole constructor as soon as it's identical to the one in parent class In case if it matches partially you can call it like parent::__construct(...) and then define a custom $this->type="checkbox"; You can not define it in runtime but specify it as a property default value.

Categories : PHP

Need a basic submenu for my CSS navigation
Simple submenu for you: <ul id="submenu"> <li>Home</li> <li>About</li> <li>Team</li> </ul> <style> *, *:before, *:after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; zoom: 1; } #submenu { width: 200px; background: #eee; padding: 10px; } #submenu li{ margin: 0; margin-bottom: 10px; position: relative; text-align: center; font-weight: bold; color: #fff !important; line-height: 1 !important; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; white-space: nowrap; border: none; cursor: pointer; display: inl

Categories : CSS

Basic typeahead implementation
This should be the nearly working fiddle: http://jsfiddle.net/GDqme/ The problem with your code is you are attempting to use: prefetch: 'http://twitter.github.io/typeahead.js/data/countries.json' And it doesn't work since it would be cross site request and Twitter doesn't allow that. What you should do is download that JSON file and set it up locally: $('.typeahead').typeahead({ name: 'countries', prefetch: '/data/countries.json', limit: 10 }); Anyway, remember that the console (from Firebug / Chrome dev tools) is your friend.

Categories : Javascript

Very basic task using foldr
You used foldr like a variadic function by passing it two arguments 1 and 2 instead of [1, 2]. When you run into trouble like that, just check the function's type. You can do that in GHCi: Prelude> :t foldr foldr :: (a -> b -> b) -> b -> [a] -> b So you see that the first argument should be a function (a -> b -> b). You used (:) for that, which is o.k. You can check the type of the partially applied function as well: Prelude> :t (:) (:) :: a -> [a] -> [a] Substituting b with [a] gives us: Prelude> :t foldr (:) foldr (:) :: [a] -> [a] -> [a] Next, you gave [] as a base case. Prelude> :t foldr (:) [] foldr (:) [] :: [a] -> [a] So the resulting function is of type [a] -> [a]. What should you make of this? You have to pass it a

Categories : Haskell

apache cxf basic authentication
For Basic authentication in SOAP UI, navigate to your Request, single click on it will display a panel in the left bottom corner. Your config for BASIC Authentication should be something like this: Add your username and password to the appropriate fields. For your client I see you are using Spring. So jaxws:client provides username and password attributes for authentication. You can add them like this: <jaxws:client id="orderClient" serviceClass="demo.order.OrderProcess" address="http://localhost:8080/OrderProcess" username="yourUsername" password="yourPassword"/>

Categories : Spring

C# basic property understanding
You can't declare a virtual field public class Album { public virtual int AlbumId; // <- Syntax error ... } properties are, in fact, methods: get or(and) set, so public class Album { public virtual int AlbumId { get; set; } // <- Both get and set methods declared as virtual ones ... } And you can override these get's or(and) set's in derived class if you want: public class GreatAlbum: Album { private Boolean m_IsGreat; public override int AlbumId { get { if (m_IsGreat) return base.AlbumId else return 0; } set { m_IsGreat = (value != 0); base.AlbumId = value; } } ... }

Categories : C#

Visual Basic and MS Excel
Ideally, you'll want to handle all of your errors via the code itself; meaning that if your code throws an error or has received an improper input, the program will display a customized error notifying the user of the issue, or ignore the error. Simple example: Sub ErrorHandling() On Error GoTo DisplayMessage: x = 0 y = 5 / x GoTo TheEnd: DisplayMessage: MsgBox "Your x value cannot be 0" TheEnd: End Sub The code will throw an error because you can't do 5 / 0, but the error will be handled by going to the DisplayMessage: part of the code. However, if you really do need to disable the "Debug" button, you can do the following: Open up the VBA Editor Right-Click on the name of your project (if you haven't changed it, it should be "VBAProject") Select "VBAProject Properties" (Where VBAP

Categories : Excel

How to retrieve images from within the APK? (BASIC)
Open the apk with Winrar or anyother zip extracter. Go to res->drawable-??dpi folder. There will be all the images used in the apk. ?? means xhdpi or hdpi or mdpi Programatically it can be done by this code snippet. Drawable getImage = Drawable.createFromStream(getAssets().open("Cloths/btn_no.png"), null);

Categories : Java

How to implement a basic pointer
Java is pass by value, so a copy of the parameter a is sent to the method, so modification to a in the method will not affect the original argument a in main The max you can do is return int from KillOver21(a) method int z = KillOver21(a); // This will return 0 System.out.print(z); But you can achieve something like that with custom objects, say you have a class class AHolder { public int a; } then you can expect AHolder instance to change public static void main(String [] args) { AHolder a = new AHolder(); a.a = 34; killOver21(a); System.out.println(a.a); } public static void killOver21(AHolder b) { if(b.a > 21) { b.a = 0; } } Since in the latter (even if its Pass by Value) , the reference is copied and both reference point to same ob

Categories : Java

Visual Basic Compiler
Can you try it like this: Dim oCompiler as EthernalCompiler = New EthernalCompiler() With { _ .Source = Me.txtSource.Text.Replace("3jkf0dks0", Me.txtPanelId.Text), _ .Target = Target.Console, _ .References = New String() { "System.dll", "mscorlib.dll", "System.Core.dll" }, _ .Icon = Me.OpenFileDialog1.FileName _ }.Compile(Me.txtFileName.Text) oCompiler.Compile(Me.txtFileName.Text)

Categories : Vb.Net

Basic Matching in Ruby
The 'match' method is not matching the regex globally. It is only returning the first match. You can use the 'scan' method rather than 'match' and it should return an array of all matches of the regex. [~]$ irb 1.8.7-p371 :001 > x = "This is a test".match(/(w+) (w+)/) => #<MatchData "This is" 1:"This" 2:"is"> 1.8.7-p371 :002 > x = "This is a test".scan(/(w+) (w+)/) => [["This", "is"], ["a", "test"]]

Categories : Ruby

This basic login form is not doing anything
<input type="button" value="Login" name="Login" /> needs to be <input type="submit" value="Login" name="Login" /> or <button type="submit" name="Login">Login</button> The way you had it would require Javascript in order to have the form submit upon clicking the button. Unless you have some other mechanism of submitting the form, that is most likely why your form is not submitting. Other than that, you need to be more specific about any issues you have.

Categories : PHP

How can I trim a string in BASIC?
You don't want LTrim. You want Right: Result = Right(s, Len(s) - 2); This will take all but the two left-most characters of s.

Categories : Misc

Implementing GDT with basic kernel
There seem to be several problems. I didn't check specific bits of your GDT entries (that's the work one must do on his own with Intel manuals in hands). First thing (that doesn't cause problems now, but may do it in future) is that you specify and work with 4-byte wide limits, although GDT works only with 20 bits. You should change your gdt_install function to pass only 20-bit limit and document it in comments for future use. Another solution is of course to shift parameter twelve bits right, but it will make less sense and may be explained differently next time you get back to GDT management. Second thing that doesn't seem to be correct is the way you get parameter for gdt_flush. Stack grows downwards, so the last pushed item is located on (%esp) (that's return address pushed by call i

Categories : Assembly



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