text:
Q: How to use Regex with spotlight
Possible Duplicate:
How Can I Search A Specific Type of File in Mac?

How could I use spotlight to search for example for files that end with jar or files that end with doc and at the same time contains "Hello" in it's name?

A: I'm assuming by "end with" you mean that files have the extension .jar or .doc. And given all those filenames, you want those who have "hello" in their filnames.
With that in mind, you're looking for something like this:
(.jar AND "hello") OR (.doc AND "hello")

Additionally, you could extend the number of "words" by adding:
(.jar AND "hello" OR "some_other_word") OR (.doc AND "hello")

For more ninja commands for Spotlight, your best bet is to read throughout this interesting doc from Apple, that's the Spotlight's Query Language documentation with lots of examples.
Finally, if you want to know what attributes are available for you to query directly, refer to this blog post.


text:
Q: Redisson best practice config with example I config Redisson client like below, as part of Singelton , what is the best practice to improve performance by redissson config ?
and what is best way to invalidate object at Redisson map ?
Config config = new Config();
config.useSingleServer().setAddress(redisProperties.getProperty(RedisProperties.REDIS_ENDPOINT)+":"+Integer.valueOf(redisProperties.getProperty(RedisProperties.REDIS_PORT)));

config.useSingleServer().setRetryAttempts(3);
config.useSingleServer().setTimeout(10000);
config.useSingleServer().setConnectionPoolSize(500);
config.useSingleServer().setRetryInterval(2000);
redisson = (Redisson) Redisson.create(config);

example of use :
RMapCache<String, Object> map = RedissonAcess.getInstance().getRedissonClient().getMapCache(currentDBUrl+mapName.getValue());

map.put(key, value,3,TimeUnit.HOURS);

redpajama_set_name: RedPajamaStackExchange


text:
Q: Golan over range interface{} I'am trying to develop simple chat application. And User talks coming from webservice like this json. And I unmarshaling this json as map[string]interface{}. My question is I am trying to get all "talk_messages" in for loop. But I can't.
{
"talk_id": 0,
"receiver_id": 1,
"receiver_name":"Jack",
"sender_id": 0,
"talk_messages":[
    {
        "message_id": 0,
        "body": "Helooo",
        "send_date": "12/3/2017 4:57:15 PM",
        "sender_id": 0,
        "talk_id": 0
    },
    {
        "message_id": 1,
        "body": "Helooo",
        "send_date": "12/3/2017 4:58:15 PM",
        "sender_id": 1,
        "talk_id": 0
    },
    {
        "message_id": 2,
        "body": "Whatsapp",
        "send_date": "12/3/2017 4:59:22 PM",
        "sender_id": 0,
        "talk_id": 0
    },
    {
        "message_id": 3,
        "body": "Lorem impus",
        "send_date": "12/3/2017 5:01:15 PM",
        "sender_id": 1,
        "talk_id": 0
    }
]
}

here is my for loop. What is my problem?
var talkData map[string]interface{}

if unMarshalError := json.Unmarshal([]byte(data), &talkData); unMarshalError != nil {
    fmt.Println("Talk initialize error :", unMarshalError)
}

idString := fmt.Sprintf("%v", talkData["talk_id"])
talk.id, _ = strconv.ParseInt(idString, 10, 64)

talk.playerOneId = fmt.Sprintf("%v", talkData["receiver_id"])
talk.playerTwoId = fmt.Sprintf("%v", talkData["sender_id"])
talk.receiverName = fmt.Sprintf("%v", talkData["receiver_name"])

for _, val := range talkData["talk_messages"] {
    fmt.Println(val)
}
fmt.Println(talk.id, talk.playerOneId, talk.playerTwoId)

A: Since you're unmarshaling into a generic value (map[string]interface{}) you'll need to use a type assertion to convert the value referenced by the "talk_messages" key into a slice of generic types ([]interface{}) so they can be iterated using the "range" keyword, e.g.:
messages := talkData["talk_messages"].([]interface{})
// assert a slice type --------------^^^^^^^^^^^^^^^^

for i, message := range messages {
    fmt.Printf("OK: message %d => %s\n", i, message)
}

Even better, since you know the structure of the data ahead of time, and assuming it is consistent, you could define struct types in which to marshal that data directly and not have to worry about the interface{} type at all:
type TalkData struct {
  Id           int           `json:"talk_id"`
  ReceiverId   int           `json:"receiver_id"`
  ReceiverName string        `json:"receiver_name"`
  SenderId     int           `json:"sender_id"`
  Messages     []TalkMessage `json:"talk_messages"`
}

type TalkMessage struct {
  Id       int    `json:"message_id"`
  Body     string `json:"body"`
  SendDate string `json:"send_date"`
  SenderId int    `json:"sender_id"`
  TalkId   int    `json:"talk_id"`
}

talkData := &TalkData{}
err := json.Unmarshal([]byte(data), &talkData)
if err != nil {
  // Handle err...
}

for i, message := range talkData.Messages {
  // Process message...
}

Also, as mentioned by commenters, you should handle errors in some way other than simply printing them otherwise the program will do unexpected things.


text:
Q: How to compile OpenCV 3.2.0 with Python on OSX? I'm currently on OSX 10.11.5 and I'm trying to build OpenCV 3.2.0 with Python, but even by disabling as many options as possible I can't seem to convince cmake to generate makefiles with BUILD_opencv_python ON.
Here's full cmake output:
-- FP16: Feature disabled
-- Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "3.4" (found /usr/local/bin/python3)
-- Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "3.2" (found /usr/local/bin/python3)
-- Found apache ant 1.9.7: /usr/local/ant/bin/ant
--
-- General configuration for OpenCV 3.2.0 =====================================
--   Version control:               unknown
--
--   Platform:
--     Timestamp:                   2017-06-27T16:16:09Z
--     Host:                        Darwin 15.5.0 x86_64
--     CMake:                       3.8.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ Compiler:                /Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  (ver 7.0.0.7000072)
--     C++ flags (Release):         -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -mno-sse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -mno-sse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
--     C flags (Release):           -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -mno-sse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -mno-sse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          /usr/lib/libz.dylib -framework Cocoa stdc++
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 core imgproc imgcodecs highgui
--     Disabled:                    calib3d features2d flann java ml objdetect photo shape stitching superres video videoio videostab world
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 python3 ts viz
--
--   GUI:
--     QT:                          NO
--     Cocoa:                       YES
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        /usr/lib/libz.dylib (ver 1.2.5)
--     JPEG:                        NO
--     WEBP:                        NO
--     PNG:                         NO
--     TIFF:                        NO
--     JPEG 2000:                   NO
--     OpenEXR:                     NO
--     GDAL:                        NO
--     GDCM:                        NO
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                YES (ver 3.5.0)
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     AVFoundation:                NO
--     V4L/V4L2:                    NO/NO
--     XIMEA:                       NO
--     gPhoto2:                     NO
--
--   Parallel framework:            GCD
--
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use IPP Async:               NO
--     Use VA:                      NO
--     Use Intel VA-API/OpenCL:     NO
--     Use Lapack:                  NO
--     Use Eigen:                   NO
--     Use Cuda:                    NO
--     Use OpenCL:                  NO
--     Use OpenVX:                  NO
--     Use custom HAL:              NO
--
--   Python 2:
--     Interpreter:                 /usr/local/bin/python2.7 (ver 2.7.13)
--
--   Python 3:
--     Interpreter:                 NO
--
--   Python (for build):            /usr/local/bin/python2.7
--
--   Java:
--     ant:                         /usr/local/ant/bin/ant (ver 1.9.7)
--     JNI:                         /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Matlab:                        NO
--
--   Tests and samples:
--     Tests:                       NO
--     Performance tests:           NO
--     C/C++ Examples:              NO
--
--   Install path:                  /usr/local
--
--   cvconfig.h is in:              /Users/George/Downloads/Grouped/cv/opencv-3.2.0/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/George/Downloads/Grouped/cv/opencv-3.2.0/build

I don't understand why python2 is disabled as unavailable.
What's the recommended OSX setup to enable OpenCV's Python bindings ?

A: Currently it's much simpler to install OpenCV Python bindings via pip:
pip install opencv-contrib-python

Currently this installed opencv 3.4.3:
python -c 'import cv2;print(cv2.__version__)'
3.4.3

And webcam/windowing also worked which previously was problematic (probably related to homebrew Python installs vs OSX Python Framwork install, existing Qt versions installed on the system, etc.)


text:
Q: show progress when httprequest in Angular I've created (using plunkers from other SO users) a feature where users can search for a movie title which causes the app to do a httprequest to themoviedb.org and serve all results in a list. By using a promise all the images are served at once dodging the waterfall effect and also it shows a "loading" update while the images are getting for being served to the browser.
http://plnkr.co/edit/Y01giYN9E3g92KjVEkua?p=preview
Pretty great. But it's not enough! I want to show the users the progress of their search action. My prefered method would be show a progress bar that fills up during the httprequest but I'm having trouble getting started.
This is my controller:
angular.module("app", [])
  .controller("main", ["moviesearchFactory", "$scope", "$q",  function(moviesearchFactory, $scope, $q) {

    $scope.createList = function(searchquery) {
      $scope.loading = true;
      moviesearchFactory.getMovies(searchquery)
        .then(function(response) {

          $scope.movies = response;
          $scope.images = [];

          $scope.movies.forEach(function(movie) {
            if (movie.poster_path !== null) {
              $scope.images.push({ poster_path: 'https://image.tmdb.org/t/p/w300_and_h450_bestv2/' + movie.poster_path ,
              title: movie.title })
            }
          });

          function preLoad() {

            var promises = [];

            function loadImage(src) {
              return $q(function(resolve, reject) {
                var image = new Image();
                image.src = src;
                image.onload = function() {
                  resolve(image);
                };
              })
            }

            $scope.images.forEach(function(image) {
              promises.push(loadImage(image.poster_path));
            })

            return $q.all(promises).then(function(results) {
              $scope.imagesLoaded = $scope.images;
              $scope.loading = false;
            });
          }

          preLoad();

        })
    }
  }])

