text:
Q: Python profiler does not exit with proper exit code I am profiling a python script using cProfile and I want it to have the same exit code as my script's exit code.
Let's say my script error.py is:
import sys

print ("Error")
sys.exit(1)

Of course when I run it with:
python3 error.py

the process exits with a code 1, but when I run it with following command:
python3 -m cProfile error.py

The exit code is 0 and I want to propagate the exit code of error.py to the profiler.
Is there a way to achieve that?

EDIT
Applying pkqxdd 's suggestions helped but my problem is more complex.
error.py is now:
print ("Error")
raise Exception

However, I am using cProfile together with py.test-3 as following:
 python3 -m cProfile -o profile $(which py.test-3) error.py

The command above still produces the exit code 0.

A: Short answer: no
Because a non-zero exit code from profiler means there is an error while running the profiler. It's not the profiler's job to check your script's exit code. However, you can raise an exception if the exit code is all you care about:
# error.py
raise Exception


text:
Q: Inheriting ArrayList property from superclass but assigning different types to it in child classes I have a superclass A that has a protected ArrayList<Object> contentList. And I have classes B and C that inherit from A.
Each of B and C initialise contentList in their constructor with ArrayList of different types
class B extends A
{
    public B (ArrayList<BContent> content)
    {
        contentList = content;
    }
...
}

class C extends A
{
    public C (ArrayList<CContent> content)
    {
        contentList = content;
    }
...
}

Both BCOntent and CContent and data structure subclasses from Object.
The compiler is complaining that this is not accepted and that I have to change the declaration type of contentListfrom ArrayList<Object> to ArrayList<BCOntent> or ArrayList<CCOntent>
I come from Objective-C background and this is possible due to dynamic type resolution. How can I achieve this in Java?
Cheers
AF

A: You could use generics.
class A<T> {
    protected List<T> content;
}

class B extends A<BContent> {
    ...
}

This means that A can be used with different possible types (T) as its content. A<BContent> holds BContent, and A<CContent> holds CContent.

A: An ArrayList<BContent> is not ArrayList<Object> even if BContent is an Object.
But what you can do is,
public B (ArrayList<BContent> content)
{
    contentList = new ArrayList<>(content);
}

This way you are creating a new ArrayList<Object> with all the elements of content

A: You can use a type bound in the member declaration :
protected ArrayList<? extends Object> contentList;

You don't have to change your constructors.

A: If you use a generic type in the superclass
public class A<T> {
    protected List<T> contentList;
}

Then you can extend it with a concrete type
public class B extends A<BContent> {
    public B (List<BContent> content) {
        contentList = content;
    }
    ...

BTW, passing around ArrayList is usually a bad idea... use the more general List instead.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Syntax Highlighting Gtk.Entry on Python I want to highlight the text of a Gtk.Entry, like this:

The first solution that came to me was foreign drawing, but I would have to manage everything myself. Other thought I had was to extend Gtk.Entry and override just the drawing of the text, but I don't think that's possible in Python.
How can I do that and take advantage of the work Gtk already does managing focus, drawing, animation, scrolling, cursor, etc.?


text:
Q: Two Layer Generic Structure in Java I want to make a binary tree keep node as heap so that
I try to make a generic in generic but I got some problem about it.
1-)I could not figure out two layer generic is it possible in Java.
2-)I adding tree as number but when I try to return node I dont now assign what and can I reach it methods if it can be return .
Binary Search Tree Heap Tree
public class BSTHeapTree <E extends Comparable<? extends Comparable<?>>>{

    BinarySearchTree<E<T>> root;    //error
    public BSTHeapTree() {
        root = new BinarySearchTree<>(); // error
    }

    int add(E _data) {
         = root.getRoot();      //Assign what
        return 0;
    }

}

Binary Search Tree
public class BinarySearchTree<E extends Comparable<E>>{

    private Node<E> head;

    public BinarySearchTree() {
        head = null;
    }
    public Node<E> getRoot() {
        return head;
    }

    private static class Node<E extends Comparable<E>>{

        E data;
        Node<E> lBranch;
        Node<E> rBranch;
    }
}

Heap
public class Heap<E extends Comparable<E>> implements Comparable<Heap<E>>{

   private E[] heapData;
}


text:
Q: I need to add space between Price and "Rs" I try to find the phtml file to add space between price and currency "Rs".
But haven't found in final_price.phtml.
Any help would be appreciated.

A: You can do it from backend
Click on Stores > Currency > Currency Symbols
Unchecked use standard and add space after the symbol of currency.
After run php bin/magento cache:flush or refresh cache from the backend.


text:
Q: Golang filepath.Walk panic error on large directory I am trying to walk through all files on the C drive which I read can be inefficient in Go, but I can't work out why I keep getting a panic error when doing this as I tell the walk function to return a nil error code.
package files

import (
   "path/filepath"
   "os"
   "fmt"
 )

func walkpath(path string, f os.FileInfo, err error) error {
    fmt.Printf("%s with %d bytes\n", path,f.Size())
    return nil
}

func GetFiles() {
    err := filepath.Walk("C:\\", walkpath)
    if err != nil {
        fmt.Printf(err.Error())
    }
}

Panic error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x40 pc=0x46d0d6]

goroutine 1 [running]:
files.walkpath(0xc0820a8f80, 0xf, 0x0, 0x0, 0x664270, 0xc082408840, 0x0, 0x0)
        C:/project/src/files/files.go:11 +0x66
path/filepath.walk(0x529140, 0x3, 0x6641e8, 0xc082012240, 0x560d50, 0x0, 0x0)
        c:/go/src/path/filepath/path.go:370 +0x41c
path/filepath.Walk(0x529140, 0x3, 0x560d50, 0x0, 0x0)
        c:/go/src/path/filepath/path.go:396 +0xe8
files.GetFiles()
        C:/project/src/files/files.go:22 +0xc9
main.main()
        c:/project/src/main.go:12 +0x49
exit status 2

c:\project>go build c:\project\src\main.go

https://gobyexample.com/panic
How do you handle errors which occur during runtime?
Thanks!

A: You're not checking the error, and trying to call a method on a nil os.FileInfo interface:
func walkpath(path string, f os.FileInfo, err error) error {
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Printf("%s with %d bytes\n", path,f.Size())
    }
    return nil
}

If you want to handle a panic at runtime, you can use recover. This should however be a last resort for unexpected panics. A panic is usually because of a programming error, and is intended to crash the program.


text:
Q: Oracle VM Virtual Box Doesn't start I had read former questions about this topic but didn't find something similar o a thing which solves my problem.
I'm using Lubuntu 16.04
Trying to run VirtualBox for Windows 8 or 10, I had downloaded Oracle VM VirtualBox from the Official Webpage. With i386 package.
When I click on the shortcut nothing happens.
Please help.

A: Uninstall completely Oracle VM with steps in question https://askubuntu.com/a/703750/632766 (source) add autopurge when the terminal suggest you to do it. And reinstall from terminal.
Steps are:

*

*sudo apt-get remove --purge virtualbox When the terminal suggest run autopurge, copy, paste and run it.

*Run

sudo rm ~/"VirtualBox VMs" -Rf
sudo rm ~/.config/VirtualBox/ -Rf

*

*Install again sudo apt-get install virtualbox

*To open VM search in Menu>Accessories> Virtual Box


text:
Q: "SyntaxError: Unexpected token h in JSON at position 0 I want to make POST request from Angular client. I have this Spring endpoint:
    @RestController()
public class HomeController {

  @PostMapping(value = "/payment/{unique_transaction_id}", consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE })
  public ResponseEntity<WpfResponse> handleWpfMessage(@PathVariable("unique_transaction_id") String unique_transaction_id,
      @RequestBody WpfPaymentsDTO transaction, HttpServletRequest request) throws Exception {

    /// ....
    return ResponseEntity.ok("http://some_domain.com/example");
  }
}

I use this typescript code:
save(main: MainForm, hash: string): void {
    this.http.post('http://localhost:8080/some_package/payment/ckjzqtyxh5pnavbjecujhuvzaa5q8n74', main, { headers }).subscribe();
  }

But when I make POST request I get:
    HttpErrorResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: "http://localhost:8080/some_package/payment/ckjzqtyxh5pnavbjecujhuvzaa5q8n74", ok: false, …}

