w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How to identify system hard drive using Win32_DiskDrive
The documentation you linked has the answer: string SerialNumber; uint32 Signature; Your management object will have those properties in it. If you're getting null for those values then the problem is that you're using a version of Windows that doesn't support them. SerialNumber ... Windows Server 2003 and Windows XP: This property is not available. In which case you have to use the Signature property, but this requires XP SP3 I believe.

Categories : C#

If I use SSLSocket in Android and hard code the passcode to the truststore in the source code is that insecure?
I haven't tried on Android, but here is how it works in plain Java. You're using your keystore as a truststore here, so (hopefully) it doesn't contain any private key or secret material. In this case, the purpose of the password is to verify the integrity of the store. From the Keystore.load(InputStream, char[]) documentation: A password may be given to unlock the keystore (e.g. the keystore resides on a hardware token device), or to check the integrity of the keystore data. If a password is not given for integrity checking, then integrity checking is not performed. Either you use null as the password (in which case you'll always be able to load the certificates) or you use a non-null char array with the actual password (in which case an incorrect password will fail with some

Categories : Java

Is it okay to hard-code complex math logic inside my code?
As the above comment states, this is far from complex. You can however store the Magic numbers in constants/app.config values, so as to make it easier for the next developer to maitain your code. When storing such constants, make sure to explain to the next developer (read yourself in 1 month) what your thoughts were, and what they need to keep in mind. Also ewxplain what the actual calculation is for and what it is doing.

Categories : C#

Looking at Hard-Code used in VS 2012
You are looking for the .NET source code: http://referencesource.microsoft.com/netframework.aspx Alternatively, use a decompiler such as JustDecompile.

Categories : C#

One line F# code is hard to understand
So lets try to understand what happens. let x x defines a function called x which takes an argument of x. `let x x = x + 2` means you have a function x which takes an argument also called x and returns x+2 The final part in x 2 calls the function with an argument of 2. So the function can be written as let f x = x + 2 f 2 which obviously returns 4.

Categories : F#

Rails: How to hard code field in a form_for
I guess you have your @entry in the new method of your controller, something like this: def new @entry = Entry.new # etc. You can use this instead: def new @entry = @project.entries.build # it will set project_id to the @project.id and in the view: = f.hidden_field :project_id If you don't want to initialize with the project_id directly in the view: = f.hidden_field :project_id, value: @project.id

Categories : Ruby On Rails

What's a simple way to hard code a 6x6 numpy matrix?
You forgot the outer brackets. A = np.matrix([[1,0,0,a,0,0],[0,1,0,0,a,0],[0,0,1,0,0,a],[0,0,0,b,0,0],[0,0,0,0,b,0],[0,0,0,0,0,b]]) The numpy.matrix constructor takes a single array-like argument to initialize the matrix, not a sequence of positional arguments representing the rows. (Additional positional arguments set things like the dtype.)

Categories : Python

JAX-WS RI generated code with hard-coded file paths?
Original developer obviously followed the approach to store WSDL locally, which is actually a good practice. Namely, JAX-WS client before execution needs to retrieve WSDL once more from the original location to check additional metadata etc. (it sounds weird, but that's how it works). But, what if original WSDL is not available anymore or the Web service developer updated the WSDL with e.g. new method? Your Web service call would not be executed and that is not probably what you want. Therefore, people started to store WSDL together with their client, to avoid vulnerability on WSDL availability/change. Is this a) OK, or b) fixable? It is not OK to store WSDL on local filesystem, and that is where the original developer made the huge mistake. WSDL should be packed together with Web se

Categories : Java

HTTP 400 - Hard to understand error code with minimal description
You can use a debugging proxy to view a client request and a server response to figure out what your client socket program needs to do. But first you need to create a simple web page that a browser displays, allows you to do a POST from the browser to the web server, and get a simple response back from the server.

Categories : Http

How to hard code Magento static block ids? or any other similar solutions?
I liked your (@Chatura Dinesh Halwatura) idea to lock CMS-Blocks so i wrote a little module which does exactly what you want. I put it onto magento connect. Its called Cartware_CmsLock. Here the link to the module: http://www.magentocommerce.com/magento-connect/catalog/product/view/id/19176/s/cartware-cmslock-7465/?___store=mc_default_store

Categories : Magento

How to hard code username and password in Secure module Play 1.2.5
You are on the right track. However, some notes: Don't check for String equality using the == operator. Use String#equals() instead. When using equals, call the method on the literal String. These can never be null and help eliminating NullPointerExceptions. Hardcoding the password and username as plain strings can be dangerous: they can be read from memory without too much effort. Because username=="abc@abc.com" && password=="abc123" is a boolean value, you can simply return that result. Disregarding point 3 about the security issue, your method could look like this: static boolean authenticate(String username, String password) { return "abc@abc.com".equals(username) && "abc123".equals(password); }

Categories : Java

While loop making even/odd blocks with uneven number. Hard code second block
It's simple use modulo % is modulo operator. <?php for($counter=0; $counter<10; ++$counter) echo (!($counter % 3) ? "gray" : "dark gray").'<br>'; ?> It outputs gray dark gray dark gray gray dark gray dark gray gray dark gray dark gray gray As you wanted. I've created fiddle to show you how it works. Check fiddle

Categories : PHP

Powershell - script is invoked by 3rd party, how to hard-code elevated credentials
can't you use the start-process CmdLet : start-process 'c:system32WindowsPowerShellv1.0powershell.exe' -verb runas -argumentlist "-file toto.ps1" toto.ps1 will run in an elevated mode.

Categories : Powershell

Hard to find bug that involves strange physics behaviour in pygame code
if directions == 'upleft', both these blocks will execute if paddleRect.colliderect(ballRect): if direction == 'upleft': direction = 'upright' ballRect.left += BALLSPEEDX * 4 ballRect.top -= BALLSPEEDY * 4 if direction == 'upright': direction = 'upleft' ballRect.left += BALLSPEEDX * 4 ballRect.top -= BALLSPEEDY * 4 Probably should be more like this if paddleRect.colliderect(ballRect): if direction == 'upleft': direction = 'upright' ballRect.left += BALLSPEEDX * 4 ballRect.top -= BALLSPEEDY * 4 elif direction == 'upright': direction = 'upleft' ballRect.left += BALLSPEEDX * 4 ballRect.top -= BALLSPEEDY * 4 elif ...

Categories : Python

Analyzing foreign source code in R - How can I find functions / operators that are hard to google?
In both of these cases, the function does the same thing. Here it is from rCharts: #' Set a default value for an object #' #' This function sets the value of an object to a default value if it is not defined. #' @params x object #' @params y object #' @keywords internal #' @noRd `%||%` <- function(x, y){ if (is.null(x)) y else x } Here it is from "ggplot2"--slightly different syntax but same operation: ggplot2:::`%||%` # function (a, b) # { # if (!is.null(a)) # a # else b # } For finding the definitions of these functions, you can start by trying getAnywhere(). Here's the result on my system: getAnywhere("%||%") # 3 differing objects matching ‘%||%’ were found # in the following places # namespace:ggplot2 # namespace:gtable # namespace:plyr #

Categories : R

Code without system call?
Yes the above has system calls. You can use ptrace() to stop every time there is a system call, and you'll see that there are system calls. How else would the program be loaded and unloaded from memory without the operating system?

Categories : C

How to set the system timezone for iOS by code?
How @Filip said in comments, that's not possible to edit system preferences inside a app. What you might do (don't know if it will be useful for you) is set the timezone of the NSDates that you are working with, inside your APP. That's an example of how to do that: NSString *dateString = @"2013-08-07 17:49:54"; NSDateFormatter *dateFormatter = [NSDateFormatter new]; NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Europe/London"]; //set here the timezone you want [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; [dateFormatter setTimeZone:timeZone]; NSDate *date = [dateFormatter dateFromString:dateString]; Here's a list of possible timezones to be used with timeZoneWithName:` : http://pastebin.com/ibNU2RcG

Categories : IOS

How to run the powershell code for all system drives?
You pretty much have it, all you really needed was to get a listing of all the physical drives on the computer and then loop through it. A couple other notes: I removed $results |ft -auto. You probably had it in there as debug output. You do this twice: $results | sort-object -property size -Descending | select-object -first 30. I did it once, storing the output back into $results. Multiple trips of the same data through the same pipeline steps is inefficient. I made $a a here-string. Easier to read & work with than concatenating strings. I reformatted the date string in your output files so that you can sort filenames by date. Don't put files in c:. It's just sloppy. Find a more appropriate location. This will capture all folders (you aren't filtering them out). Is that desired?

Categories : Powershell

Code not running after os.system call
modify your sudoers file (with the visudo command) to add this line myusername ALL=(ALL:ALL) NOPASSWD:/home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py Where "myusername" is the user name that you intend to run the program as You also mentioned you would like to run the system program in a new shell? os.system('sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py '+ str(repr(wherefrom[0])) + " &") runs the program in such a way that the shell it starts does not block the process that starts it. Hope this helps

Categories : Python

System.EntryPointNotFoundException when calling C++ code from C#
This is almost certainly because C# cant map your name of the method Test to the Test method in the native code. Try specifying the EntryPoint="Test" attribute for the method as follows: [DllImport("MarshallStringsWin32.dll", EntryPoint="Test", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] extern static void Test([MarshalAs(UnmanagedType.AnsiBStr)] out String str);

Categories : C#

Python Code-complete System
inspect.getargspec(func) Get the names and default values of a Python function’s arguments. A tuple of four things is returned: (args, varargs, keywords, defaults). args is a list of the argument names (it may contain nested lists). varargs and keywords are the names of the * and ** arguments or None. defaults is a tuple of default argument values or None if there are no default arguments; if this tuple has n elements, they correspond to the last n elements listed in args. Changed in version 2.6: Returns a named tuple ArgSpec(args, varargs, keywords, defaults). This will only work for actual functions written in Python; other callables, such as types or built-in functions, won't be compatible.

Categories : Python

System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)
That method not exists in .net 4.5 - before then, Delegate.CreateDelegate should be used instead. It sounds to me like maybe NInject is incorrectly using that method in a 4.0 nuget package, in which case you should report that as a bug in NInject. The first thing to do is to check you are using the correct version of the dll, i.e. specifically a 4.0 build. After that, one of: roll back to an earlier NInject version upgrade your .net framework version download the code, fix it, and submit a patch

Categories : C#

Exception: Operating System error code 3
The file needs to be accessable on the server. The file path is relative to the server, not your PC. Also, if you are trying to use a share or a mapped drive it will not work. You need to use the UNC path. UNC Name Examples \teelaadmin$ (to reach C:WINNT) \teelaadmin$system32 (to reach C:WINNTsystem32) \teela emp (to reach C: emp)

Categories : Java

How to use custom code generators in waf build system?
Answered here: https://groups.google.com/forum/#!topic/waf-users/E7sh_AB5kcc Example in the waf book: http://docs.waf.googlecode.com/git/book_16/single.html#_project_organization

Categories : C++

How do I prevent my parallel code using up all the available system memory?
A competently-run cluster will put your jobs under some form of resource limits (RLIMIT_AS or cgroups). You can do this yourself just by calling setrlimit(RLIMIT_AS,...). I think you're overcomplicating things by worrying about sysconf, since on a shared cluster, there's no reason to think that your code should be using even a fixed fraction of the physical memory size. Instead, you should choose a sensible memory requirement (if your cluster doesn't already provide one - most schedulers do memory scheduling reasonably well.) Even if you insist on doing it yourself, auto-sizing, you don't need to know about which cores are in use: just figure out how many copies of your process are on the node, and divide appropriately. (you will need to figure out which node (host) each process is ru

Categories : C++

Refactor code to use Custom class instead of the one the System provides
Well, as nobody seems to know the solution and after excessive testing and tweaking plus some very lucky finds in the site, namely How to deal with GetDataPresent to let it accept all the derived types and C# Drag and Drop - e.Data.GetData using a base class, I am happy to report that the problem can easily enough be solved by substituting the GetPresentData and GetData calls. I provide the tweaked code for Tab_OnDragOver which was where the problem originated and I hope it all works fine for anyone who hits this page and looks for a solution! private void Tab_OnDragOver(object sender, System.Windows.Forms.DragEventArgs e) { TabPage hover_Tab = HoverTab(); if (hover_Tab == null) e.Effect = DragDropEffects.None; else {

Categories : C#

Is there any way to read System.Web.Optimization contents from code-behind?
You can do this via the Optimizer classes, this code is current as of the 1.1-beta1 release: BundleCollection bundles = new BundleCollection(); bundles.Add(new StyleBundle("~/bundles/css").Include("~/Styles/image.css", "~/Styles/nested/image2.css")); OptimizationSettings config = new OptimizationSettings() { ApplicationPath = TestContext.DeploymentDirectory, BundleTable = bundles }; BundleResponse response = Optimizer.BuildBundle("~/bundles/css", config); And response.Content is the raw bundle data.

Categories : C#

Java System.setProperties might effect other code
Believe System will tie to the JVM running. If I'm understanding your question correctly, you're wondering if this will affect functionality elsewhere. It is possible to affect functionality if you load up another application that depends on the properties being set above within the same JVM. i.e. System.setProperty("weblogic.security.SSL.enforceConstraints","on"); being set in a different application. The other thing to worry about is are these properties being set at deploy time, then considered immutable? If they're accessed and changed, and other applications are accessing and changing, you'll have chaos. Hopefully that makes sense.

Categories : Java

How do I repeatedly run code in a C# system tray application (Like on a timer)?
You'r right, recursive call blocks your app main thread what stops any interaction in GUI. If you had application wth form Windows would mark it as "(Not responding)". You can use Timer class http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx var timer = new Timer(tick_milliseconds); timer.Elapsed += DoOnTimerClick; timer.Enabled = true;

Categories : C#

ruby system command check exit code
system returns false if the command has an non-zero exit code, or nil if there is no command. Therefore system( "foo" ) or exit or system( "foo" ) or raise "Something went wrong with foo" should work, and are reasonably concise.

Categories : Ruby

is there any scratch code for e-commerce rating system(codeigniter)
Here are some simple tutorials: Star rating with jQuery and Codeigniter Implement a star rating with a CodeIgniter For more you need to create something more complex and more better.

Categories : Codeigniter

android import system source code into Eclipse
Open the navigation pane and right click on your android.jar > go to Properties > Java source attachment > External Location and add the sources folder there as pictured : Now if you ctrl click on an android class/method in one of your classes you will jump to the class file for that class/method inside the java editor

Categories : Android

How to delete (null) files outputted from .cxx code using system()
In the string you are passing to system(), the parenthesis are being interpreted literally because of the backslash. This isn't really what you want. You want to pass the backslash along in the string, so you need to escape the backslashes themselves. system("sudo rm -- \(null\)*"); Or you can quote the filename rather than escaping the parethesis. system("sudo rm -- "(null)*"");

Categories : C

System.OverflowException in CallWindowProc for 64 bit configuration when called from C# code
Out of curisoity, what happens if you change: private static extern IntPtr SetWindowLongPtr(IntPtr hwnd, int index, WndProcPointer wndProcPointer); to private static extern IntPtr SetWindowLongPtr(IntPtr hwnd, IntPtr index, WndProcPointer wndProcPointer); Changing index to be an IntPtr rather then an int. I got this idea from the following SO question Does P/Invoke on 64-bit windows require different signatures than on 32-bit?

Categories : Dotnet

Can not understand why i am getting System.ArgumentNullException was unhandled by user code
The exception means that the source of the Linq query (groups) is null. You need to make sure that ViewBag.Groups is initialized (this does not happen anywhere in your posted code). Did you want Model.Groups instead?

Categories : Asp Net Mvc

Is it possible to hide/encode/encrypt php source code and let others have the system?
There are commercial products such as ionCube (which I use), source guardian, and Zen Guard. There are also postings on the net which claim they can reverse engineer the encoded programs. How reliable they are is questionable, since I have never used them. Note that most of these solutions require an encoder to be installed on their servers. So you may want to make sure your client is comfortable with that.

Categories : PHP

How to make a simple plus one voting system in code igniter
first of all you dont have to echo all your html code, just use <?php ?> when you need it for dynamic content. as dianuj suggested you need to use ajax. make an ajax call using jquery (for simplicity sake) to your ajax handling public function, handle it there (for example using an id and increment a counter) and then return some data to the client. If the ajax request succeeds update the counter using javascript. i'll give you an example taken from my app codeigniter part, inside the controller i handle a post that provides an imageid and the userid to check their permissions and echo a response. for more complex app you should use json for various reasons. public function changeImage(){ if ($this->input->post('imageid')){ .... handle imageid and userid, check for per

Categories : Jquery

how to convert pdf to pksmraw by using ghostscript in android system?the error code is -15
Try this example gs -sDEVICE=pdfwrite -o foo.pdf /usr/local/share/ghostscript/8.71/lib/viewjpeg.ps -c (my.jpg) viewJPEG reads my.jpg and produces foo.pdf. You will have to find where your installation installed the PostScript program viewjpeg.ps. Same way do it for to convert pdf to pksmraw it will work for you.

Categories : Android

Exception in System.Data.Entity.dll but was not handled in user code
When using LINQ to entities, all parts of your LINQ statement must be supported by the database. values["FacebookId"] is a local dictionary. So it cannot be executed on the remote SQL database. Pull the value from the dictionary first into a local variable, then execute your LINQ statement. QvDb dba = new QvDb(); var id = values["FacebookId"]; if (dba.KUser.Count(us => us.FacebookId == id) == 0)

Categories : Asp Net Mvc

Strange Error :- System.Web.HttpCompileException was unhandled by user code
As far I see, the view GetRequestors.cshtml attempted to call a method or variable named ORG_ID in generic list that implements IPagedList of TSM.Models.AaaUser but type object does not have a method called ORG_ID and if have, this is not visible or is protected make sure that ORG_ID can be access

Categories : Asp Net Mvc



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