How would I go about adding a progress bar to this controller?

A: I've created two plunks that may help you. Check them out here.

*

*http://plnkr.co/edit/vKACEbYrwbpENyIOua8x?p=preview
$scope.createList = function(searchquery) {
      $scope.showProgress= true;

<md-progress-circular class="" ng-show="showProgress"
                        md-diameter="100px"></md-progress-circular>

*http://plnkr.co/edit/1P3mpR61XOuMPON7IDce?p=preview


text:
Q: How to optimize this LINQ expression? I have this code:
var query = from deal in db.Deals
            where deal.EndDate >= DateTime.UtcNow
            select deal;

var priceList = filters.Price.GetPriceRangeList();
foreach(var price in priceList)
{
    var startPrice = price.StartPrice;
    var endPrice = price.EndPrice;
    var priceResult = from deal in query
          where (deal.DiscountPrice >= startPrice && deal.DiscountPrice <= endPrice)
          select deal;
    if(priceResult.Count() != 0)
        priceResults = (priceResults == null) ? priceResult : priceResult.Union(priceResults);
}
query = priceResults != null ? query.Intersect(priceResults) : Enumerable.Empty<Deal>().AsQueryable();

My query is slow when priceList has more ten values.
I use Intersect for filters.
How to optimize these queries?

A: One idea for optimization would be to sort query by StartPrice ascending, that way your inner query can just stop traversal once StartPrice is higher than the DiscountPrice property:
var query = from deal in db.Deals
            where deal.EndDate >= DateTime.UtcNow
            orderby deal.DiscountPrice ascending
            select deal;

..
foreach(..)
{
    var startPrice = price.StartPrice;
    var endPrice = price.EndPrice;

    var queryLocal = query.SkipWhile(deal => deal.DiscountPrice < startPrice);
    var priceResult = queryLocal.TakeWhile(deal => deal.DiscountPrice >= startPrice
                                      && deal.DiscountPrice <= endPrice);

    ..
}

A: You have a few issues. The first one is that the query is executed every iteration in your foreach loop. Calling ToList or ToArray will ensure that it is only executed once
Secondly the union is costly. It will iterate priceResult for every iteration of the foreach loop
thirdly your count will also iterate priceResult. Use .Any instead if you wish to know if theres any elements. However I think you can avoid that. If I've read your code correctly I believe the below should have the same result but it does not have the above three issues
var query = (from deal in db.Deals
             where deal.EndDate >= DateTime.UtcNow
             orderby deal.DiscountPrice ascending
             select deal).ToList();

var priceResults = (from price in filters.Price.GetPriceRangeList()
                    let startPrice = price.StartPrice
                    let endPrice = price.EndPrice
                    select query.SkipWhile(d => deal.DiscountPrice < startPrice)
                           .TakeWhile(d => deal.DiscountPrice <= endPrice)
                    ).SelectMany(x => x);

instead of iterating for each union there's a distinct only once


text:
Q: Why is my screen black when I do VNC from my phone to my laptop and how can I fix it? Why is my screen black when I do VNC from my phone to my laptop and how can I fix it?
Hello,
I am connecting from my phone (Samsung Galaxy S5) to my laptop running Linux Ubuntu 15.10 over VNC using a D-link router connected to the Ethernet port of the laptop.
The screen as shown on my mobile phone is black. I can move the finger on the mobile screen and the mouse pointer will move correspondingly on the laptop so there has to be some kind of connection but I cannot see anything because the mobile screen is black.
How can I fix this?
Vesa
Android app: bVNC


text:
Q: Generate HTML in Racket What would be the recommended way to generate HTML from X-expressions in Racket? Looks like response/xexpr would do it, but seems to be designed for serving http responses. The only thing I need is to generate an HTML string from Racket lists (or X-expressions), no need to have a web server involved.

A: The xexpr->string function in the xml library should do what you're asking, if I'm not mistaken.  For an example where it's used, you can take a look here, where the example uses it to generate HTML responses for a simplified web server application.
> (xexpr->string '(html (head (title "Hello")) (body "Hi!")))
"<title>Hello</title>Hi!"

A: If you're willing to dump xexprs for a potentially more convenient facility, then there is a new language which is used to generate the Racket web pages.  It's not yet documented (therefore it is still new and not properly public), but you can see how it's used in these sources.  As a quick example that demonstrates it, run this:
#lang scribble/html
@(define name "foo")
@html{@head{@title{@name}}
      @body{@h1{@name}}}

Another example uses it as a library:
#lang at-exp racket/base
(require scribble/html)
(define (page name)
  (output-xml
   @html{@head{@title{@name}}
         @body{@h1{@name}}}))
@page{foo}

The at-exp is not needed, it just makes it easy to write lots of text in code.  (And it would be just as useful with xexprs too.)
The main difference is that in this language the HTML tags are actually bindings, which makes it convenient to maintain code.  It's also very flexible in what it can take as texts -- for example, there is no need to keep it to a strict list of strings and sub-tags, so you never face questions like where to use append-map etc.


text:
Q: Ensure drive is mapped at login on laptop with strictly wireless So, $software runs on a 'server' (windows client w/ file sharing to share out the db folder), and laptop client has the drive mapped and $software also installed. This is the vendor's recommended setup.
Well, when user boots up laptop and logs in, wireless isn't connected yet, no mapped drives, so when software is opened it doesn't detect the files (b/c they aren't mapped) and user can't work.
I thought I got around this by using a powershell login script to detect when the wireless connected and then map the drive, but I just followed up and she says the laptop stop working again, so I can only assume that must have broken somehow. The user starts the software manually after logging in, and I'm not going to tell her to go in My Computer and double click the Z drive to manually initiate the mapping, then start the software. Makes me look bad.
What I will be trying when I go onsite is make use of local group policy and
-Set the wireless profile for the office as a computer config, so it logs on before login
-Set the Always wait for network at computer startup and logon group policy
-Use Group policy to set the drive mapping for the user at login
My hope is that all this is done before the desktop appears, because from a user experience standpoint if the desktop is up then everything should be ready to go.
Any other ideas, or things I've overlooked?

A: If the software supports UNC paths, you can just use those. You can also add them in Network Places via Group Policy User Configuration \ Preferences \ Shortcuts.
Alternatively, you could have the user start the software via a PowerShell script which does the appropriate actions and/or sanity checking before starting the software.

A: Local group policy does not have the ability to drive map via GPP. I ended up using a powershell script that

*

*Deletes the old mapped drive

*Waits an arbitrary number of seconds for the computer to connect to the office's specific SSID, and exits if it's not connected w/in that time frame

*Once the wireless is connected, it imports the user's password from a textfile (securestring of course!) and uses that combined with the hardcoded user name to map the drive.
I can easily tell the user that when this black box disappears that everything is connected. This is what I used originally that stopped working for some reason. Well, that reason was that the user changed her password. I probably should have seen that coming, but I fixed that by creating a specific resource account and giving it permission to the required shares.
84104 brought up the suggestion of using UNC paths, but when the software is installed it will only connect via a mapped drive. Also, she would get password prompted the first time she opened the software after login with that approach, since this is not a domain environment.


text:
Q: Pattern match using Regex with substring limit I am working on pattern matching within a string messages for * character. So that I could identified any substring between two * characters.
I am able to do this using below regex
[*]((?s).*?)[*]
This regex return me all expected results, which I wanted except it also consider * pair, if two * characters are together like (ex:  Test**ing).
I need to avoid this case while matching pattern.
Is their any way, I can add some condition while regex match that if * character is followed by another *, then ignore that match and return match only if two * characters have another character/characters between them.
For example:
**test  -> This should not return any match
***test* -> It should return *test*
***testing* message *additional* ->  It should return *testing* and *additional*
Let me know, If something is unclear.

A: s isn't the way to get a string in regex. We use [a-z]. To cater to all upper and lower cases between asterisks, use:
[*](([A-Za-z]+).*?)[*]
See here for the results this yields.


text:
Q: SQL Injection in Rails I read something about SQL Injection in Rails, but things are pretty unclear for me. For example, I didn't understand if code like the one listed below is safe from SQL Injection or not.
User.where("first_name like ? ", "%#{params[:q]}%")

If not, what's the alternative?

A: Yes, this is safe. ActiveRecord will use a prepared statement after sanitising your parameters to prevent SQL injection.
The Rails guides give more information: http://guides.rubyonrails.org/security.html#sql-injection


text:
Q: MySQL Queries using Doctrine & CodeIgniter EDIT: The reason why my Doctrine queries (see below) did not work/produced those errors was because I left out

ci_doctrine.

when creating this database:
CREATE TABLE `ci_doctrine`.`user` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `username` VARCHAR( 255 ) NOT NULL ,
    `password` VARCHAR( 255 ) NOT NULL ,
    `first_name` VARCHAR( 255 ) NOT NULL ,
    `last_name` VARCHAR( 255 ) NOT NULL ,
    UNIQUE (`username`
)
)

END OF EDIT
How do I write plane SQL queries using Doctrine connection object and display the results? For example, how do I perform:
SELECT * FROM table_name WHERE column_name LIKE '%anything_similar_to_this%';

using Doctrine something like this (this example does not work)
 $search_key = 'search_for_this';

 $conn = Doctrine_Manager::connection();

 $conn->execute('SELECT * FROM table_name WHERE column_name LIKE ?)',  $search_key);

 echo $conn;

I've also tried:
$search_key = 2;
$q = new Doctrine_RawSql();
$result = $q->select('column_name')
  ->from('table_name')
  ->where('id = ?', $search_key)
  ->execute();

echo $result;

A: Doctrine uses It's own query language called DQL. And it uses a query class to handle the queries called Doctrine_Query. Through this class you can build a query using the so called query builder.
You can look at the documentation at http://doctrine-project.com to find out how it works exactly.

A: You have an unnecessary parenthesis which is probably causing an error. Try changing:
SELECT * FROM table_name WHERE column_name LIKE ?)

to:
SELECT * FROM table_name WHERE column_name LIKE ?

If it still doesn't work, try posting the error message.


text:
Q: What pieces of armor can carry the increased attack speed attribute?
Possible Duplicate:
What affixes are available on items?

What are all the pieces of armor that can carry the increased attack speed attribute?
I know gloves and amulets can, but what else?

A: The one's that I am aware of are as follows:
Amulet
Gloves
Rings
You weapon can also have attack speed increase, but its already calculated into the dps of the weapon, so it's not as usefull as the other slots.


text:
Q: Qt mouse cursor does not change when opening dialog after drop event I am using Qt for C++ and have a dropEvent which opens a dialog. However when the dialog opens, the mouse cursor retains the drop cursor instead of going back to the generic default cursor. This is strange behavior especially while clicking on buttons on the dialog. Below is a rough outline of my dropEvent code.
MyClass::dropEvent(QDropEvent *event)
{
   //do some stuff
   event->accept();

   MyDialog::runDialog(arg1, arg2, arg3);
}

MyDialog::runDialog(arg1, arg2, arg3)
{
   MyDialog dlg(arg1, arg2, arg3);

   if(dlg.exec() == QDialog::Accepted)
   {
      //do some stuff
   }
}

NOTE: Unfortunately I cannot post pictures of the cursors yet because I do not have enough rep.

A: Below is a workaround that I am using since it isn't feasible to change the dialog code from exec to show.
MyClass::MyClass()
{
   //qRegisterMetaType was necessary for two of my parameters.
   qRegisterMetaType<arg1>("arg1");
   qRegisterMetaType<arg2>("arg2");
   connect(this, SIGNAL(signalDialog(arg1, arg2, arg3)), this, SLOT(runDialog(arg1, arg2, arg3)), Qt::QueuedConnection);
}

MyClass::dropEvent(QDropEvent *event)
{
   //do some stuff
   event->accept();

   emit signalDialog(arg1, arg2, arg3);
}

MyClass::runDialog(arg1, arg2, arg3)
{
  MyDialog::runDialog(arg1, arg2, arg3);
}

MyDialog::runDialog(arg1, arg2, arg3)
{
   MyDialog dlg(arg1, arg2, arg3);

   if(dlg.exec() == QDialog::Accepted)
   {
      //do some stuff
   }
}

The cursor was changed back to the default correctly.

A: I would do:
QApplication::restoreOverrideCursor()


text:
Q: A bijection $\phi:\mathbb R \to \mathbb R$ that must be an identity A bijection $\phi:\mathbb R \to \mathbb R$ that satisfies:
$$\phi(a+b)=\phi(a) +\phi(b)\text{, }$$
$$\phi(ab)=\phi(a)\phi(b)$$
$$\forall a,b\in \mathbb R$$
must be the identiy function. What I've done is to show the obvious $\phi(0)=0$ and that the function is the identity $\forall a,b\in \mathbb Z$, which follows from $\phi(\underbrace{a+\dots +a}_n)=n\phi(a)=\phi(a)\phi(n) \implies \phi(n)=n \text{ }\forall n\in \mathbb N$. Now it is easy to show that $\phi(-1)=-1$ and to extend the identity to the integers. I can't seem to find a way to the reals.

A: From what you've done, it's easy to see that $\phi(q) = q$ for any rational number $q$.
Now the key point is to show that $\phi$ is monotone.
In fact, if $x\in\mathbb{R}$ is non-negative, then there exists $y\in\mathbb{R}$ such that $x = y^2$. It follows that $\phi(x) = \phi(y)^2 \geq 0$. Thus we have shown that $\phi$ maps non-negative real numbers to non-negative real numbers.
Hence if $u \geq v$ are real numbers, then we have $u - v \geq 0$ and therefore $\phi(u) - \phi(v) = \phi(u - v) \geq 0$, or $\phi(u)\geq\phi(v)$.
Once this is done, it only remains to note that $\mathbb{Q}$ is dense in $\mathbb{R}$.

A: You can now state that $\phi(0)=0$.
If $a>0$, then $a=b^2$, for some $b>0$; therefore
$$
\phi(a)=\phi(b^2)=(\phi(b))^2>0
$$
by the assumed multiplicative property. Conversely, if $\phi(a)>0$, then $\sqrt{\phi(a)}=\phi(b)$ for some $b\ne0$, so
$$
\phi(b^2)=\phi(b)^2=\phi(a)
$$
implying $a=b^2>0$; therefore $a>0$ if and only if $\phi(a)>0$. In particular, $\phi(1)=\phi(1^2)=(\phi(1))^2$, so $\phi(1)=1$.
Also $\phi(a-b)=\phi(a)-\phi(b)$ (easy to prove) and consequently
$$
\phi(a)<\phi(b)\text{ if and only if }a<b
$$
Consider now a rational $q=m/n$: then
$$
m\phi(a)=\phi(ma)=\phi(n(qa))=n\phi(qa)
$$
so that $\phi(qa)=q\phi(a)$.
Can you finish?


text:
Q: Reflect AbstractValidator rules in ServiceStack's metadata page Imagine you have the following simplified CustomerRequest class:
public class CustomerRequest : IReturn<CustomerResponse>
{
    public string OrgNumber { get; set; }
}

For this request, you have the following validator:
public CustomerValidator()
{
    RuleFor(r => r.OrgNumber).NotEmpty();
}

If you view ServiceStack's auto generated metadata page on http://[myService]/json/metadata?op=CustomerRequest, it will look like this:

NAME PARAMETER   DATA TYPE   REQUIRED
OrgNumber   body    string  No

As you can see, the parameter is marked as "Required: No" even though the validator requires it to exist and be not empty.
Is it possible to reflect the validator's rules in the metadata automatically? I know I can use [ApiMember(IsRequired = false)], but I'd prefer to have it tied to the validator if possible.

A: Only declarative attributes show up on the metadata Pages as they can be statically inferred, any validators registered at runtime are opaque and cannot be statically inferred by ServiceStack.


text:
Q: Allocate space for object 'dbo.SORT temporary run storage DBCC CHECKDB returns:

Could not allocate space for object 'dbo.SORT temporary run storage:
  140737951236096' in database 'tempdb' because the 'PRIMARY' filegroup
  is full.
Create disk space by deleting unneeded files, dropping
  objects in the filegroup, adding additional files to the filegroup, or
  setting autogrowth on for existing files in the filegroup.
Msg 9002,
  Level 17, State 4, Line 1

A: This is pretty self explanatory - your tempdb is full, and can't be grown to perform the operation it needs tempdb for.
As indicated, either the disk where it is located is full, or you haven't got suitable autogrowth settings (see this earlier post for information about that), if it's not autogrowth, you'll have to either delete other files from the disk that your tempdb is on, or locate your tempdb on a bigger disk.
This sqlservercentral post is similar to yours and might take be worth a look. This video by Brent Ozar might be worth a look too, covering tempdb performance and config.

A: Run this command to get the estimated tempdb space required for the check:
DBCC CHECKDB ('databasename') WITH ESTIMATEONLY

See the DBCC CHECKDB documentation

ESTIMATEONLY
  Displays the estimated amount of tempdb space that is required to run DBCC CHECKDB with all the other specified options. The actual database check is not performed.

A: I ran the below query and it released the unused space:
USE [tempdb]
GO
DBCC SHRINKFILE (N'tempdev' , 0, TRUNCATEONLY)
GO

A: I also got this error message. It turns out that the physical disk was full. Our SQL Server admin deleted some history backups and changed backup mode from full to simple at some databases which had large transaction log and their purpose was for reporting and not for transaction's (application).


text:
Q: responsive textbox I would like some help with my website, i am trying to make the website responsive and i want the 'text box' to remain in place while changing the viewport but at the moment when the viewport shrinks the textbox is no longer in sync, if that makes sense.
Thanks in advance!

body {
    background-color: #F2F2F2;

}

.body1 {
    background-color: #FFFFFF;
    width: 72.6vw;
    height: 80vw;
    max-width: 72.6vw;
    overflow:hidden;
    margin-top:0px;
    max-font-size:16px;
 margin-left: 23.4vw;
 position:relative;
 bottom:200px;
 padding: 5px 5px;

}

.webheadimg {
width:96vw;
height:auto;
    max-width:96vw;
    max-height:auto;
    font-family: Tahoma, Geneva, sans-serif;
    font-weight: normal;
    overflow:hidden;
margin-left:1vw;

    }
#menu {
    width: 21.4vw;
    font-family: Tahoma, Geneva, sans-serif;
    font-weight: normal;
  font-size: 1vw;
    text-align: left;
    margin-left: 1vw;
    background-color: #CA2A2A;
        border-radius: 0px;
        max-width: 96vw;

}
#menu ul {
    height: auto;
    padding: 0.5vw 0vw;
    margin: 0px;
}
#menu li {
    display: block;

}
#menu a {
    text-decoration: none;
    color: #FFFFFF;
    padding: 0.5vw 0.5vw 0.5vw 0.5vw;
 font-size: 3vw;
 display:block;

}
#menu a:hover {
    color: #000000;
    background-color: #FFFFFF;

}
.webheadlogo {
position:absolute;
overflow:hidden;
margin-left: 1vw;
float:left;
height: auto;
width: 10%;
padding: 5px 5px;

}

}

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>Hull Daily News</title>