"SyntaxError: Unexpected token h in JSON at position 0
    at JSON.parse (<anonymous>)
    at XMLHttpRequest.onLoad (http://localhost:4200/vendor.js:13388:51)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:2781:31)
    at Object.onInvokeTask (http://localhost:4200/vendor.js:54479:33)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:2780:60)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (http://localhost:4200/polyfills.js:2553:47)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.js:2856:34)
    at invokeTask (http://localhost:4200/polyfills.js:4102:14)
    at XMLHttpRequest.globalZoneAwareCallback (http://localhost:4200/polyfills.js:4139:21)"

I get status OK but I can't find why I get this error message. Do you know how I can fix it?

A: You need to include { responseType: 'text' } in your headers. i.e.
  const headers = {
        responseType: 'text'
  }

  this.http.post('http://localhost:8080/some_package/payment/ckjzqtyxh5pnavbjecujhuvzaa5q8n74', main, { headers }).subscribe();

Late answer but can help others in future.

A: I've no clue form spring but from your code it seems that you return JSON but the return value is string "http://some_domain.com/example" which is not JSON.


text:
Q: How to do this Observable correctly? I have a part of code:
id$!: Observable<string | null>;

and I need to rewrite this to Observable for using this method:
getCharacterDetail() {
   if (!this.id$) {
     return;
   }
   this.store$.dispatch(getCharDetailsData({id: this.id$ }));

 }

A: id!: string;

for url parameter no need to use observables.
this.id = this.router.snapshot.paramMap.get('id');

and use it in getCharacterDetail.
getCharacterDetail() {
   if (!this.id) {
     return;
   }
   this.store$.dispatch(getCharDetailsData({id: this.id }));

 }

but if you persist to change that:
ngOnInit(): void {
   this.router.paramMap.subscribe((res: any) => {
     this.id = res.id;
     this.getCharacterDetail();
     this.characterDetail$ = this.store$.select(charDetailsSelector);
    });
}

UPDATE:
if you need id as observable:
ngOnInit(): void {
  this.id$ = this.router.paramMap.pipe(params => params.id);
  // or this.id$ = of(this.router.snapshot.paramMap.get('id'));
  this.id$.subscribe(id => {
     if (!id) {
      return;
     }
     this.getCharacterDetail(id);
});

}

getCharacterDetail(id) {
  this.store$.dispatch(getCharDetailsData({id: id}));
  this.characterDetail$ = this.store$.select(charDetailsSelector);
}


text:
Q: Why can't my friend join my game? My friend and I have been having trouble with multiplayer in Borderlands 2. Whenever I join his game his says that the xbox is unable to read the disc, sends me to the main menu and him to the dashboard. He has the downloadable version off of Xbox LIVE and I have the disc version. I also have most DLCs (except for most of the skin packs). I was trying to join as Krieg the Psycho which we've done flawlessly before.
Also, when we tried having him join my game it said on his screen that I was in a DLC he didn't have when I was in Sanctuary. This all started before the recent compatibility pack update' I think after the recent game update.

A: Have your friend delete or re download the compat pack and make sure your dlc is fully downloaded. I've occasionally had this happen to me.


text:
Q: SwiftUI how to get the coordinate in Sheet View(Modal View) [from .sheet(isPresented: )ViewModifier] I am using SwiftUI framework to construct the view, and use the .fullScreenCover and .sheet viewModifer to test the coordiate inside, I put a button inside the view and my question is:

*

*the coordinate origin Y of the button inside the full screen cover view is 143, it is ok.

*the coordinate origin Y of the button inside the sheet view is 165, more than 143, I guess it may be there is a space above the sheet view, and I get the coordiate using Geometry Reader proxy.frame in global, so it may be based on the device's cooridate space.

*My target is how can I get the coordinate based on the sheet view, i.e. i wanna make the origin Y show 143 too in the sheet view.
Note: I am testing it using iPhone 12 Pro simulator.

This is the image link.
import SwiftUI

struct ContentView: View {
@State var showSheet = false
@State var ShowFullScreen = false
@State var origin: CGPoint?

var body: some View {
    NavigationView {
        VStack {
            Button {
                showSheet = true
            } label: {
                Text("showSheet")
            }
            .sheet(isPresented: $showSheet) {
                NavigationView {
                    GeometryReader { proxy in
                        Button {
                            origin = proxy.frame(in: .global).origin
                        } label: {
                            Text("origin Y in Sheet: \(origin?.y.description ?? "nil")")
                        }
                        .buttonStyle(.borderedProminent)
                    }
                    .toolbar {
                        Button {
                            showSheet = false
                            origin = nil
                        } label: {
                            Text("Dismiss")
                        }
                    }
                }
            }

            Button {
                ShowFullScreen = true
            } label: {
                Text("ShowFullScreen")
            }
            .fullScreenCover(isPresented: $ShowFullScreen) {
                NavigationView {
                    GeometryReader { proxy in
                        Button {
                            origin = proxy.frame(in: .global).origin
                        } label: {
                            Text("origin Y in FullScreen: \(origin?.y.description ?? "nil")")
                        }
                        .buttonStyle(.borderedProminent)
                    }
                    .toolbar {
                        Button {
                            ShowFullScreen = false
                            origin = nil
                        } label: {
                            Text("Dismiss")
                        }
                    }
                }
            }
        }
    }
}
}


text:
Q: http load testing tool I want to record web activity as would be done by a single user and then run one or multiple such simulteanous users (perhaps tweaking some params, such as converting user/password into user1/password, ..., usern/password).
Playing with timing would be nice too.

A: Grinder is one of the best I have used, the tool is built in java but I used this to test my ASP.NET application. Tested using 3 machines. (each machine would only simulate a max of 1000 users at one time). We ended up doing the load test for 3000 concurrent users.

A: My company, BrowserMob, provides a low-cost load testing service that might work well for you. You can sign up for a free trial, upload a Selenium script, and then further modify the script to use different logins, etc. The entire script ends up written with a  JavaScript API, so you can do some pretty advanced things. You can $100 worth of free testing, which can go a long ways, especially if you use our Virtual Users feature rather than our Real Browser Users feature.

A: ab is a nice simeple way to start.

A: I work on a project that may fit the bill. It's called engulf. If you need to generate a lot of load engulf works pretty well because it supports multiple workers. It also has a real-time web interface, which  is pretty enjoyable to watch IMHO.


text:
Q: Parsing RAW HTTP headers and converting it to JSON I have an endpoint which receives a parameter called headers which contains RAW string of HTTP headers. I need this string to be converted to JSON/Hash object.
Example values of headers:
"Received: by mx0047p1mdw1.sendgrid.net with SMTP id 6WCVv7KAWn Wed, 27 Jul 2016 20:53:06 +0000 (UTC)
Received: from mail-io0-f169.google.com (mail-io0-f169.google.com [209.85.223.169]) by mx0047p1mdw1.sendgrid.net (Postfix) with ESMTPS id AA9FFA817F2 for <example@example.comom>; Wed, 27 Jul 2016 20:53:06 +0000 (UTC)
Received: by mail-io0-f169.google.com with SMTP id b62so81593819iod.3 for <example@example.comom>; Wed, 27 Jul 2016 13:53:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sendgrid.com; s=ga1; h=mime-version:from:date:message-id:subject:to; bh=DpB1CYYeumytcPF3q0Upvx3Sq/oF4ZblEwnuVzFwqGI=; b=GH5YTxjt6r4HoTa+94w6ZGQszFQSgegF+Jlv69YV76OLycJI4Gxdwfh6Wlqfez5yID 5dsWuqaVJZQyMq/Dy/c2gHSqVo60BKG56YrynYeSrMPy8abE/6/muPilYxDoPoEyIr/c UXH5rhOKjmJ7nICKu1o99Tfl0cXyCskE7ERW0=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=DpB1CYYeumytcPF3q0Upvx3Sq/oF4ZblEwnuVzFwqGI=; b=Sq6LVHbmywBdt3sTBn19U8VOmelfoJltz8IcnvcETZsYwk96RBxN+RKMN5fOZSKw4j 15HrgdIFfyDmp67YK0ygvOITlTvZ6XY5I0PtnvDtAQt79kS3tKjI3QKJoEp/ZjIjSzlL KG7agl6cxFgBbIN0yHWBOvy3O+ZXY8tZdom1yOvULjmjW1U9JkdOs+aJ6zq4qhZX/RM/ tIgLB461eJ5V95iQDDc5Ibj9Cvy4vJfXLQRO0nLVQAT2Yz58tkEO1bDZpWOPAyUNneIL yhIWp+SpbuqhMA68mq0krG1PjmWalUbpVcGJIGuOKB9mQFFo/MqdrUCjvYnyo1jPLPeX psdQ==
X-Gm-Message-State: AEkoousvdxmDoxLlTUYJ1AOmCGJv77xRBBlfKv6YrthH0M2NueMwlOxUD6t8nidE9uonXbdJ/DQy/chmHUnN//a4
X-Received: by 10.107.6.101 with SMTP id 98mr38024553iog.41.1469652785829; Wed, 27 Jul 2016 13:53:05 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.107.48.17 with HTTP; Wed, 27 Jul 2016 13:53:05 -0700 (PDT)
From: Sender Name <example@example.com>
Date: Wed, 27 Jul 2016 14:53:05 -0600
Message-ID: <CAN_P_JMvV7ZpAQhOnDienypLrJmuhN=LQWweu4yScw4jQyXY2w@mail.gmail.com>
Subject: Different File Types
To: example@example.comom
Content-Type: multipart/mixed; boundary=001a113f8ad03e85160538a4343c
"

Please help me to convert the above HTTP header string to JSON.
Thanks..

A: Split by carriage returns ⏎, then split each line by colon, two parts at most, then convert the result to the hash:
input.split($/).map { |line| line.split(':', 2).map(&:strip) }.to_h

The strip operation in between is optional.


text:
Q: method, return in a while I'm working in a class and I have a method which returns :
while ($donnees = $reponse->fetch()){
        $temp[$i] = new Membres($donnees['id_membres']);
        return '' . $temp[$i]->getPseudo() . '
';
        $i++;

it only returns the first data of the while, and when I'm using echo instead of return it's working but the printing is in top of the page.

A: Try this
$var = '';
while ($donnees = $reponse->fetch()){
        $temp[$i] = new Membres($donnees['id_membres']);
        $var .= '' . $temp[$i]->getPseudo() . '
';
        $i++;
}
return $var;


text:
Q:  render problem in a form i have a question about rendering a simple <h:inputText> value. When i write
<h:inputText id="username" value="#{userBean.user.username}" />

it's output is
<input id="form:username" name="form:username" type="text" />

is there a way for an output without form:xxx like this?
<input id="username" name="username" type="text" />

Also minlength is not working with <h:inputText>. do you have an idea without writing javascript for each data in form?

A: Yes it's possible. You should add prependId attribute inside h:form
<h:form prependId="false" id="form1">
Now everything won't have prefix form1
</h:form>


text:
Q: Split a Table to Format into Spreadsheet I have a table, that has data like.
    ------------+---------------+---------------+---------------+---------------+---------------+---------------+------------+
    Agent Name  |   Total Fails |   To Process  |   Processed   |   Declined    |   Total Today |   Daily Net   |   Switched |
    ------------+---------------+---------------+---------------+---------------+---------------+---------------+------------+
    John H      |       0       |       3       |       0       |       3       |       10      |       18      |       3    |
    Mary B      |       0       |       1       |       0       |       1       |       14      |       25      |       4    |
    Department  |       0       |       4       |       0       |       4       |       24      |       43      |       7    |
    ------------+---------------+---------------+---------------+---------------+---------------+---------------+------------+

What I would like is an Embedded Excel sheet in an Access Form. Added to the complexity, I need it to be organized in a different fashion. I need the Excel sheet to be in this format.
    Agent Name      |   John H  |   Mary B  |   Department
    ----------------+-----------+-----------+---------------
    Total Fails     |       0   |       0   |       0
    To Process      |       3   |       1   |       4
    Processed       |       0   |       0   |       0
    Declined        |       3   |       1   |       4
    Total Today     |       10  |       14  |       24
    Daily Net       |       18  |       25  |       43
    Switched        |       3   |       4   |       7

So in simple terms I would want the first Column values in the table to be the Column headers in excel. The column names to be the First column of the Excel sheet. I am unable to explain exactly what I need.
I need to transpose the Sheet, not completely. Any ideas or thoughts?

A: The following is one example, from Microsoft, of how to transpose the data rows/columns in a table: http://support.microsoft.com/kb/182822
Titled 'ACCESS: How to Transpose Data in a Table or Query', it offers two methods:

*

*Method 1 - Transpose the Data in Microsoft Excel

*Method 2 - Use a Custom Function to Transpose the Table (includes sample code)

Glad it worked!

A: I would bring the data into a local table in Access and then bind your form to a Crosstab Query. Then the only code you need is the import from Excel to Access.


text:
Q: Detecting connectivity with the Drive Realtime API I want to display a message when my user is offline and disable all editing features, then reenable them when the user comes back online.  Right now I'm using navigator.onLine which doesn't actually detect connectivity very well in some cases.
What's the best way to determine whether the Drive Realtime API is connected?

A: We've had success with using the Save State Change event on the realtime document to determine the offline/online status of the connection. This means that you wont know you're offline until you try to make a change to the doc, but you could add a heartbeat doc change if knowing the status is critical.
See https://developers.google.com/drive/realtime/reference/gapi.drive.realtime.DocumentSaveStateChangedEvent for the event info.

A: One addition to Grant's answer which may be important to consider, is that 'isSaving' can NOT be relied on to determine that a new realtime document or an update has been fully saved to the servers.
To make sure that a disconnection or page closure is safe, you also have to check that document.saveDelay has dropped to zero.
This isn't currently documented by Google, but can be verified by looking at network traffic when uploading, for instance, an in-memory model:
var saving = false;
var ev = gapi.drive.realtime.EventType.DOCUMENT_SAVE_STATE_CHANGED;

document.addEventListener(ev, function(e) {
    saving = e.isSaving;
});

document.saveAs(fileId);

var h = window.setInterval(function() {
    if (!saving && !document.saveDelay) {
        window.clearInterval(h);
        console.log("Good to go");
    }
}, 1000);


text:
Q: How enum can be used as string I have CurrentType as enum in a class like following:
typedef enum {
        login = 0,
        Details,
        SendImages,
       UpdateDetails,

}CurrentType;

Now In another ViewController,I want to use this CurrentType as parameter like as follows:
-(void)getLoginUserDetails:(NSData *)response :(CurrentType)service{

But when I write the following in method body
service==UpdateDetails

it gives error
How can I use this CurrentType as parameter ???

A: Concerning your subject: Enums in (Objective-)C are of an integral type like intor long. You can't assign or cast enums to strings directly, but rather have to implement your own conversion function.


text:
Q: How to define override services in a shared module I have a shared module, written in AngularJS 1.6.5. This module is to be used by multiple applications. This module has several services, internally, that must be overridden by the host application. This is to handle things such as request authorization differences to varying REST endpoints, which are all different between the different host systems.
I know that I could define my shared module first, and then define services of the same name later in my code, but this feels very dirty. Especially when each application already has services like this, just under different names.
Any suggestions?
Clarification:
So my shared module might have directives with controllers that inject a service

class MyDirectiveController {
  /*@ngInject*/
  constructor($element, entity) {
    this.$element = $element;
    this.entity = entity;
  }

  $onInit() {
    this.entity.get(this.id)
      .then((data) => this.dataSet = data);
  }
}

And, within the shared module, I would have a dummy service:

class Entity {
  /*@ngInject*/
  constructor($q) {
    this.$q = $q;
  }

  get() {
    console.info('You must include your own override service for retrieving entity data');
    return this.$q.reject();
  }
}

Then somehow pass my parent app service in as an override to the module's entity service:

entity = MyAppEntityService;

A: The order of service definitions matters only for config phase. For run phase the hierarchy of modules matters (unless there are several definitions of same service within a single module).
Considering that shared module has foo service, a module that loads will be capable of overriding its services:
angular.module('app', ['shared']).factory('foo', ...);


text:
Q: Sonata Admin English backend language I have a website developed using Symfony 2.8 and Sonata Admin.
The frontend website is entirely in French and so are all the database entities (translated using Gedmo Translatable).
Unfortunately I can't set the global default language to 'fr' because I want the admin area to be in English:
parameters:
    locale: fr

framework:
    #esi: ~
    translator: { fallbacks: ['%locale%'] }
    default_locale: '%locale%'

stof_doctrine_extensions:
    default_locale: '%locale%'
    orm:
        default:
            timestampable: true
            blameable: true
            translatable: true

sonata_translation:
    locales: ['%locale%']
    default_locale: '%locale%'
    gedmo:
        enabled: true

If I change the global language to 'fr' all the labels become French (Déconnexion, Éditer etc...).
How can I have all the website and the entities in French but the admin interface in English?

A: You can override the locale for an area of the site with a onKernelRequest event listener, as detailed in 'How to Work with the User's Locale'. Here, you would watch for a URL that was within the admin-area, and change the locale to 'en_GB', etc, in the Request object.


text:
Q: Math macro with \left can only be used in math mode error I use \eq{} and \eq*{} instead of \begin and \end equation.
\def\eq{\@ifstar\@eq\@eeq}
\def\@eq#1{\begin{equation*}\begin{split}#1\end{split}\end{equation*}}
\def\@eeq#1{\begin{equation}\begin{split}#1\end{split}\end{equation}}

It works well, however, when I try to use
\eq{\left( .... \right)}   % no error
\eq*{\left( .... \right)}   % \left can only be used in math mode

The editor warns me that left can only be used in math mode.
How do I make the editor think that my input is 100% math?
...
\def\@eq#1{\begin{equation*}\begin{split}\ensuremath{#1}\end{split}\end{equation*}}
...

does yield same error, but,
\eq*{\ensuremath{\left(...\right)}}

This works without error.
*When I say error, Its not that It fails to compile, but has red x mark on the left.. both method compiles as expected..
*Other maths (\frac{}{}, x_s,... ) work without error...

A: Your editor knows that
\[ ... \]
\begin{equation} ... \end{equation}
\begin{equation*} ... \end{equation*}

(not necessarily with the initial and terminal marks on the same line) and other environments are math, so it won't signal math specific commands inside them.
Instead, it apparently seems to be wanting to help you in avoiding common errors, like using math specific commands out of context.
You don't say which editor you're using, but the answer is independent of the editor. You have two choices:

*

*teach the editor that the argument of \eq or \eq* is math;

*avoid using "abbreviations" such as \eq and \eq*.
The second strategy is preferable: you perhaps gain a few keystrokes at the expense of input clarity and flexibility. I have no doubt what input is clearer in the following code.
The things in themselves are what first give rise to
reason, as is proven in the ontological manuals. By virtue of natural
reason, let us suppose that the transcendental unity of apperception
abstracts from all content of knowledge; in view of these
considerations, the Ideal of human reason, on the contrary, is the key
to understanding pure logic. Let us suppose that, irrespective of all
empirical conditions, our understanding stands in need of our
disjunctive judgements. As is shown in the writings of Aristotle, pure
logic, in the case of the discipline of natural reason, abstracts from
all content of knowledge
\begin{equation}\label{abc}
\int_{-\infty}^{\infty} \exp(-x^2)\,dx=\sqrt{\pi}
\end{equation}
Our understanding is a representation of, in accordance with the principles
of the employment of the paralogisms, time. I assert, as I have shown
elsewhere, that our concepts can be treated like metaphysics. By means of
the Ideal, it must not be supposed that the objects in space and time are
what first give rise to the employment of pure reason
\eq{\label{abc}\int_{-\infty}^{\infty} \exp(-x^2)\,dx=\sqrt{\pi}}
Thus, the Antinomies exclude the possibility of, on the other hand, natural
causes, as will easily be shown in the next section.  Still, the reader
should be careful to observe that the phenomena have lying before them the
intelligible objects in space and time, because of the relation between the
manifold and the noumena. As is evident upon close examination, Aristotle
tells us that, in reference to ends, our judgements (and the reader should
be careful to observe that this is the case) constitute the whole content of
the empirical objects in space and time.


text:
Q: How to clear the session between two consecutive intents? We are using bot trees master which uses bot graph dialog for loading graph based dialogs dynamically. We have created a scenario to load multiple intents(whose intents scores are nearly matching). Now the problem I am facing is when I request for single intent , I am getting the bot response and able to enter into next intent but when I request for multiple intents bot is giving the response and when I request for another intent , bot is giving the same response of multiple intents. When bot is entering into multiple intent handler it is not clearing the session and not coming out of that  handler. I have tried using session.endConversation().
To understand about bot graph dialog:
https://www.microsoft.com/developerblog/2016/11/11/extending-microsofts-bot-framework-with-graph-baseddialogs-/
Can somebody help on this. Thank you

A: the builder.IntentDialog() used in this project is no longer considered a best practice. Additionally, further support is not expected. Instead, you will want to use bot.Dialog() to create your dialog flows with a .triggerAction(). The trigger matches on phrases which you can set a score to. Unfortunately, it means you will need to recreate the bot-trees project to fit this new model.
You can find information on managing conversations here, including creating triggers.
If you need a more robust system, you can integrate LUIS into your project. Information regarding recognizing intents with LUIS can be found here.


text:
Q: Visual studio can't find a controller even though I have added a reference to it and made sure it is public I have a Unit Test solution that references the main solution for the controller.
Reference: using Solution.Controllers;
Unit Test class:
namespace solution.UnitTests.SolutionTests.ControllersTests
{
    [TestClass]
    public class BrandCategoryControllerTests
    {
        private BrandCategoryController _brandCategoryController;
        [TestInitialize]
        public void Init()
        {
            _brandCategoryController = new BrandCategoryController();
        }
    }
}

The controller it is referencing is in Solution/Controllers folder.
The file begins with:
namespace Solution.Controllers
{
    public class BrandCategoryController : Controller

So I don't see why it can't find it. I've tried the intellisense and it doesn't recognize it. I've tried Cleaning and rebuilding the solution and closing and reopening visual studio. The annoying part is I have another controller and another controller test class both of which share the same folder structures and they work fine.
The error I am getting is "The type or namespace "BrandCategoryController" could not be found (are you missing a using directive or an assembly reference?)" I have added a using Directive and have tried using the full reference on the private variable.

A: Rebuild the Solution.Controllers project separately and fix build errors.

A: I've managed to get this working. The way it was fixed was I added a new controller to that folder to see if the intellisense would pick it up and when I did and checked the intellisense it picked up all three of the controllers in there. The original, the one I wanted and the new one. So I deleted the new one I created and it works fine now. Not Sure what caused this.


text:
Q: Automating High Availability and Disaster Recovery Tests Can anyone suggest some good test automation strategies or design patterns for high availability and disaster recovery testing?

A: The best way to avoid failure is to fail constantly. Netflix uses a strategy called "Chaos Monkey", the code can be found here: SimianArmy. It generated random failures in your cloud infrastructure making you prepared to any random disaster.


text:
Q: Ubuntu 13.10 on Acer V5-472 with HD 4000 I have an Acer V5-472 with intel HD4000 graphics chipset and a built-in 1366*768 display.
I have installed ubuntu 13.10 amd64 in legacy boot mode with an external monitor.
Installation showed no problems, I can boot from HDD and log into my system.
The internal display doesn't work and I have to use an external monitor.
I have tried the following (found in other threads) to no avail:

*

*Setting grub option "acpi_backlight=vendor" or "acpi_osi=Linux" or both.

*Installing the intel HD drivers for Linux from their homepage.

*Running in circles, screaming and shouting.
The internal display lights up (I can change the brightness with Fn-Left and Fn-Right) but that's all.
When I boot, I get a purple splash screen and from then only the external monitor works.
I read somewhere that this might be a problem with kernel 3.11? Has anybody ubuntu running on an Acer V5-472? Should I change ubuntu version or use 32-bit instead? In general, how can I get the internal display to work?
Edit: The settings->display dialogue shows the internal display correctly with supported resolution of 1366.


text:
Q: Surface Integral over scalar field I'm stuck on this question and not sure how to approach it.
A metallic surface S is in the shape of a hemisphere
$z$=$\sqrt{R^2-x^2-y^2}$    ,$0\leq x^2$+$y^2$$\leq R^2$
if the mass density of the metal per unit area is given by $m(x,y,z)$=$x^2$+$y^2$ Find the total mass of S.

A: Total mass of S is given by
$$\mathrm{
\iint_{S}m\;\color{blue}{dS}}
$$
Using spherical coordinates (physics convension) this integral can be written as
$$\mathrm{
\int_0^{2\pi}\int_0^{\pi\over2} R^2\sin^2\theta\;\color{blue}{R^2\sin\theta\;d\theta\;d\phi}=\frac{4}{3}\pi R^4
}$$


text:
Q: How to Serialize an object of rx.Single returned by a function? I am using Spring Framework and trying to cache the results returned by a method using @Cacheable annotation.
The method returns an object of rx.Single class. I am getting following error when trying to cache the results,

Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [rx.Single]

How can I proceed to cache the results? or
How can I serialize an object of rx.Single class?

A: The answer is: you can't.
You can create your own class, which will hold all required information and make it Serializable.


text:
Q: How to properly check if a variable is in array using Ruby? I am trying to check if variable is in array so I used a solution found here.
The code below works fine if I pass value of tea direct in the include function as per below.
mycheck= ['Soap', 'Tea', 'Sugar'].include? 'Tea'
      if mycheck == true
        print("yes present")
      else
        print("not present")
      end

My issues:
My issue if I set value tea to a variable as per code below, it returns false
var_tea = 'Tea'
mycheck= ['Soap', 'Tea', 'Sugar'].include? var_tea
      if mycheck == true
        print("yes present")
      else
        print("not present")
      end

Is there any other alternative way like using is_array(), etc?

A: I tried these two lines
var_tea = 'Tea'
mycheck = ['Soap', 'Tea', 'Sugar'].include? var_tea

and mycheck is true
My guess is that you obviously don't have that variable in the line above, it's probably coming from a request, and that's not exactly Tea, maybe tea. Try to print var_tea before that check.
puts var_tea.inspect

A: Your code seems right, but you could make it better.
First of all, you're checking if a variable is true. A better way to do it in ruby would be:
if mycheck
  print("yes present")
else
  print("not present")
end

You can also try:
my_check = var_tea.in? ['Soap', 'Tea', 'Sugar']

If you have the same issue, make sure that you double check your code, and that you don't have any my_check= method or something.


text:
Q: Join two tables at the same server I have two databases at the same server 192.168.1.100 DB1 and DB2
When I'm trying to execute :
select h.code,eh.Defaultname From hotels h JOIN [192.168.1.100].[dbo].[DB2].Hotels eh ON h.code = eh.code

I get
Could not find server '192.168.1.100' in sysservers. Execute sp_addlinkedserver to add the server to sysservers.

I don't understand :/
I'm using ms sql server 2005 and this query is fired when I'm at DB1.
What's the reason of this , and how to fix it ? :/

A: Since the databases are on the same SQL Server instance, you don't need to use a linked server, so don't specify the IP, just the other database's name.
select h.code,eh.Defaultname
From hotels h
JOIN [DB2].dbo.Hotels eh ON h.code = eh.code

A: JOIN [DB2].[dbo].[Hotels] AS eh


text:
Q: How to get the roles associated to a report in iccube I am  willing to list users their roles and the reports that are attached to every role, i could already list the users and their roles based on the files users and roles in iccube folder installation.
Is there any way to get the list of roles associeted to a report in iCcube?

A: You can have the access rights associated to the reports (and any other files) through the Docs application in the icCube Web interface. Out of the box, the Docs repository is backup by the file system (see docsRepository in icCube.xml).


text:
Q: Javascript/jquery error aDiv.children is not a function Here is the relevant javascript
var DIV_ID = "agencyHoursTable";
function getAgencyHoursTable()
{
    var aDiv = document.getElementById(DIV_ID);
    return aDiv.children(0);
}

Here is the relevant jsp code

                        Day
                        Time

                Remove Selected

The error message that comes up is Uncaught TypeError: aDiv.children is not a function. I am thinking it is possible an issue with the jquery version, i am using jquery 1.7.1. The interesting thing is that for me the issue is only coming up in chrome, but not in ie. Some others using ie are seeing the issue, some others are not.

A: you are not using jQuery at all.
var DIV_ID = "agencyHoursTable";
function getAgencyHoursTable()
{
    var aDiv = document.getElementById(DIV_ID);
    return aDiv.children[0];
}

You can reach the element through css selector:
jQuery("#agencyHoursTable > table");


text:
Q: JAVA Employee Type with Arrays package javaapplication2;
import java.util.Scanner;

public class JavaApplication2
{
    public static void main(String[] args)
    {
       person_type salespeople[] = new person_type [100];
       person_type person = new person_type();
       int counter = 0;

       person.gross=0;
       person.salary=0;

       System.out.println("How many workers are there?");
       Scanner number_of_workers = new Scanner(System.in);
       counter=number_of_workers.nextInt();

       for(int i=0; i<counter; i++)
       {
           salespeople[i] = person;
           System.out.println(person.salary);
       }

       for(int i=0; i<counter; i++)
       {
           System.out.print("Enter the salary of the salesperson ");
           System.out.print(i+1);
           System.out.println(":");
           Scanner salary = new Scanner(System.in);
           salespeople[i].salary = salary.nextInt();

           System.out.print("Enter the gross of the salesperson ");
           System.out.print(i+1);
           System.out.println(":");
           Scanner gross = new Scanner(System.in);

           salespeople[i].gross = gross.nextInt();

           System.out.println("1---- " + salespeople[0].salary);
           System.out.println(i);
       }

        System.out.println("First worker's salary is: " + salespeople[0].salary);
        System.out.println("First worker's gross " + salespeople[0].gross);

        System.out.println("Second worker's salary is: " + salespeople[1].salary);
        System.out.println("Second worker's gross is: " + salespeople[1].gross);
    }

    private static class person_type
    {
        int salary;
        int gross;
    }

}

I am trying to put every employee stored to the array, but all the employees' details are overwritten by the very last one entered by the user. Can you please help? Thanks in advance!!

A: All the elements in the array refer to the same person_type instance :
for(int i=0; i<counter; i++)
{
    salespeople[i] = person;
    System.out.println(person.salary);
}

You must create a new person_type instance for each index of the array.
for(int i=0; i<counter; i++)
{
    salespeople[i] = new person_type ();
}

BTW, I suggest you change your class name to either Person or PersonType to conform to Java naming conventions.


text:
Q: ESP32 Analog Pin 4 Value Failed to refresh after WIFI is connected I could not understand why the ESP32 pin 4 analog value from the photoresistor connected with 10kohms resistor could not be refreshed after WIFI smart config is completed, it is always stay at maximum 4095.
On the other hand , the analog value input from pin 4 would be refresh if there is no WIFI smart config relevant  coding  is added to the source code as shown below
int sensorPin = 4;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 1000;  // variable to store the value coming from the sensor
#include <WiFi.h>

void setup() {
  // declare the ledPin as an OUTPUT:
  Serial.begin(115200);

 WiFi.mode(WIFI_AP_STA);
  WiFi.beginSmartConfig();
  Serial.println("Waiting for Smart Config");

  while (!WiFi.smartConfigDone()) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("Smart Config Done");
  //*Wait for WiFi to connect to AP
  Serial.println("waiting for WiFi");

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi Connected");
  Serial.print("IP Address ");
  Serial.println(WiFi.localIP());

}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);

  delay(sensorValue);

}

Log
0:40:35.846 ->
20:40:35.846 -> rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
20:40:35.846 -> configsip: 0, SPIWP:0xee
20:40:35.846 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:40:35.846 -> mode:DIO, clock div:1
20:40:35.846 -> load:0x3fff0018,len:4
20:40:35.846 -> load:0x3fff001c,len:1100
20:40:35.846 -> load:0x40078000,len:10088
20:40:35.846 -> load:0x40080400,len:6380
20:40:35.846 -> entry 0x400806a4
20:40:36.215 -> Waiting for Smart Config
20:40:36.719 -> ..............................................................................
20:41:15.217 -> Smart Config Done
20:41:15.217 -> waiting for WiFi
20:41:15.724 -> ..WiFi Connected
20:41:16.233 -> IP Address 192.168.1.7
20:41:16.233 -> 4095
20:41:20.333 -> 4095
20:41:24.427 -> 4095

Without WIFI log are refreshed
20:43:16.964 -> 3115
20:43:20.077 -> 3121
20:43:23.196 -> 3122
20:43:26.298 -> 2971
20:43:29.272 -> 1886
20:43:31.159 -> 3109

A: just need to change the sensorPin to GPIO 36 or 39 or any pins running on ADC1 as analog listening input will resolve the WIFI pull up issue


text:
Q: Android Studio update broke Gradle I just updated my Android Studio 135.14 etc to 135.15.
First, I get an SDK not found error, since now the SDK cannot be in the Android Studio folder any more due to checksum problems. I fixed this as instructed, but now when I try to run my app I get the following message.

Failed to complete Gradle execution.
Cause: tried to access method
  com.google.common.base.Stopwatch.()V from class
  com.android.tools.idea.gradle.invoker.GradleTasksExecutor$3

I've already tried a clean and to delete .gradle from home. I don't see anything in build.gradle that has anything remotely to do with this and I am unsure on how to proceed.
I am not familiar with gradle at all since it just worked for months until the update.


text:
Q: ubuntu--vg-ubuntu--lv partition full for no apparent reason? I am using ubuntu server on a few machines but it seems 2 of them are afflicted with this issue while the others are totally normal. Both machines are very barebones, outside of the ubuntu server OS there is very few additional installs and nothing which accounts for the massive disk usage.
I tried using tips from previous posts here, checking with du, wajig large, ncdu but nothing shows what is using this vast amount of space. It seems this space is not accounted for at all yet is being blocked from use as if it was full.
Below are images of df -h indicating the disk is near-full (deleted some logs to free space from 0 and install ncdu) and the ncdu printout *note /media is space utilized by HDD on the server since I mount them there. It does not contain anything from the partition in question so it can be ignored.


text:
Q: The try block doesn't execute Code:- The try block doesn't execute and if I extend Asynctask the app
crashes and if I don't extend the Asynctask then the catch(Exception e) gives me an error msg - "android.os.NetworkOnMainThradException".
try {
            HttpURLConnection con = (HttpURLConnection) new URL("http://apis.hofficedemo1.ondemandcrm.co/AppRequestAPI").openConnection();
            con.setRequestMethod("POST");
            con.setDoInput(true);
            con.setDoOutput(true);
            con.connect();

            con.getOutputStream().write( ("txt_username=" + txt_username).getBytes());
            con.getOutputStream().write( ("txt_password=" + txt_password).getBytes());
            con.getOutputStream().write( ("appMode=" + appMode).getBytes());
            con.getOutputStream().flush();

            //System.out.println(txt_username+" "+txt_password+" "+appMode);

            InputStream is = con.getInputStream();
            byte[] b = new byte[1024];
            while ( is.read(b) != -1) {
                System.out.println(Arrays.toString(b));
            }
            con.disconnect();
        } catch (IOException e) {
            Log.d("IOException", "Some error");
        }
        catch (Exception e){
            e.printStackTrace();
        }

A: Runtime exception is parent of Io exception so when you put catch blocks in a order such that parent exception is placed;Any exception will be catched and executed in parent catch only. so it executes runtime exception:
remove runtime exception for an instance and see the diffrence

A: Add after try block so that we can see what exception is there.
catch(Exception e){
e.printStackTrace();
}


text:
Q: Vba issue in copying rows from multiple worksheets based on searching dynamic value and paste it in another new workbook Sub multiple()

    Workbooks("A.xlsx").Activate
    lastRow11 = Range("I" & Rows.Count).End(xlUp).Row

    For i = lastRow11 To 1 Step -1

        If i <> "" Then

            Value = Workbooks("A.xlsx").Worksheets(1).Cells(i, "I").Value
            Workbooks("B.xlsx").Activate
            Worksheets(1).Select

            Set DynRange = Selection.Find(What:=Value, LookIn:=xlFormulas, _
          LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
          MatchCase:=False, SearchFormat:=False)

            If DynRange Is Nothing Then
                 MsgBox ("No codes found")
            Else
                cell.EntireRow.Copy
                Workbooks.Add
                ActiveSheet.Paste
            End If
        End If
    Next i
End Sub

In the above-mentioned code, I am trying to search the "DynRange" value (that is dynamic every time) in workbook B. The purpose is to copy the rows for which particular column is having those values from all the worksheets of workbook B and paste it to a new workbook.
If worksheet B has 5 worksheets the new workbook should have 5 worksheets respectively. But data in those 5 worksheets must be filtered according to the "DynRange" value.
Also, for the next "DynRange" value. The new workbook should be added and the rest of the process should be the same.
How can i optimize performing this task? My code is not working as expected.

A: Use this for finding all matches:
If DynRange Is Nothing Then
     MsgBox ("No codes found")
Endif
Do While Not DynRange Is Nothing
     'process here the recent hit
     Set Fnd = Selection.FindNext(DynRange)
Loop

If I understand your needs correctly you want to process all worksheets in B.xlsx, but you only refer to Worksheet(1).
I would avoid using .Selection.
You may also consider Sheets.Add instead of Workbooks.Add.


text:
Q: Overloaded operator new and matching delete I'm overloading operator new/delete in a subclass, and I'm noticing a behaviour that seems rather odd to me. Take a look at the sample code below:
#include <stdlib.h>
#include <stdio.h>

class Base
{
public:

    virtual ~Base()
    {
    }
};

class Derived : public Base
{
public:

    void* operator new(unsigned int size, int capacity)
    {
        printf("> new(unsigned int, int)\n");
        return malloc(sizeof(Derived));
    }

    void operator delete(void* ptr, int)
    {
        printf("> delete(void*, int)\n");
        free(ptr);
    }

    void operator delete(void* ptr)
    {
        printf("> delete(void*)\n");
        free(ptr);
    }
};

int main(int argc, char** argv)
{
    Base* base = new (0) Derived();
    delete base;

    return 0;
}

This code generates the following output when compiled with Visual Studio 2010:
> new(unsigned int, int)
> delete(void*)

Why is the matching delete operator (Derived::operator delete(void*, int)) not getting called here? No matter what I do, I cannot get the code to call the matching operator delete.

A: The fundamental mantra:
There is no placement-delete expression.
If you use placement-new to create an object, you must destroy it manually and then invoke the deallocation function:
Base * p = new (0) Derived;

p->~Derived();

Derived::operator delete(p, 0);

If you will, it is sort of undefined behaviour to say delete base; in your code because you never obtained base as the result of a standard new-expression. It's entirely possible that you defined a placement-new allocation function that does something entirely different, and calling the standard operator delete-deallocation function might wreak total havoc. It just so happens that in your program it works out.


text:
Q: How do I figure out which gem(s) caused a particular gem to be bundled? Is there a simple (Bundle?) command to determine which gem(s) caused a particular gem to be bundled and added to my Gemfile.lock?
There are one or two similar questions but they only seem to address the general problem of figuring out which gems out there depend on a given gem.
Another question is the closest to this one but it's overly specific and didn't get a good general answer.
Eventually I found the info I was after using bundle viz and eyeballing the resulting image until I found it and traced it back to its parent but it seems like something bundle should be able to tell me with a one line command.
I also tried grep -r rest-client ~/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0 which kind of told me but the results were messy and also included a bunch of other gems that weren't from this particular app.
Is there a simpler way for next time?

A: Normally Gemfile.lock documents which dependencies were generated from other dependencies, it's listed in a rough tree form, but you may have to do some digging to get to the right spot.


text:
Q: How to get geolocation in html form and post it into php/sql database I am setting up a website similar to AirBnB, when a user is adding an apartment, I need them to be able to click a button to get their longitude and latitude, I then need the longitude and latitude posted into my database via php/sql code.
I have tried a lot of code, such as below, and it works perfectly to get the users current location of the user, which I am happy with, but I am not sure how to post the varibales to php/sql database. I have my database connection working fine.

Click the button to get your coordinates.

<button onclick="getLocation()">Try It</button>

Note: The geolocation property is not supported in
IE8 and earlier versions.

A: A very quick and easy ajax function ( not tested ) that gets called by the Geolocation callback and sends whatever information is required in the params object payload.

In the PHP script ( assigned by url variable )
<?php
    if( $_SERVER['REQUEST_METHOD']=='POST' ){

        if( isset( $_POST['lat'], $_POST['lng'] ) ){
            $lat=$_POST['lat'];
            $lng=$_POST['lng'];

            $sql='insert into `table` (`lat`,`lng`) values (?,?)';
            /* etc */
        }

    }
?>

A: Something like this should do the trick. Simply build a form object and add the geolocation to it, then send it through an ajax request.
var formData = new FormData();
formData.append("lat", x.lat);
formData.append("lon", x,lon);

$.ajax({
  type: "POST",
  url: url,
  data: formData.serialize(),
  success: success,
  dataType: dataType
});

<?php
$lat=$_POST["lat"];
$lon=$_POST["lon"];


text:
Q: How to enabe SCM polling with the Jenkins DSL plugin I'd like to enable SCM polling in Jenkins by DSL code. As it's easily possible manually ( without DSL ) and works perfectly, but I'm looking for DSL code to
Make it enable -- check attached image for reference.
I already checked below link, but no any solution here.
https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.scm
GitHub hook trigger for GITScm polling
and
Poll SCM
click here to check image
I'm not using Jenkins pipeline

A: Finally I got solution for this:
Following are the DSL code to enable scm polling:
triggers {
   configure {
it / 'triggers' << 'com.cloudbees.jenkins.GitHubPushTrigger'{
    spec''
}
scm('')
            }
    }

I have tested, It's working perfectly

A: Another Solution:
job('myjob') {
    configure { it / 'triggers' / 'com.cloudbees.jenkins.GitHubPushTrigger' / 'spec' }
}

A: I had a similar situation when trying to enable scm polling for a pipeline.
I am configuring pipelines via job-dsl and CasC, and I specifically wanted to enable SCM polling.
So here's what I have working; I'm within the pipelineJob context, but I believe the solution is the same for the job context:
pipelineJob('myPipelineName') {
  environmentVariables {
    ...
  }
  definition {
    ...
  }
  configure { project ->
    project / 'properties' / 'org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty' / 'triggers' / 'hudson.triggers.SCMTrigger' {
      'spec'('* * * * *')
    }
  }
}

The way I landed on this was manually changing a pipeline config (in the UI) to enable polling, then going and looking at the job's .xml on disk.
The slash delimited stuff you see in the code above represents the xml tag path to the value i want to change.


text:
Q: Adding groupby min / max / count aggregations I have following pandas dataframe.
 ex_one  ex_two weight  fake_date
0  228055  231908      1 2004-12-17
1  228056  228899      1 2000-02-26
2  228050  230029      1 2003-01-27
3  228055  230564      1 2001-07-25
4  228059  230548      1 2002-05-04

Here is what I want:
from column ex_one take for an example 228055 and then count number of occurrences based on fake_date (max) and fake_date(min) value for 228055
 ex_one  ex_two weight  fake_date      max_date     min_date   frequency
0  228055  231908      1 2004-12-17   2004-12-17   2001-07-25  2
1  228056  228899      1 2000-02-26
2  228050  230029      1 2003-01-27
3  228055  230564      1 2001-07-25
4  228059  230548      1 2002-05-04

A: This is one way.
df['fake_date'] = pd.to_datetime(df['fake_date'])

g = df.groupby('ex_one')['fake_date'].agg(['min', 'max', 'count']).reset_index()

res = df.merge(g, how='left')

Result
   ex_one  ex_two  weight  fake_date        min        max  count
0  228055  231908       1 2004-12-17 2004-12-17 2004-12-17      1
1  228056  228899       1 2000-02-26 2000-02-26 2000-02-26      1
2  228050  230029       1 2003-01-27 2003-01-27 2003-01-27      1
3  228059  230564       1 2001-07-25 2001-07-25 2002-05-04      2
4  228059  230548       1 2002-05-04 2001-07-25 2002-05-04      2

Explanation

*

*Caste fake_date column as datetime type if not already done.

*Create a groupby dataframe with your 3 aggregations.

*Left merge with original dataframe.


text:
Q: SQL LEFT JOIN Query reporting with optional parameters I'm running a query that generates a report for an inventory system. The query takes in 6 parameters, 3 of which are optional. The query works fine if all the parameters are entered, however I can't get the query to operate correctly when one or more optional parameters are omitted.
The important parameters are @AccountNumber, @Branch, @Department, and @OrderBy. The @AccountNumber parameter is required while the other three are optional. If @Branch is omitted I would like the report to show all of the inventory in that account. Similarly, If @Department is omitted but @Branch is present I would like to show all of the inventory in that account's branch. If all three parameters are present then it will show all of the inventory in that account's branch and department. If @OrderBy is omitted then the report orders the inventory by account number ordered ascending by default. The query that I'm using is below:
USE database;
GO
CREATE PROCEDURE RetrievedList
    @AccountNumber int,
    @Branch nvarchar(50),
    @Department nvarchar(50),
    @StartDate date,
    @EndDate date,
    @OrderBy nvarchar(10)
AS

IF @OrderBy = 'Locator'
BEGIN
    SELECT [Container].[Acct] AS [Account]
         ...
         FROM [File] LEFT JOIN [Container]
         ON [File].[BoxID] = [Container].[BoxID]
         WHERE [Container].[Acct] = @AccountNumber
         AND [Container].[Branch] = @Branch
         AND [Container].[Dept] = @Department
         AND [File].[Out_Date] IS NOT NULL
         AND [File].[Out_Date] BETWEEN @StartDate AND @EndDate
         ORDER BY [Container].[Loc];
END
ELSE IF @OrderBy = 'Title'
BEGIN
    SELECT [Container].[Acct] AS [Account]
         ...
         FROM [File] LEFT JOIN [Container]
         ON [File].[BoxID] = [Container].[BoxID]
         WHERE [Container].[Acct] = @AccountNumber
         AND [Container].[Branch] = @Branch
         AND [Container].[Dept] = @Department
         AND [File].[Out_Date] IS NOT NULL
         AND [File].[Out_Date] BETWEEN @StartDate AND @EndDate
         ORDER BY [File].[Title1];
END
ELSE
BEGIN
    SELECT [Container].[Acct] AS [Account]
         ...
         FROM [File] LEFT JOIN [Container]
         ON [File].[BoxID] = [Container].[BoxID]
         WHERE [Container].[Acct] = @AccountNumber
         AND [Container].[Branch] = @Branch
         AND [Container].[Dept] = @Department
         AND [File].[Out_Date] IS NOT NULL
         AND [File].[Out_Date] BETWEEN @StartDate AND @EndDate
         ORDER BY [Container].[Acct], [Container].[Branch], [Container].[Dept], [Container].[BoxNo], [File].[Title1];
END
GO

Keep in mind that I can't use the WHERE [Container].[Branch] = @Branch OR [Container].[Branch] = NULL approach because of the LEFT JOIN; it returns six times the records that are expected.

A: My typical pattern for this issue is using the IsNull operator like this:
AND [Container].[Branch] = IsNull(@Branch, [Container].[Branch])

It will compare against the parameter if passed; otherwise, it'll compare the column to itself.

A: @bassrek is right you can compare against itself for that matter you can create a case expression in the JOIN conditions and make things whatever value you really want.  One more thing to note though if the only thing that is changing in your query is the order by why not write a series of case statments in your order by to do the ordering you desire instead of copying the same query 3 times and then changing the order by.  It will make it easier to maintain your business logic should changes need to be made.
another method instead of having to compare against itself instead for performance as Sean suggests could be to use the IN operator and deal with the null:
ISNULL(@Branch,'') IN ([Container].[Branch],'')

for Example you could do the following to make @Branch, @Department, and @OrderBy optional and combine all 3 selects into a single statement:
SELECT [Container].[Acct] AS [Account]
        ...
        FROM [File] LEFT JOIN [Container]
        ON [File].[BoxID] = [Container].[BoxID]
        WHERE [Container].[Acct] = @AccountNumber
        AND ISNULL(@Branch,'') IN ([Container].[Branch],'')
        AND ISNULL(@Department,'') IN ([Container].[Dept],'')
        AND [File].[Out_Date] IS NOT NULL
        AND [File].[Out_Date] BETWEEN @StartDate AND @EndDate
        ORDER BY
       CASE
          WHEN ISNULL(@OrderBy,'') = 'Locator' THEN [Container].[Loc]
          WHEN ISNULL(@OrderBy,'') = 'Title' THEN [File].[Title1]
          ELSE [Container].[Acct]
       END
       ,CASE
          WHEN LEN(ISNULL(@OrderBy,'')) <> 0 THEN '1'
          ELSE [Container].[Branch]
       END
       ,CASE
          WHEN LEN(ISNULL(@OrderBy,'')) <> 0 THEN '1'
          ELSE [Container].[Dept]
       END
       ,CASE
          WHEN LEN(ISNULL(@OrderBy,'')) <> 0 THEN '1'
          ELSE [Container].[BoxNo]
       END
       ,CASE
          WHEN LEN(ISNULL(@OrderBy,'')) <> 0 THEN '1'
          ELSE [File].[Title1]
       END


text:
Q: Subquery on SELECT with conditional WHERE clause after it So I have three tables,
news :
id|title                                                      |body                                                                                |publised_at        |deleted_at|created_at         |
--+-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+----------+-------------------+
 1|Tax are Increasing Again, But Why?                         |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|                   |          |2021-06-06 14:11:24|
 2|AwanKinton are Making Brand New University Named DragonBall|Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|                   |          |2021-06-06 14:11:24|
 3|AwanKinton Released New Car that Can Fly                   |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|                   |          |2021-06-06 14:11:24|
 4|Indonesia National Team Are Not Gonna Make it to World Cup |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|2021-06-06 14:11:24|          |2021-06-06 14:11:24|
10|10 Penyebab Istri Sebel Sama Suami                         |Sebel aslkdjas askldjlsajd alskdjlkas alskdjsalk asldkjaslk asdlkjasld asdljasl asldjsalk alsdjals lajsdlkaj                                                                                |                   |          |2021-06-06 14:34:08|

topics :
id|name         |created_at         |
--+-------------+-------------------+
 1|politics     |2021-06-06 18:43:13|
 2|economy      |2021-06-06 18:43:13|
 3|auto         |2021-06-06 18:43:13|
 4|education    |2021-06-06 18:43:13|
 5|tech         |2021-06-06 18:43:13|
 6|culture      |2021-06-06 18:43:13|
 7|money        |2021-06-06 18:43:13|
 8|sports       |2021-06-06 18:43:13|
 9|uncategorized|2021-06-06 18:43:13|

and news_topics :
id|news_id|topics_id|
--+-------+---------+
 1|      1|        7|
 2|      1|        4|
 3|      2|        3|
 4|      2|        4|
 5|      2|        5|
 6|      3|        3|
 7|      3|        4|
 8|      4|        8|

And I want to return it like these :
id|title                                                      |body                                                                                |published_at|deleted_at|created_at         |t   |
--+-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+----------+-------------------+----+
 1|Tax are Increasing Again, But Why?                         |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|            |          |2021-06-06 18:43:13|    |
 2|AwanKinton are Making Brand New University Named DragonBall|Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|            |          |2021-06-06 18:43:13|auto|
 3|AwanKinton Released New Car that Can Fly                   |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i|            |          |2021-06-06 18:43:13|auto|

I succeed on returning that value using this query
select "news".*,
(
    SELECT STRING_AGG("topics"."name", ',') as "topics"
    FROM "topics"
    INNER JOIN "news_topics" ON "topics"."id" = "news_topics"."topics_id"
    WHERE "news_topics"."news_id" = "news"."id"
    AND "topics"."name" IN ('auto')
) AS "topics"
from "news"
where published_at IS NULL AND deleted_at IS null
order by "created_at"
asc limit 10

But there is one flaw to that query, on the above result there are one row that contains null topics. When I add AND topics IS NOT NULL after it gave me error SQL Error [42703]: ERROR: column "topics" does not exist  it is makes sense because the order of the query SQL executed.
I want rows that had null value on topics aren't included on the query result. How do I get that?

A: Instead of using a correlated subquery to get the column topics, aggregate on the joined tables topics and news_topics and then join to news:
select n.*, t.topics
from news n
inner join (
  SELECT nt.news_id, STRING_AGG(t.name, ',') AS topics
  FROM topics t INNER JOIN news_topics nt
  ON t.id = nt.topics_id
  WHERE t.name IN ('auto')
  GROUP BY nt.news_id
) t ON t.news_id = n.id
where n.published_at IS NULL AND n.deleted_at IS null
order by n.created_at asc limit 10

See the demo.


text:
Q: how to select categories that are in one dataset, but not in another in R There are 2 datasets
s=structure(list(var1 = c("a", "f", "k", "tt", "ee"), var2 = c("b",
"g", "l", "qq", "rr"), var3 = c("c", "h", "m", "ff", "cc"), var4 = c("d",
"i", "n", "gg", "vv"), var5 = c("e", "j", "o", "aa", "xx"), metric_var = c(100L,
200L, 300L, 567L, 789L)), class = "data.frame", row.names = c(NA,
-5L))

and
medagger=structure(list(var1 = c("a", "z", "w", "f", "k"), var2 = c("b",
"u", "e", "g", "l"), var3 = c("c", "p", "r", "h", "m"), var4 = c("d",
"q", "q", "i", "n"), var5 = c("e", "n", "w", "j", "o"), metric_var = c(100L,
200L, 400L, 500L, 700L)), class = "data.frame", row.names = c(NA,
-5L))

var1-var5 are categorical variables, their values are categories.
if we do an inner join s and a medagger we get this result
merge(s,medagger,by=c("var1","var2","var3","var4","var5"))
  var1 var2 var3 var4 var5 metric_var.x metric_var.y
1    a    b    c    d    e          100          100
2    f    g    h    i    j          200          500
3    k    l    m    n    o          300          700

only 3 rows to return, because in these datasets there are the same categories.
However, I need the categories that there are in the s dataset but not in the medagger dataset
were put in separate dataframes.
In this case, I need the dataframe new to appear, which will contain only 2 of these rows from s .
var1    var2    var3    var4    var5    metric_var
tt  qq  ff  gg  aa  567
ee  rr  cc  vv  xx  789

How to do that  the categories that were in s but not in the medagger appear in the new dataframe ?
Thank you.

A: You need anti_join from dplyr library to get the expected result. According to the documentation:

anti_join() return all rows from x without a match in y.

documentation
library(dplyr)

df <- s %>%
  anti_join(medagger, by = c("var1","var2","var3","var4","var5"))

The output will be like this:
  var1 var2 var3 var4 var5 metric_var
1   tt   qq   ff   gg   aa        567
2   ee   rr   cc   vv   xx        789

A: The anti-join is the best approach, I think.
base R
While dplyr::anti_join is a convenient one-shot function to do this, if you'd prefer base R, then a two-step of merge and setdiff works:
merged <- merge(s,medagger,by=c("var1","var2","var3","var4","var5"), suffixes = c("",".y"))
setdiff(s, merged[,colnames(s)])
#   var1 var2 var3 var4 var5 metric_var
# 1   tt   qq   ff   gg   aa        567
# 2   ee   rr   cc   vv   xx        789

data.table
The data.table DT1[!DT2] is its canonical anti-join mechanism, which only requires that keys be set on DT1.
library(data.table)
sDT <- as.data.table(s)
medaggerDT <- as.data.table(medagger)
setkeyv(sDT, c("var1","var2","var3","var4","var5")) # or setkey(S, var1, ...)
sDT[!medaggerDT]
#    var1 var2 var3 var4 var5 metric_var
# 1:   ee   rr   cc   vv   xx        789
# 2:   tt   qq   ff   gg   aa        567

A: library(dplyr)
s %>% inner_join(medagger, by=c("var1","var2","var3","var4","var5")) -> result1

  var1 var2 var3 var4 var5 metric_var.x metric_var.y
1    a    b    c    d    e          100          100
2    f    g    h    i    j          200          500
3    k    l    m    n    o          300          700

and the second dataframe:
s %>% anti_join(medagger, by=c("var1","var2","var3","var4","var5")) -> result2
  var1 var2 var3 var4 var5 metric_var
1   tt   qq   ff   gg   aa        567
2   ee   rr   cc   vv   xx        789

In base R, this works assuming that medagger and s do not have NA's:
merge(s,medagger,by=c("var1","var2","var3","var4","var5"), all.x=T) -> result
result2  <- result[!complete.cases(result),]

A: You could rbind each row and look if it's not duplicated.
s[apply(s, 1, \(x) tail(!duplicated(rbind(medagger[1:5], x[1:5])), 1)), ]
#   var1 var2 var3 var4 var5 metric_var
# 4   tt   qq   ff   gg   aa        567
# 5   ee   rr   cc   vv   xx        789


text:
Q: How do you retrieve WebGL bitmap data? It is possible to retrieve the bitmap data HTML Canvas 2D element, is it also possible to access the rendered content of a Canvas 3D / WebGL element as bitmap data?

A: The signature of WebGL's readPixels has changed in a later draft.
Instead of returning a new array with the pixel data everytime, you pass an array to fill as last argument :
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView pixels)
This allows to reuse the same array for multiple readPixels operations.

A: Not as direct as using readPixels, but this might also work. You can also render the canvas to a Image element, like so:
var img = document.getElementById("game-canvas").toDataURL("image/jpeg");
$("#shots").append("<img src=\"" + img + "\" width=\"320\" height=\"480\"/>");

You have to get your webgl context with the special option preserveDrawingContext for this to work though:
var gl = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});

From there on, if you want to manipulate the image easily, you could render that in a 2d canvas and read the pixels there if you want.
I regularly use this to take "screenshots" of the things I'm playing with.

A: From the working draft of the WebGL Specification:
ArrayBufferView readPixels(GLint x, GLint y,
    GLsizei width, GLsizei height, GLenum format, GLenum type)

Return a ArrayBufferView with pixels
  within the passed rectangle. The data
  returned from readPixels must be
  up-to-date as of the most recently
  sent drawing command. Any unprocessed
  drawing commands must be completed and
  their results presented to the current
  drawing buffers before readPixels
  accesses the drawing buffer.
The specific subclass of
  ArrayBufferView returned depends on
  the passed type. If it is
  UNSIGNED_BYTE, a Uint8Array is
  returned, otherwise a Uint16Array is
  returned.


text:
Q: Moving a relationship arrow in an EER diagram in MySQL Workbench's data modeling tool? Is there any way to move a relationship arrow in an EER diagram in MySQL Workbench's data modeling tool? (without having to move or resize any table)
E.g. before:

After:

A: The relationships are laid out dynamically. You have only very limited control of that. The only layout adjustment you can do is to move the middle line in a 3-lines relationship:

Click on the line to make the grab handle visible and then drag that.


text:
Q: Multiple array data post through Angular JS Here is the part of the view in the HTML page of through this a user can fill the data and send it to api

in the form there is three parameter will pass in a single array, day. fromtime and to-time. how to pass these three parameter in a single array... in jSON in angular JS, My code is not working here is the code. i want to also now how to send data in this format in HTML/Angular view side?
My (i thought it would work) Angular Js code
  $scope.schedule = [];
                $scope.schedule[0] = $scope.data1.day;
                $scope.schedule[1] = $scope.data1.from_time;
                $scope.schedule[2] = $scope.data1.to_time;

            var dataParam =  {

                                "Schedule":[$scope.data1.schedule]

                              }
         console.log(angular.toJson(dataParam));

HTML code

                                            <input type="checkbox" name="checkbox1" ng-model="data.checkbox1">
                                            Sunday

                                                <select  id="user_time_zone" ng-disabled="!data.checkbox1" class="form-control form-group" value="Schedule" name="user_time_zone">
                                                    <option id="optionspec" value="" >00</option>
                                                    <option id="optionspec" value="01" >01</option>
                                                    <option id="optionspec" value="02" >02</option>
                                                    <option id="optionspec" value="o3" >03</option>
                                                    <option id="optionspec" value="04" >04</option>
                                                    <option id="optionspec" value="05" >05</option>
                                                    <option id="optionspec" value="06" >06</option>
                                                    <option id="optionspec" value="07" >07</option>
                                                    <option id="optionspec" value="08" >08</option>
                                                    <option id="optionspec" value="09" >09</option>
                                                    <option id="optionspec" value="10" >10</option>
                                                    <option id="optionspec" value="11" >11</option>
                                                    <option id="optionspec" value="12" >12</option>
                                                    <option id="optionspec" value="13" >13</option>
                                                    <option id="optionspec" value="14" >14</option>
                                                    <option id="optionspec" value="15" >15</option>
                                                    <option id="optionspec" value="16" >16</option>
                                                    <option id="optionspec" value="17" >17</option>
                                                    <option id="optionspec" value="18" >18</option>
                                                    <option id="optionspec" value="19" >19</option>
                                                    <option id="optionspec" value="20" >20</option>
                                                    <option id="optionspec" value="21" >21</option>
                                                    <option id="optionspec" value="22" >22</option>
                                                    <option id="optionspec" value="23" >23</option>
                                                </select>

                                                     <select  id="user_time_zone" ng-disabled="!data.checkbox1" class="form-control  form-group" value="Schedule" name="user_time_zone">
                                                    <option id="optionspec" value="" >00</option>
                                                    <option id="optionspec" value="05" >05</option>
                                                    <option id="optionspec" value="10" >10</option>
                                                    <option id="optionspec" value="15" >15</option>
                                                    <option id="optionspec" value="20" >20</option>
                                                    <option id="optionspec" value="25" >25</option>
                                                    <option id="optionspec" value="30" >30</option>
                                                    <option id="optionspec" value="35" >35</option>
                                                    <option id="optionspec" value="40" >40</option>
                                                    <option id="optionspec" value="45" >45</option>
                                                    <option id="optionspec" value="50" >50</option>
                                                    <option id="optionspec" value="55" >55</option>
                                                    </select>

                                            :

                                                <select  id="user_time_zone" ng-disabled="!data.checkbox1" class="form-control  form-group" value="Schedule" name="user_time_zone">
                                                    <option id="optionspec" value="" >00</option>
                                                    <option id="optionspec" value="01" >01</option>
                                                    <option id="optionspec" value="02" >02</option>
                                                    <option id="optionspec" value="o3" >03</option>
                                                    <option id="optionspec" value="04" >04</option>
                                                    <option id="optionspec" value="05" >05</option>
                                                    <option id="optionspec" value="06" >06</option>
                                                    <option id="optionspec" value="07" >07</option>
                                                    <option id="optionspec" value="08" >08</option>
                                                    <option id="optionspec" value="09" >09</option>
                                                    <option id="optionspec" value="10" >10</option>
                                                    <option id="optionspec" value="11" >11</option>
                                                    <option id="optionspec" value="12" >12</option>
                                                    <option id="optionspec" value="13" >13</option>
                                                    <option id="optionspec" value="14" >14</option>
                                                    <option id="optionspec" value="15" >15</option>
                                                    <option id="optionspec" value="16" >16</option>
                                                    <option id="optionspec" value="17" >17</option>
                                                    <option id="optionspec" value="18" >18</option>
                                                    <option id="optionspec" value="19" >19</option>
                                                    <option id="optionspec" value="20" >20</option>
                                                    <option id="optionspec" value="21" >21</option>
                                                    <option id="optionspec" value="22" >22</option>
                                                    <option id="optionspec" value="23" >23</option>
                                                </select>

                                                     <select  id="user_time_zone" ng-disabled="!data.checkbox1" class="form-control  form-group" value="Schedule" name="user_time_zone">
                                                    <option id="optionspec" value="" >00</option>
                                                    <option id="optionspec" value="05" >05</option>
                                                    <option id="optionspec" value="10" >10</option>
                                                    <option id="optionspec" value="15" >15</option>
                                                    <option id="optionspec" value="20" >20</option>
                                                    <option id="optionspec" value="25" >25</option>
                                                    <option id="optionspec" value="30" >30</option>
                                                    <option id="optionspec" value="35" >35</option>
                                                    <option id="optionspec" value="40" >40</option>
                                                    <option id="optionspec" value="45" >45</option>
                                                    <option id="optionspec" value="50" >50</option>
                                                    <option id="optionspec" value="55" >55</option>
                                                    </select>

                                            <input type="button" class="btn btn-primary"  value="Add Break" id="btn" ng-disabled="!data.checkbox1">

A small snippet of java code
public class Schedule {
private String Working_day;
private List<String> Working_from;
private List<String> working_to;

........ }

A: Replace
var dataParam =  {"Schedule":[$scope.data1.schedule]} with
var dataParam =  {"Schedule":$scope.schedule}


text:
Q: How to assert two variables are equal when the implementation of PartialEq isn't appropriate? In my program, I represent "events" with the following structure:
struct Event {
    value: &'static str,
    timestamp: usize,
}

So far, I used PartialEq to compare Event variables: most of the time, I consider two Events to be equal if their value is the same:
impl PartialEq for Event {
    fn eq(&self, other: &Self) -> bool {
        self.value == other.value
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_loose_equality() {
        let a = Event { value: "a-value", timestamp: 12345 };
        let b = Event { value: "a-value", timestamp: 23456 };

        assert_eq!(a, b);
    }
}

However, in certain tests, I would like to ensure that two such variables are "strictly equals": The  test should fail they have different timestamp (are not the same in respect to Eq).
As per the documentation of assert_eq!:

Asserts that two expressions are equal to each other (using PartialEq).
  source

So, I am looking for an Eq equivalent, an assert_Eq_eq! in sort.
(or am I misunderstanding how Eq works and should be used?)
Here is what I fail to complete:
impl Eq for Event {}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_strict_equality() {
        let a = Event { value: "a-value", timestamp: 12345 };
        let b = Event { value: "a-value", timestamp: 12345 };

        // ???
    }
}

A: You're swimming upstream fighting against the current. Go with the flow. Let PartialEq be strict equality and define a separate trait or method for loose equality.
#[derive(Eq, PartialEq)]
struct Event { .. }

impl Event {
    fn loose_eq(&self, other: &Self) -> bool {
        self.value == other.value
    }
}

#[test]
fn test_loose_equality() {
    let a = Event { value: "a-value", timestamp: 12345 };
    let b = Event { value: "a-value", timestamp: 23456 };

    assert!(a.loose_eq(b));
}

A: I would create "views" of the type as appropriate:
struct Event {
    value: &'static str,
    timestamp: usize,
}

#[derive(Debug, PartialEq)]
struct Exact<'a> {
    value: &'a &'static str,
    timestamp: &'a usize,
}

impl Event {
    fn exact(&self) -> Exact<'_> {
        let Self { value, timestamp } = self;
        Exact { value, timestamp }
    }
}

