天道酬勤,学无止境

问答

Dictionary get value without knowing the key

In python if I have a dictionary which has a single key value pair and if I don't know what the key might be, how can I get the value? (and if I have a dict with more than 1 key, value pair, how can I return any one of the values without knowing any of the keys?)

2021-12-09 06:05:05   python   dictionary

Error : The resource you are looking for has been removed, had its name changed, or is temporarily unavailable

Offlate almost every website/api service/mobile service I deploy, When I hit any route apart from default one, I get the following error 'The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.' For testing I created a simple ASP.Net WebAPI app and ASP.Net MVC Website and deployed to Azure. It gets deployed and default pages come up. For any link after that, I get that error. Below is the mobile service.. created and uploaded without modification and configured facebook authentication on portal.azure.com https://wayweb.azurewebsites.net/.auth

2021-12-07 17:00:04   azure   asp.net-web-api   azure-web-app-service

What's inside my rails ./bin directory?

Ruby on Rails 4 introduced* the ./bin directory. Inside of ./bin are a few executables: bundle, rails, rake, setup, spring. My questions are: What do these executables do? Why do they exist? When are they invoked? Can I edit them? Why would I edit them? I've read the source of these files, and I've tried to Google their purpose, but I can't wrap my head around it. I'm looking for an in-depth explanation. *I believe many of these files existed before Rails 4, just in different location.

2021-12-04 13:20:04   ruby-on-rails

How to correctly import FormGroup in NgModule in Angular 2

I try to import FromGroup, FormBuilder and FormControl to my CustomModule: import { FormsModule, FormGroup } from '@angular/forms'; @NgModule({ imports: [ FormsModule, FormGroup ] }) But it throws an error: EXCEPTION: Uncaught (in promise): Error: Unexpected value 'FormGroup' imported by the module 'CustomModule' If i only import FormsModule it works fine though. Any ideas?

2021-12-04 06:31:03   angular   import   angular2-forms   ng-modules

Detecting when you're in/out of the main thread in Xamarin.iOS

Is there a way in Xamarin/MonoTouch to detect whether code is being called in the main thread? I'm looking for something like the equivalent of Java's EventQueue.isEventDispatchThread() -- I've found in Swing programming it's handy to assert that from time to time (or sometimes to assert that it's not) -- making sure that models are consistently updated and read from the EDT, and that long-running calls don't block the UI. I'd like to do the same in my MonoTouch app, to ensure that various bits of code are/aren't called from the UI, or wrapped in InvokeOnMainThread. Updated: For anyone coming

2021-12-04 02:50:03   multithreading   ios   xamarin.ios

String.IsNullOrEmpty like function for VARCHARs in SQL?

Say I've got a function or stored procedure that takes in several VARCHAR parameters. I've gotten tired of writing SQL like this to test if these parameters have a value: IF @SomeVarcharParm IS NOT NULL AND LEN(@SomeVarcharParm) > 0 BEGIN -- do stuff END There's gotta be a better way to do this. Isn't there?

2021-12-02 22:45:25   sql-server   tsql

Any way of detecting whether a browsers console is able to render colors?

Is there a way of checking to see if a browser is capable of using console colors without sniffing? console.log('%c Oh my heavens! ', 'background: #222; color: #bada55'); For example that in chrome 26+ and firebug will print colored output.

2021-11-29 04:05:37   javascript   console

How to change the value of an attribute in an XML document?

I have an XML document below and there is a tag called <FormData> in side this tag it as an attribute called FormId="d617a5e8-b49b-4640-9734-bc7a2bf05691" I would like to change that value in C# code? XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(MapPath(tempFolderPathAlt + "dvforms" + "\\XmlDataTemplate.xml")); //Change value of FormID xmlDoc.Save(tempFolderPath + "data.xml"); Be is my XML document: <?xml version="1.0"?> <FormData Platform="Android" PlatformVersion="100" Version="966" DataVersion="1" Description="Investec - Res" FormId="d617a5e8-b49b-4640-9734-bc7a2bf05691" FileId=

2021-11-29 04:05:28   c#   xml

Why is it not recommended to store constants in a separate class?

It's been told me (and I have seen this statement in a few other places) that it's not recommended to store your constants in a separate class in Java, in order to use them in the other classes. But I haven't seen anywhere WHY is it so. What is the reason I should not store them in their own interface/class? I came from C to Java and in C i would just make a .h file where i defined constants with #define

2021-11-29 04:05:24   java   constants

Location getAccuracy() what this function do?

I know that this function returns a float indicating the accuracy of a particular location. My question is: Is it right that greater the value returned by this function means more accurate the location is? Or it is the inverse what I am saying ?

2021-11-29 04:05:19   android   location