<webhead>

</webhead>

Home

Breaking News

Sport

Hull Today

Property

Social Media

Music

Reviews

Movies

Weather

Text Box

A: Made some changes to you css and removed the break tag between ul and textbox. Try this css, I think it is doing what you are looking for.

body {
    background-color: #F2F2F2;

}

.body1 {
    background-color: #FFFFFF;
    height: 80vw;
    max-width: 72.6vw;
    overflow:hidden;
    margin-top:0px;
    max-font-size:16px;
    position:relative;
    padding: 5px 5px;

}

.webheadimg {
width:96vw;
height:auto;
    max-width:96vw;
    max-height:auto;
    font-family: Tahoma, Geneva, sans-serif;
    font-weight: normal;
    overflow:hidden;
margin-left:1vw;

    }
#menu {
    width: 21.4vw;
    font-family: Tahoma, Geneva, sans-serif;
    font-weight: normal;
  font-size: 1vw;
    text-align: left;
    margin-left: 1vw;
    background-color: #CA2A2A;
    border-radius: 0px;
    max-width: 96vw;
 float:left;

}
#menu ul {
    height: auto;
    padding: 0.5vw 0vw;
    margin: 0px;
}
#menu li {
    display: block;

}
#menu a {
    text-decoration: none;
    color: #FFFFFF;
    padding: 0.5vw 0.5vw 0.5vw 0.5vw;
 font-size: 3vw;
 display:block;

}
#menu a:hover {
    color: #000000;
    background-color: #FFFFFF;

}
.webheadlogo {
position:absolute;
overflow:hidden;
margin-left: 1vw;
float:left;
height: auto;
width: 10%;
padding: 5px 5px;

}

}