fn demo(a: Event, b: Event) {
    assert_eq!(a.exact(), b.exact());
}

Here I've chosen to take references to each of the fields to demonstrate the general case, but you don't need references for this specific example (&str and usize implement Copy and are small).
You could also choose to not implement PartialEq on the original type at all, and only perform comparisons through views:
assert_eq!(a.exact(), b.exact());
assert_eq!(a.loose(), b.loose());

A: If you need the strict equality only in tests, and your struct only has two fields, I'd simply compare these fields directly:
let a = Event { value: "a-value", timestamp: 12345 };
let b = Event { value: "a-value", timestamp: 12345 };
assert_eq!(a.value, b.value);
assert_eq!(a.timestamp, b.timestamp);

This looks like the easiest and most readable option to me.

A: Yes, you are misunderstanding something. Eq doesn't have any new methods over PartialEq. It's just an assertion that the implementation of PartialEq is reflexive (as well as the transitivity and symmetry assumed with PartialEq).
If you want to have a different "strict" equality, you could make your own trait (if you expect to use this a lot) or simply have a method fn strict_eq(&self, other: &Self) -> bool attached to Event.
Given such a method you could write a macro to use that method.
The full source for assert_eq! can be found here and could be easily adapted, but a (perhaps overly) simple version would be something like
macro_rules! assert_strict_eq {
    ($left: expr, $right: expr) => {
        if !$left.strict_eq(&$right) {
            panic!(r#"assertion failed: `(left == right)`
  left: `{:?}`,
 right: `{:?}`"#, $left, $right)
        }
    }
}

(example usage)

A: Unlike JavaScript, Rust does not support equal vs. strict equal.
However, you can achieve similar effect by implementing your own trait and macro:
pub trait StrictEq {
    fn strict_eq(&self, other: &Self) -> bool;
}

macro_rules! assert_strict_eq {
    ($left:expr, $right:expr) => {{
        match (&$left, &$right) {
            (left_val, right_val) => {
                assert!(left_val.strict_eq(right_val));
            }
        }
    }};
}

The implementation for Event would be rather simple:
impl StrictEq for Event {
    fn strict_eq(&self, other: &Self) -> bool {
        self.value == other.value && self.timestamp == other.timestamp
    }
}


text:
Q: How do I display annotations titles for an array of locations on MapKit I'm filtering some Google Places data and then displaying each location on a map view. currently I have all the points displaying on the map. I need to figure out how to show a annotationPoint.title = place.name; for each of these locations.
Any idea how I'd go about doing this for the entire array of location places?
thanks so much for any help!
 //UPDATE - to handle filtering
    - (void)googlePlacesConnection:(GooglePlacesConnection *)conn didFinishLoadingWithGooglePlacesObjects:(NSMutableArray *)objects
    {

        if ([objects count] == 0) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No matches found near this location"
                                                            message:@"Try another place name or address"
                                                           delegate:nil
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles: nil];
            [alert show];
        } else {
            locations = objects;
            //UPDATED locationFilterResults for filtering later on
            locationsFilterResults = objects;
            [tableView reloadData];

            [mapView removeAnnotations:mapView.annotations];
            [mapView addAnnotations:objects];

        }
    }

