text:
Q: How can I get city name from geolocation data in node express mongoose mongoDb I have this document in my collection inside a db in MongoDB
{
 name: "steve",
 id: 11,
 address: "24 rue Victor Hugo"
 geolocation:
 {latitude:"16.66667",longitude:"101.18333"}
}

I want to get the city name from the geolocation data, I am working in Vs with node, express and mongoose. I tried to find a way to do without manipulating my db, because I already have my collection set before starting.

A: You can make requests with your geolocation parameters for address information.
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY

A: What you are trying to do is called reverse geocoding. It is available through the Google Maps Geocoding API. You have to sign up for a Google Developers account. Afterwards, you create a project from the Google Developers console. You can then request an API key. You can then use this API key in your request to the Google Maps API as follows:
https://maps.googleapis.com/maps/api/geocode/json?latlng=16.66667,101.18333&key=YOUR_API_KEY

Take a look at Google's Goecoding API documentation here. You can also test that URL in a browser to see the returned JSON-result, or using curl from the command-line.


text:
Q: Use variable once I have code that refetches events in calendar every 10sec. But before that it needs to be rendered correctly (different colors if past time or future time) so I use variables now and time to get time. But now I am getting time that is set first which is always same and I need to get time which is set with setInterval function.Can I somehow use first variable time just once or is there some other soltion?
var now = new Date();
var time = now.getTime();
setInterval(function(){
    var now = new Date();
    var time = now.getTime();
    $('#calendar').fullCalendar('refetchEvents');
},  10 * 1000);

if (eventTime < time) {
    //do something
}else {
    // do something else
}

A: Remove var from now & time in function in setInterval, It recreating those vars there.
And for accessing new value call every thing after changing the time.
try like bellow
var now = new Date();
var time = now.getTime();
setInterval(function(){
    now = new Date();
    time = now.getTime();
    $('#calendar').fullCalendar('refetchEvents');

    if (eventTime < time) {
       //do something
     }else {
       // do something else
     }
 },  10 * 1000);

A: Since you're using var keyword inside the function, time and now are created again within the function's scope. That means they're different from the variables outside the function although they have the same name. If you remove that keyword, the value of the variables in global scope will be updated and you can access the values set by your function from outside.
Also, I would put that if-statement inside of the intervalled function. JavaScript will execute your if-statement before setting that time variable to the new value otherwise.
See: http://jsfiddle.net/Whre/7VBcn/1/

redpajama_set_name: RedPajamaStackExchange


text:
Q: JS regular expression confusion Firstly apologies for being a tad dim. I need to create a test to check the if the value of an input field.
I currently use /[^A-Za-z0-9 ]/.test(document.form.Serial.value) to test to see if the value of Serial is alphanumeric only.
Now, if an additional field is set, Serial must either being with 'i' or 'I', then the remaining characters must all be numbers. I had considered doing this with substrings, but it seems a bit long and unnecessary.
Any advice people can give would be very much appreciated!

A: If you want to test if a string begins with i or I, and then only contain numbers, you could use a regular expression such as this one :
/^[iI][0-9]+$/

Or, for a case-insensitive match :
/^i[0-9]+$/i

Basically, this will match :

*

*Beginning of string : ^

*an i

*any character between 0 and 9 : [0-9]

*

*one or more time : [0-9]+

*end of string : $

A: You may try the code below
var test_value = false
if (document.form.Additional_Field.value) {
   test_value = /^(i|I)[0-9]+/.test(document.form.Serial.value) }
else {
    test_value = /[A-Za-z0-9]+/.test(document.form.Serial.value) }

it will result in test_value set to true if Serial is either alphanumeric or if Additional_Field has value true and Serial begins with i or I fallowed by any number of numbers, and test_value set to false otherwise.

A: Why not break the problem down. You have two valid inputs, so a pattern for syntactically checking the input would be:
/^([iI][0-9]+)|([A-Za-z0-9]+)$/

Then you have a separate, and simpler, problem of determining whether the validated input is appropriate based on the state of the other controls on the form.


text:
Q: Defining categories for protocols in Objective-C? In Objective-C, I can add methods to existing classes with a category, e.g.
@interface NSString (MyCategory)
- (BOOL) startsWith: (NSString*) prefix;
@end

Is it also possible to do this with protocols, i.e. if there was a NSString protocol, something like:
@interface <NSString> (MyCategory)
- (BOOL) startsWith: (NSString*) prefix;
@end

I want to do this since I have several extensions to NSObject (the class), using only public NSObject methods, and I want those extensions also to work with objects implementing the protocol .
To give a further example, what if I want to write a method logDescription that prints an object's description to the log:
- (void) logDescription {
    NSLog(@"%@", [self description]);
}

I can of course add this method to NSObject, but there are other classes that do not inherit from NSObject, where I'd also like to have this method, e.g. NSProxy. Since the method only uses public members of protocol , it would be best to add it to the protocol.
Edit: Java 8 now has this with "virtual extension methods" in interfaces: http://cr.openjdk.java.net/~briangoetz/lambda/Defender%20Methods%20v4.pdf. This is exactly what I would like to do in Objective-C. I did not see this question earning this much attention...
Regards,
Jochen

A: It isn't really meaningful to do so since a protocol can't actually implement the method. A protocol is a way of declaring that you support some methods. Adding a method to this list outside the protocol means that all "conforming" classes accidentally declare the new method even though they don't implement it. If some class implemented the NSObject protocol but did not descend from NSObject, and then you added a method to the protocol, that would break the class's conformance.
You can, however, create a new protocol that includes the old one with a declaration like @protocol SpecialObject <NSObject>.

A: Short answer:  No.
Long answer: how would this work?  Imagine you could add methods to existing protocols?  How would this work?  Imagine we wanted to add another method to NSCoding, say -(NSArray *) codingKeys;  This method is a required method that returns an array of the keys used to encoding the object.
The problem is that there are existing classes (like, say NSString) that already implement NSCoding, but don't implement our codingKeys method.  What should happen?  How would the pre-compiled framework know what to do when this required message gets sent to a class that does not implement it?
You could say "we can add the definition of this method via a category" or "we could say that any methods added via these protocol categories are explicitly optional".  Yes, you could do this and theoretically get around the problem I've described above.  But if you're going to do that, you might as well just make it a category in the first place, and then check to make sure the class respondsToSelector: before invoking the method.