Home

Breaking News

Sport

Hull Today

Property

Social Media

Music

Reviews

Movies

Weather

Text Box


text:
Q: Swashbuckle generated Swagger creates duplicate version path in Azure API Management I am trying to configure Azure API Management to use versioning and have it work with a Swagger / Open API document generated by Swashbuckle.
I have an API with 2 versions - 1.0 and 2.0.  I have configured Swashbuckle to generate 2 seperate Swagger documents, one for each version.  All good.
The versioning scheme is by path so consumers need to call the correct path (v1.0 or v2.0).  Like so: https://someurl/v1.0/some/thing
I have defined both versions in Azure API Management and imported both documents.
The problem is that Azure API Management is adding the path to the base URL and then because the path that is defined in the Swashbuckle generated Open API document I'm ending up with https://someurl/v1.0/v1.0/some/thing in Azure API Management.
Below is a snippet of the generated Swagger / Open API...

And the API version settings in Azure API Management...

And the full URL in Azure API Management...

So, my questions is how can I generate a Swagger document, using Swashbuckle or any other tool in a way that I can support Azure API Management versioning using the path versioning scheme.
Thank you in advance!

A: Since OpenAPI specification itself does not allow you to define versioning scheme, it is impossible to infer user intention at APIM level. One may want to import API with /v1.0/ in path as a single API, someone else, like in your case, wants to have API + version set. APIM by default does not create/update version sets during API import, so the only way at the moment is to remove /v1.0 prefixes from OpenAPI spec before you import into APIM.
APIMs domain model allows one to control versioning scheme (path prefix, header name/value, query parameter name/value) at the level of API version set, so that you do not need to duplicate /v1.0 on every operation of your API. By nature of this if your API version set is configured to have path prefix of /v1.0 it will be appended to all API paths included into this version set. And that is what produces the doubling.


text:
Q: xsb "No procedure usermod" when predicate is already defined So in my file I have
:- use_module(standard, datime/1).

today(Y, M, D) :-
    datime(datime(Y, M, D, _, _, _).

Running this directly in the command line gives
XSB Version 3.6. (Gazpatcho) of April 22, 2015
[x86-pc-windows; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2015-04-22]

| ?- use_module(standard, datime/1).

yes
| ?- datime(datime(Y, M, D, _, _, _)).

Y = 2016
M = 5
D = 17

yes

But loading the file itself and running the function gives an error
| ?- [utils].
[Compiling .\utils]
[utils compiled, cpu time used: 0.0780 seconds]
[utils loaded]

yes
| ?- today(Y, M, D).
++Error[XSB/Runtime/P]: [Existence (No procedure usermod : today / 3 exists)] []
Forward Continuation...
... machine:xsb_backtrace/1  From C:\Program Files (x86)\XSB\syslib\machine.xwam
... loader:load_pred1/1  From C:\Program Files (x86)\XSB\syslib\loader.xwam
... loader:load_pred0/1  From C:\Program Files (x86)\XSB\syslib\loader.xwam
... loader:load_pred/1  From C:\Program Files (x86)\XSB\syslib\loader.xwam
... x_interp:_$call/1  From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... x_interp:call_query/1  From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... standard:call/1  From C:\Program Files (x86)\XSB\syslib\standard.xwam
... standard:catch/3  From C:\Program Files (x86)\XSB\syslib\standard.xwam
... x_interp:interpreter/0  From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... loader:ll_code_call/3  From C:\Program Files (x86)\XSB\syslib\loader.xwam
... standard:call/1  From C:\Program Files (x86)\XSB\syslib\standard.xwam
... standard:catch/3  From C:\Program Files (x86)\XSB\syslib\standard.xwam

Any idea why this is the case and how to fix this? This happens for other predicates in the file as well.

A: There are 3 problems with your code:

*

*Your declaration of today/3 is missing a closing ),

*today/3 isn't exported

*use_module/2 expects a list of symbols as second argument, alternatively use import sym from mod.

If you define your utils.P file as following
:- import datime/1 from standard.
:- export today/3.
today(Y, M, D) :- datime(datime(Y, M, D, _, _, _)).

you can use it in either of the following ways:
Import the predicate directly:
| ?- import today/3 from utils.

yes
| ?- today(Y,M,D).

Y = 2016
M = 5
D = 18

use a qualified name using :
| ?- utils:today(Y,M,D).

Y = 2016
M = 5
D = 18

loading the module directly
| ?- [utils].
[utils loaded]

| ?- today(Y,M,D).

Y = 2016
M = 5
D = 18


text:
Q: What languages are used in Stack Overflow's 404 polygot? Currently, when a user here gets a 404, they see the following image:

Which represents the text:
# define v putchar
#   define print(x) main(){v(4+v(v(52)-4));return 0;}/*
#>+++++++4+[>++++++<-]> ++++.----.++++.*/
print(202*2);exit();
#define/*>.@*/exit()

This looks suspiciously polyglottish. Which languages does this do something interesting in?

Side thought: Is it just me, or did I find a bug in Prettify?

A: It is C and brainf**k. They both print 404.

A: Line 4 with the print(202*2) is valid in any number of scripting languages like Perl, Ruby, ECMAScript (provided a suitable implementation of a print function) and probably Python.
Line 2 is there to make line 4 valid in C and Objective-C, maybe also C++ and Objective-C++.
Line 3 contains some Brainfuck, but there seems to be something else there.
I have no idea what line 1 with the v is for. Why not just call putchar directly in line 2? So, I suspect that there's another language that is somehow made valid through this line. (At first I thought about Whitespace, but there's not enough whitespace in there to be a valid Whitespace program.)
And line 5 obviously also contains some code in some highly compressed language. Maybe something in the APL family (J, K, ...) or Golfscript?


text:
Q: Update CRM 2011 Access Right Programmatically I would like to know if there is some way to update an Access Right in CRM 2011.
Let's say I have an Access Right named Marketing Manager which has user level privilege to create Account, I'd like to change this privilege to Organization level programmatically.
I'm waiting hopefully,
Thanks in advance

A: Please have a look at the code below. However it actually copy Role Privileges from existing Role to new Role. But I think it can give you an idea.
Guid existingRoleId = new Guid("C85F0FFF-4C80-E211-A877-1CC1DE79B4CA");
Guid newRoleId = new Guid("B6690FFF-4C80-E211-A877-1CC1DE79B4CA");

// Step 2
RetrieveRolePrivilegesRoleRequest getPrivilagesRequest =
                 new RetrieveRolePrivilegesRoleRequest();

getPrivilagesRequest.RoleId = existingRoleId;
RetrieveRolePrivilegesRoleResponse privilagesResponse =
         (RetrieveRolePrivilegesRoleResponse)service.Execute(getPrivilagesRequest);

if (privilagesResponse != null && privilagesResponse.RolePrivileges != null)
{
    // Step 3
    AddPrivilegesRoleRequest addPrivilagesRequest = new AddPrivilegesRoleRequest();
    addPrivilagesRequest.Privileges = privilagesResponse.RolePrivileges;
    addPrivilagesRequest.RoleId = newRoleId;
    AddPrivilegesRoleResponse addPrivilagesResponse =
            (AddPrivilegesRoleResponse)service.Execute(addPrivilagesRequest);
}

Ref: Copy a security role programmatically – CRM 2011
Link 2


text:
Q: Dash plotly customized map I went through various tutorial on mapbox but i am not able to create a sample report of a region in india.i am completely new to css so i am finding it difficult to edit the file from tutorial and put the data from my custom file.
I created a geojson file and downloaded a sample date but i am unable to create a map.
Need some help in creating a regional map file along with some data and interactions.
you can find the json files and a code attached to it in the below link
https://github.com/9192gks/mapbox

A: I recommend Folium to produce maps in dash, itegrate them via an iFrame. Here are two links to get you started.
Folium and Dash
Choropleth Maps


text:
Q: using http https or // for referencing a file in link or script tags When referencing a file in my index.html file like this(using a link tag):
<link rel="stylesheet" type="text/css" href="//dc-js.github.io/dc.js/css/dc.css"/>

or using script tags to reference a file
<script type="text/javascript" src="https://dc-js.github.io/dc.js/js/d3.js"></script>

Is it best practice to write it like this:
//dc-js.github.io/dc.js/css/dc.css
as opposed to
http://dc-js.github.io/dc.js/css/dc.css
 or
https://dc-js.github.io/dc.js/css/dc.css.
My understanding is that this way whether a user visits the index.html page with http or https that is the protocol that will be used when for the referenced file. I am just wondering what is best practice?
Copy from my code for reference:
<!-- use //dc-js.github.io/dc.js/css/dc.css instead of

href="dc-js.github.io/dc.js/css/dc.css" -- will look on smae server
"NetworkError: 404 Not Found - https://192.168.99.100/lte_data_day_summary/dc-js.github.io/dc.js/css/dc.css"