A: try this code:
if ([myArr containsObject:@"Germany"])
{
    gerArr = [[NSMutableArray alloc]init];
    [gerArr addObject:@"Berlin"];
    [gerArr addObject:@"Dresden"];

    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region.center.latitude = 52.524268 ;
    region.center.longitude = 13.40629;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;
    [mapView setRegion:region animated:YES];

    [mapView setDelegate:self];

    DisplayMap *gann = [[DisplayMap alloc] init];
    gann.title = @"Berlin";
    gann.subtitle = @"Germany";
    gann.coordinate = region.center;
    [mapView addAnnotation:gann];

    MKCoordinateRegion region1 = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region1.center.latitude = 51.050991 ;
    region1.center.longitude = 13.733634;
    region1.span.longitudeDelta = 0.01f;
    region1.span.latitudeDelta = 0.01f;
    [mapView setRegion:region1 animated:YES];

    DisplayMap *gann1 = [[DisplayMap alloc] init];
    gann1.title = @"Dresden";
    gann1.subtitle = @"Germany";
    gann1.coordinate = region1.center;
    [mapView addAnnotation:gann1];

    MKCoordinateRegion region2 = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region2.center.latitude = 50.111445 ;
    region2.center.longitude = 8.680615;
    region2.span.longitudeDelta = 0.01f;
    region2.span.latitudeDelta = 0.01f;
    [mapView setRegion:region2 animated:YES];

    DisplayMap *gann2 = [[DisplayMap alloc] init];
    gann2.title = @"Frankfurt";
    gann2.subtitle = @"Germany";
    gann2.coordinate = region2.center;
    [mapView addAnnotation:gann2];

}