A: While it's true that you can't define categories for protocols (and wouldn't want to, because you don't know anything about the existing object), you can define categories in such a way that the code only applies to an object of the given type that has the desired protocol (sort of like C++'s partial template specialization).
The main use for something like this is when you wish to define a category that depends on a customized version of a class.  (Imagine that I have UIViewController subclasses that conform to the Foo protocol, meaning they have the foo property, my category code may have need of the foo property, but I can't apply it to the Foo protocol, and if I simply apply it to UIViewController, the code won't compile by default, and forcing it to compile means someone doing introspection, or just screwing up, might call your code which depends on the protocol.  A hybrid approach could work like this:
@protocol Foo
- (void)fooMethod

@property (retain) NSString *foo;
@end

@implementation UIViewController (FooCategory)

- (void)fooMethod {
    if (![self conformsToProtocol:@protocol(Foo)]) {
        return;
    }

    UIViewController<Foo> *me = (UIViewController<Foo>*) self;
    // For the rest of the method, use "me" instead of "self"
    NSLog(@"My foo property is \"%@\"", me.foo);
}
@end

With the hybrid approach, you can write the code only once (per class that is supposed to implement the protocol) and be sure that it won't affect instances of the class that don't conform to the protocol.
The downside is that property synthesis/definition still has to happen in the individual subclasses.

A: extObjC has the NEATEST stuff you can do with Protocols / Categories... first off is @concreteprotocol...

*

*Defines a "concrete protocol," which can provide default implementations of methods within protocol.

*An @protocol block should exist in a header file, and a corresponding @concreteprotocol block in an implementation file.

*Any object that declares itself to conform to this protocol will receive its method implementations, but only if no method by the same name already exists.

MyProtocol.h
@protocol MyProtocol
@required - (void)someRequiredMethod;
@optional - (void)someOptionalMethod;
@concrete - (BOOL)isConcrete;

MyProtocol.m
 @concreteprotocol(MyProtocol) - (BOOL)isConcrete { return YES; } ...

so declaring an object MyDumbObject : NSObject <MyProtocol> will automatically return YES to isConcrete.
Also, they have pcategoryinterface(PROTOCOL,CATEGORY) which "defines the interface for a category named CATEGORY on a protocol PROTOCOL". Protocol categories contain methods that are automatically applied to any class that declares itself to conform to PROTOCOL."  There is an accompanying macro you also have to use in your implementation file.  See the docs.
Last, but NOT least / not directly related to @protocols is
synthesizeAssociation(CLASS, PROPERTY), which  "synthesizes a property for a class using associated objects. This is primarily useful for adding properties to a class within a category.  PROPERTY must have been declared with @property in the interface of the specified class (or a category upon it), and must be of object type."
So many of the tools in this library open (way-up) the things you can do with ObjC...  from multiple inheritance... to well, your imagination is the limit.

A: I think you may be mixing up terms here and there.  Extensions, Categories, Protocols, Interfaces and Classes are all different things in Objective-C.  In The Objective-C 2.0 Language Apple describes the differences very well, including the benefits and drawbacks to using categories and extensions.
If you think about it, what is a "Category" or "Extension" in the conceptual sense?  It's a way of adding functionality to a Class.  In Objective-C, protocols are designed to have no implementation.  Therefore, how would you add or extend the implementation of something that doesn't have implementation to begin with?

A: if you're already writing a category, why not just add in the protocol definition in the header right after the category definition?
i.e.
@interface NSString (MyCategory)
- (BOOL) startsWith: (NSString*) prefix;
@end

@protocol MyExtendedProtocolName <NSString>
//Method declarations go here
@end

this way any class that imports the category header will also get the protocol definition, and you can add it into your class..
@interface MyClass <OriginalProtocol,MyExtendedProtocolName>

also, be careful when subclassing NSString, it's a cluster and you may not always get the behaviour you're expecting.

A: Adam Sharp posted a solution that worked for me.
It involves 3 steps:

*

*Defining the methods you want to add as @optional on a protocol.

*Making the objects you want to extend conform to that protocol.

*Copying those methods into those objects at runtime.

Check out the link for the full details.


text:
Q: how to print this pattern using python iterator L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
head = 'head'
tail = 'tail'

suppose we can and can only get the iterator of some iterable(L).
and we can not know the length of L.
Is that possible to print the iterable as:
'head123tail'
'head456tail'
'head789tail'
'head10tail'

My try at it is as follows.
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
head = 'head'
tail = 'tail'
slice_size = 3

i = iter(L)
try:
    while True:
        counter = 0
        while counter < slice_size:
            e = next(i)
            if counter == 0:
                print(head, end='')
            print(e, end='')
            counter += 1
        else:
            print(tail)
except StopIteration:
    if counter > 0:
        print(tail)

A: Here's one way to do it with itertools.groupby and itertools.count.
groupby on the key function lambda _: next(c)//3 groups the items in the iterables in threes  in successions. The logic uses the integer division of the next object in the count item on 3:
from itertools import groupby, count

L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
head = 'head'
tail = 'tail'

c = count()
for _, g in groupby(L, lambda _: next(c)//3):
    item = head + ''.join(map(str, g)) + tail
    print(item)

Output:
head123tail
head456tail
head789tail
head10tail

A: You can split the iterator into chunks of three, using chain and slice from itertools and a for loop, and then join them. The for loop will do most of what your try/while True/except construct is doing.
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
head = 'head'
tail = 'tail'
slice_size = 3
iterator = iter(L)

from itertools import chain, islice
for first in iterator:
    chunk = chain([first], islice(iterator, slice_size - 1))
    print(head, ''.join(str(x) for x in chunk), tail)

However, if your iterator is just a list, you can just use range with a step parameter:
for start in range(0, len(L), slice_size):
    chunk = L[start : start + slice_size]
    print(head, ''.join(str(x) for x in chunk), tail)


text:
Q: Documenting Dependency Injection Parameters Should documentation be added for constructor parameters that are passed via dependency injection? In my current project I have decided to omit documentation to describe each of these parameters and my reasoning for this is as follows:

*

*These constructors are not meant to be called by a developer (outside of unit testing, but I will only be using integration testing in this project) so why bother documenting the parameters passed to them? The parameters are passed by a DI framework, which isn't going to read the documentation when constructing these classes.

*Many of the services being injected are singletons. By adding parameter documentation for every constructor to which they are injecting, I'm adding a bunch of duplicate documentation all over the project. Now, if the semantics of how that service is used changes later, I will have to update the comments in every constructor. It seems like a better solution for the developer to just go look at the class documentation for the service.
Is this reasoning sound? Are there any reasons you would disagree with my rationale for excluding these comments? Are there potential benefits of including these comments that I have overlooked?
To add some further context to this question, these are XML comments in C# that will eventually also be used to generate documentation for the project. I am in the process of integrating StyleCop into the project which has a rule to make sure that all function arguments are documented. So this issue arose because I am being forced to choose between documenting these parameters or suppressing the warning messages for each constructor using injection. I do not want to disable the rule globally because I do want to ensure that parameters for regular methods and constructors are documented.

A: If you can't refactor without changing your comments your comments are too coupled to your code.
Comments should never describe how the code works. Comments should describe why the code is does what it does. Or at least, what it was supposed to do. Show your intent not your method of achieving your intent.
As Doc Brown points out a good name makes leaving off comments perfectly acceptable. Comments should never be redundant duplications of what the code tells you.
Now all that said, if you go completely without comments your code had damn well be extremely readable with no surprises.
Read your code while giving thought to how it will look to the next programmer. Give them what they need and no more.
There is nothing special about parameters, DI or otherwise, that requires comments in any special way.
So please, spare us comments that add no new information and are needlessly coupled to the code like this:
//reads a file
public void read(File file){
    ...
}

Comments should add something new
//Parse all numbers and load them into a collection
public void read(File file){
    ...
}

Which is better but should lead to this:
//Loads into a collection
public void parseNumbers(File file){
    ...
}

Or even this:
public List<Integer> parseInts(File file){
    ...
}

And now you don't need any comments at all. You already know what it does.
But you don't have to take my word for it. I've asked about this before.

A: You should never comment how, only why. The code is the how-comment in it self (If its not refactors are in place).
Dependencies are 99% of the time irrelevant to the why-question.


text:
Q: NSImageView - scaling image down loses sharpness I am trying to render a few images in NSImageView's. These images are much larger than the size of the NSImageView (which I have set to scale proportionally up or down). But, the rendered image don't look very good. For example, in this sample image, the white border seems to have jagged edges at the 12,3,6 and 9 o'clock positions. The source image seems to be fine, even when I zoom out all the way in Preview.app.
I have tried scaling the image myself (using MGCropExtensions - which sets the interpolation quality to High), but, it doesn't seem to help. I would imagine NSImageView would internally draw on device boundary automatically, so that shouldn't be an issue?
Any ideas on how to get the image rendered crisply in the NSImageView? Thanks
Source Image - It has a white border which doesn't show here (against the white background)

Rendered NSImageView screenshot


text:
Q: Template Parameter Inheritance in C++ I haven't written C++ in a while, so I'm a bit rusty. If I have a class like this:
class JsonType{
    protected:
        map<string, JsonType>* objects;
}

and a class that inherits from that:
class JsonObject : public JsonType{
    public:
        JsonObject(){
            this->objects = new map<string, JsonObject>();
        }
}

why would I be getting a compiler error cannot convert...JsonObject...to...JsonType? Shouldn't that be legal, since JsonObject is a JsonType?

A: You can add JsonObject objects to the map, but the types do not match for initialization.
Edit: You have to initialize it as:
this->objects = new map<string, JsonType>();

But if you have either objects:
JsonType js = new JsonType();

or
JsonObject js2 = new JsonObject();

or
JsonType js3 = new JsonObject();

You can add any of these objects to the map initialized as above.

A: objects doesn't use JsonObject for its value_type, it uses JsonTypes.
In other words you are allocating the wrong kind of map to store into objects.


text:
Q: Mobile Keyboard moves up, when I focus on the input tag HTML
<input id="inputText" type="text" />

JS
document.getElementById('inputText').focus();

When My page is opened, I want to show the mobile keyboard by focusing on the input tag.


text:
Q: Solr search part of the word I am indexing data in Solr.
My search keyword is "tendulkar"
Then a word like sachintendulkar, Solr is unable to split it using any of the Tokenizer Factory.
I am familar with NGramFilterFactory.I dont want to use that.I just want the specific keyword to get filtered out from the lowercase word.
Can anyone help me out.
I am using this configuration:
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
    <filter class="solr.KeepWordFilterFactory" words="keepwords.txt" ignoreCase="true" enablePositionIncrements="false"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
    <filter class="solr.KeepWordFilterFactory" words="keepwords.txt" ignoreCase="true" enablePositionIncrements="false"/>

A: I think you are looking for the DictionaryCompoundTokenfilter


text:
Q: How can I use ILSpy or other tools to find out which code in the .NET framework generated a particular exception message? Suppose I have a bit of a particular exception message generated by the framework while running in standard English-US culture, e.g. "This failure occured while attempting to connect to the Principle server." How can I figure out which code in the framework generates an exception containing this text in the message?
The stack trace does not always help, because the framework code often uses several levels of helper methods to generate the exception before finally throwing it.
I would imagine that the string is localized, which is why I can't find it within any constants in ILSpy. I suppose the string would be stored with a unique resource ID or something to that effect, and then referenced by that ID, but I'm not sure where to start in finding the ID...


text:
Q: Whats the best way in kotlin for an null object's toString() method to return an empty string instead of "null" According to the official kotlin documentation, the toString() call of a null object returns "null" toString()
I want, that toString() should return an empty string ("") instead. I implemented it with an extension function.
fun Any?.toEmptyStringIfNull() :String {
if (this == null) {
    return ""
} else {
    return toString()
}

I am wondering if this could be achieved simpler/easier/cleaner and without calling the extension function everytime.

A: How about:
nullable?.toString() ?: ""

or as Alexander Udalov suggested:
nullable?.toString().orEmpty()

Which one can wrap in an extension method:
fun Any?.toStringOrEmpty() = this?.toString() ?: ""

A: you can directly use nullable.orEmpty().
Reference:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/or-empty.html
Edit:
Answer provided is incomplete - does only apply for String? and not Any? as pointed out in comment below.

A: nullable?.let {it.toString()}

If "nullable" is null it won't go further. As a variant. The only problem is that there will be a warning "redundant 'let' call could be removed.

A: I propose an extension function stringify, the name of which I borrowed from JavaScript's JSON.stringify().
fun <T> T?.stringify(toString: (T) -> String = { it.toString() }): String =
    if (this == null) "" else toString(this)

This covers the simple case and cases where you want to further process the string:
fun simplyConcatenate(s: String, postfix: String?): String =
    s + postfix.stringify()

fun getFullTitle(title: String, disambiguation: String?): String =
    title + disambiguation.stringify { " ($it)" }

fun demo() {
    println(simplyConcatenate("a", null)) // "a"
    println(simplyConcatenate("a", "b")) // "ab"
    println(getFullTitle("a", null)) // "a"
    println(getFullTitle("a", "b")) // "a (b)"
}

Edit: Now available in kotlin-lib.

A: The above answer not work for variable that is not original as String?
because the toString() will directly transform a Any? to String (not to String?)
if you write something like xxx.toString() ?: "" or xxx.toString().orEmpty() the IDE will tell you the right path will never be reach.
The solution is use "let" or "run". Depend on do you need to access outer scope class' fun.
    Any? let { it.toString() } ?: ""
    Any? run { toString() } ?: ""

For example a fun we want a file name string from a nullable Path, or even a non-null path, its getFileName() may return null. And we want a empty string in that case instead of a "null" string.
    fun fileName(path: Path?): String = path?.fileName?.run { toString() } ?: ""

    fun removeExtension(path: Path?): String = path?.fileName?.let { removeExtension(it.toString()) } ?: ""
    fun removeExtension(fileName: String): String = FilenameUtils.removeExtension(fileName)


text:
Q: libva info: va_openDriver() returns -1 I'd like to utilize my old netbook with the help of Kubuntu 20.04 to watch YouTube and write essays through "Google Documents."
After the Kubuntu installation, I tried to install chromium by using snap (candidate/vaapi) and proprietary nvidia-340 driver in order to enable hardware decoding.
During the installation of the Nvidia proprietary driver, I encountered the error:
nvidia-340 dpkg: error: version '-' has bad syntax: revision number is empty

By replacing KERNELS written in /var/lib/dpkg/info/nvidia-340.postinst file to CURRENT_KERNEL and subsequently executing dpkg-reconfigure nvidia-340, the problem was easily resolved. Thanks to Linux community.
Vapau hardware acceleration on VLC works well with low cpu usage.
However, in the case of Chrome, it was not as easy as before. It says on terminal like below.
[7873:7873:0601/140059.075024:ERROR:browser_switcher_service.cc(238)] XXX Init()
[8007:8007:0601/140103.101729:ERROR:vaapi_wrapper.cc(482)] vaInitialize failed: unknown libva error
[8007:8007:0601/140106.191463:ERROR:gl_context_glx.cc(227)] Couldn't make context current with X drawable.
[8007:8007:0601/140106.191708:ERROR:gpu_info_collector.cc(81)] gl::GLContext::MakeCurrent() failed
[8007:8007:0601/140106.191909:ERROR:gpu_info_collector.cc(208)] Could not create context for info collection.
[8007:8007:0601/140106.192123:ERROR:gpu_init.cc(66)] gpu::CollectGraphicsInfo failed.
[8007:8007:0601/140106.254424:ERROR:viz_main_impl.cc(159)] Exiting GPU process due to errors during initialization
[8119:8119:0601/140107.561057:ERROR:vaapi_wrapper.cc(468)] Could not get a valid VA display
[8091:7:0601/140107.821836:ERROR:command_buffer_proxy_impl.cc(125)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.

And almost all of the "graphics feature status" in chrome://gpu/ has been changed to "software only, hardware acceleration unavailable".
And also chrome://gpu said:

Problem Detected
GPU compositing has been disabled, either via blacklist, about:flags
  or the command line. The browser will fall back to software
  compositing and hardware acceleration will be unavailable.
Disabled Features: gpu_compositing

I've googled around so much time, but I couldn't find a clear answer on the web.
I just guess it is related to libva (although I don't know what it is..).
The result of running vainfo is like below.
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nvidia_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

If anyone has experience in my situation, please give me feedback and shed a light on this.
A brief summary of my computer is as follows.

*

*Operating System: Kubuntu 20.04

*KDE Plasma Version: 5.18.5

*Kernel Version: 5.4.0-33-generic

*Processors: 4 × Intel® Atom™ CPU 330 @ 1.60GHz

*Graphics: C79 Geforce 9400M/Ion

A: I got this to work on Ubuntu 20.04 by downloading the .deb file on https://launchpad.net/ubuntu/cosmic/amd64/vdpau-va-driver/0.7.4-6ubuntu1 and installing it. Either double click the .deb file or run sudo dpkg -i path/to/file.deb.
Specifically, it's the vdpau-va-driver_0.7.4-6ubuntu1_amd64.deb file under Downloadable Files section.


text:
Q: Python: Get the list of difference in object names and sub-objects between jsons python newbie:
json1.json
{
    "key1": {
        "s11": 1,
        "s12": 2,
        "s13": "abc"
    },

    "key2": {
        "s21": [1, 2, 3, 4],
        "s22": {
            "s221": {
                "s2211": "abc"
            }
        }
    },
    "key3": "name1"
}

json2.json
{
    "key1": {
        "p12": 2,
        "p13": "abc",
        "s11": 1
    },

    "key2": {
        "ps22": {
          "ps221": {
            "ps2211": "abc"
          }
        },
        "ps21": ["1", "2", "3", "4"],
        "ps23" : "abc",
        "ps24":1,
        "s21": [1,2,3,4]
    }
}

I am trying to compare the two json object names; json1.json and json2.json and want to list out the difference in the object names
eg., list out the below differences
     1. key3 is missing from json2 that is present in json1   --> Got this with below code
     2. key2.s22 is changed to key2.ps22 and key1.s12 to key1.p12
     3. will not bother the key2.s22.s221.s2211 different to key2.ps22.ps221.ps2211 as want to capture initial hierarchical differences
Can someone please help me with the appropriate methods or commands to capture these differences?
I could get the differences in the object names with below code.
d1=json.load(open("json1.json"))
d2=json.load(open("json2.json"))
s1=set(d1.keys()) - set(d2.keys())
print(s1)

o/p -> {'key3'}
but my requirement is to get the difference in the next level hierarchy i.e.,
key2.s22 is changed to key2.ps22
key2.s21 is changed to key2.ps21

A: import json

d1=json.load(open("1.json"))
d2=json.load(open("2.json"))

d11=list(d1.keys())
d22=list(d2.keys())

print(set(d1.keys())^set(d2.keys()))
chk_list = ["key2"]  # picking the keys to get the assymetry keynmaes within keynames

for i in chk_list:
    print(sorted(list(d1[i].keys())))
    print(sorted(list(d2[i].keys())))
    print(set(d1[i].keys()) ^ set(d2[i].keys()))

output is
{'key3'}
['s21', 's22']
['ps21', 'ps22', 'ps23', 'ps24', 's21']
{'ps23', 's22', 'ps24', 'ps22', 'ps21'}


text:
Q: Value does not fall within the expected range using nlog with entity frameWork I use nlog dll(version 3.1.0.0) to write to database - oracle with entity frameWork  in the line :
logger.Log(logLevel, "try");
I get in the logs of nlog the following error:

Error Error when writing to database System.ArgumentException: Value
  does not fall within the expected range.    at
  Oracle.ManagedDataAccess.Client.OracleCommand.set_CommandType(CommandType
  value)    at
  NLog.Targets.DatabaseTarget.WriteEventToDatabase(LogEventInfo
  logEvent)    at NLog.Targets.DatabaseTarget.Write(LogEventInfo
  logEvent)

the code is:
        SetPropGDC(LogEntity);
        NLog.LogLevel logLevel = SetLogLevel(Level.Debug);
        logger.Log(logLevel, "try");
        ClearGDC();

private static LogLevel SetLogLevel(Level level)
    {
        switch (level)
        {
            case Level.Debug: return LogLevel.Debug;
            case Level.Error: return LogLevel.Error;
            case Level.Fatal: return LogLevel.Fatal;
            case Level.Info: return LogLevel.Info;
            default: return LogLevel.Error;
        }

    }

 private void SetPropGDC(LogEntity LogEntity)
    {
        GlobalDiagnosticsContext.Set("connectionString", _unitOfWork.getConnectionString());
        GlobalDiagnosticsContext.Set(processId, LogEntity.PROCESS_ID.ToString());
        GlobalDiagnosticsContext.Set("TIME_STAMP", LogEntity.TIME_STAMP.ToString());
        GlobalDiagnosticsContext.Set(customerId, LogEntity.CUSTOMER_ID.ToString());
        GlobalDiagnosticsContext.Set("REQUEST", LogEntity.REQUEST.ToString());
        GlobalDiagnosticsContext.Set("RESPONSE", LogEntity.RESPONSE.ToString());
        GlobalDiagnosticsContext.Set("EXCEPTION", LogEntity.EXCEPTION.ToString());
        GlobalDiagnosticsContext.Set("STACK_TRACE", LogEntity.STACK_TRACE.ToString());
        GlobalDiagnosticsContext.Set("DETAILS", LogEntity.DETAILS.ToString());
    }
<targets>
<target name="TRACEDatabase" type="DataBase"  keepConnection="false"
         dbProvider="Oracle.ManagedDataAccess.Client" connectionString="${gdc:connectionString}"
         commandText="insert into TLOG_SITE_GENERAL_TRACE( PROCESS_ID,TIME_STAMP,CUSTOMER_ID,LOG_LEVEL,REQUEST,RESPONSE,EXCEPTION,STACK_TRACE,MESSAGE)
                       values(:PROCESS_ID,:TIME_STAMP,:CUSTOMER_ID,:LOG_LEVEL,:REQUEST,:RESPONSE,:EXCEPTION,:STACK_TRACE,:MESSAGE)">
  <parameter name="PROCESS_ID" layout="${gdc:PROCESS_ID}" />
  <parameter name="TIME_STAMP" layout="${gdc:TIME_STAMP}" />
  <parameter name="CUSTOMER_ID" layout="${gdc:CUSTOMER_ID}" />
  <parameter name="LOG_LEVEL" layout="${level:uppercase=true}" />
  <parameter name="REQUEST" layout="${gdc:REQUEST}" />
  <parameter name="RESPONSE" layout="${gdc:RESPONSE}" />
  <parameter name="EXCEPTION" layout="${gdc:EXCEPTION}" />
  <parameter name="STACK_TRACE" layout="${gdc:STACK_TRACE}" />
  <parameter name="MESSAGE" layout="${message}" />
</target>

Can anyone help?

A: I think you're looking for type support for database parameters, that's  introduced in NLog 4.6.
PS: Please note that event properties (on LogEventInfo) are a more robust than the GlobalDiagnosticsContext in your example


text:
Q: Why can't I get info one both two Spring "many-to-many" entities after association via PUT/PATCH route? I'm trying to use a many-to-many association and spring to associate an existing worker with an existing task but when I use the PUT/PATCH route can't get any data back from (only) those items using either GET /tasks/{taskId} or GET /dev/{devId}.
Here are the two models. The Workers model:
@Entity
@Table(name = "Workers")
public class Worker implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String workerName;
    private String passwd;

    @RestResource(path = "/assocTask")
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
    @JoinTable(name = "tasks_workers",
            joinColumns = @JoinColumn(name = "worker_id",  referencedColumnName = "id",nullable = false, updatable = false),
            inverseJoinColumns = @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false, updatable = false))
    //@JsonManagedReference
    private List<Task> tasks = new ArrayList<>();

    public Worker() {
    }

    public Worker(String name, String password) {
        this.workerName = name;
        this.passwd = password;
    }

    public String getName() {
        return workerName;
    }

    public void setName(String name) {
        this.workerName = name;
    }

    public String getPassword() {
        return passwd;
    }

    public void setPassword(String password) {
        this.passwd = password;
    }

    public List<Task> getTasks() {
        return tasks;
    }

    public void setTasks(List<Task> tasks) {
        this.tasks = tasks;
    }

    public Long getId() {
        return id;
    }

    @Override
    public String toString() {
        return "Worker{" +
                "id=" + id +
                ", workerName='" + workerName + '\'' +
                ", passwd='" + passwd + '\'' +
                ", tasks=" + tasks +
                '}';
    }
}

and the task model:
@Entity
@Table(name = "Tasks")
public class Task implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String title;
    private String description;

    @ManyToMany(mappedBy = "tasks", fetch = FetchType.LAZY)
    @JsonBackReference
    private List<Worker> workers = new ArrayList<>();

    public Task() {
    }

    public Task(@NotNull String title, @NotNull String description) {
        this.title = title;
        this.description = description;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Worker> getWorkers() {
        return workers;
    }

    public void setWorkers(List<Worker> workers) {
        this.workers = workers;
    }

    @Override
    public String toString() {
        return "Task{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", workers=" + workers +
                '}';
    }
}

This is the error I'm getting if I GET /tasks/1, for example:
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate java.util.Optional.toString()

coming from the service implementation to get it from the DB:
    @Override
public Task getTaskById(Long taskId) throws TaskNotFoundException {
    if (taskId == null || taskId < 0) {
        LOGGER.error("Invalid params received");
        throw new Error("INVALID_ID");
    }

    return taskRepository.findById(taskId)
            .orElseThrow(() -> new TaskNotFoundException(taskId, messageSource));
}

And this is the query that is executed by hibernate:
select
    tasks0_.worker_id as worker_id1_2_0_,
    tasks0_.task_id as task_id2_2_0_,
    task1_.id as id1_1_1_,
    task1_.description as descript2_1_1_,
    task1_.title as title5_1_1_
from
    tasks_workers tasks0_
inner join
    tasks task1_
        on tasks0_.task_id=task1_.id
where
    tasks0_.worker_id=?

If I run it in Postgres I get the results as expected...
Seems like it is looping infinitely... But what is causing the overflow and why doesn't it happen before the association or after breaking it?
Any ideas?

A: Is a StackOverflowError with the information that it happens in the toString method not obvious enough to you to figure out the issue? Assume you call Worker.toString() on the worker with id 1. In Worker.toString() you call List.toString() on tasks which for every Task calls Task.toString(). In Task.toString() you then call List.toString() on workers which is where you enter your infinite recursion because every Task that is connected to Worker is part of the tasks list and also the other way round, every Worker that is connected to Task is part of the workers list. This is a cyclic object graph.
The simple solution, just don't call toString() on collections that might have a back-reference. Or decide who is the "owner" and only call toString on the owning side.


text:
Q: What's wrong with Lotus Notes / Lotus Domino I have a client who is using Lotus Domino for their web application/server platform. The client has two "web developers" who are more comfortable with Lotus Domino than more mainstream tools and technologies and are not enthusiastic about making a switch. I have been asked to provide an assessment of why it may be prudent to migrate to a different web application platform.
I would be particularly interested in understanding deficiencies related to the platform as I have very little knowledge of Domino but am very familiar with other platforms.
In addition to the fact that Apache has over 70% of web server market, IIS over 21%, and Lotus almost 0%, what other reasons would you give for moving away from this platform?
Thank you for your help!

A: The only thing wrong with Lotus Domino is that it's a distributed database which didn't sell, so they decided it would make a good email platform.
The user interface for the email platform was odd, partially because email isn't really built on a distributed database architecture, it's a client-server architecture.  Due to it's distributed database underpinnings, it was possible to better manage email (especially when it came to email retention rules).  That actually made problems worse for the majority of users, because now they had something called email, that somewhat looked like email, and acted quite different than email.
I would be cautious about moving away from a Lotus platform.  Odds are excellent that there is something behind the covers that made the Lotus platform desirable.  Remember that while Apache has 70% of the web server market, they have 0% of the distributed database market.  If you know 100% that there's not a single bit of distributed database (or even non-distributed database) dependency, then it's a safe move.  Odds are it's not.

A: Biggest issue is the ever-decreasing market share.  There just isn't enough interest in the platform anymore and it can't compete in the email market against Exchange.  Eventually it will disappear and there's no point building on top of an infrastructure that's bound to collapse.
Maybe you can convince the developers to move away slowly by using another technology in tandem with Domino.  I found that necessary after my company switched from Notes to Exchange email, but was left with dozens of Notes applications still in use.  One simple trick is to expose Notes data using XML or the NotesSQL driver.  It's very easy to pull that data into an ASP.NET application, or some other platform better suited to Web development than Domino.
Even if they love working with Notes, unless they plan to retire in 10 years they'd better start learning some new technologies anyway.

A: *

*Development languages / tools. There are no (that I know of) good & free source version control systems for Notes & Domino. There are products available for purchase that provide these functions, but they don't work quite the same as Subversion or other popular systems. As a language, Lotusscript is on par with VB 6. Code auto-completion in even the latest version of the IDE is not even close to what you get from Visual Studio or many comparable alternatives.

*Indexing performance. Indexing performance can be a huge problem in any system, but index updates in Domino don't appear to happen in quite the same way as in an say MS-SQL server. MS-SQL server appears to update every relevant index with each write, where Domino has an index update process which periodically updates the indexes. In my opinion, this leads to less consistent performance of applications under Domino.

*Replication / Save conflicts. Being a distributed database, these are issues that have to be dealt with, and no implementation will ever be perfect. The biggest problem with these is not when they are legitimate conflicts, but if you don't do proper document locking, rapid updates (even by the same user on the same machine) can cause problems. This is less of an issue on a single server, web based application.

*This is a tiny point, but for web-based applications, the inability to add binary information to the response stream is a terrible weakness.

A: I have been working with lotus notes/domino since 1996 to build an electronic document storage and workflow system for a law firm (www.proctors.com.au/legalnotes.nsf).  I use the notes client for the creation and filing of documents - and everything else - in the office.  I use the net to retrieve data.  The only disadvantage of using the notes client over the net is that it is slow; mainly - I imagine - because of the code that is being executed.
I am not a programmer by trade and there may be something better, but I have not seen it.  I cannot imagine building the security in notes from scratch in something like exchange.  I have not heard of anyone building a document management system like mine.  I think Notes is a great platform.

A: The only real deficiency notes has a web development platform is the inability of developers to use its capabilities as well as they might. I've vastly improved the look and feel of a couple of my websites e.g http:\www.meteorflight.com by getting good with css and writing better html but now for the next stage of web application development I need Java as that gives me the ability to do far more.
Indeed there has been a move away in recent years from using the notes client and instead writing internal applications for the browser so end users have no idea (nor do they even care) that its a lotus domino application.

A: Update...
And now there is Domino XPages, which is a great environment to use for Domino web development. No reason to move away, for it can be applied to the existing databases. Minor drawback: it takes quite some time to learn XPages development.
See:
http://en.wikipedia.org/wiki/XPages
and http://www-10.lotus.com/ldd/ddwiki.nsf


text:
Q: Buildozer 0.32 fails to build After downloading the official Buildozer VM from the kivy project (https://kivy.org/#download)and updating it like in the README of the VM suggested (https://kivy.org/docs/guide/packaging-android-vm.html#kivy-android-vm). I tried to build with buildozer android_new debug
After fixing several missing dependencies, I'm running in to an unintelligible error:
[INFO]:    Unpacking sdl2_image for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/build/bootstrap_builds/sdl2-python2/jni
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 837, in <module>
    main()
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 834, in main
    ToolchainCL()
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 489, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 147, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 190, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "pythonforandroid/build.py", line 548, in build_recipes
  File "pythonforandroid/recipe.py", line 542, in prepare_build_dir
  File "pythonforandroid/recipe.py", line 444, in unpack
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1021, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 486, in __init__
    self.wait()
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 500, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_2
# Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/media/sf_PycharmProjects/settings/.buildozer/android/platform/build create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs

Any ideas what is missing?
Full Debug Output:
kivy@kivy-VirtualBox:/media/sf_PycharmProjects/settings$ buildozer android_new debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian `dpkg' package management program version 1.17.5 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /usr/local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-7-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/keytool
# Install platform
# Apache ANT found at /home/kivy/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/kivy/.buildozer/android/platform/android-sdk-20
# Android NDK found at /home/kivy/.buildozer/android/platform/android-ndk-r9c
# Check application requirements
# Check garden requirements
# Compile platform
# Run 'python -m pythonforandroid.toolchain --color=always --storage-dir=/media/sf_PycharmProjects/settings/.buildozer/android/platform/build create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs'
# Cwd /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI
[INFO]:    Available Android APIs are (19)
[INFO]:    Requested API target 19 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Using Google NDK r9c
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv
[INFO]:    ccache is missing, the build will not be optimized in the future.
[INFO]:    Found the following toolchain versions: ['4.6', '4.8', 'clang3.3']
[INFO]:    Picking the latest gcc toolchain, here 4.8
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.
[INFO]:    Bootstrap requires recipes ['sdl2', ('python2', 'python3crystax')]
[INFO]:    Loaded recipe sdl2 (depends on [('python2', 'python3crystax'), 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf'], conflicts ['sdl', 'pygame', 'pygame_bootstrap_components'])
[INFO]:    Loaded recipe kivy (depends on ['pyjnius', ('sdl2', 'pygame'), ('python2', 'python3crystax')])
[INFO]:    Loaded recipe sdl2_image (depends on [])
[INFO]:    Loaded recipe sdl2_mixer (depends on [])
[INFO]:    Loaded recipe sdl2_ttf (depends on [])
[INFO]:    Loaded recipe pyjnius (depends on ['six', ('sdl2', 'sdl', 'genericndkbuild'), ('python2', 'python3crystax')])
[INFO]:    Loaded recipe six (depends on [('python2', 'python3crystax')])
[INFO]:    Found multiple valid recipe sets:
[INFO]:        ['six', 'sdl2', u'kivy', 'sdl2_ttf', 'sdl2_mixer', 'sdl2_image', 'pyjnius', 'python2']
[INFO]:        ['sdl2', 'six', 'sdl2_ttf', 'python3crystax', 'sdl2_mixer', 'sdl2_image', 'pyjnius', u'kivy']
[INFO]:    Using the first of these: ['six', 'sdl2', u'kivy', 'sdl2_ttf', 'sdl2_mixer', 'sdl2_image', 'pyjnius', 'python2']
[INFO]:    The selected bootstrap is sdl2
[INFO]:    # Creating dist with sdl2 bootstrap
[INFO]:    Dist will have name myapp and recipes (kivy)
[INFO]:    -> running cp -r /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/bootstraps/sdl2/build /media/sf_PycharmProjects/settings/.buildozer/android...(and 51 more)
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/build/bootstrap_builds/sdl2-python2
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Recipe build order is ['python2', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sdl2', 'six', 'pyjnius', u'kivy']
[INFO]:    # Downloading recipes
[INFO]:    Downloading python2
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/python2
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/python2
[INFO]:    -> running basename http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-Python-2.7.2.tar.bz2
[INFO]:    Downloading python2 from http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
Downloading python2 from http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
- Do[INFO]:    -> running touch .mark-Python-2.7.2.tar.bz2
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading sdl2_image
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2_image
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2_image
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-SDL2_image-2.0.1.tar.gz
[INFO]:    Downloading sdl2_image from https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz
Downloading sdl2_image from https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz
- Download[INFO]:    -> running touch .mark-SDL2_image-2.0.1.tar.gz
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading sdl2_mixer
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2_mixer
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2_mixer
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.tar.gz
                                                                                [WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-SDL2_mixer-2.0.1.tar.gz
[INFO]:    Downloading sdl2_mixer from https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.tar.gz
Downloading sdl2_mixer from https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.tar.gz
- Download [INFO]:    -> running touch .mark-SDL2_mixer-2.0.1.tar.gz
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading sdl2_ttf
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2_ttf
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2_ttf
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz
           working: SDL2_ttf-2.0.14.tar.gz                                                                                [WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-SDL2_ttf-2.0.14.tar.gz
[INFO]:    Downloading sdl2_ttf from https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz
Downloading sdl2_ttf from https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz
- Download 90.27%[INFO]:    -> running touch .mark-SDL2_ttf-2.0.14.tar.gz
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading sdl2
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/sdl2
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.4.tar.gz
           working: SDL2-2.0.4.tar.gz                                                                                [WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-SDL2-2.0.4.tar.gz
[INFO]:    Downloading sdl2 from https://www.libsdl.org/release/SDL2-2.0.4.tar.gz
Downloading sdl2 from https://www.libsdl.org/release/SDL2-2.0.4.tar.gz
- Download 90.51%[INFO]:    -> running touch .mark-SDL2-2.0.4.tar.gz
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading six
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/six
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/six
[INFO]:    -> running basename https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz
           working: six-1.9.0.tar.gz                                                                                [WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-six-1.9.0.tar.gz
[INFO]:    Downloading six from https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz
Downloading six from https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz
[INFO]:    -> running touch .mark-six-1.9.0.tar.gz
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading pyjnius
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/pyjnius
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/pyjnius
[INFO]:    -> running basename https://github.com/kivy/pyjnius/archive/master.zip
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-master.zip
[INFO]:    Downloading pyjnius from https://github.com/kivy/pyjnius/archive/master.zip
Downloading pyjnius from https://github.com/kivy/pyjnius/archive/master.zip
[INFO]:    -> running touch .mark-master.zip
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Downloading kivy
[INFO]:    -> running mkdir -p /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/kivy
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/kivy
[INFO]:    -> running basename https://github.com/kivy/kivy/archive/master.zip
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    -> running rm -f .mark-master.zip
[INFO]:    Downloading kivy from https://github.com/kivy/kivy/archive/master.zip
Downloading kivy from https://github.com/kivy/kivy/archive/master.zip
- Down[INFO]:    -> running touch .mark-master.zip
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    # Building all recipes for arch armeabi-v7a
[INFO]:    # Unpacking recipes
[INFO]:    Unpacking python2 for armeabi-v7a
[INFO]:    -> running basename http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
                                                                                [INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/build/other_builds/python2/armeabi-v7a
[INFO]:    -> running tar tf /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/packages/python2/Python-2.7.2.tar.bz2
           working: Python-2.7.2/Mac/Demo/sound/morse.py                                                                                [INFO]:    -> running mv Python-2.7.2 /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/build/other_builds/python2/armeabi-v7a/python2
[INFO]:    <- directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master
[INFO]:    Unpacking sdl2_image for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz
[INFO]:    -> directory context /media/sf_PycharmProjects/settings/.buildozer/android/platform/build/build/bootstrap_builds/sdl2-python2/jni
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 837, in <module>
    main()
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 834, in main
    ToolchainCL()
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 489, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 147, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/media/sf_PycharmProjects/settings/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 190, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "pythonforandroid/build.py", line 548, in build_recipes
  File "pythonforandroid/recipe.py", line 542, in prepare_build_dir
  File "pythonforandroid/recipe.py", line 444, in unpack
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1021, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 486, in __init__
    self.wait()
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 500, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_2
# Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/media/sf_PycharmProjects/settings/.buildozer/android/platform/build create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

Edit 1
The Project is the kivy settings example.
Project Tree:
.
├── android.txt
├── bin
├── buildozer.spec
├── debug.txt
├── main.py
└── my.ini

buildozer.spec
[app]

# (str) Title of your application
title = My Application

# (str) Package name
package.name = myapp

# (str) Package domain (needed for android/ios packaging)
package.domain = org.test

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec

# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = tests, bin

# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
version = 0.1

# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (list) Garden requirements
#garden_requirements =

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (str) Supported orientation (one of landscape, portrait or all)
orientation = landscape

# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

#
# OSX Specific
#

#
# author = © Copyright Info

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 1

# (list) Permissions
#android.permissions = INTERNET

# (int) Android API to use
#android.api = 19

# (int) Minimum API required
#android.minapi = 9

# (int) Android SDK version to use
#android.sdk = 20

# (str) Android NDK version to use
#android.ndk = 9c

# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True

# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =

# (str) Android SDK directory (if empty, it will be automatically downloaded.)
#android.sdk_path =

# (str) ANT directory (if empty, it will be automatically downloaded.)
#android.ant_path =

# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#android.p4a_dir =

# (list) python-for-android whitelist
#android.p4a_whitelist =

# (bool) If True, then skip trying to update the Android sdk
# This can be useful to avoid excess Internet downloads or save time
# when an update is due and you just want to test/build your package
# android.skip_update = False

# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity

# (list) List of Java .jar files to add to the libs so that pyjnius can access
# their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example:
# OUYA-ODK/libs/*.jar
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar

# (list) List of Java files to add to the android project (can be java or a
# directory containing the files)
#android.add_src =

# (str) python-for-android branch to use, if not master, useful to try
# not yet merged features.
#android.branch = master

# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME

# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png

# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters =

# (list) Android additionnal libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
#android.add_libs_x86 = libs/android-x86/*.so
#android.add_libs_mips = libs/android-mips/*.so

# (bool) Indicate whether the screen should stay on
# Don't forget to add the WAKE_LOCK permission if you set this to True
#android.wakelock = False

# (list) Android application meta-data to set (key=value format)
#android.meta_data =

# (list) Android library project to add (will be added in the
# project.properties automatically.)
#android.library_references =

# (str) Android logcat filters to use
#android.logcat_filters = *:S python:D

# (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1

#
# iOS specific
#

# (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios

# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"

# (str) Name of the certificate to use for signing the release version
#ios.codesign.release = %(ios.codesign.debug)s

[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1

# (str) Path to build artifact storage, absolute or relative to spec file
# build_dir = ./.buildozer

# (str) Path to build output (i.e. .apk, .ipa) storage
# bin_dir = ./bin

#    -----------------------------------------------------------------------------
#    List as sections
#
#    You can define all the "list" as [section:key].
#    Each line will be considered as a option to the list.
#    Let's take [app] / source.exclude_patterns.
#    Instead of doing:
#
#[app]
#source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
#
#    This can be translated into:
#
#[app:source.exclude_patterns]
#license
#data/audio/*.wav
#data/images/original/*
#

#    -----------------------------------------------------------------------------
#    Profiles
#
#    You can extend section / key with a profile
#    For example, you want to deploy a demo version of your application without
#    HD content. You could first change the title to add "(demo)" in the name
#    and extend the excluded directories to remove the HD content.
#
#[app@demo]
#title = My Application (demo)
#
#[app:source.exclude_patterns@demo]
#images/hd/*
#
#    Then, invoke the command line with the "demo" profile:
#
#buildozer --profile demo android debug

A: Installing the most recent dev version (0.33dev) from github in a new (Ubuntu) vm solved the problem for me.
These are the commands from https://kivy.org/docs/guide/packaging-android.html:
cd ~
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python2.7 setup.py install

Don't forget the buildozer requirements: https://buildozer.readthedocs.io/en/latest/installation.html#targeting-android
Keep in mind to delete the buildozer.spec and .buildozer/. After creating the new buildozer.spec you'll have to 'enable' the line #android.bootstrap = sdl2 and add hostpython2 as requirement. This is due to a known Bug: https://github.com/kivy/python-for-android/issues/620
Running buildozer the first time will result in some missing packages. Just install them.
If you are using shared folders with the vm, errors may occur. Just copy the files to local VM storage in such a case.


text:
Q: Change several texts color in Flutter I have a widget containing many different Text() widgets in it.
How could I change all of these widgets color to white at once without modifying one by one?

A: I think you can think about ThemeData - https://flutter.dev/docs/cookbook/design/themes

A: To do that you can use variables
class yourclass extends StatelessWidget {

Color mycolor = Colors.red; // define your color here.

                  Text('some Text',style:TextStyle(color: mycolor),),
                  Text('another text', style: TextStyle(color: mycolor),)


text:
Q: Using baseController inside Alloy widget I would like to extend my controller within simple widget.
I've created two files:

*

*app/widgets/mywidget/controllers/base.js

*app/widgets/mywidget/controllers/index.js

I start mycontroller.js file with line: exports.baseController = 'base'; and on Android it crashes with Exception:

/V8Exception(19693): Exception occurred at ti:/module.js:280: Uncaught Error: Requested module not found: alloy/controllers//glass/parent

Project tree looks like this:
app
├── README
├── alloy.js
├── assets
├── config.json
├── controllers
│   ├── base.js
│   ├── index.js
│   └── view.js
├── lib
│   └── user.js
├── models
├── styles
│   ├── app.tss
│   └── index.tss
├── views
│   ├── index.xml
│   └── view.xml
└── widgets
    └── mywidget
        ├── controllers
        │   ├── base.js
        │   ├── index.js
        │   └── view.js
        ├── styles
        ├── views
        └── widget.json

index.js & view.js inside app/controller use base.js as baseController.
index.js & view.js inside app/widgets/mywidget/controllers use base.js inside same directory as their baseController. I don't try to extend baseController from app inside widget.


text:
Q: Python - WTForms Coerce to Object I'm using a SelectMultipleField in a WTForm class that gets values from MongoDB.The input needs to be coerced to handle these MongoDB object IDs or I get this error:

Invalid choice(s): one or more data inputs could not be coerced

I have tried the following.
groups = SelectMultipleField("Groups: ", coerce=object)

but it doesn't doesn't work.
Here's what the HTML looks like (notice the object IDs used for value):
<select class="form-control" id="groups" multiple name="groups">
    <option value="53921416b45ba747082829f1">My Group</option>
    <option value="53921c1402b8754f85446e5a">ttt</option>
    <option value="53921cf602b8755019a9562e">Developers</option>
    <option value="53921de202b875518e449bad">sadf</option>
    <option value="53921fa902b87553366482cc">asdf</option>
</select>

What is the correct way to coerce the value (to handle object IDs)?

A: It turns out you just need to use ObjectID() from MongoDB. First, import ObjectID
from bson import ObjectID

Then modify your coerce parameter to
coerce=ObjectId


text:
Q: How to merge multiple numbers into one number like 4,0,0 into 400 without stdlib I'm trying to parse a file that has following data eg:
MAGICNUMBER 400

4 is = 0x34
0 is = 0x30
4
0
0
are different unsigned chars
what i want is those different chars  to be converted into
unsigned int x = 400;

when parsing them into my program i want to merge them into one integer i tried bitshifting but it didn't work and i probably did it very wrong and got a very large number probably due misunderstanding of something, what i'm susposed to do to merge those numbers without string tricks and without using std but only using bitshift with a explanation how it works?

A: Each digit is c - '0'. When you get a new digit, you know that prior ones are one decimal place greater, so you multiply the current number by 10 and add the new digit:
char *s = "400";
int sum = 0;

while(*s >= '0' && *s <= '9') {
    sum = 10 * sum + (*s - '0');
    s++;
}


text:
Q: Change the value of a cell based on the hidden value of another cell On a 2012 SSRS report I have the following:

You can see that "Site", 0098110, has a total of 13 "tests" associated with it. This is what I want to show while the group is in the collapsed state.
When I expand the group you can see the number of specific services - 9 "ABC" services, and 4 "XYZ" services. This accounts for the total of 13. Naturally there is a row grouping of Site Name, Service Type, Site Fee and Tests.
What I want is for the Total column to remain visible, but for its value to be set to blank (null) when a specific group is expanded like below instead of the image of the expanded group above:

...but the total for the group should reappear when the group is again collapsed, like in image 1. If I can simply make the Total cell blank based on the hidden value of the Service Type cell I'd be good.
I've combed the site and can't find anything specifically like this problem. Any advice appreciated.


text:
Q: Replacing HDD with SSD; what about non-APFS/APFS? iMac 27-inch, Late 2013, macOS up-to-date
I would like to back up my internal HDD (non-APFS) with Time Machine. Then erase the HDD. Then have the HDD replaced with a new internal SSD. Then restore from Time Machine.
Should I take precautions for the simultaneous switch from non-APFS to APFS? For example, must I convert the HDD to APFS before the steps mentioned above?

A: No, you don't need to convert the HDD. I recently did exactly what you're doing (though I installed the new SSD myself, which meant not having to worry about erasing the HDD) and didn't have to do any conversion.
But, just to be on the safe side, it would be smart to not only make sure you have a Time Machine backup but also clone your HDD to a different drive than the one that has your Time Machine backup. That way if, for whatever reason, you have a problem with restoring from the Time Machine backup, you have a fall-back plan. Better safe than sorry. You can clone the internal HDD to a second drive using Apple's Disk Utility or something like Carbon Copy Cloner. Instructions are readily available.
The other thing I'd suggest is that instead of simply restoring everything from your Time Machine backup to the new SSD you do a clean installation of macOS onto the new drive and then just restore your files and data using Migration Assistant. That way you get the benefits of a fresh OS installation along with the benefits of your new SSD.

A: No - I wouldn't do anything for the HFS -> APFS transition if you are on an SSD. This has been vetted for months across many architectures and as long as you have a backup of the data, proceed.
I wouldn't make any upgrade without a backup, so YMMV if you go without recent backups - any change at that point might not be worth the risk - even letting the system run is a risk if you have no backups and would want any of your time or data back when it inevitably gets corrupted or fails.
My recommendation would be to move all the data to the SSD using an external bus connection and test that restarting to it works before you open the hardware and do any swap. Lots of people put the SSD in and then try to worry if the part is tested or the cables are correct. Do all the testing and data migration before you put in the drive is my main advice.

*

*Install the OS you want on the external SSD.

*Run Migration Assistant to move all the apps and data to the SSD (when booted off the SSD).

*Test things with the SSD running everything. Including set up backup of the new SSD to whatever destination you want for Time Machine.

*Run for a week - letting the internal HDD just be there, not even mounted if you prefer.

*Do the swap SSD for HDD.


text:
Q: Nonhomogeneous Linear O.D.E I found this question and I cannot seem to answer it correctly and its kinda bothering. I am not seeing what I am not getting right with this particular problem. I took the same route as the OP and found the individual particular solutions of the RHS and added them together as a linear combination but to my surprise, get something totally different. Can someone look at this and let me know what I may be doing wrong.
Original question is linked here:  Solving Diff. Eq.
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             {\textbf{Method of Undetermined Coefficients}}$
${\bf{SOLUTION:}}$
$y(x)=y_{h}~+~y_{p}$
${\text{Differential Equation:}}~~~~~~~~~~~~~~~~~$  $y^{(5)}+2y^{(3)}+y'=2x+\sin(x)+\cos(x)$.
${\text{Homogeneous Case:}}~~~~~~~~~~~~~~~~~~~~$  $y^{(5)}+2y^{(3)}+y'=0$.
${\text{Characteristic Polynomial:}}~~~~~~~~~$ $r^5+2r^3+r=0$.
${\text{Solved Roots of polynomial:}}~~~~~~$  $\bigg[\{r\rightarrow 0\},\; \{r\rightarrow -i\},\; \{r\rightarrow -i\},\; \{r\rightarrow i\},\; \{r\rightarrow i\}\bigg]$
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$
$${\text{General Form of the Homogeneous Solution}}$$
$$
y_{h}(x)=C_{1}e^{r_{1}x}+e^{ax}\Big(C_{2}\cos(bx)+C_{3}\sin(bx)+C_{4}x\cos(bx)+C_{5}x\sin(bx) \Big)
$$
$${\text{Homogeneous Solution to the Differential Equation}}$$
$$y_{h}(x)=C_{1}+C_{2}\cos(x)-C_{3}\sin(x)+C_{4}x\cos(x)-C_{5}\sin(x);~~\Big(~\because \sin(-x)=-\sin(x)~\Big).$$
Now we shall seek a particular solution.
${\text{Non-Homogeneous Case:}}~~~~~~~~~~~~~~~~$  $y^{(5)}+2y^{(3)}+y'=2x$
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$
$$ f(x)=2x $$
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$Let,
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{array}{llll}
y_{p}(x)=Ax+b \\
y_{p}'(x)=A \\
y_{p}''(x)=0 \\
y_{p}^{(3)}(x)=0 \\
y_{p}^{(4)}(x)=0 \\
y_{p}^{(5)}(x)=0
\end{array}$
Substituting derivatives into differential equation:
$(0)+2(0)+(A)=2x$.
After equating the undetermined coefficient ${\underline{A}}$ we get:
$
\begin{array}{l}
A=~0
\end{array}
$
Making our particular solution to become,
$$ y_{p}(x)=0. $$
(2)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~y^{(5)}+2y^{(3)}+y'=\sin(x)$
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$
$$ f(x)=\sin(x) $$
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$Let,
$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{array}{llll}
y_{p}(x)=A\sin(x)+B\cos(x) \\
y_{p}'(x)=A\cos(x)-B\sin(x) \\
y_{p}''(x)=-A\sin(x)-B\cos(x) \\
y_{p}^{(3)}(x)=-A\cos(x)+B\sin(x) \\
y_{p}^{(4)}(x)=A\sin(x)+B\cos(x) \\
y_{p}^{(5)}(x)=A\cos(x)-B\sin(x)
\end{array}$
Substituting derivatives into differential equation:
$A\cos(x)-B\sin(x)+2\Big(-A\cos(x)+B\sin(x)\Big)+\Big(A\cos(x)-B\sin(x)\Big)=\sin(x)$.
After equating the undetermined coefficients ${\underline{A}}$ and ${\underline{B}}$ we get:
$
\begin{array}{l}
A=~0 \\
0\cdot B=1~~ ????~~ {\text{Huh}}
\end{array}
$
Making our particular solution to become,
$$ y_{p}(x)=0~~?? $$
I guessed it will be the same situation for the $\cos(x)$ on the RHS when finding the particular solution, though I could be missing an important fact.
Thanks.

A: Because $\sin(x)$ and $\cos(x)$ solve the homogeneous equation, you don't try solutions $y_p(x) = A\cos(x) + B\sin(x)$ when the right hand side is a multiple of $\sin(x)$ or $\cos(x)$.
Instead, you count the multiplicity $m$ of the root $i$ of the characteristic polynomial $r(r+i)^2(r-i)^2$, in this case $2$, and use
$$y_p(x) =  Ax^m\cos(x) + Bx^m\sin(x) =  Ax^2\cos(x) + Bx^2\sin(x)$$
The calculations might be annoying but you'll eventually be able to solve for $A$ and $B$.
Another thing you can do is try $y_p(x) = Ax^2e^{ix}$, and solve for $A$. The real part of this will give the particular solution for $\cos(x)$ on the right-hand side, and the imaginary part will give the particular solution for $\sin(x)$. The calculations will likely be a lot easier. Note $A$ will be a complex number this time.


text:
Q: MYSQL - How to convert a string resulting from GROUP_CONCAT function into a digit I have been stuck for a while with this query and was wondering if anyone here knows what I may be doing wrong.
The problem I'm facing is that the following query sends me a 0 instead of a -5 and if I remove the "CAST" function, I get -05, so it would appear as if the string -05 is not being converted to -5, however if I replace the entire "GROUP_CONCAT" function by '-05' then the "CAST" function DOES convert -05 to -5... is there something I'm missing here?
SELECT CAST(GROUP_CONCAT(if(FIELD_ID = 8, LEFT(VALUE,3), NULL)) as SIGNED INTEGER) as 'user_timezone'
FROM tn_cimy_uef_data
WHERE user_id = '58';

Expected Result: -5
Actual Result: 0 (NOT GOOD)
SELECT GROUP_CONCAT(if(FIELD_ID = 8, LEFT(VALUE,3), NULL)) as 'user_timezone'
FROM tn_cimy_uef_data
WHERE user_id = '58';

Excpected Result: -05
Actual Result: -05 (GOOD)
SELECT CAST('-05') as 'user_timezone'
FROM tn_cimy_uef_data
WHERE user_id = '58';

Excpected Result: -5
Actual Result: -5 (GOOD)
The table looks like this (table tn_cimy_uef_data):
ID      USER_ID         FIELD_ID        VALUE
1       58              1               12121212
2       58              2               12121212
3       58              3               lorem ipsum
4       58              4               lorem ipsum
5       58              5               lorem ipsum
6       58              6               lorem ipsum
7       58              7               lorem ipsum
8       58              8               −05:00:00 -> America/Miami
9       58              9               lorem ipsum
10      58              10              12121212

I appreciate if anyone could shed some light in this darkness xD
Thanks,
P


text:
Q: Systemd service unit failed with result 'exit-code' I have a python script that works fine if I run it with /usr/bin/python3.
But I would like to be able to run it from a bash file as root through a service unit from systemd. I want to be able to pass a bash script because I would like to chain this python script and then a php script afterwards).
For this, I have created the following service (without timer for the moment):
[Unit]
Description=My service

[Service]
User=root
ExecStart=/usr/bin/bash /home/myself/script.sh
Type=oneshot

and a simple bash script :
#!/bin/bash

python3 /home/myself/script.py

but  when I run "sudo systemcl start myservice.service", I have this error :
Job for myservice.service failed because the control process exited with error code.
See "systemctl status myservice.service" and "journalctl -xe" for details.

and when I look at the status :
..... systemd[1]: Starting My service...
..... bash[13176]: Traceback (most recent call last):
..... bash[13176]:   File "/home/myself/script.py", line 33, in <module>
..... bash[13176]:     files_number = next(os.walk(files_path))[2]
..... bash[13176]: StopIteration
..... systemd[1]: myservice.service: Main process exited, code=exited, status=1/FAILURE
..... systemd[1]: myservice.service: Failed with result 'exit-code'.
..... systemd[1]: Failed to start My service.

I don't understand why it doesn't work. Is it because I'm using the 'os' library in my script or something else I don't understand?


text:
Q: How to fix exception in setResultTransformer method during Hibernate 4 using with MS SQL 2008? How to fix exception in setResultTransformer method during Hibernate using?
I have method which calls named query
SessionFactory sf =  HibernateUtil.createSessionFactory();
        Session session = sf.openSession();
        Transaction t = session.beginTransaction();
        Query  qr = session.getNamedQuery("Product_Create");
        qr.setParameter("@Return", 0);
        qr.setParameter("@ProdIDID", 0);
        qr.setParameter("@PassID", new BigInteger("9999999999"));
        qr.setParameter("@Amount", new BigInteger("7777777777"));

        t.commit();
        List<CreatedCardBean> list = qr.setResultTransformer(Transformers.aliasToBean(CreatedCardBean.class)).list();
        for(int i=0; i<list.size(); i++){
            CreatedCardBean card = (CreatedCardBean)list.get(i);
            LOG.info(String.valueOf(card.getCardId()));
        }

MS SQL procedure looks like:
PROCEDURE Product_Create(
        @Return  int  output,
        @ProdID numeric(18,0)  output,
        @PassID numeric(18,0),
        @Amount numeric(18,2))

My hibernate config looks like:
    <hibernate-configuration>
  <session-factory>
    <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
    <property name="connection.url">jdbc:sqlserver://....</property>
    <property name="connection.username">user</property>
    <property name="connection.password">pass</property>
    <property name="connection.pool_size">10</property>
    <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
    <property name="show_sql">true</property>
    <property name="hibernate.connection.autocommit">true</property>
    <!--<property name="current_session_context_class">thread</property> -->

    <mapping resource="com/comp/common/Product_Create.hbm.xml"></mapping>

  </session-factory>
</hibernate-configuration>

and hibernate-mapping looks
<hibernate-mapping>
    <sql-query name="Product_Create" callable="true">
        <return-scalar column = "retVal" type="int"/>
        <return-scalar column = "cardId" type="long"/>
        <![CDATA[{CALL Product_Create (:@Return, :@ProdID, :@PassID, :@Amount)}]]>
  </sql-query>
</hibernate-mapping>

When I run the method it create a product (aim of procedure) in db, but after it shows the exception :
INFO : [окт-06 11:49:56,775] annotations.common.Version - HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
INFO : [окт-06 11:49:56,788] org.hibernate.Version - HHH000412: Hibernate Core {4.3.8.Final}
INFO : [окт-06 11:49:56,791] hibernate.cfg.Environment - HHH000206: hibernate.properties not found
INFO : [окт-06 11:49:56,794] hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist
INFO : [окт-06 11:49:56,828] hibernate.cfg.Configuration - HHH000043: Configuring from resource: /hibernate.cfg.xml
INFO : [окт-06 11:49:56,828] hibernate.cfg.Configuration - HHH000040: Configuration resource: /hibernate.cfg.xml
WARN : [окт-06 11:49:56,861] util.xml.DTDEntityResolver - HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
INFO : [окт-06 11:49:56,888] hibernate.cfg.Configuration - HHH000221: Reading mappings from resource: com/comp/common/Product_Create.hbm.xml
WARN : [окт-06 11:49:56,919] util.xml.DTDEntityResolver - HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
...
...
INFO : [окт-06 11:49:56,953] hibernate.cfg.Configuration - HHH000041: Configured SessionFactory: null
WARN : [окт-06 11:49:57,091] connections.internal.DriverManagerConnectionProviderImpl - HHH000402: Using Hibernate built-in connection pool (not for production use!)
INFO : [окт-06 11:49:57,202] connections.internal.DriverManagerConnectionProviderImpl - HHH000006: Autocommit mode: true
INFO : [окт-06 11:49:57,204] connections.internal.DriverManagerConnectionProviderImpl - HHH000115: Hibernate connection pool size: 10 (min=1)
INFO : [окт-06 11:49:57,895] hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
INFO : [окт-06 11:49:57,986] transaction.internal.TransactionFactoryInitiator - HHH000399: Using default transaction strategy (direct JDBC transactions)
INFO : [окт-06 11:49:57,992] internal.ast.ASTQueryTranslatorFactory - HHH000397: Using ASTQueryTranslatorFactory
INFO : [окт-06 11:49:58,056] internal.util.Version - HV000001: Hibernate Validator 5.1.3.Final
Hibernate: {CALL Product_Create (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}
WARN : [окт-06 11:50:02,280] jdbc.spi.SqlExceptionHelper - SQL Warning Code: 0, SQLState: S0001
....
WARN : [окт-06 11:50:02,301] jdbc.spi.SqlExceptionHelper - ProductID = 78712878
Exception in thread "main" java.lang.NullPointerException
    at org.hibernate.loader.Loader.processResultSet(Loader.java:950)
    at org.hibernate.loader.Loader.doQuery(Loader.java:921)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355)
    at org.hibernate.loader.Loader.doList(Loader.java:2554)
    at org.hibernate.loader.Loader.doList(Loader.java:2540)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370)
    at org.hibernate.loader.Loader.list(Loader.java:2365)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:353)
    at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1873)
    at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:311)
    at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:141)

Could anybody help me with idea to fix this Exception?
UPDATE
CreatedCardBean is:
public class CreatedCardBean {
        private int ReturnValue;
        private long prodID;

        public int getReturnValue() {
            return ReturnValue;
        }
        public void setReturnValue(int returnValue) {
            ReturnValue = returnValue;
        }
        public long getProdID() {
            return prodID;
        }
        public void setProdID(long prodID) {
            this.prodID = prodID;
        }
}


text:
Q: Inno Setup "return" like command/construct in Code Is there any command/construct like return in C that exits immediately from a function of Inno Setup script code keeping the result code?
I would like something
If k = false then
Begin
    Result:=false;
    Exit;
End;

A: Your code is correct.
Use the Exit statement to exit a function or a procedure. With the function, set the Result automatic variable, before you call the Exit, to set the return value.
function MyFunction: Boolean;
begin
  if not SomeTest then
  begin
    // cannot do stuff, aborting
    Result := False;
    Exit;
  end;

  // do stuff

  Result := True;
end;


text:
Q: Set value of dynamic var in bash I have the following case:
A=1
echo $A # output 1
B='A'
echo $B  # output A
echo "\$$B=2" # output $A=2
echo "\$$B=2" | eval # this won't set $A to 2

I'd like $A to get 2 as value.

A: Found a solution using declare ( Dynamic variable names in Bash )
B='A'
declare "$B=2"
echo $A # output 2