href="/dc-js.github.io/dc.js/css/dc.css"
"NetworkError: 404 Not Found - https://192.168.99.100/dc-js.github.io/dc.js/css/dc.css"

href="//dc-js.github.io/dc.js/css/dc.css" -- this works -- use this one
NO ERROR

href="///dc-js.github.io/dc.js/css/dc.css" -- this works
NO ERROR

href="////dc-js.github.io/dc.js/css/dc.css" -- this even works
NO ERROR

-->
  <link rel="stylesheet" type="text/css" href="//dc-js.github.io/dc.js/css/dc.css"/>

Found a related Q here

A: It all depends..
- Updated -
Externally: http or https included is the best practice. Biggest concern being most sites are moving towards SSL and having mixed or unresolved content will surely come back to haunt you.
Internally: relative path as described at the bottom is the best method.

Externally:
http://dc-js.github.io/dc.js/css/dc.css

and
https://dc-js.github.io/dc.js/css/dc.css

Internally
I use the the path versus full address in case a sites name is changed. It makes it a whole lot easier not having to back track.
This is of course only when I am hosting the file on the same site.
It should look more like this.
<link rel="stylesheet" type="text/css" href="/dc.js/css/dc.css"/>

or using script tags to reference a file
<script type="text/javascript" src="/dc.js/js/d3.js"></script>

Note:

*

*no forward slash means it is located in the same folder you are loading the page from.

*single forward slash means it is in the root folder of the site located on the same server.

*double-infinite forward slashes means external file. Thats why there are no errors on your external links using 2 or more forward slashes.

A: When you writing url without protocol (http or https) then it takes protocol automatic according to your url.
*Of course, if you're viewing the file locally (not from server), it'll try to request the file with the file:// protocol.
such url example is
file:///D:/test.html

If you are trying to browse from your local server or your website then
http://localhost/yourproject/test.html
or
http://www.example.com/test.html
then it will take http protocol as i written above in first paragraph.
Why to write url without protocol ?
Because it may possible some websites don't need https protocol when it's launch. but later it may require due to security concern. so when website owner is not sure to convert to secure protocol, in such cases you can write this pattern to avoid further coding changes.