else if([myArr containsObject:@"Austria"])
{

    ausArr = [[NSMutableArray alloc]init];
    [ausArr addObject:@"Vienna"];
    [ausArr addObject:@"Danube River"];

    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region.center.latitude = 48.208174 ;
    region.center.longitude = 16.373819;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;
    [mapView setRegion:region animated:YES];

    [mapView setDelegate:self];

    DisplayMap *ausann = [[DisplayMap alloc] init];
    ausann.title = @"Vienna";
    ausann.subtitle = @"Austria";
    ausann.coordinate = region.center;
    [mapView addAnnotation:ausann];

    MKCoordinateRegion region1 = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region1.center.latitude = 48.266667 ;
    region1.center.longitude = 16.366667;
    region1.span.longitudeDelta = 0.01f;
    region1.span.latitudeDelta = 0.01f;
    [mapView setRegion:region1 animated:YES];

    DisplayMap *ausann1 = [[DisplayMap alloc] init];
    ausann1.title = @"Danube River";
    ausann1.subtitle = @"Austria";
    ausann1.coordinate = region1.center;
    [mapView addAnnotation:ausann1];

}


text:
Q: Set width of HTML in UIWebView Can I programmatically set the width of the HTML file i throw into the UIWebView ? My problem is that the UIWebView frame ist set in a TableView cell, so I had to set CGRectMake to fit it in the Cell. But now the size of the content is bigger than the frame... Can I set the width in the UIWebView for the HTML ?
This is the HTML Code:

Maßgeblich beteiligt – Mathias Hofbauer sprang von der Strafbank und netzte zum 3:1 ein. / Foto: Hans Ulrich Muelchi, Swiss Unihockey

In der Schweiz kann Wiler sein historisches Ausscheiden aus den Playoffs mit einem versöhnlichen Cupsieg kurieren. Vor über 3.000 Zuschauern besiegen die Berner Grünenmatt mit 3:1. Bei den Damen kann Sandra Dirksen ihren Titelreigen nicht fortsetzen, die Red Ants brachten eine versprechende Führung nicht über die Runden.

Als Wilers Kapitän Mathias Hofbauer in 56. Spielminute auf die Strafbank wanderte, wurde es nochmal eng für den noch aktuellen Meister. Sein Unterzahlspiel überstand man aber mit Bravour und als Hofbauer wieder zurück aufs Feld durfte, dauerte es gerade mal sechs Sekunden und der WM-Rekordscorer machte mit einem scharfen Schlenzer alles klar.

Bei den Damen waren Deutschlands Ex-Nationalspielerin Sandra Dirksen und ihre Red Ants auf dem Weg zum vierten Cupsieg in Folge. Rychenberg führte zu Beginn des Schlussdrittels mit 2:0, brach aber ein und unterlag Chur mit 2:5. “Wer den Pokal mit nach Hause nehmen will, muss drei Drittel gut spielen und nicht nur zwei”, bedauert Dirksen.

“Wir hatten zwar den besseren Start, aber am Ende doch nur Silber. Fünfzehn Sekunden vor der 2. Drittelspause haben wir ein abgelenktes, unglückliches Tor kassiert, das war der Knackpunkt leider.” Dafür sei man umso motivierter für die bevorstehenden Play-Offs. “Die Atmosphäre bei einem Cup-Finale ist und bleibt einzigartig. Unsere Fans waren toll”, schätzt Dirksen.

This is what happens in the cell:

A: If you are loading your own HTML you can do this in it's CSS.
body,
.yourClass,
#yourDiv {
  width: 30px;
}

If you are not, why not try changing the width of the UIWebView?

A: You can use br tag in the HTML file to adjust your width.