text:
Q: PayPal IPN listener by WCF When i send test IPN by "Instant Payment Notification (IPN) Simulator" i get this:
"IPN was not sent, and the handshake was not verified. Please review your information."
In this case no reaction on the server is not happening :(
What am I doing wrong?
P.S. My server accessible from the Internet and nothing is blocking access. I asked a friend to send me a test message with Post request and my server accepted it. But on PayPal my method does not react at all!
[ServiceContract]
public interface IPayPalService
{
   [OperationContract]
   [WebInvoke(Method = "POST", UriTemplate = "/")]
   void Notify(Stream data);
}

public void Notify(Stream data)
{
}

<service name="PayPal.PayPalService">
   <endpoint address="http://myip:myport/PayPalService"
             binding="webHttpBinding"
             contract="PayPal.IPayPalService"/>
</service>


text:
Q: Why do we define the complex exponential as we do? Why do we define the complex exponential as we do? Defining $e^{z}$ as $e^{x}e^{iy}$ certainly seems to make sense, but I'm not sure the formal reason as to why it's defined like this. Was it from looking at Taylor Series, or was it just because we want the nice multiplicative structure? We can show that the real exponential function splits over addition, but the complex one has an addition that is different, so is it simply defined as I stated above, or is there an obvious thing I'm missing?

A: The short answer is:  we don't always.
Many places will define the complex exponential by the power series:
$$\exp(z)=\sum_{n=0}^\infty {z^n\over n!}$$
and justify that by analyticity, this always matches the value on the real axis.
From here one can verify that it satisfies the functional equation
$$\exp(z+w)=\exp z\exp w$$
directly by treating $w$ as fixed, but arbitrary and performing the analysis on the variable $z$.
Certainly the definition you mention makes some sense, as wanting the complex exponential to behave the same way as the real one by demanding the functional equation hold can give rise to the equations
$${\partial\over \partial x}(e^xe^{iy})=e^xe^{iy},\; {\partial\over\partial y}e^xe^{iy}=ie^xe^{iy}$$
From there we use that
$${d\over dz}={1\over 2}\left({\partial\over\partial x}-i{\partial\over\partial y}\right)$$
With the given definition, we get:
$${d\over dz}e^z={1\over 2}\left(e^xe^{iy}-i\left(ie^xe^{iy}\right)\right)=e^xe^{iy}=e^z$$
so that the complex exponential satisfies the appropriate differential equation, one of it's best properties from real variables, so it supports the choice made there.


text:
Q: Attach .m and .h files to a storyboard's TabBar Controller I've implemented a new part of my application made by .m .h and xib (yeah, it's old) with storyboard, in particular a view with a tabBar controller and 2 item linked to it. I instantiate the storyboard with:
NVPassportViewController *passportBookController = [[UIStoryboard storyboardWithName:@"NVPassportViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"passportViewController"];

Now, I know that I can attach .m and .h files in the tabBar controller of the storyboard, setting "custom class" to NVPassportViewController, but the viewDidLoad method of  NVPassportViewController is never called with the tabBar of the storyboard on screen. Why? linking the tab1's and tab2's view to specific .m and .f files is working, but with main tabView controller no.
EDIT: solved and i think that's a important know-how for custom class and storyboard: you can't name your Storyboard file and custom class with the same name.

A: It sounds like you might be creating the view in question as a subview. I believe you will find that viewDidLoad is being called on the subview before the parent view, which may map to your description that it "is never called with the tabBar of the storyboard on screen".
Without knowing what functional problem this is causing, it's hard to suggest a specific solution, though it is quite likely that some combination of prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender and the correct use of dependency injection may resolve your problems... :)


text:
Q: Automatically open reaveal modal I want to open Reveal Modal Popup when page loads, without clicking anything
Here is what have:
<!DOCTYPE html>

    <title>Modal PopUp</title>
    <link type="text/css" rel="stylesheet" href="css/style.css">
    <link type="text/css" rel="stylesheet" href="css/reveal.css">

Reveal Modal Goodness

This is a default modal in all its glory, but any of the styles here can easily be changed in the CSS.

            ×

I don't want to use this trigger:
Click Me For A Modal

It should open automatically.

A: Try this
$(document).ready(function() {  //or  $(window).load(function(){
    $('#myModal').reveal($(this).data());
});

A: you can hide the anchor tag and click it programmatically:
Click Me For A Modal

$('#clickMe').click();

it will open without clicking any link or button on page but on behind we programmatically click it.
you can also do:
$("#myModal").reveal();


text:
Q: TypeError: new_open_window() takes exactly 3 arguments (4 given) - Odoo v8 to Odoo v10 community consider this method:
@api.multi
def new_open_window(list_ids, xml_id, module):
    """ Generate new window at view form or tree """
    action = self.env.ref("{}.{}".format(module, xml_id))
    result = action.read()[0]
    if isinstance(list_ids, (list, tuple)):
        result['domain'] = [('id', 'in', list_ids)]
    else:
        result['res_id'] = list_ids
    return result

This method is called by this one:
@api.multi
def create_invoice(self):
    """ Create a invoice refund
    """
    #context = context or {}
    wizard_brw = self.browse()
    inv_id = self._context.get('active_id')
    for wizard in wizard_brw:
        if not wizard.sure:
            raise UserError(
                _("Validation error!"),
                _("Please confirm that you know what you're doing by"
                  " checking the option bellow!"))
        if (wizard.invoice_id and wizard.invoice_id.company_id.jour_id and
                wizard.invoice_id and wizard.invoice_id.company_id.acc_id):
            inv_id = self.action_invoice_create(wizard,
                                                wizard.invoice_id)
        else:
            raise UserError(
                _('Validation error!'),
                _("You must go to the company form and configure a journal"
                  " and an account for damaged invoices"))
    return self.new_open_window([inv_id], 'action_invoice_tree1', 'account')

On clicking create_invoice button/method it throws me this:
Traceback (most recent call last):
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 675, in dispatch
result = self._call_function(**self.params)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 331, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 324, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 933, in __call__
return self.method(*args, **kw)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 504, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 866, in call_button
action = self._call_kw(model, method, args, {})
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 854, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 681, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 672, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/wizard_invoice_nro_ctrl.py", line 138, in create_invoice
return self.new_open_window(inv_id, 'action_invoice_tree1', 'account')
TypeError: new_open_window() takes exactly 3 arguments (4 given)

SO, since this uses @api.multi and it's a method which is called from a button, I don't know if part of the problem is the lack of self.ensure_one(), but I guess it's not, or not only that at least.
Any ideas?

A: Replace :
def new_open_window(list_ids, xml_id, module):

by :
def new_open_window(self, list_ids, xml_id, module):


text:
Q: tmux on OSX - lock server/session not working I am on OSX Mountain Lion. I've configured tmux.conf to lock the screen, but the screen only flashes, no locking takes place. (fyi, when i used GNU-screen, the screen did lock).
My system does not have a lock/slock or vlock, nor could i find these on homebrew or macports. I understand that Screen uses its own internal locking whereas tmux uses external locking. I do not care whether I am asked to enter a new passkey or the system password is used.  So how to get tmux to lock the session/terminal ?
# Screen lock
bind-key C-x    lock-server
bind-key x      lock-server
bind-key -n M-x lock-server
set-option -g   lock-after-time 0
set-option -g   lock-server on
# set-option -g   lock-command "vlock"

p.s. I am aware of other alternatives, but these typically require a mouse (hot corners) or a Mac keyboard (eject key).

A: As far as I know, OS X does not supply any variation of the tty-locking program that tmux requires.
You will probably need to find a third-party tty-locking program, try to port one from a related OS, or write your own.

A: This isn't an exact answer as you expected. @chris-johnsen gave the best answer about locking on OSX. I did however find two screen savers for the terminal. It doesn't lock the terminal but it does blank out the screen.

*

*tmux has a built in time function that will blank the screen and display a clock. It is local to the window.

*cmatrix is a terminal program that displays the matrix screen like in the movie. The con is that it doesn't lock and it eats up some CPU. But it is fun. It can be installed via homebrew
Here is how to get it working:
brew install cmatrix

Then add this to your ~/.tmux.conf:
set -g lock-command "cmatrix -s -b"
set -g lock-after-time 90
set -g lock-server on

In 90 seconds of inactivity it will display. Use the command tmux lock-server to test it.

A: I was disappointed to not see any valid responses for actually locking the screen. I'll continue looking for a way to properly lock the terminal session itself, but in the meantime I do have a functional alternative.
By running a command on the command line, you can lock your entire mac. The following command will make it happen:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

You can find a lot more about what's happening exactly at this page.
Tie that command into:
set-option -g lock-command

And you should have a way to functionally lock up your session. I know locking the entire machine is not the most desirable outcome, but this is at least a working alternative for now.


text:
Q: Where can the broken stasis pod be found? In which sectors can I find the broken stasis pod?

A: According to this Wiki article

Engi Homeworlds or Engi Controlled (Green), Pirate (Red), or Rock (Red) Controlled sectors at a distress beacon.


text:
Q: Espressif Esp32 Wifi Driver SoftAP+Sta mode ... set config interface? The esp_wifi_set_config method requires an interface parameter of type wifi_interface_t.
This an enum which has values [WIFI_IF_STA || WIFI_IF_AP]
I have my config merged from the two examples on the esp32 examples page with neccesary config params. But I am unsure what interface mode I am meant to pass from the above to set the config. I would expect a WIFI_IF_AP_STA or something.
wifi_config_t wifi_config = {
    .ap = {
        .ssid = ESP_AP_WIFI_SSID,
        .ssid_len = strlen(ESP_AP_WIFI_SSID),
        .channel = ESP_AP_WIFI_CHANNEL,
        .password = ESP_AP_WIFI_PASS,
        .max_connection = AP_MAX_STA_CONN,
        .authmode = WIFI_AUTH_WPA_WPA2_PSK
    },
    .sta = {
        .ssid = ESP_STA_WIFI_SSID,
        .password = ESP_STA_WIFI_PASS,
     .threshold.authmode = WIFI_AUTH_WPA2_PSK,

        .pmf_cfg = {
            .capable = true,
            .required = false
        },
    },
};
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
ESP_ERROR_CHECK(esp_wifi_set_config(
    **WHAT DO I PUT HERE? [WIFI_IF_STA : WIFI_IF_AP]
    , &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());

A: Firstly, note that wifi_config_t is not a struct with two members. It's a union, meaning you can store either the AP or the STA configuration but not both. So you need to create two different configuration structures, one for each mode.
As for your confusion, according to the sample here you call esp_wifi_set_config() twice - once for the AP and once for the STA.
wifi_config_t ap_config = {
    .ap = {
        .ssid = ESP_AP_WIFI_SSID,
        .ssid_len = strlen(ESP_AP_WIFI_SSID),
        .channel = ESP_AP_WIFI_CHANNEL,
        .password = ESP_AP_WIFI_PASS,
        .max_connection = AP_MAX_STA_CONN,
        .authmode = WIFI_AUTH_WPA_WPA2_PSK
    }
};
wifi_config_t sta_config = {
    .sta = {
        .ssid = ESP_STA_WIFI_SSID,
        .password = ESP_STA_WIFI_PASS,
        .threshold.authmode = WIFI_AUTH_WPA2_PSK,
        .pmf_cfg = {
            .capable = true,
            .required = false
        }
    }
};

...
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &sta_config));


text:
Q: Excel VBA 2010 - If-Then-ElseIf statement not recognizing string variables I have an Excel VBA macro with an If-Then-ElseIf statement that is within a For-Next loop. I'll show the code before describing the issue. I post the entire code just in case I'm wrong about thinking the problem lies within the If statement.
Code:
Option Explicit

Sub GetData()

    Dim wsPasteTo As Worksheet, wbDATA As Workbook
    Dim NextRow As Long, LastRow As Long, i As Long

    Set wsPasteTo = ThisWorkbook.Sheets("ACP")
    NextRow = wsPasteTo.Range("A" & Rows.Count).End(xlUp).Row + 2

    Set wbDATA = Workbooks.Open("\\cmicro.com\Shares\Amb\Amb-Probes\DataLogs\CQS-03-033-2012 Coax Shelf Cut Log R2.6.xlsm", ReadOnly:=True)
    Application.ScreenUpdating = False

    With wbDATA.Sheets("ACP")

        LastRow = .Range("A" & .Rows.Count).End(xlUp).Row

        For i = 2 To LastRow

            If Cells(i, "E") = "Angle" Then
                .Range("K2:L" & LastRow).Copy
                wsPasteTo.Range("I" & NextRow).PasteSpecial xlPasteValues

            ElseIf Cells(i, "E") = "Vertical" Then
                .Range("K2:L" & LastRow).Copy
                wsPasteTo.Range("D" & NextRow).PasteSpecial xlPasteValues

            Else
                .Range("K2:L" & LastRow).Copy
                wsPasteTo.Range("N" & NextRow).PasteSpecial xlPasteValues

            End If

        Next i

    End With

    Application.ScreenUpdating = True
    wbDATA.Close False

End Sub

This macro copies data from another Excel workbook (let's call it the Copy Workbook) based on what's in column E of the Copy Workbook. Column E has 3 options for the user to choose: "Angle", "Vertical", and "n/a". I used data validation so the user must chose one of those 3 options from a drop down in all column E cells. Based on that, the macro pastes data into columns in a separate workbook, let's call it the Paste Workbook.
This code doesn't have errors, however all the data is being pasted into the wrong place in the Paste Workbook.
I think the problem is with the lines of code:
If Cells(i, "E") = "Angle" Then

and
ElseIf Cells(i, "E") = "Vertical" Then

because when I'm in debug mode, these lines are skipped as though the string variables "Vertical" and "Angle" aren't there in column "E". That's why all the data is going into one place.
I can't figure what is wrong with the code. I checked out column E in the Copy Workbook and there are no spelling/capitalization issues. Maybe a Case statement would be better for what I'm doing, but I'm not savvy with VBA and I don't know how to do that.

A: Option Explicit

Sub GetData()

Dim wsPasteTo As Worksheet, wbDATA As Workbook
Dim NextRow As Long, LastRow As Long, i As Long
Dim val, col

    Set wsPasteTo = ThisWorkbook.Sheets("ACP")
    NextRow = wsPasteTo.Range("A" & Rows.Count).End(xlUp).Row + 2

    Set wbDATA = Workbooks.Open( _
          "\\cmicro.com\Shares\Amb\Amb-Probes\DataLogs\" & _
         "CQS-03-033-2012 Coax Shelf Cut Log R2.6.xlsm", ReadOnly:=True)

    Application.ScreenUpdating = False

    With wbDATA.Sheets("ACP")

        LastRow = .Range("A" & .Rows.Count).End(xlUp).Row

        For i = 2 To LastRow

            val = .Cells(i, "E").Value
            Select Case val
                Case "Angle": col = "I"
                Case "Vertical": col = "D"
                Case Else: col = "N"
            End Select

            wsPasteTo.Cells(NextRow, col).Resize(1,2).Value = _
                                .Cells(i, "K").Resize(1, 2).Value

            NextRow = NextRow + 1 'or whatever....

        Next i

    End With

Application.ScreenUpdating = True
wbDATA.Close False

End Sub

A: Here is the working code:
Option Explicit

Sub GetData()

Dim wsPasteTo As Worksheet, wbDATA As Workbook
Dim NextRow As Long, LastRow As Long, i As Long
Dim val, col

Set wsPasteTo = ThisWorkbook.Sheets("ACP")

Set wbDATA = Workbooks.Open("\\cmicro.com\Shares\Amb\Amb-Probes\DataLogs\CQS-03-033-2012 Coax Shelf Cut Log R2.6.xlsm", ReadOnly:=True)
Application.ScreenUpdating = False

    With wbDATA.Sheets("ACP")

        LastRow = .Range("E" & .Rows.Count).End(xlUp).Row

        For i = 2 To LastRow

            val = .Cells(i, "E").Value
            Select Case val
                Case "Angle": col = "I"
                    NextRow = wsPasteTo.Range("I" & Rows.Count).End(xlUp).Row + 1
                Case "Vertical": col = "D"
                    NextRow = wsPasteTo.Range("D" & Rows.Count).End(xlUp).Row + 1
                Case Else: col = "N"
                    NextRow = wsPasteTo.Range("N" & Rows.Count).End(xlUp).Row + 1
            End Select

            wsPasteTo.Cells(NextRow, col).Resize(1, 2).Value = .Cells(i, "K").Resize(1, 2).Value

        Next i

    End With

Application.ScreenUpdating = True
wbDATA.Close False

End Sub

I forgot that the 'NextRow' for each type of data would be unique.
Thanks for your help Tim.


text:
Q: JavaConfig : The type javax.servlet.ServletContext and javax.servlet.ServletException cannot be resolved create my first project in Spring and I have some problem.
I use JavaConfig to configuration my project and when I start I have this error :
Error:(6, 8) java: cannot access javax.servlet.ServletException
class file for javax.servlet.ServletException not found

I now I have to add javax.servlet api but I do not know where to do it.
I create my project in IntelliJ Ultimate 2017.

A: It seems like you haven't included the javax.servlet.jar library in your project.
If you're not using any dependency managers, you should add 'javax.servlet.jar' file to your classpath manually with Intellij IDEA: Project Structure (Ctrl+Alt+Shift+S) -> Libraries -> New Project Library -> Java. This jar-file can be downloaded here: http://central.maven.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar
If you're using Maven, then just add this dependency to maven pom.xml file.
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
 </dependency>

A: ran into a similar problem, I already had a dependency implemented
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>
    <scope>provided</scope>
</dependency>

However, the problem was solved by changing the version of
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>6.0.4</version>
</dependency>

to:
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.2.9.RELEASE</version>
</dependency>


text:
Q: Implementing a callback function or execute function when another function returns I have two functions that are executed simultaneously but one needs to be called only when another returns. There is a bit of complexity that goes into how the two functions are called, so unfortunately, I cannot put one of the functions in another function and add a callback.
Here are the two functions:
function loadJson = function(json, url, link) {
    /* blackbox function called by a process */
    return json;
}

function onLoad = function () {
    /* do some actions after json is loaded and returned */
}

Is there any way to detect that loadJson has returned and only then call the onLoad function?

A: You just pass the callback to loadJson as an argument, and call it before returning:
var loadJson = function(json, url, link, callback) {
    //Your mysterious secret and complex function;
    callback(json);
    return json;
}

var onJsonLoaded = function(json) {
    //do some actions
    console.log(json);
}

Then, call it like this:
loadJson(YOUR, PARAMETERS, HERE, onJsonLoaded);

Or you could even inline the callback, saving a variable:
loadJson(YOUR, PARAMETERS, HERE, function(json) {
    //do some actions
    console.log(json);
});


text:
Q: c gobjects.h passing color value through variable to setColor I am trying to write a function which draws certain amount of blocks within a window. I would like to make the colors of the blocks random. Ideally I would like to have a variable which would be randomly modified each iteration making the next block with different color:
setColor(brick, myColorVariable);

Unfortunately, gobjects allows to declare color in a form of:
setColor(brick, "BLACK") //

Here is the function code:
void initBricks(GWindow window)
{
     int x = 5;
     int y = 100;
     int color = 0xff0000;

     GRect brick = newGRect(x,y,55,10);
     setFilled(brick, true);
     setColor(brick, PROBLEM HERE);
     add(window, brick);

}

Thank you very much!

A: The library itself probably have a way to set colors from RGB values or palette indexes (see its documentation), but in order to use that specific function, which takes the color by its name, you can make your "palette" as an array of color names:
static const char* COLOR_NAMES[] = {
  "BLACK",
  "WHITE",
  ...
};

Then choose a random element from the array:
int colorIndex = rand() % (sizeof(COLOR_NAMES)/sizeof(COLOR_NAMES[0]));
setColor(brick, COLOR_NAMES[colorIndex]);


text:
Q: Controlling order of operations with services and controllers I have two services - one to store user details and the other to make a call to retrieve those details:
userService stores user details to be used across the entire app (i.e. injected in controllers, services, etc.)
function userService($log) {
    var id = '';
    var username = '';
    var isAuthenticated = false;

    var service = {
        id: id,
        username: username,
        isAuthenticated: isAuthenticated
    };

    return service;
}

authService is used (hopefully just once) to retrieve the user details from a Web API controller:
function authService($log, $http, userService) {
    $log.info(serviceId + ': Inside authService method');

    var service = {
        getUserDetails: getUserDetails
    };

    return service;

    function getUserDetails() {
        $log.info(serviceId + ': Inside getUserDetails method');

        return $http.get('api/authentication', { cache: true });
    }
}

Initially, I had the call to the authService fire in a .run block like so:
.run(['$log', 'authService', 'userService', function ($log, authService, userService) {

    authService.getUserDetails()
        .then(querySucceeded);

    function querySucceeded(result) {
        userService.id = result.data.Id;
        userService.username = result.data.username;
    }
}]);

But the problem was that the getUserDetails-returned promise did not resolve until after I my controllers fired and, thus, too late for me.  The user data was not ready.
I then looked at the resolve option in the $stateProvider (for UI-Router):
.state('dashboard', {
                url: '/dashboard',
                views: {
                    header: {
                        templateUrl: 'app/partials/dashboard/header.template.html',
                        controller: 'DashboardHeaderController',
                        controllerAs: 'dashboardHeaderVM',
                        resolve: {
                            user: function (authService) {
                                return authService.getUserDetails();
                            }
                        }
                    }
                }
            })

The assumption is that the view won't be rendered until the promise in the resolve section is, well, resolved.  That seems to work fine.
Here's the (relevant part of the) controller where I use the returned user property:
function DashboardHeaderController($log, user) {
    var vm = this;

    // Bindable members
    vm.firstName = user.data.firstName;
}

However, I have two routes (more to come) and a user can navigate to either one.  Do I need to have a resolve property in each state section for the authService?  I want to fire the call to authService.getUserDetails just once no matter which route is served and have it available after that for any route, controller, etc.
Is there a better (best practice) way to do this?

A: Not sure about better or best practice, but here is a plunker with my way.
The point is to move resolve into some parent root state. The one who is ancestor of all states in the application:
$stateProvider
  .state('root', {
    abstract : true,
    // see controller def below
    controller : 'RootCtrl',
    // this is template, discussed below - very important
    template: '<div ui-view></div>',
    // resolve used only once, but for available for all child states
    resolve: {
      user: function (authService) {
          return authService.getUserDetails();
      }
    }
  })

This is a root state with resolve. The only state with resolve. Here is an example of its first child (any other would be defined similar way:
$stateProvider
    .state('index', {
        url: '/',
        parent : 'root',
        ...

This approach will work out of the box. I just would like to mention that if the 'RootCtrl' is defined like this:
.controller('RootCtrl', function($scope,user){
  $scope.user = user;
})

we should understand the UI-Router inheritance. See:

*

*Scope Inheritance by View Hierarchy Only
small cite:

Keep in mind that scope properties only inherit down the state chain if the views of your states are nested. Inheritance of scope properties has nothing to do with the nesting of your states and everything to do with the nesting of your views (templates).
It is entirely possible that you have nested states whose templates populate ui-views at various non-nested locations within your site. In this scenario you cannot expect to access the scope variables of parent state views within the views of children states...

More explanation could be found in this Q & A
So, what does it mean?

Our root view can pass the resolved stuff into child state only - if their views are nested.

For example, the $scope.user will be inherited in child states/views/$scopes only if they are nested like this
.state('index', {
    url: '/',
    parent : 'root',
    views: {
      '' : { // the root view and its scope is now the ancestor
             // so $scope.user is available in every child view
        templateUrl: 'layout.html',
        controller: 'IndexCtrl'
      },
      'top@index' : { templateUrl: 'tpl.top.html',},
      'left@index' : { templateUrl: 'tpl.left.html',},
      'main@index' : { templateUrl: 'tpl.main.html',},
    },

Check it here

A: If I correctly understand you want that on page load you would have user info before any controller or service request it.
I had similar task in my current project.
To solve the problem I manually requested current user info before app bootstapping & store it in localStorage.
Then after app bootstrapping all controllers/services have accesss to current user info.
TIP: to get user info before app bootstrap you can still use $http service by manually injecting it:
angular.injector(['ng']).get('$http');


text:
Q: how to set multiple ImageViews in a row in Constraint Layout? I am trying to recreate this Layout with ImageViews instead of buttons.
This is what I had so far when using buttons:

The buttons were all in a row and with equal distance to each other.
Thats the old xml code btw (only the buttons):
<Button
    android:id="@+id/btnOneXXX"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:layout_marginBottom="36dp"
    android:text="Back"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@id/btnTwoXXX"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline2XXX" />

<Button
    android:id="@+id/btnTwoXXX"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="Home"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@id/btnThreeXXX"
    app:layout_constraintStart_toEndOf="@id/btnOneXXX"
    app:layout_constraintTop_toTopOf="@+id/guideline2XXX" />

<Button
    android:id="@+id/btnThreeXXX"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="Like"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@id/btnFourXXX"
    app:layout_constraintStart_toEndOf="@id/btnTwoXXX"
    app:layout_constraintTop_toTopOf="@+id/guideline2XXX" />

<Button
    android:id="@+id/btnFourXXX"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="Next"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@id/btnThreeXXX"
    app:layout_constraintTop_toTopOf="@+id/guideline2XXX" />

I tried to recreate this using ImageViews. This is how it looks so far:

I kept the xml code nearly the same, as I only changed the view element.
<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginEnd="48dp"
    android:layout_marginRight="48dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/imageView2"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline2"
    app:srcCompat="@drawable/back" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="48dp"
    android:layout_marginLeft="48dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/imageView3"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toEndOf="@+id/imageView"
    app:layout_constraintTop_toTopOf="@+id/guideline2"
    app:srcCompat="@drawable/home" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="55dp"
    android:layout_marginLeft="55dp"
    android:layout_marginEnd="20dp"
    android:layout_marginRight="20dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/imageView4"
    app:layout_constraintStart_toEndOf="@+id/imageView2"
    app:layout_constraintTop_toTopOf="@+id/guideline2"
    app:srcCompat="@drawable/emptyheart" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginEnd="60dp"
    android:layout_marginRight="60dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/imageView3"
    app:layout_constraintTop_toTopOf="@+id/guideline2"
    app:srcCompat="@drawable/next" />

As you can see, the buttons positions are messed up and not in equal distance. I am new to using ConstraintLayout. Can anyone help me on that and explain to me why my code doesn't work as expected and how to solve it? Thanks for all answers.

A: You need to add a chain style. In your case, a horizontal one like: app:layout_constraintHorizontal_chainStyle="packed" to the first image. You can find more info on this here

A: Well, those margins were messing up the positions. I simply get rid of the margins in every ImageView and now they are aligned perfectly.

A: Try this:
<ImageView
    android:id="@+id/image1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/image2"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/image2"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/image3"
    app:layout_constraintStart_toEndOf="@+id/image1"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/image3"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/image4"
    app:layout_constraintStart_toEndOf="@+id/image2"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/image4"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/image5"
    app:layout_constraintStart_toEndOf="@+id/image3"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/image5"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/image4"
    app:layout_constraintTop_toTopOf="parent" />

You can also add a layout_constraintHorizontal_chainStyle
and give it a value of packed or spread or spread_inside
Hope this helps.

A:
It's a very simple mistake.
You have added some unnecessary margins.

Remove those margins and add/remove equal margins for each image.
  And you can make this as a horizontal chain too(not mandatory)

app:layout_constraintHorizontal_chainStyle="spread"


text:
Q: Adding and Displaying List Object Im developing a web app in spring and trying to display a list of all staff in my db using the following code
@PostMapping("/request_list")
 public List <Staff> processCreationForm(Model model){
        var sList = (List<Staff> staff.findAll());
        model.addAttribute("staff_list",sList);
            return "requestList";

for some reason this doesnt work. Please advice

A: Adds @ResponseBody on method name processCreationForm then you can return sList.
@PostMapping("/request_list")
@ResponseBody
public List <Staff> processCreationForm(Model model){
    return (List<Staff> staff.findAll());

Spring will use Jackson convert List<Staff> to json array.
Try to this tutorial >>> https://spring.io/guides/gs/rest-service/


text:
Q: Bootstrap popover does not work as expected <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Bootstrap Popover</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
</head>
<body>

    <div class="container" style="margin-top:100px;">
        <button type="button" class="btn btn-primary" data-trigger="focus" data-toggle="popover" data-bs-placement="right" title="Popover on right" data-content="彈出提示框(Popover)的彈出位置在按鈕右方">
            Popover on right
        </button>
        <button type="button" class="btn btn-primary" data-trigger="focus" data-toggle="popover" data-bs-placement="top" title="Popover on top" data-content="彈出提示框(Popover)的彈出位置在按鈕上方">
            Popover on top
        </button>
        <button type="button" class="btn btn-primary" data-trigger="focus" data-toggle="popover" data-bs-placement="bottom" title="Popover on bottom" data-content="彈出提示框(Popover)的彈出位置在按鈕下方">
            Popover on bottom
        </button>
        <button type="button" class="btn btn-primary" data-trigger="focus" data-toggle="popover" data-bs-placement="left" title="Popover on left" data-content="彈出提示框(Popover)的彈出位置在按鈕左方">
            Popover on left
        </button>
    </div>
    <script>
        $(document).ready(function () {
            $('[data-toggle="popover"]').popover();
        });
    </script>
</body>
</html>

At least now when I clicked on the buttons, the popovers did show up but the data-content still could not be shown on the popovers so what is still missing in order to have the whole popover with the content shown?

A: Change data-placement attributes to data-bs-placement.
https://getbootstrap.com/docs/5.0/components/popovers/
In bootstrap 5 they use data-bs-placement instead of data-placement
and bootstrap 4 they use data-placement.


text:
Q: MySql returning multiple rows from stored procedure / function I need to make a stored procedure or function that returns a set of rows. I've noted that in a stored procedure i can SELECT * FROM table with success. If i fetch rows in a loop and SELECT something, something_other FROM table once per loop execution, I only get one single result.
What I need to do is looping, doing some calculations and returning a rowset. What's the best way to do this? A temporary table? Stored functions?
Any help appreciated.

A: It sounds like you're using a cursor inside the body of the stored procedure to accomplish your looping?
My first advise is: try to do your calculations in a single query without resorting to cursors.  What's the calculation exactly?
If you really do need to use a cursor, then INSERT the results of each loop into a temporary table and then SELECT * from that table when you're done looping.

A: You can return multiple result sets but only if the client library supports it and the client is expecting it. Some don't, so using them will result in out-of-sequence errors.
You can certainly build a temporary table, select from it and drop it inside the procedure, that would be safe. Another option is to build a UNION select using a prepared SQL statement which returns all the rows you need and execute that. That's a bit messy.


text:
Q: Determine range of elements that do not occur in any of several arrays I have several arrays denoting x- and y-coordinates. What I would like to do is to determine the y-range for which none of the resulting lines overlap with one another. To illustrate what I mean I wrote the following code:
import numpy
import matplotlib.pyplot as plt

x1, y1 = numpy.array([1., 2., 3., 4., 5., 6.]), numpy.array([5., 6., 7., 8., 9., 10.5])
x2, y2 = numpy.array([1., 2., 3., 4., 5., 6.]), numpy.array([7., 4., 3., 2., 1., 0.])
x3, y3 = numpy.array([1., 2., 3., 4., 5., 6.]), numpy.array([0., 7.5, 8.5, 4., 3., 5.])
x4, y4 = numpy.array([1., 2., 3., 4., 5., 6.]), numpy.array([14., 17., 16., 20., 19., 18.])
x5, y5 = numpy.array([1., 2., 3., 4., 5., 6.]), numpy.array([20., 18., 16., 13.5, 16., 17.])

plt.figure()

plt.plot(x1, y1)
plt.plot(x2, y2)
plt.plot(x3, y3)
plt.plot(x4, y4)
plt.plot(x5, y5)

plt.axhline(10.5, color = "black", ls = "dashed")
plt.axhline(13.5, color = "black", ls = "dashed")

plt.xlim(1, 6)
plt.ylim(0, 20)

plt.show()

This code produces the following image:

In this example there are 5 sets of x and y data arrays. There is a certain range (indicated by the horizontal black dashed lines) for which none of the data arrays overlap with one another with respect to the y-axis.
How can I determine this region? I'm sorry I do not have any suggestions as how to tackle this problem as I do not even have any idea as to which search terms I should use in this situation.
Thank you very much!

A: IIUC, this is basically an overlapping intervals problem.  Stealing code from this answer -- which I haven't really tested, to be honest, but once you know the keywords are "merge overlap interval" there are lots of implementations to be found -- you can merge the y ranges.  For example:
def merge(times):
    if not times: return
    saved = list(times[0])
    for st, en in sorted(sorted(t) for t in times):
        if st <= saved[1]:
            saved[1] = max(saved[1], en)
        else:
            yield tuple(saved)
            saved = [st, en]
    yield tuple(saved)

ys = [y1, y2, y3, y4, y5]
mms = [[y.min(), y.max()] for y in ys]
used = list(merge(mms))
unused = [(low[1], high[0]) for low, high in zip(used, used[1:])]

produces
>>> used
[(5.0, 10.5), (13.5, 20.0)]
>>> unused
[(10.5, 13.5)]

where used is a list of the y-bands where there's data, and unused is a list of the y-bands where there isn't data.

A: I think I'm understanding this correctly ..
We can simplify the problem by combining all the data sets together.
>>> combined = [5., 6., 7., 8., 9., 10.5] + [7., 4., 3., 2., 1., 0.] + [0., 7.5, 8.5, 4., 3., 5.] + [14., 17., 16., 20., 19., 18.] + [20., 18., 16., 13.5, 16., 17.]
>>> combined
[5.0, 6.0, 7.0, 8.0, 9.0, 10.5, 7.0, 4.0, 3.0, 2.0, 1.0, 0.0, 0.0, 7.5, 8.5, 4.0, 3.0, 5.0, 14.0, 17.0, 16.0, 20.0, 19.0, 18.0, 20.0, 18.0, 16.0, 13.5, 16.0, 17.0]

Next, we need to sort the combined list.
>>> combined.sort()

From there, all that remains is pairing the numbers up, in this case via a generator object.
>>> pairs = ((combined[i], combined[i-1]) for i in range(1, len(combined)))

and finding the maximum difference between the values in any pair!
>>> max(pairs, key=lambda x:x[0]-x[1])
(13.5, 10.5)

Hope this is of use.


text:
Q: Cosmosdb spring boot sdk setting x-ms-max-item-count How can I set x-ms-max-item-count from java sdk?
is there an option to set page size to retrieve documents? currently it is limited to 100, i would like to increase it to 1000? how can i do it through the java SDK?
I am using ReactiveCosmosTemplate and have a bean of CosmosClientBuilder that I configure connection and consistency level.
But I cant find the max-item-count for a query. 100 batches is very small for me, I need to increase it. How can I do that?
I couldnt find it anywhere.

A: x-ms-max-item-count cannot be directly set but can only be set using CosmosPagedFluX#byPage API in the java V4 SDK.
In non-reactive spring repository this can be set using the "pageSize" in CosmosPageRequest object. Please review the Pagination section in this blog post
In reactive spring repository there is no way of setting "x-ms-max-item-count.


text:
Q: Saving MATLAB graphs in a specific resolution How do I change the resolution of my MATLAB graphs? The default seems to be 96x96 PPI.

A: Changing a Figure's Settings: Setting the resolution

A: You can save using the print command; here's how:
h1=figure;
your plotting commands here

print(h1,'-djpeg','-r150','filename')

The -r150 argument sets the resolution to 150 DPI. you can set it higher or lower depending on your need. This is assuming you're saving as a JPEG. If not, there are other options such as -dpng for PNG, -dbmp for 24-bit bitmap, etc. more can be found in the help section for print.
That said, if your plot consists only of lines, I would recommend using -depsc which saves it as an EPS file, which is scalable and lossless. You also won't have to define a resolution, so you can simply do
print(h1,'-depsc','filename')
You can convert this EPS file to PDF and retain the same resolution, yet have portability between applications and platforms. I wouldn't recommend saving to PDF directly as MATLAB puts additional white spaces around the plot, wheras the EPS bounding box is tight, and looks neat.


text:
Q: Service Bus Explorer - Unable to see messages on Subscription Topic when added rule/filer Service Bus Explorer - Unable to see messages on Subscription Topic when added rule/filer.
Following is a message being generated on bus;
{
  "header": {
    "Major": 1,
    "Minor": 0,
    "Patch": 0,
    "MessageType": "EmployeeMessage",
  },
  "message": "message text"
}

I have created two subscriptions;

*

*All - with rule as "1=1"
In this subscription I get all the messages.

*MessageType - here rule is MessageType="EmployeeMessage"
In this, I am expecting messages with MessageType as EmployeeMessage. But I am not getting single message in this subscription.

Can some help me on this?

A: Topic Subscription validates the Rule against the message custom properties (headers)
If you send the right set of custom properties with the message, it gets validated and get into the Subscription.
The problem might be with the message, that is sent to the Topic. Please try to receive the message in All Subscription through Service Bus Explorer and check whether the required custom property is available in it.