text:
Q: Why is $element available/injected in controller? In AngularJS, I've noticed that a controller is injected with $element, which is a JQuery/JQLite wrapper of the element the controller is controlling. For example:
<body ng-controller="MainCtrl">

Then you can have access to the body element in the controller by injecting $element
app.controller('MainCtrl', function($scope, $element) { ...

This can be seen working at this Plunkr.
And seems to be confirmed as a deliberate feature in the docs for $compile
My questions are:

*

*In the light of the various guides and tutorials that suggest you shouldn't access the DOM in a controller, why is this even possible?

*Is there any non-hacky use case for this?

*Are there any examples of this being used in available code somewhere?
Thanks.

A: In the light of the various guides and tutorials that suggest you shouldn't access the DOM in a controller, why is this even possible?
Whether you inject $element or not, the controller's scope is bound on that element.
angular.element('#element-with-controller').scope();

Angular revolves around directives. It's what glues things together in the MVC.
And if you think about it, ng-controller, is a directive itself.
Is there any non-hacky use case for this?
I guess this can come in handy when you're using a single controller for multiple directives.
.controller('MyController', function($scope, $element){
    $scope.doSomething = function(){
        // do something with $element...
    }
})
.directive('myDirective1', function(){
    return {
        controller: 'MyController'
    }
})
.directive('myDirective2', function(){
    return {
        controller: 'MyController'
    }
})

Each directive will have a new instance of the assigned controller, but basically share it's properties, dependencies.
Are there any examples of this being used in available code somewhere?
I wrote a form handler controller once, for registration/login/contactus, etc.

A: Actually, $element is injected because you specified it as a dependency in the argument list.
If you remove it from the list, it will not be injected.
http://plnkr.co/edit/CPHGM1awvTvpXMcjxMKM?p=preview
And as commented, there are case in which you need $element in the controller, although i can't think of any at the moment.

A: Posting my comment as an answer because of the character limits in comments and due to feeling  that contains part of the answer.

In the light of the various guides and tutorials that suggest you shouldn't access the DOM in a controller, why is this even possible?

As said before that people suggest to take a specific approach in your code does not require them to limit you.

Is there any non-hacky use case for this?

From the top of my head I cannot think of a benefit (reply on your comment) in most of the cases. One time that I used this approach was implementing a youtube iframe API directive.
When someone stopped the player the element had to be deleted from the DOM.

Are there any examples of this being used in available code somewhere?

Here is some code for that, though it is from quite some time ago and I've removed some parts and is considered hacky?
angular.module('mainApp.youtube').directive('youtubePlayer', function($window,$element logging, ui,) {
    return {
        restrict: 'A', // only activate on element attribute
            scope: true, // New scope to use but rest inherit proto from parent
            compile: function(tElement, tAttrs) {
            // Load the Youtube js api
            var tag = document.createElement('script');
            tag.src = "https://www.youtube.com/iframe_api";
            var firstScriptTag = document.getElementsByTagName('script')[0];
            firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
        },
        controller: function($scope, $element, $attrs) {

        // This is called when the player is loaded from YT
        $window.onYouTubeIframeAPIReady = function() {
            $scope.player = new YT.Player('player', {
                    height: '250',
                    width: '400',
                    playerVars: {
                'autoplay': 0,
                        'controls': 1,
                        'autohide': 2
                    },
                    //videoId: $scope.live_track.video_id,
                    events: {
                'onReady': $scope.onPlayerReady,
                        'onStateChange': $scope.onPlayerStateChange,
                        'onError': $scope.onError
                    }
                });
            };

            // When the player has been loaded and is ready to play etc
            $scope.onPlayerReady = function (event) {
                $scope.$apply(function(){
                    logging.info("Playa is ready");
                    logging.info($scope.player);
                    // Lets also broadcast a change state for the others to catch up
                    player_service.broadcast_change_state({"state": $scope.player.getPlayerState()});
                    // Should try to just load the track so that the users can press play on the playa
                });
            };

            // When the player has been loaded and is ready to play etc
            $scope.onError = function (event) {
                $scope.$apply(function(){
                    logging.info("Playa Encountered and ERROR");
                    logging.info(event)
                    });
            };

            $scope.start_playing = function (jukebox_id){
                logging.info('Yes I am starting...');

            };

            $scope.$on('handleStartPlaying', function(event, jukebox_id) {
                console.log('Got the message I ll play');
                $scope.start_playing(jukebox_id);
            });

            $scope.$on('handlePausePlaying', function() {
                console.log('Got the message I ll pause');
                $scope.player.pauseVideo();
            });

            $scope.$on('handleResumePlaying', function() {
                console.log('Got the message I ll resume');
                $scope.player.playVideo();
            });

            $scope.$on('handleStopPlaying', function() {
                console.log('Got the message I ll stop');
                $scope.player.stopVideo();
            });

            $scope.$on('HandleCloseframe', function() {
                console.log('Got the message I ll stop');
                $scope.player.stopVideo();
                //Should destroy obje etc
                // Look here
                $element.remove(); // blah blah blah
            });

        },
            ink: function(scope, elm, attrs, ctrl) {

        }
        }
    });

Feel free to correct me or offer better approaches. At that time this seemed legit. At least if we don't do mistakes we don't learn.

A: Quick summary
A well written directive that is extendable and/or interacts with other directives will have a controller.  That controller needs to access the DOM because it is where that directive's functionality is defined.  Directives are effectively a different way to bind a controller/scope to an element on the page; the preferred way to add functionality to the DOM.  From what I understand, the best practice is: don't use both a controller and a link function.  So directive controllers need an $element.
Detail answers

In the light of the various guides and tutorials that suggest you shouldn't access the DOM in a controller, why is this even possible?

The guides are a little misleading once you dig into how it all works.
what the guides say:
Controllers handle defining functions and assign variables to be used by the view.  And the right way to bind those functions and variables to the view is with a directive.  That is my understanding of best practices, having worked with large and growing angular applications for the past year.
why it is confusing:
The tricky thing is that the directive basically binds a controller to the DOM.  ng-model is a directive and has a controller that can be accessed from other directives.  You will want to take advantage of this if you do things like add custom validation fanciness.  This controller of the directive is supposed to manipulate the DOM. So a generic controller is actually is a super set of view controllers; a detail that the tutorials usually glaze over.

Is there any non-hacky use case for this?

'correct' ways of using $element:
Using it in a directive's controller for example.

Are there any examples of this being used in available code somewhere?

Examples:
Angular source code, though perhaps a little dense of a read, is good code and well commented.  It may take a little bit to see what's going on, but usually quite informative.
NgModelController (complex example)
https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js
https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L1660
What could be a simple example, but uses a compile function instead, the eventDirectives (ng-click for example),
https://github.com/angular/angular.js/blob/master/src/ng/directive/ngEventDirs.js#L3


text:
Q: Scrapy webscraping output missing elements from page I am trying to scrape the SSD prices off of a url on amazon but the scraper only returns some of the prices. Please explain where I went wrong, I am new with scrapy.
import scrapy
from scrapy import Spider

class SSDSpider(scrapy.Spider):
   name = "SSD_spider"
   start_urls = ['https://www.amazon.ca/s/ref=nb_sb_noss_2?url=search-
   alias%3Daps&field-keywords=ssd']

   def parse(self, response):
       for ssd in response.css('.
            NAME_SELECTOR = '//span[contains(@class,"a-size-base a-
            color-price s-price a-text-bold")]/text()'
            yield {
                'price': response.xpath(NAME_SELECTOR).extract()
            }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Service is not under 'rootDir' in Angular secondary entry point When compiling an Angular library, I am getting this error concerning rootDir of my sub libraries
library/services/src/public-api.ts:31:15 - error TS6059: File 'C:/libname/library/services/src/orders/orders.service.ts' is not under 'rootDir' 'C:/libname\library\classes\src'. 'rootDir' is expected to contain all source files.
I have come to understanding that it is not a good practice to use relative imports inside Angular library between individual secondary entries. So I have divided my code into secondary entries + setup paths in TSConfig
Code structure
library
  services
    src
      public-api.ts
    package.json
  models
    src
      public-api.ts
    package.json
  src
    public-api.ts
  package.json

TSConfig
{
  "rootDir": "./library/",
  "paths": {
    "@core/services": [ "library/services/src/public-api.ts" ]
  }
}

angular.json
{
  "projects": {
    "lib": {
      "root": "library",
      "sourceRoot": "library"
    }
  }
}

So the question is - how to fix imports between individual secondary entry points or file structure and make the project compile okay? I understand that the compilation of secondary entry points is separate and "treated as a separate project", hence the error. Should I therefore add individual secondary entry points as peer dependencies?
Of course there are more paths and secondary endpoints - But that is irrelevant for the issue, this is enough to show my file structure and setup

A: you may use relative imports which results in a file outside of the root directory of the secondary entrypoint, eg. import Users from "../../models/src/public_api.ts"
Instead, import the module using the name of the library, eg. import Users from "library/models"
This issue from ng-packagr repo provides good code examples.

A: also can happen when IDE import helper generates nonrelative path (e.g. "src/sevices/.." instead of "../../services")
actually had the issue in primary entrypoint part of the lib when a component imported service using this kind of autogenerated path (yet throwing error during compilation of secondary entrypoint, go figure...)


text:
Q: SQL SELECT QUERY COUNT I'm new to this so bear with me.
I'm trying to create a select query from a Movie database. Amongst other tables there is a Role table that features information such as roleID, roleName, gender, actorID, movieID. An actor can have many roles in different movies.
I am trying to create the query so it will tell me how many actors have three or more roles in the database.
I've tried a few solutions and they output data just not sure if it is right.
SELECT COUNT (DISTINCT actorID) FROM Role WHERE actorID >= 3

SELECT COUNT (actorID) FROM Role GROUP BY movieID HAVING COUNT (actorID) >=3

A: Try something like:
select actorID, count(*)
from Roles
group by actorID
having count (*) >= 3

If you want to retrieve other properties about the actor you add those to both the select and group by clauses

A: Try:
SELECT COUNT(*) FROM Role
GROUP BY actorid
HAVING COUNT(*) >= 3

A: Please try the following
SELECT actorID, COUNT(actorID)
FROM Role
GROUP BY actorID
HAVING COUNT (actorID) >=3

A: Try this ..
SELECT COUNT(*)
FROM (SELECT actorID FROM Roles GROUP BY actorID HAVING COUNT(*)>=3) AS actor;

This query return number of actors who have three or more roles in the database.

A: your second query is almost correct.
You need to group by actorId, because you want to count them. You have put movieId, which makes no sense in that case.
SELECT COUNT (*) as actorRoles
FROM Role
GROUP BY actorId
HAVING actorRoles >=3;

A: select   count(*)
from     Role
where    actorID in
         (
             select    actorID
             from      Role
             group by  actorID
             having    count(actorID) > 3
         )


text:
Q: How to find login and password input in Selenium WebDriver How to find login and password input in Selenium WebDriver?
I tryed with .//[@id='login_input'] and .//[@id='password'] but is one problem: these fields input are loaded by script JavaScript. Source code page:
<!DOCTYPE html>

        <meta charset="utf-8">
        <link rel="http://oexchange.org/spec/0.8/rel/related-target" type="application/xrd+xml" href="http://www.gg.pl/info/static/files/oexchange.xrd"/>

        <link rel="stylesheet" href="/info/1.2.0/css/style.css" />

        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <title>GG - pobierz najpopularniejszy polski komunikator</title>
        <meta name="keywords" content="gg, gadu, gadu-gadu, komunikator, gg download, gg pobierz, web gadu, mobilne gg, gg android, gg iphone, gg linux, gg windows, gg na telefon, gg w przeglądarce, webowe gg, przesyłanie plików, katalog publiczny, archiwum gg">
        <meta name="description" content="Pobierz komunikator GG dostępny na systemy Windows, OS X, Linux, na telefony komórkowe: iPhone oraz z systemem Android, Windows Phone i inne. Korzystaj z GG także przez stronę WWW.">
        <meta property="og:url" content="http://www.gg.pl/" />
        <meta property="og:title" content="GG - pobierz najpopularniejszy polski komunikator" />
        <meta property="og:site_name" content="GG" />
        <meta property="og:description" content="Pobierz komunikator GG dostępny na systemy Windows, OS X, Linux, na telefony komórkowe: iPhone oraz z systemem Android, Windows Phone i inne. Korzystaj z GG także przez stronę WWW." />
        <meta property="og:type" content="website" />
        <meta property="og:image" content="http://www.gg.pl/info/1.2.0/img/scfbg.png" />
        <meta property="og:locale" content="pl_PL" />
        <meta name="google-site-verification" content="d109cRFzSCCNSp1FE0PJ1u8iyomEuC7fG0Hi1J-xMh4" />

        Polski.
        Najpopularniejszy.
        Komunikator.

        Pobierz GG

Windows

OS X

Linux

Windows 8

Android

iPhone

Windows Phone

W domu, w pracy, w drodze

Rozmawiaj na komputerze i komórce.

Możesz też rozmawiać w przeglądarce bez instalowania komunikatora.

Bezpieczne rozmowy

Korzystając z oficjalnej wersji komunikatora GG możesz czuć

się bezpiecznie. Rozmowy, które prowadzisz są szyfrowane

i zapisywane* w archiwum on-line, abyś nigdy ich nie stracił.

*Szanujemy Twoją prywatność, więc masz pełną kontrolę nad tym co trafi do archiwum.

Konferencje z przyjaciółmi

Rozmawiaj z grupą znajomych w jednym oknie.

Do każdej rozmowy możesz dodać więcej osób.

GG Plugin

Nie przegap żadnej wiadomości od znajomych.

GG widżet - komunikator na Twoją stronę

Darmowe narzędzie
do szybkiej i niezawodnej komunikacji online z Twoimi klientami.

Poznaj nowych znajomych.
Wtedy, kiedy chcesz. Tam, gdzie jesteś.

Wystarczy kilka sekund, aby trafić na osobę, która chce Cię poznać.
Takich osób są miliony. Może to być ktoś z Twojej miejscowości
lub oddalony o wiele kilometrów. Klika w przycisk "Losuj rozmówcę".
Ty robisz to samo i gotowe. Trafiacie na siebie.
To może być początek ciekawej znajomości albo czegoś więcej...

Pobierz GG

Pomoc

Regulamin

Prywatność

Zgłoś nadużycie

Reklama

Kontakt

© 2017 Xevin Consulting Limited

This is the script: XPATH: html/body/script[1]
The source code script:

How I can run this script that adds form login? I don't have any idea. You can find this page at the address https://www.gg.pl/ (if it's against the law please remove the address). Thank you very much for help!

A: Make sure you are waiting long enough for the Javascript to execute. You should take a screen shot of the web page before you try to set the login. (That would tell you if you have waited long enough, and if the fields have loaded.)

A: This is a nifty one. Seems like the page doesn't want you to scrape it ;-) The page wraps the login form into an iframe so you have to find out this iframe first and switch to it:
from selenium import webdriver
from selenium.webdriver.common import by
from selenium.webdriver.support import ui, expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://www.gg.pl/')

iframe = driver.find_element_by_xpath('//iframe[@class="com frame centered"]')
driver.switch_to.frame(iframe)
element_login = ui.WebDriverWait(driver, 10).until(EC.element_to_be_clickable((by.By.ID, 'login_input')))
element_password = ui.WebDriverWait(driver, 10).until(EC.element_to_be_clickable((by.By.ID, 'password')))
# or use xpath if you like:
#element_login = ui.WebDriverWait(driver, 10).until(EC.element_to_be_clickable((by.By.XPATH, '//input[@id="login_input"]')))
#element_password = ui.WebDriverWait(driver, 10).until(EC.element_to_be_clickable((by.By.XPATH, '//input[@id="password"]')))

Also, note that I used implicit waiting so selenium will wait 10 seconds max. for the login input to appear on page (and be accessible). This technique will protect you against long page loads where driver.find_element_by... can fail if the page is not being loaded fast enough.


text:
Q: Installing React app with yarn Plug n Play I want to make a react app with yarn using PnP(Plug and Play), so that I can install any dependencies without using node modules, so I type this in terminal:
yarn create react-app project-name --use-pnp

Then, the app has created, but when I start the server it says
    Failed to compile.

    ./src/App.js
    Module not found: You cannot require a package ("react-refresh") that is not declared in your dependencies (via "/home/path/path/path/path/project-name/src/App.js")

Then, when I install the "react-refresh" it gives me another error.
Is it possible to create react app with PnP?

A: After some research, it seems to be a Yarn issue with the v1.12, which version do you have and this link helped you?
https://github.com/facebook/create-react-app/issues/5255

A: Currently i don't use yarn pnp, use pnpm instead if you want to save your storage.
npm i -g pnpm

pnpm will save your disk space out of the box.


text:
Q: Algorithm and Hint for Scientific Calculator I have a Scientific Calculator project using Java Swing. but, I ended up in wrong calculation. Example: If push button:
1 then + then 2 then  * then 3 the answer is 9, not 7.
Could you give me a hint, I must use what classes? And how about the algorithm to make it right answer?
Thank you
class Calculator{
    public static void main(String[] args){
        EventQueue.invokeLater(new Runnable(){
            public void run(){
                CalculatorFrame frame = new CalculatorFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setVisible(true);
                }
            }
        );
    }
}

class CalculatorFrame extends JFrame{
    public CalculatorFrame(){
    setTitle("Calculator");
    CalculatorPanel panel = new CalculatorPanel();
    add(panel);
    pack();
    }
}

class CalculatorPanel extends JPanel{
    public CalculatorPanel(){
        setLayout(new BorderLayout());
        result = 0;
        lastCommand = "=";
        start = true;
        // add the display
        display = new JButton("");
        display.setEnabled(false);
        add(display, BorderLayout.NORTH);
        ActionListener insert = new InsertAction();
        ActionListener command = new CommandAction();
        // add the buttons in a  x  grid
        panel = new JPanel();
        panel.setLayout(new GridLayout(4,4 ));
        addButton("7", insert);
        addButton("8", insert);
        addButton("9", insert);
        addButton("/", command);

        addButton("4", insert);
        addButton("5", insert);
        addButton("6", insert);
        addButton("*", command);

        addButton("1", insert);
        addButton("2", insert);
        addButton("3", insert);
        addButton("-", command);
        addButton("0", insert);
        addButton(".", insert);
        addButton("=", command);
        addButton("+", command);
        add(panel, BorderLayout.CENTER);
    }

    private void addButton(String label, ActionListener listener){
        JButton button = new JButton(label);
        button.addActionListener(listener);
        panel.add(button);
    }

    private class InsertAction implements ActionListener{
        public void actionPerformed(ActionEvent event){
            String input = event.getActionCommand();
            if (start){
                display.setText("");
                start = false;
            }
            display.setText(display.getText() + input);
        }
    }

    private class CommandAction implements ActionListener{
        public void actionPerformed(ActionEvent event) {
            String command = event.getActionCommand();

            if (start){
                if (command.equals("-")){
                display.setText(command);
                start = false;
                }
                else lastCommand = command;
            }
            else{
                calculate(Double.parseDouble(display.getText()));
                lastCommand = command;
                start = true;
            }
        }
    }

    public void calculate(double x){
        if (lastCommand.equals("+")) result += x;
        else if (lastCommand.equals("-")) result -= x;
        else if (lastCommand.equals("*")) result *= x;
        else if (lastCommand.equals("/")) result /= x;
        else if (lastCommand.equals("=")) result = x;
        display.setText("" + result);
    }

    private JButton display;
    private JPanel panel;
    private double result;
    private String lastCommand;
    private boolean start;
}

A: You can also create String with some mathematical task and use it in JavaScript engine to calculate it. More info here.
// create a script engine manager
ScriptEngineManager factory = new ScriptEngineManager();
// create a JavaScript engine
ScriptEngine engine = factory.getEngineByName("JavaScript");

Double d=(Double)engine.eval("1 + 2 * 3");
System.out.println(d);

output 7.0

A: My approach for this would be to represent operations as objects. (Classes like Number, Add, Multiply, that hold the operands as fields and have a getValue() method.) As the user presses buttons (except =), you build up a tree of such objects according to the precedence rules of maths, so you can calculate the result of the whole expression when the user presses =.
Alternatively, store the expression as a string, then parse it in one go in the end.


text:
Q: Trying to build the open source Signal iOS app and connect to my own server I'm trying to build the Signal iOS app to connect to my own Signal server.
I have already successfully built the Signal Android app to connect to my own server.
For both I followed the article,
https://github.com/madeindra/setup-guide/tree/master/signal-ios
Using Signal iOS build 3.13.2.6
XCode 12
I was able to get the app to build in XCode after some effort.
The app ran, got through the verify phone number screen (so I assume was able to hit our server successfully and I got the SMS message through Twilio)
Next was the User info screen asking for name, this crashed with this error,
**Fatal error: [OWSUploadV2.swift:78 upload(data:uploadForm:uploadUrlPath:progressBlock:)]: Error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://xxx.cloudfront.net/, NSErrorFailingURLKey=https://xxx.cloudfront.net/, _NSURLErrorRelatedURLSessionTaskErrorKey=(**
**"LocalUploadTask <2455BE4E-077E-4FD5-B8FA-7F03FD733F70>.<1>"**
**), _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <2455BE4E-077E-4FD5-B8FA-7F03FD733F70>.<1>, NSLocalizedDescription=cancelled}: file SignalCoreKit/OWSSwiftUtils.swift, line 35**

This seemed to be some kind of SSL issue, although opening the cloudfront URL in a browser or in the Android app did not have any issues.
I added the code to OWSUploadV2.swift,
class func upload(data: Data,... {
        var uploadSessionManager = self.uploadSessionManager
        let securityPolicy = AFSecurityPolicy(pinningMode: AFSSLPinningMode.none)
            securityPolicy.validatesDomainName = false
            securityPolicy.allowInvalidCertificates = true
        uploadSessionManager.securityPolicy = securityPolicy

and this seemed to solve the issue, but not sure why the issue occurred...
so this gets me to the next screen for entering a PIN, but this crashed with the error,
**2020-10-08 14:22:10:284 Signal[4202:2191958]**  **[OWSWebSocket.m:605 -[OWSWebSocket processWebSocketResponseMessageAsync:]]: received WebSocket response requestId: 7765599138296075969, status: 200**
**2020-10-08 14:22:10:287 Signal[4202:2191848]** ❤ **[VersionedProfilesImpl.swift:234 didFetchProfile(profile:profileRequest:)]: Invalid credential: VerificationFailed.**
**Fatal error: [VersionedProfilesImpl.swift:234 didFetchProfile(profile:profileRequest:)]: Invalid credential: VerificationFailed.: file SignalCoreKit/OWSSwiftUtils.swift, line 35**

This is where I am stuck. Anyone have any ideas?
Has anyone else successfully got Signal iOS connecting to their own server?
*** some more info
So this error occurs in line 234 of VersionedProfilesImpl.swift didFetchProfile()
in receiveProfileKeyCredential()

let credentialResponse = try ProfileKeyCredentialResponse(contents: UInt8)
let clientZkProfileOperations = try self.clientZkProfileOperations()
let profileKeyCredential = try clientZkProfileOperations.receiveProfileKeyCredential(profileKeyCredentialRequestContext: requestContext, profileKeyCredentialResponse: credentialResponse)

In the server logs I see,
127.0.0.1 - - [16/Oct/2020:14:40:50 +0000] "GET /v1/accounts/apn/preauth/3d80bda824920abd18b41aee5bb2559e01545705d52e7e00da49f3a43a745d96/+16137966017 HTTP/1.1" 200 0 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 9
127.0.0.1 - - [16/Oct/2020:14:40:50 +0000] "GET /v1/accounts/sms/code/+16137966017?client=ios HTTP/1.1" 200 0 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 11
127.0.0.1 - - [16/Oct/2020:14:41:21 +0000] "PUT /v1/accounts/code/443388?transfer=true HTTP/1.1" 200 70 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 153
127.0.0.1 - - [16/Oct/2020:14:41:21 +0000] "PUT /v1/accounts/attributes/ HTTP/1.1" 204 0 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 96
127.0.0.1 - - [16/Oct/2020:14:41:21 +0000] "PUT /v2/keys HTTP/1.1" 204 0 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 24
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "PUT /v1/accounts/apn HTTP/1.1" 204 0 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 111
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "GET /v1/profile/1337589b-38e8-4d09-9ae1-0c362b94ef42/af9e332d7ad279230a009d6ceb08928ce016207edd535d9fcfd5b1a34c76b9e1/0092959035165afc50b3e02c63520618462daec7f9fbe0a33a0fa2a4b5f84b5e4e78a149606a4b2b3e3221dc266093d337bf2cbbd38029bfc0d8d608a4e3945a02f83663dcb4a504c717f63bcdbf89cc86a22aaaa88b15d792fd0a9c6328eb1a475ab4612763ec95b77cf3227bd07b601f9a5b3e3b976987b2d14282227e33dc5b1695eadb513c99c047bb0f5568265d9279b21dc49c9acf7de0f6393fd1230d56a0000000000000007fad1caa1ea858ce6ca91e4db5ab60e2d4b5dba0d561ca1f8da2bbdbefed7c0ed1d630313e05e474b42c95cb6fe42ea38e27a13510ab99170b147372f4270200fc41ae958ed04c10b3fb182f34bb7d27ab030df1ee2aa01bb3da848a6fb14a0e3bc5e1583dadaefa66d3b9232e9ac0f33cc651b7ac01e21320d3d413041ffb091a3756f0eda2cf8ec4d0a2280bffbb40741db358ad4d29ef3be1542aeb59ad0a HTTP/1.1" 200 281 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 110
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "GET /v1/config/ HTTP/1.1" 200 13 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 140
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "GET /v1/websocket/?login=1337589B-38E8-4D09-9AE1-0C362B94EF42&password=0f9a8ed6a5909226b76f520fe7181447 HTTP/1.1" 101 0 "-" "-" 6
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "GET /v1/certificate/delivery?includeUuid=true HTTP/1.1" 200 386 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 2
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "PUT /v1/directory/tokens HTTP/1.1" 200 173 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 9
127.0.0.1 - - [16/Oct/2020:14:41:22 +0000] "GET /v2/attachments/form/upload HTTP/1.1" 200 908 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 117
174.112.230.123 - - [16/Oct/2020:14:41:23 +0000] "GET /v2/attachments/form/upload WS" 200 911 "-" "-"
127.0.0.1 - - [16/Oct/2020:14:41:23 +0000] "GET /v1/certificate/delivery?includeUuid=true HTTP/1.1" 200 386 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 3
174.112.230.123 - - [16/Oct/2020:14:41:23 +0000] "PUT /v1/messages/1337589B-38E8-4D09-9AE1-0C362B94EF42 WS" 200 19 "-" "-"
174.112.230.123 - - [16/Oct/2020:14:41:23 +0000] "GET /v2/attachments/form/upload WS" 200 911 "-" "-"
127.0.0.1 - - [16/Oct/2020:14:41:23 +0000] "GET /v1/certificate/delivery?includeUuid=true HTTP/1.1" 200 386 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 9
127.0.0.1 - - [16/Oct/2020:14:41:24 +0000] "GET /v1/certificate/delivery?includeUuid=true HTTP/1.1" 200 386 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 3
174.112.230.123 - - [16/Oct/2020:14:41:30 +0000] "GET /v2/attachments/form/upload WS" 200 911 "-" "-"
127.0.0.1 - - [16/Oct/2020:14:41:30 +0000] "PUT /v1/profile/ HTTP/1.1" 200 0 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 123
127.0.0.1 - - [16/Oct/2020:14:41:30 +0000] "GET /v1/certificate/delivery?includeUuid=true HTTP/1.1" 200 386 "-" "Signal/3.13.2 (iPhone; iOS 13.7; Scale/2.00)" 6
174.112.230.123 - - [16/Oct/2020:14:41:30 +0000] "GET /v1/profile/1337589b-38e8-4d09-9ae1-0c362b94ef42/af9e332d7ad279230a009d6ceb08928ce016207edd535d9fcfd5b1a34c76b9e1/00bc7024e8593f2ca3665200bc3c71dee84f3524d883fd22edbddc6559efa13618ac2a3736c8086c1aa1bf5751eee2f888889fffc6e1c69f780cc8f3c17a6c1e11dc7f701c382d730165315b30030135fe3f7ff3a3ef8130415ce32af84961022a02f28cea455dd5ab797d27a1387e84c8a9ef67e9f8e643d403f070953402941ea0476ff62c5c035790b6498859327a70700655658cc0c219dcd2e28c2561ac25a000000000000000ed8bc9223598e010648d19f3d3687763ab922475a3359056df73fa88f0652901213e131a46dd57be49160d2b303b724d579d1dabc51f01acb74e2e8976a1d4053787f9c02d5f37535e8fdc0cec7a06fda935f679a479b13bb6e4eb37923ded00bf9dadf786813b400dbad61886132030d881c99860392ddafc33c5bd85bd4f0b4e0165418bb91896a73c726624ee6759c732543d6287ec7162d781532dde1200 WS" 200 997 "-" "-"

Any idea what the cause could be?
I can connect from Android to the same server with the same settings.

A: So I was able to get it to work in the latest XCode.
I think it was meant for XCode 11, so just to get it to compile I had to make changes in,
DebugUIStress.swift
BlurHashEncode.swift
(but if anyone has correct updates to these classes please post)
To get the app to run I made changes in,
OWSUploadV2.swift

*

*ignored SSL certificate error

ClientZkProfileOperations.swift

*

*ignored profile credential errors

KeyBackupService.swift

*

*ignored errors

It is now running, and I can send messages, but still having some issues.

A: It seems like there's a problem uploading something to aws cloudfront. It gives you a -999 error. The -999 error is this one:

-999 is caused by ErrorCancelled. This means: another request is made before the previous request is completed.

Is the program making a request before uploading the profile details to the server?


text:
Q: Simultaneously Output and show the result in R I'm wondering if it would be possible to both show a cat(...) in the console (Rstudio) "AND ALSO" save the file in .txt format?
Here is my R code:
   SOS = 33
    df = 12

  cat("\n","-------------", "\n" ,"SOS  ","  df","\n", "-------------","\n",
       SOS,"    ",df,"\n", "-------------", file = "Output.txt" )

A: SOS = 33
df = 12

#prepare your output
x = paste("\n","-------------", "\n" ,"SOS "," df","\n", "-------------","\n",
                                    SOS," ",df,"\n", "-------------", sep = "")

#display in console
cat(x)
#-------------
#SOS  df
#-------------
#33 12
#-------------

#Write to a txt file
cat(x, file = "output.txt")


text:
Q: Writing a formula and trying to loop it in R    A2.DM19C.MICSw… A2.DM19C.MICSw… A2.IF12C.MICSwm… A2.DM12C.MICSwm… A2.HA12C.MICSwm…
           <dbl>            <dbl>            <dbl>            <dbl>            <dbl>
1           -0.131           0.0516           -0.294             1.29           0.144
2           -0.175          -0.0250           -0.183             1.31           0.146
3           -0.128           0.0691           -0.294             1.31           0.0224
4           -0.175           0.0359           -0.294             1.31           0.136
5           -0.142           0.0169           -0.295             1.31           0.0239
6           -0.252          -0.0918           -0.272             1.33          -0.0263

I have a head of data that looks like this and the dataset is called data_LOG. I want to z-score all these columns. Because there are over 1000 columns, I want to loop the formula so that I can quickly change all these values to a z-score. The equation for z-score is (y-mean(y)/sd(y)). So i made a function called 'zscore'.
zscore <- function(r){
  Cal <- (r-mean(r))/sd(r)
  return(Cal)
}

Which works just fine when tested against the first column. I want the z-score data to be in a new data frame i call dataZ.
dataZ <- data_log

However, when i attempt to loop the formula, i get an error code.
for (i in 1:ncol(data_log)) {
  dataZ[,i] <- zscore(data_log[,i])
}

Error in is.data.frame(x) :
  'list' object cannot be coerced to type 'double'
In addition: Warning message:
In mean.default(r) :
 Show Traceback

Rerun with Debug
Error in is.data.frame(x) :
  'list' object cannot be coerced to type 'double'

I am unsure what this means and how to fix it? please help!

A: If you want to keep your approach try this
dataZ <- NULL
for (i in 1:ncol(df)) {
  z <- zscore(df[[i]])
  dataZ <- cbind(z, dataZ)
}

dataZ <- as.data.frame(dataZ)

A: You could use apply() in combination with standardize()or scale()
dataZ <- apply(data_LOG, 2, scale)   # margins = 2, indicates that the function is applied columns
HTH :)


text:
Q: Uncaught TypeError: Cannot read property 'length' of undefined from props I'm stacked so long.
Regarding to following code, when I get members object from state, it is not recognized as array object.
So I wrote dummy_member from copy text, it works and recognized as array object.
    render() {
        const members = this.props.members; // <- Get from state.
        console.log(members); //Show Array Object (1)
        console.log(members.length); //Error

        const dummy_members = [{xx:xxx},..]; // <- Copied & paste text from JSON data on browser from server.
        console.log(dummy_members); // Show Array Object (2)
        console.log(dummy_members.length); // It shows array length.

both console.log shows following result.
(12) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 3, away_team_p1_shots: 20, away_team_p2_score: 4, …}
1: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 1, away_team_p1_shots: 13, away_team_p2_score: 2, …}
2: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 1, away_team_p1_shots: 15, away_team_p2_score: 2, …}
3: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 2, away_team_p1_shots: 15, away_team_p2_score: 3, …}
4: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 6, away_team_p1_shots: 23, away_team_p2_score: 9, …}
5: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 0, away_team_p1_shots: 10, away_team_p2_score: 2, …}
6: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 1, away_team_p1_shots: 12, away_team_p2_score: 1, …}
7: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 1, away_team_p1_shots: 19, away_team_p2_score: 1, …}
8: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 0, away_team_p1_shots: 10, away_team_p2_score: 2, …}
9: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 3, away_team_p1_shots: 16, away_team_p2_score: 4, …}
10: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 0, away_team_p1_shots: 8, away_team_p2_score: 1, …}
11: {away_team_ot_score: 0, away_team_ot_shots: 0, away_team_p1_score: 0, away_team_p1_shots: 8, away_team_p2_score: 1, …}
length: 12

It seems not to be wrong.
My Question is both members (1) and dummy_members (2) have same console log, however both has different result. members from props (1) had not been recognized as array.
I would like to get members object from this.props.members.
Thanks.

A: If reducer01 does not always contain a members array, then const members = reducer01.members will be undefined and members.length will throw the error you observe.
To guard against undefined, you can use console.log(members && members.length).
(To help you fix the reducer, you will have to share code of the reducer in your question.)


text:
Q: Anaconda import Error I wrote my own module for Aanaconda and placed it into the correct site-package for Anaconda.
The issue I'm having is that Python says the module does not exist even though its saved in site-packages.
So how do I make /anaconda/lib/python2.7/site-packages find my module?

A: Perhaps your module isn't built correctly? Or you are using a different python than the one where you put your module?
Let's confirm the site-packages (and the python).  In your python interpreter do:
import site
site.getsitepackages()

Did that return ['/anaconda/lib/python2.7/site-packages', '/anaconda/lib/site-python']? If it returned a different site-packages folder then put your module there. Perhaps you are using a different python (confirm with which python).
If that looked fine then I would check on your module. Are you sure you have the __init__.py defined? What error did you get?
Try creating a simple test module like:
simple_test/
|-- __init__.py
`-- simple.py

Where simple.py just has:
def print_hello():
    print("hello")

Now copy the whole of simple_test directory into the site-packages directory that we discovered above.  Now do, in the python interpreter, the following:
from simple_test.simple import print_hello
print_hello()

That should work and give a blueprint for how to do this setup.
FYI long term you should probably be building conda packages and installing them instead of doing this copying work.


text:
Q: Positively oriened boundary of Q^3 First, an example in Baby Rudin Chapter 10 says that the positive oriented boundary of Q$^3$ is [e$_1$,e$_2$,e$_3$]-[0,e$_2$,e$_3$]+[0,e$_1$,e$_3$]-[0,e$_1$,e$_2$].   Any further explanation? How can we tell it is a positively oriented boundary?
Second, let J$^2$=F$_1$+F$_2$, where F$_1$=[0,e$_1$,e$_1$+e$_2$], F$_2$=-[0,e$_2$,e$_2$+e$_1$], why we can say J$^2$ is the positively oriented unit square in R$^2$? By drawing a picture, I can see that range of J$^2$ covers the unit square, but why it is a positively oriented boundary?


text:
Q: JQUERY AJAX and SELECT ELEMENT on JSP Here is my question. I have ajax call which gives one of the value that i need to display on the select field of JSP page and remaining values that i added to model object.
Here is the snippet. if anyone one helps that would be great.
JSP:-
 <select class="form-control  mb-6 mr-sm-2" name="parRole" required id="inputSuccess3" style="width:225px;">

    <c:forEach var="role" items="${allParRolesList}">
      <option  value="${role.roleId}" >${role.roleName}</option>
    </c:forEach>
     </select>

JQUERY-AJAX:
 $.ajax({
    type:"GET",
    dataType:"text",
    contentType: "application/json",
    url:url,
    data: "",
    success:function(data){
    console.log(data);
     $('[name="parRole"] option').filter(function(){
     this.value==dataout.parRole.roleId
    }).prop('selected',true);

  }

Controller:
public @ResponseBody  ParMaster getParDetails(@PathVariable("parNo") String parNo,HttpServletRequest request) throws Exception {
    ModelAndView modelView  = new ModelAndView();
    modelView.addObject("allParRolesList", parRoleServiceImpl.getActiveParRoles());
    modelView.setViewName("paredit");
    return pareditserviceImpl.getParDetails(parNo);
}


text:
Q: onclick and function calling using reactjs when ever i click the student button it should call the function inside that i have called the other component, but i am getting error. what should i do to call other component by onlick .
   import React from 'react';
//import s from './style.css';
import Students from './students.js'
require('./style.scss');
class Display extends React.Component {

  function  studentfunction(){
  <Students/>
  };
  render()
  {

    return(

      {this.state.clicked ? <Students/>}

Dashboard

    <input  type="button" value="Students" onClick={this.studentfunction} />
     <input type="button" value="Teachers" />

     <input type="button" value="Inbox" />

    <input type="button" value="Holidays" />
     <input type="button" value="Circular" />

     <input type="button" value="Notifications" />

     <input type="button" value="Events" />

       <input type="button" value="Gallery" />

    );
  }
}
export default Display

;

A: What you need is not an onClick handler on the button but a Link to route to the correct component
Try and specify route for Student component
and then use
<button type="button"><Link to="/Students">Students</Link>

onClick expects a function and not a component that is why you get an error

A: The best way is to use react-router library. I highly recommend you to follow the tutorial.
You will get something like this after setting up react-router in your app.
  <Router history={hashHistory}>
    <Route path="/" component={App}/>
    <Route path="/students" component={Students}/>
  </Router>

The next step is to use Link component from react-router.
// modules/App.js
import React from 'react'
import { Link } from 'react-router'

export default React.Component {
  render() {
    return (

Your App

<Link to="/about">About</Link>

<Link to="/students">Students</Link>

    )
  }
}


text:
Q: Blob to Uint8Array without callback Is it possible to convert a Blob to Uint8Array without using a callback and just using JavaScript?
How to return the uint8array for the calling variable uint8data?
let str='content';

str2blob=(str,type='text/plain')=>new Blob([str],{type:type});

let blob=str2blob(str);

function blob2uint(blob){
    new Response(blob).arrayBuffer().then(buffer=>{
        uint=[...new Uint8Array(buffer)];
        console.log("Uint8Array",uint);
        return uint;
    });
}

let uint8data=blob2uint(blob);
console.log(uint8data); //Show Uint8Array

A: Assuming this is somewhere inside a function, you can make it async and use await to wait for the Promise to complete once you return it from the blob2uint function:
async function myBlobToUIntDemo() {
  let str='content';

  str2blob=(str,type='text/plain')=>new Blob([str],{type:type});

  let blob=str2blob(str);

  function blob2uint(blob){
      return new Response(blob).arrayBuffer().then(buffer=>{
          uint=[...new Uint8Array(buffer)];
          console.log("Uint8Array",uint);
          return uint;
      });
  }

  let uint8data = await blob2uint(blob);
  console.log(uint8data); //Show Uint8Array
}

Let's spike this up with some more information:
Why do I need a callback in the first place?
Because you are doing asynchronous work by pulling the arrayBuffer from a response. JavaScript (as far as I know) only runs in a single thread. Waiting for a website in your code without using a callback would halt all other JavaScript execution on your page if you didn't put it in the background somehow; that's what callbacks and Promises do for you (from the outside at least).
Promises?
Functions doing asynchronous work typically return a Promise object, that promises to provide you with the value once the work completes (by calling the function passed in the then callback with it) or an error in case something goes wrong (by calling the catch callback with it).
async / await
async / await was introduced to make working with Promises a bit nicer and readable, reducing the need for callbacks a lot. You can read more about that in this MDN article.
The code block above only contains the bare minimum changes to get things working. Let's simplify that a bit more!
async function myBlobToUIntDemo() {
  let str = 'content';
  let str2blob = (str, type = 'text/plain') => new Blob([str], { type: type });
  let blob = str2blob(str);

  const buffer = await new Response(blob).arrayBuffer();
  const uint = [...new Uint8Array(buffer)];

  console.log(uint);
}

Note that this returns a Promise as well (this automatically happens if you mark your function as async) so make sure to remember that if you were to use this function anywhere in your code.


text:
Q: iOS Pinch Scale and Two Finger Rotate at same time Here is my code:
viewDidLoad:
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinch:)];
[self.canvas addGestureRecognizer:pinch];
pinch.delegate = self;

UIRotationGestureRecognizer *twoFingersRotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(pinchRotate:)];
[[self canvas] addGestureRecognizer:twoFingersRotate];

twoFingersRotate.delegate = self;

Code For Pinches and Rotates:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

-(void)pinchRotate:(UIRotationGestureRecognizer*)rotate
{
    SMImage *selectedImage = [DataCenter sharedDataCenter].selectedImage;

    switch (rotate.state)
    {
        case UIGestureRecognizerStateBegan:
        {
            selectedImage.referenceTransform = selectedImage.transform;
            break;
        }
        case UIGestureRecognizerStateChanged:
        {
            selectedImage.transform = CGAffineTransformRotate(selectedImage.referenceTransform, ([rotate rotation] * 55) * M_PI/180);
            break;
        }

        default:
            break;
    }
}

-(void)pinch:(UIPinchGestureRecognizer*)pinch
{
    SMImage *selectedImage = [DataCenter sharedDataCenter].selectedImage;
    [self itemSelected];

    switch (pinch.state)
    {
        case UIGestureRecognizerStateBegan:
        {
            selectedImage.referenceTransform = selectedImage.transform;
            break;
        }
        case UIGestureRecognizerStateChanged:
        {
            CGAffineTransform transform = CGAffineTransformScale(selectedImage.referenceTransform, pinch.scale, pinch.scale);
            selectedImage.transform = transform;
            break;
        }

        default:
            break;
    }
}

My rotation works great on its own and my scale works great on its own, but they wont work together. One always works or the other doesn't.  When I implement shouldRecognizeSimultaneouslyWithGestureRecognizer the two gestures seem to fight against each other and produce poor results.  What am I missing? (Yes I have implemented <UIGestureRecognizerDelegate>)

A: For this to happen you need to implement gesture delegate shouldRecognizeSimultaneouslyWithGestureRecognizer and put what gestures you would like to recognize simultaneously.
// ensure that the pinch and rotate gesture recognizers on a particular view can all recognize simultaneously
// prevent other gesture recognizers from recognizing simultaneously
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    // if the gesture recognizers's view isn't one of our views, don't allow simultaneous recognition
    if (gestureRecognizer.view != firstView && gestureRecognizer.view != secondView)
        return NO;

    // if the gesture recognizers are on different views, don't allow simultaneous recognition
    if (gestureRecognizer.view != otherGestureRecognizer.view)
        return NO;

    // if either of the gesture recognizers is the long press, don't allow simultaneous recognition
    if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] || [otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]])
        return NO;

    return YES;
}

This code needs to be modified to the view for which you want simultaneous gesture recognisers. The above code is what you need.

A: Every time pinch: is called, you just compute the transform based on the pinch recognizer's scale.  Every time pinchRotate: is called, you just compute the transform based on the rotation recognizer's rotation.  You never combine the scale and the rotation into one transform.
Here's an approach.  Give yourself one new instance variable, _activeRecognizers:
NSMutableSet *_activeRecognizers;

Initialize it in viewDidLoad:
_activeRecognizers = [NSMutableSet set];

Use one method as the action for both recognizers:
- (IBAction)handleGesture:(UIGestureRecognizer *)recognizer
{
    SMImage *selectedImage = [DataCenter sharedDataCenter].selectedImage;

    switch (recognizer.state) {
        case UIGestureRecognizerStateBegan:
            if (_activeRecognizers.count == 0)
                selectedImage.referenceTransform = selectedImage.transform;
            [_activeRecognizers addObject:recognizer];
            break;

        case UIGestureRecognizerStateEnded:
            selectedImage.referenceTransform = [self applyRecognizer:recognizer toTransform:selectedImage.referenceTransform];
            [_activeRecognizers removeObject:recognizer];
            break;

        case UIGestureRecognizerStateChanged: {
            CGAffineTransform transform = selectedImage.referenceTransform;
            for (UIGestureRecognizer *recognizer in _activeRecognizers)
                transform = [self applyRecognizer:recognizer toTransform:transform];
            selectedImage.transform = transform;
            break;
        }

        default:
            break;
    }
}

You'll need this helper method:
- (CGAffineTransform)applyRecognizer:(UIGestureRecognizer *)recognizer toTransform:(CGAffineTransform)transform
{
    if ([recognizer respondsToSelector:@selector(rotation)])
        return CGAffineTransformRotate(transform, [(UIRotationGestureRecognizer *)recognizer rotation]);
    else if ([recognizer respondsToSelector:@selector(scale)]) {
        CGFloat scale = [(UIPinchGestureRecognizer *)recognizer scale];
        return CGAffineTransformScale(transform, scale, scale);
    }
    else
        return transform;
}

This works if you're just allowing rotating and scaling.  (I even tested it!)
If you want to add panning, use a separate action method and just adjust selectedImage.center.  Trying to do panning with rotation and scaling using selectedImage.transform is much more complicated.

A: Swift 3 with Pan, Rotate and Pinch
// MARK: - Gesturies

    func transformUsingRecognizer(_ recognizer: UIGestureRecognizer, transform: CGAffineTransform) -> CGAffineTransform {

        if let rotateRecognizer = recognizer as? UIRotationGestureRecognizer {
            return transform.rotated(by: rotateRecognizer.rotation)
        }

        if let pinchRecognizer = recognizer as? UIPinchGestureRecognizer {
            let scale = pinchRecognizer.scale
            return transform.scaledBy(x: scale, y: scale)
        }

        if let panRecognizer = recognizer as? UIPanGestureRecognizer {
            let deltaX = panRecognizer.translation(in: imageView).x
            let deltaY = panRecognizer.translation(in: imageView).y
            return transform.translatedBy(x: deltaX, y: deltaY)
        }

        return transform
    }

    var initialTransform: CGAffineTransform?

    var gestures = Set<UIGestureRecognizer>(minimumCapacity: 3)

    @IBAction func processTransform(_ sender: Any) {

        let gesture = sender as! UIGestureRecognizer

        switch gesture.state {

        case .began:
            if gestures.count == 0 {
                initialTransform = imageView.transform
            }
            gestures.insert(gesture)

        case .changed:
            if var initial = initialTransform {
                gestures.forEach({ (gesture) in
                    initial = transformUsingRecognizer(gesture, transform: initial)
                })
                imageView.transform = initial
            }

        case .ended:
            gestures.remove(gesture)

        default:
            break
        }
    }

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {

        return true
    }

A: This example does not use gesture recognizers, and directly computes the transformation matrix. It also properly handles one-to-two finger transitions.
class PincherView: UIView {

    override var bounds :CGRect {
        willSet(newBounds) {
            oldBounds = self.bounds
        } didSet {
            self.imageLayer.position = ┼self.bounds
            self._adjustScaleForBoundsChange()
        }
    }
    var oldBounds :CGRect

    var touch₁  :UITouch?
    var touch₂  :UITouch?
    var p₁      :CGPoint?  // point 1 in image coordiate system
    var p₂      :CGPoint?  // point 2 in image coordinate system
    var p₁ʹ     :CGPoint?  // point 1 in view coordinate system
    var p₂ʹ     :CGPoint?  // point 2 in view coordinate system

    var image   :UIImage? {
        didSet {self._reset()}
    }
    var imageLayer :CALayer
    var imageTransform :CGAffineTransform {
        didSet {
            self.backTransform = self.imageTransform.inverted()
            self.imageLayer.transform = CATransform3DMakeAffineTransform(self.imageTransform)
        }
    }
    var backTransform  :CGAffineTransform
    var solutionMatrix :HXMatrix?

    required init?(coder aDecoder: NSCoder) {
        self.oldBounds = CGRect.zero
        let layer = CALayer();
        self.imageLayer = layer
        self.imageTransform = CGAffineTransform.identity
        self.backTransform = CGAffineTransform.identity

        super.init(coder: aDecoder)

        self.oldBounds = self.bounds
        self.isMultipleTouchEnabled = true
        self.layer.addSublayer(layer)
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        for touch in touches {
            let pʹ = touch.location(in: self).applying(self._backNormalizeTransform())
            let p = pʹ.applying(self.backTransform)
            if self.touch₁ == nil {
                self.touch₁ = touch
                self.p₁ʹ = pʹ
                self.p₁ = p
            } else if self.touch₂ == nil {
                self.touch₂ = touch
                self.p₂ʹ = pʹ
                self.p₂ = p
            }
        }
        self.solutionMatrix = self._computeSolutionMatrix()
    }

    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        for touch in touches {
            let pʹ = touch.location(in: self).applying(self._backNormalizeTransform())
            if self.touch₁ == touch {
                self.p₁ʹ = pʹ
            } else if self.touch₂ == touch {
                self.p₂ʹ = pʹ
            }
        }

        CATransaction.begin()
        CATransaction.setValue(true, forKey:kCATransactionDisableActions)
        // Whether you're using 1 finger or 2 fingers
        if let q₁ʹ = self.p₁ʹ, let q₂ʹ = self.p₂ʹ {
            self.imageTransform = self._computeTransform(q₁ʹ, q₂ʹ)
        } else if let q₁ʹ = (self.p₁ʹ != nil ? self.p₁ʹ : self.p₂ʹ) {
            self.imageTransform = self._computeTransform(q₁ʹ, CGPoint(x:q₁ʹ.x + 10, y:q₁ʹ.y + 10))
        }
        CATransaction.commit()
    }

    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        for touch in touches {
            if self.touch₁ == touch {
                self.touch₁ = nil
                self.p₁ = nil
                self.p₁ʹ = nil
            } else if self.touch₂ == touch {
                self.touch₂ = nil
                self.p₂ = nil
                self.p₂ʹ = nil
            }
        }
        self.solutionMatrix = self._computeSolutionMatrix()
    }

    //MARK: Private Methods

    private func _reset() {
        guard
            let image = self.image,
            let cgimage = image.cgImage else {
                return
        }

        let r = CGRect(x:0, y:0, width:cgimage.width, height:cgimage.height)
        imageLayer.contents = cgimage;
        imageLayer.bounds = r
        imageLayer.position = ┼self.bounds
        self.imageTransform = self._initialTransform()
    }

    private func _normalizeTransform() -> CGAffineTransform {
        let center = ┼self.bounds
        return CGAffineTransform(translationX: center.x, y: center.y)
    }

    private func _backNormalizeTransform() -> CGAffineTransform {
        return self._normalizeTransform().inverted();
    }

    private func _initialTransform() -> CGAffineTransform {
        guard let image = self.image, let cgimage = image.cgImage else {
            return CGAffineTransform.identity;
        }
        let r = CGRect(x:0, y:0, width:cgimage.width, height:cgimage.height)
        let s = r.scaleIn(rect: self.bounds)
        return CGAffineTransform(scaleX: s, y: s)
    }

    private func _adjustScaleForBoundsChange() {
        guard let image = self.image, let cgimage = image.cgImage else {
            return
        }
        let r = CGRect(x:0, y:0, width:cgimage.width, height:cgimage.height)
        let oldIdeal = r.scaleAndCenterIn(rect: self.oldBounds)
        let newIdeal = r.scaleAndCenterIn(rect: self.bounds)
        let s = newIdeal.height / oldIdeal.height
        self.imageTransform = self.imageTransform.scaledBy(x: s, y: s)
    }

    private func _computeSolutionMatrix() -> HXMatrix? {
        if let q₁ = self.p₁, let q₂ = self.p₂ {
            return _computeSolutionMatrix(q₁, q₂)
        } else if let q₁ = self.p₁, let q₁ʹ = self.p₁ʹ {
            let q₂ = CGPoint(x: q₁ʹ.x + 10, y: q₁ʹ.y + 10).applying(self.backTransform)
            return _computeSolutionMatrix(q₁, q₂)
        } else if let q₂ = self.p₂, let q₂ʹ = self.p₂ʹ {
            let q₁ = CGPoint(x: q₂ʹ.x + 10, y: q₂ʹ.y + 10).applying(self.backTransform)
            return _computeSolutionMatrix(q₂, q₁)
        }
        return nil
    }

    private func _computeSolutionMatrix(_ q₁:CGPoint, _ q₂:CGPoint) -> HXMatrix {
        let x₁ = Double(q₁.x)
        let y₁ = Double(q₁.y)
        let x₂ = Double(q₂.x)
        let y₂ = Double(q₂.y)
        let A = HXMatrix(rows: 4, columns: 4, values:[
            x₁, -y₁, 1, 0,
            y₁,  x₁, 0, 1,
            x₂, -y₂, 1, 0,
            y₂,  x₂, 0, 1
        ])
        return A.inverse()
    }

    private func _computeTransform(_ q₁ʹ:CGPoint, _ q₂ʹ:CGPoint) -> CGAffineTransform {
        guard let solutionMatrix = self.solutionMatrix else {
            return CGAffineTransform.identity
        }

        let B = HXMatrix(rows: 4, columns: 1, values: [
            Double(q₁ʹ.x),
            Double(q₁ʹ.y),
            Double(q₂ʹ.x),
            Double(q₂ʹ.y)
            ])
        let C = solutionMatrix ⋅ B

        let  U = CGFloat(C[0,0])
        let  V = CGFloat(C[1,0])
        let tx = CGFloat(C[2,0])
        let ty = CGFloat(C[3,0])

        var  t :CGAffineTransform = CGAffineTransform.identity
        t.a  =  U; t.b  = V
        t.c  = -V; t.d  = U
        t.tx = tx; t.ty = ty

        return t
    }
}


text:
Q: Not able to filter search result using searchable plugin I have been using Searchable to search contacts created by a user. So far, it is working fine. Now I want to implement filtration, like search those contacts which are "Buyer" type of contacts. For this, first the user has to select "Contact Type" from select box and search contacts by name.
My problem is it shows search results but they aren't filtered by Contact Type. Like when I select "Contact_Type" as "Buyer" and name as "vim", it shows search result with vim but without filtering on Contact_Type.
Search method in ContactController:
def search = {
    def query =  params.q
    def filterContact = params.filter

    if(query && filterContact){
        def srchResults = searchableService.search(query, filterContact)
        render(view: "list",
            model: [contactInstanceList: srchResults.results,
            contactInstanceTotal:srchResults.total])
    }
    else{
        render "not record found";
    }
}

Select box
<g:select style=" background:transparent;border:none;margin-bottom:10px;color:#787878;"  from="${com.vproc.enquiry.ContactType?.values()}"
            noSelection="['':'Search By']" value="${contactInstance?.contactType?.values()}" name="filter" />

JS method to redirect to search results:
<script type="text/javascript">
    function showContact(id){
        document.location.href ='/VProcureFinal/contact/search?q=' + $("#"+ id).val()
            + "&filter=" + $("#filter").val();
    }
</script>

Suppose I create a contact whose name is "Vim" and contact_type is "Buyer". When I search it with contact_type="Seller" and name="Vim', it still shows search result but it should not show this. Does anyone have any idea how to do this?


text:
Q: Having only specific column selectable JTable and/or getting the data from only one column I have a Swing program with a JTable, and there are two columns: one for names, and one for phone numbers associated with those names. Currently, the program allows for selection of rows, which causes data in both columns to become selected. I want selected data to be output to an array of strings, but only the data from within a certain column (that with phone numbers), no matter how many rows are selected. How would I go about this?
I was thinking of changing setColumnSelectionAllowed(false) to setColumnSelectionAllowed(true) and allowing a JHeader to be clicked to select an entire row, or somehow allowing for getValueAt(int row, int column) to be put into an array and only allow for reading of the phone numbers column.
Code for initializing table:
        // Initializing the JTable
        String[] columns = {"Student", "Phone"};
        students = new JTable(data, columns);
        students.setGridColor(Color.lightGray);
        students.setPreferredScrollableViewportSize(new Dimension(500, 400));
        TableColumnModel columnModel = students.getColumnModel();
        columnModel.getColumn(0).setPreferredWidth(100);
        columnModel.getColumn(1).setPreferredWidth(100);
        students.setRowHeight(25);
        students.setFillsViewportHeight(true);
        students.setRowSelectionAllowed(true);
        students.setColumnSelectionAllowed(false);
        students.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

Table is made from CSV file as an array:
        String[][] myNewArray1 = new String[30][30]; //creates an array
        Scanner myScanner1 = new Scanner(filePath1); //creates a scanner which uses the text file
        int k = 0;
        while (myScanner1.hasNext()) {
            myNewArray1[k] = myScanner1.nextLine().split(",");
            k++;
        }
        return (myNewArray1);
    }

    // Driver method
    public static void main(String[] args) throws Exception {
        File filePath1 = new File("C:\\Users\\cmorl\\IdeaProjects\\CompSciIA\\src\\CompSciIA.csv"); //file path
        String[][] data1;
        data1 = makeArrayFromTxt(filePath1);
        new Database(data1);
    }

A:  TableModel model =  table.getModel();
  List <String> data = new ArrayList();
  for (int count = 0; count < model.getRowCount(); count++){
                  data.add(model.getValueAt(count, 0).toString()); //Change 0 with 1 if you want column 2
   }


text:
Q: Return results when size range has one or more values greater than 0 I have a ledger entry table used to calculate item stock (where sales and returns are summed to calc current stock).
It seems pretty straight forward to sum this quantity column using:
select [Item Ledger].[Location],[Item].[Item Division Code],
[Ledger Entry].[Item],[Variant Code],
SUM([Item Ledger].[Quantity]) as 'stock'
from [Item Ledger]
join [Item] on [Ledger Entry].[Item] = [Item].[no_]
where [Item Ledger].[Location Code] = 'xx'
group by [Item Ledger].[Location],[Item Ledger].[Item],
[Variant Code],[Item].[Item Division Code]
order by [Item Ledger Entry].[Item]

What i'm trying to see is a list where the item may have 1 or more variants in stock but the other variants may have 0 in stock. At the moment I can either return all 0 stock/all stock or all stock that has a value. I can't see how to return items that have variants with both zero and a value (but exclude all items that only have 0 against the variants)
eg
I may have one shirt (shirt 1) with variant codes (sizes) small (s), medium(m), large (l)
running the code above, It may show I have 2 small, 1 medium and 0 large in stock
it may also show for shirt2 I have 0 small, 0 medium and 0 large
What i would like to see is only shirt1 as i am not interested in styles that have only 0 values across the whole size range.

A: Okay, I think I understand the question. Right now your data looks like:

Item      Varient     Stock
Shirt1        S           2
Shirt1        M           1
Shirt1        L           0
Shirt2        S           0
Shirt2        M           0
Shirt2        L           0
Shirt3        M           2
Shirt4        L           0
Shirt5        S           1
Shirt5        M           2
Shirt5        L           4

However, you only want the data for Shirt1. You aren't interested in shirt3 or shirt4 because there is only one varient, so they just don't fit. You don't want shirt2 because there isn't anything in stock, and you don't want shirt5 because there isn't anything out of stock. Here is the approach that I recommend:
select  il.Location,
        i.ItemDivisionCode,
        il.Item,
        VariantCode,
        SUM(il.Quantity) as 'stock'
 from ItemLedger il
 join Item i
    on il.Item = i.no_
where il.LocationCode = 'xx'
and Case When ( Select sum(1)
                 From ItemLedger il2
                Where   il2.item = il.item
                 and    il2.quantity = 0
                Group by il2.item) > 0
    Then ISNULL(
                    (Select sum(1)
                      From  ItemLedger il2
                     Where  il2.item = il.item
                      and   il2.quantity > 0
                     Group by il2.item)
                , 0)
    Else 0
    End > 0

group by    il.Location,
            il.Item,
            VariantCode,
            i.ItemDivisionCode
order by il.Item

Now, let's talk about what this query means. To start off with, I grabbed the query that you posted and added aliases. Aliases are essentially giving a table a nickname. Instead of referencing the table name over and over again, you can use the alias and sql will know what you are talking about.
Now, the meat of what you are looking for is in the where clause, namely the case statement. A case statement is essentially sql's version of an if... then... else... statement. The first part of the case statement is the condition.
Case When ( Select sum(1)
                     From ItemLedger il2
                    Where   il2.item = il.item
                     and    il2.quantity = 0
                    Group by il2.item) > 0

In this case, the condition is a subquery. This subquery is looking in the item legder table for all the items of the same type as the row we are currently looking at with 0 as the quantity in stock. So, for shirt1 this subquery will return 1. For shirt2, this subquery is going to bring back 3. Now the condition part comes in. If the value we get back is greater than 0, we're going to move on to the next part of the case statement.
Then ISNULL(
            (Select sum(1)
              From  ItemLedger il2
             Where  il2.item = il.item
              and   il2.quantity > 0
             Group by il2.item)
            , 0)

Now we are looking to see how many varients there are that are in stock. For shirt1, this subquery is going to pull back 2. For shirt2, this query will pull back null. Why? Well, the subquery is saying to count how many rows there are that have a quantity greater than 0. Shirt2 doesn't have any rows with a quantity greater than 0. If we were to run the subquery itself, we just wouldn't get any information. How can you sum no information? Luckily for us, we can handle this. The ISNULL says, if this query doesn't bring anything back, let's just say that it brought back 0.
What happens where the 'if' part of our case statement comes back as false? Instead of going to the 'then' part of the case statement, we are going to head here:
Else 0

This really does just say return 0 as a number. Then, we are done with the case statement because we have covered all of our bases. Now, we aren't completely done yet. The case statement is contained in the where clause. We have said
and --the case statement

Everything in the where clause must return true or false, we cannot evaluate and 0 or and 12. So, we have to do something with the information we just found to make the result a boolean. We do this by requiring the result of the case statement to be greater than 0. I'm sure right now you are thinking "will this work?"
It actually will. Here's why. If the item doesn't have a varient where the stock is 0, we will get 0 from the case and rule that out (since 0 isn't greater than 0). If the item does have a varient with stock 0, we are checking if they have something with stock greater than 0. If they don't, we still return 0 and rule that out.
This may seem like a convoluted answer to a simple problem, but in reality the problem is not so simple. You are asking about information about different data points. What you are trying to do is like asking your friend Joe if Steve is going to the movies tonight. Joe doesn't know anything about Steve. The only way to get that information is by reaching out to Steve and finding out the information from him. The subqueries essentially do that by pulling data from completely different select statements.


text:
Q: Adding a Button on a View I am going nuts over this.
I did not find any working solution (tried a few from stackoverflow)
Scenario (this is an actual screenshot what is already done):

I have a Activity that has a View as his Attribute.
This view adds another view via View.addView(myView).
I now want to add a Button to myView (to be specific: after MotionEvent.ACTION_UP the button should appear in the right lower corner (this will start the robot to drive the track))
Here is a shortcut of my code:
public class ModeRouting extends View {
public ModeRouting(Context context) {
    super(context);
Button asuroStartButton = new Button(context) //does not work
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    int actionevent = event.getAction();
    if (actionevent == MotionEvent.ACTION_UP
            || actionevent == MotionEvent.ACTION_CANCEL) {
asuroStartButton.visible=true;
view.add(asuroStartButton);
    }
    return true;
}
}

and my Activity:
//in constructor
contentView = (FrameLayout) findViewById(R.id.content);
onClickListenerFacade(routingMode, route);

//this removes all views from stack and places the new one on the view
private void onClickListenerFacade(View v, final View target) {
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            contentView.removeAllViews();
            contentView.setBackgroundColor(0xff000000);
            contentView.addView(target);
            modeSelectorAnimation();
        }
    });
}

I tried to create a button in my mainactivity.xml  and instantiate in my mainactivity.
I am missing some point in here but i am not sure which.
Since my view is purely dynamic (no layout.xml) i dont think i should use a layout.xml (maybe thats my mind-blockage) but instead set the button attributes dynamically too.
Any hint is appreciated!

A: You want to extend ViewGroup rather than just a View (LinearLayout, RelativeLayout, FrameLayout, etc) - they handle child views for you.

A: I think maybe you need to refresh the whole view/activity. Try to do this in the onResume methode, maybe this helps. But as you don't use a layout.xml, I'm not sure if this helps you much..
@Override
protected void onResume(){
super.onResume();
setContentView(R.layout.activity_main);
}


text:
Q: How to change cpu frequency using c code? I am working on an energy saving algorithm for which I want to change the frequency of the CPU for saving the energy so I need C code so that I can change the frequency of the CPU.I tried below code, but the problem with the code is that it directly execute the Linux command and the command needs root permission.Is there any way to change the CPU frequency using C code.
My Code is...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 int main(){
     char cmd[]="sudo cpufreq-set -c 1 -f 1862Mhz";
     system(cmd);
     return 0;
}

A: This is the kernel's job to throttle up and down the CPU frequency.
As a user space application you don't have enough information about other processes that currently use the system.
even f if you run as root and you have the ability to issue such a command, the whole concept is wrong.
look for DVFS kernel drivers, that's how you do it.


text:
Q: Listing of Directories A user wants to make sense of a very messy Windows shared drive, and asked for a way to print out all the directories together with their subdirectories.
Is there any way to do that?

A: I have never tried this but in theory can you not use command prompt (cmd) then change to the directory you require....run the following
tree > tree.txt

this would make you a file named tree.txt listing the tree of the directory it was run from
or another would be (replace Folder with the folder in question)
dir /d /s C:\Folder > C:\mydir.txt

This would make a file name mydir.txt in the root of C:\
hope that helps.

A: Have a look at Treesize Free.  It'll show you the directory structure, and how much space each folder is using of the total disk size.  Very handy tool for shared drive cleanups.

(source: jam-software.com)

A: Not an answer to the exact question but also useful for making sense of drives is https://windirstat.info/

A: Use the command:
dir /S /B /A:D


text:
Q: vba excel how to paste values without font/color/bg color formatting I've got a macro to copy a summary row from each of a series of worksheets. The summary row is specially formatted with font/font color/bg color, but when pasted into the 'sumamry sheet', it needs to just paste values without formatting.
For LoopIndex = StartIndex To EndIndex
    ' start in a task sheet
    Sheets(LoopIndex).Select
    CopiedCells = ActiveSheet.Range("A156:L156").Copy

    ' now move to Summary sheet
    Sheets("Summary Sheet").Select
    ActiveSheet.Range("A8").Select
    ActiveCell.EntireRow.Insert

    ActiveCell.PasteSpecial Paste:=xlPasteValues
    ' tried variations of: ActiveCell.PasteSpecial paste:=xlValues, operation:=xlPasteSpecialOperationNone

    Application.CutCopyMode = False ' clears clipboard
Next LoopIndex

All the research I've done says the PastSpecial, xlValues, xlPasteValues should work but nothing strips the formatting, don't know what I'm doing wrong here. It does paste the values rather than the referenced values, so that is good. I have a macro to reset the formatting in loop but I'd like to make more efficient. I'm using Excel 2007.

A: That's really odd!
The reason is that you are Copying, Inserting and then Pasting.  Try Insert, Copy and then Paste:
'we must commence on the Summary Sheet
Sheets("Summary Sheet").Select
For LoopIndex = StartIndex To EndIndex

    ' insert the row before we start
    ActiveSheet.Range("A8").Select
    ActiveCell.EntireRow.Insert

    ' select the task sheet
    Sheets(LoopIndex).Select
    CopiedCells = ActiveSheet.Range("A156:L156").Copy

    ' now move to Summary sheet
    Sheets("Summary Sheet").Select

    ActiveCell.PasteSpecial Paste:=xlPasteValues
    ' tried variations of: ActiveCell.PasteSpecial paste:=xlValues, operation:=xlPasteSpecialOperationNone

    Application.CutCopyMode = False ' clears clipboard
Next LoopIndex

For what it's worth, I've had problems using copy & paste.  It means that while your macro is running, you can't do much else.
Since it is a fixed range, I would suggest this:
For LoopIndex = StartIndex To EndIndex
    Sheets("Summary Sheet").Range("A8").EntireRow.Insert
    For i = 1 To 12
        Sheets("Summary Sheet").Cells(8, i) = Sheets(LoopIndex).Cells(156, i)
    Next
Next

A: ActiveSheet.Range("A1").EntireRow.Copy
ActiveSheet.Range("A2").EntireRow.PasteSpecial xlPasteValues
Application.CutCopyMode = False

or
ActiveSheet.Range("A2").EntireRow.Value = ActiveSheet.Range("A1").EntireRow.Value

Replace A1 with your source and A2 with your target.

A: Once I selected the range then I put this  Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Works fine for me :)


text:
Q: C# XSL Transformation Breaks Encoding SOLVED
Long story short, don't use CDATA in your XSL transformation.  Read on for details.
Background
Standard C# application saves an object to and XML file using the XmlSerializer.  I need to grab that saved XML file, add the reference to the XSL transformation, apply said transformation, then save as .graphml
Problem
Currently my output seems to have improper encoding.  The < and > signs are represented as "&lt" and "&gt" which is not valid graphml (or xml for that matter)
Details
Here is what the output file looks like at the moment:
<?xml version="1.0" encoding="utf-8"?>

<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
 http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">

<graph id="G" edgedefault="undirected">

        <node id="n1"/>

            <edge source="n1" target="n2"/>

            <edge source="n1" target="n3"/>

            <edge source="n1" target="n5"/>

            <edge source="n1" target="n7"/>

            <edge source="n1" target="n9"/>

        <node id="n2"/>

            <edge source="n2" target="n1"/>

            <edge source="n2" target="n9"/>

For what it's worth, I know that the XML that I'm transforming is valid (and in the proper format), and I know that the xsl file is valid and working properly because I can use it on other files just fine.  Something about the way the XSL transformation is applied by C# is causing this issue.  Here is the relevant code:
// Create an XML writer
        XmlSerializer writer = new XmlSerializer(typeof(formattedMeshNet));

        var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\netTransform.xml";
        var transformPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\GraphFormatTransform.xsl";
        var savePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ExportedNetwork.graphml";

        System.IO.FileStream file = System.IO.File.Create(path);

        writer.Serialize(file, saveMe);
        file.Close();

        // Add style sheet association
        XmlDocument xDoc = new XmlDocument();
        var transformAssn = xDoc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"GraphFormatTransform.xsl\"");
        xDoc.AppendChild(transformAssn);

        // Load xml just saved
        System.Xml.Xsl.XslCompiledTransform myXslTransform;

        myXslTransform = new System.Xml.Xsl.XslCompiledTransform();

        myXslTransform.Load(transformPath);
        myXslTransform.Transform(path, savePath);

Any ideas would be appreciated!  Feel free to ask nicely for details which will be happily provided if you see I've left out anything :)
Potentially related issue which didn't really tell me anything, but you might get something useful:
XSL transformation give me wrong encoding
I also tried doing what was suggested here:
The XslCompiledTransform output encoding
Thanks!
** EDIT **
Per request, here is the full XML document and associated XSL transformation
    <?xml version="1.0"?>
<formattedMeshNet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <contents>
    <node>
      <nodeID>1</nodeID>
      <physNeighbors>
        <int>4</int>
        <int>6</int>
        <int>7</int>
        <int>8</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>2</nodeID>
      <physNeighbors>
        <int>4</int>
        <int>11</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>3</nodeID>
      <physNeighbors>
        <int>4</int>
        <int>9</int>
        <int>10</int>
        <int>11</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>4</nodeID>
      <physNeighbors>
        <int>1</int>
        <int>2</int>
        <int>3</int>
        <int>8</int>
        <int>11</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>5</nodeID>
      <physNeighbors>
        <int>8</int>
        <int>11</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>6</nodeID>
      <physNeighbors>
        <int>1</int>
        <int>7</int>
        <int>8</int>
        <int>10</int>
        <int>12</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>7</nodeID>
      <physNeighbors>
        <int>1</int>
        <int>6</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>8</nodeID>
      <physNeighbors>
        <int>1</int>
        <int>4</int>
        <int>5</int>
        <int>6</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>9</nodeID>
      <physNeighbors>
        <int>3</int>
        <int>11</int>
        <int>12</int>
        <int>13</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>10</nodeID>
      <physNeighbors>
        <int>3</int>
        <int>6</int>
        <int>13</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>11</nodeID>
      <physNeighbors>
        <int>2</int>
        <int>3</int>
        <int>4</int>
        <int>5</int>
        <int>9</int>
        <int>13</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>12</nodeID>
      <physNeighbors>
        <int>6</int>
        <int>9</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
    <node>
      <nodeID>13</nodeID>
      <physNeighbors>
        <int>9</int>
        <int>10</int>
        <int>11</int>
      </physNeighbors>
      <visited />
      <neighbors />
    </node>
  </contents>
</formattedMeshNet>

XSL

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
    <![CDATA[
    <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
     http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">]]>

    <![CDATA[<graph id="G" edgedefault="undirected">]]>
        <xsl:for-each select="/formattedMeshNet/contents/node">
        <xsl:variable name="parentNodeID">
            <xsl:value-of select="nodeID" />
        </xsl:variable>
            <![CDATA[<node id="n]]><xsl:copy-of select="$parentNodeID" /><![CDATA["/>]]>
            <xsl:for-each select="physNeighbors/int">
                <![CDATA[<edge source="n]]><xsl:copy-of select="$parentNodeID" /><![CDATA[" target="n]]><xsl:value-of select="." /><![CDATA["/>]]>
            </xsl:for-each>
        </xsl:for-each>

    <![CDATA[</graph>
     </graphml>]]>
</xsl:template>
</xsl:stylesheet>

A: If I am guessing correctly, your stylesheet should look like this:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/formattedMeshNet">
    <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
     http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
        <graph id="G" edgedefault="undirected">
            <xsl:for-each select="contents/node">
                <xsl:variable name="parentNodeID" select="nodeID" />
                <node id="n{$parentNodeID}" />
                <xsl:for-each select="physNeighbors/int">
                    <edge source="n{$parentNodeID}" target="n{.}" />
                </xsl:for-each>
            </xsl:for-each>
        </graph>
     </graphml>
</xsl:template>

</xsl:stylesheet>

Applied to your input example, the result will be:
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns      http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
   <graph id="G" edgedefault="undirected">
      <node id="n1"/>
      <edge source="n1" target="n4"/>
      <edge source="n1" target="n6"/>
      <edge source="n1" target="n7"/>
      <edge source="n1" target="n8"/>
      <node id="n2"/>
      <edge source="n2" target="n4"/>
      <edge source="n2" target="n11"/>
      <node id="n3"/>
      <edge source="n3" target="n4"/>
      <edge source="n3" target="n9"/>
      <edge source="n3" target="n10"/>
      <edge source="n3" target="n11"/>
      <node id="n4"/>
      <edge source="n4" target="n1"/>
      <edge source="n4" target="n2"/>
      <edge source="n4" target="n3"/>
      <edge source="n4" target="n8"/>
      <edge source="n4" target="n11"/>
      <node id="n5"/>
      <edge source="n5" target="n8"/>
      <edge source="n5" target="n11"/>
      <node id="n6"/>
      <edge source="n6" target="n1"/>
      <edge source="n6" target="n7"/>
      <edge source="n6" target="n8"/>
      <edge source="n6" target="n10"/>
      <edge source="n6" target="n12"/>
      <node id="n7"/>
      <edge source="n7" target="n1"/>
      <edge source="n7" target="n6"/>
      <node id="n8"/>
      <edge source="n8" target="n1"/>
      <edge source="n8" target="n4"/>
      <edge source="n8" target="n5"/>
      <edge source="n8" target="n6"/>
      <node id="n9"/>
      <edge source="n9" target="n3"/>
      <edge source="n9" target="n11"/>
      <edge source="n9" target="n12"/>
      <edge source="n9" target="n13"/>
      <node id="n10"/>
      <edge source="n10" target="n3"/>
      <edge source="n10" target="n6"/>
      <edge source="n10" target="n13"/>
      <node id="n11"/>
      <edge source="n11" target="n2"/>
      <edge source="n11" target="n3"/>
      <edge source="n11" target="n4"/>
      <edge source="n11" target="n5"/>
      <edge source="n11" target="n9"/>
      <edge source="n11" target="n13"/>
      <node id="n12"/>
      <edge source="n12" target="n6"/>
      <edge source="n12" target="n9"/>
      <node id="n13"/>
      <edge source="n13" target="n9"/>
      <edge source="n13" target="n10"/>
      <edge source="n13" target="n11"/>
   </graph>
</graphml>


text:
Q: Bash: wait for image to be available in dockerhub I am trying to create a bash script that will download the image from docker hub if present else it will wait for 5 mins before exiting
#!/bin/sh

waitForDockerImage=0
res='Error response from daemon'
while [[ "${res}" == *"Error response from daemon"* ]]; do
    echo $res
    res=$(docker pull node/base-alpine:test)
    echo $res
    waitForDockerImage=$(($waitForDockerImage+10))
    if [ $waitForDockerImage -gt 300 ];then
        echo "waited for 5 mins, exiting now.."
        exit
    else
        sleep 1 # wait for 1 the second before check again
    fi
done

Also, while loop is running for the 1st iteration time but failing on the 2nd iteration.
For the 2nd run
res=Error response from daemon: manifest for Error response from daemon: manifest for not found: manifest unknown: manifest unknown

So I am checking if res contains Error response from daemon

A: The error response is written to standard error, not standard output. It works the first time because you manually set res, rather than failing to capture standard error from docker. Change the assignment in the loop to
res=$(docker pull node/base-alpine:test 2>&1)

Better yet, ignore the standard error and test the exit status of docker pull.
i=0
while :;do
    docker pull node/base-alpine:test 2>/dev/null && break
    if [ "$i" -gt 300 ]; then
        printf 'Waited 5 minutes, exiting now\n' >&2
        exit 1
    fi
    i=$((i+1))
    sleep 1
done

Since you are using bash, though, it's easy to check if 5 minutes have passed without using a counter as a proxy.
SECONDS=0
while :; do
    docker pull node/base-alpine:test 2>/dev/null && break
    if (( $SECONDS > 300 )); then
        printf 'Waited 5 minutes, exiting now\n' >&2
        exit 1
    fi
    sleep 1
done

SECONDS is a special variable in bash whose value is effectively incremented once per second.


text:
Q: buttons in a grid with arrows in gaps I have buttons that are displayed on a css grid.  I would like to put arrows in the gaps that will be like a flow chart.  If not possible using css grid can think of something that can implement using another technique.  This is stackblitz which will show my implementation without the arrows in between.  https://stackblitz.com/edit/angular-wipq2r-miu8fl?file=src%2Fapp%2Fproduct-list%2Fproduct-list.component.html
here is an illustration:

A: I would create classes that can be applied to each "step" depending on which way the arrow needs to point (up, down, left, right) and then use an ::after pseudo selector to create the arrow element on each class, styling as required.
See below.

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  grid-gap: 20px;
}

.step {
  background-color: blue;
  color: white;
  padding: 10px;
  position: relative;
}

.arrow-right::after {
  color: black;
  content: '→';
  font-size: 20px;
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
}

.arrow-down::after {
  color: black;
  content: '↓';
  font-size: 16px;
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
}

.arrow-up::after {
  color: black;
  content: '↑';
  font-size: 16px;
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
}

.arrow-left::after {
  color: black;
  content: '←';
  font-size: 20px;
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
}

Step X

Step X

Step X

Step X

Step X

Step X

Step X

Step X

Step X

A: Another approach is use SVG

**Update** I forget add window.scrollX and window.scrollY when calculate the paths (just corrected in code and stactblitz)

Update 2 When we calculate the position we need susbstrat from element.getBoundingClientRect(), the getBoundingClientRect().top and getBoundingClientRect().left of the "wrapper"
The idea is put all under a wrapper div

  <svg [attr.width]="size.width" [attr.height]="size.height"
  xmlns="http://www.w3.org/2000/svg">
    <path *ngFor="let path of paths" [attr.d]="path" />
  </svg>

    ..your buttons..

You get the elements using viewChild and ViewChildren and declare an array of "paths" and an object with the size of the wrapper
  @ViewChildren('bt') items:QueryList<ElementRef>
  @ViewChild('wrapper') wrapper:ElementRef

  paths:string[]=[]
  size={width:0,height:0}

Then, when you resize (I use fromEvent rxjs operator in the stackblitz )
  ngOnInit()
  {
    this.subscription=fromEvent(window,'resize').pipe(
      startWith(null),
      debounceTime(200)
    ).subscribe(_=>{
      setTimeout(()=>{
        this.paths=this.createPath()
        const rect=this.wrapper.nativeElement.getBoundingClientRect()
        this.size={width:rect.width,height:rect.height}
      })

    })
  }
  ngOnDestroy(){
    this.subscription.unsubscribe()
  }

The function createPath is like
  createPath()
  {
    const path:string[]=[]
    const add=.5; //if stroke-width is even use add=.5 else use add=0
    //get the position of "wrapper"
    const wrapper=this.wrapper.nativeElement.getBoundingClientRect()
    this.items.forEach((x,i)=>{
      if (i)
      {

        /*   replace this lines
        const ini=this.items.find((_,index)=>index==i-1)
                   .nativeElement.getBoundingClientRect()
        const fin=x.nativeElement.getBoundingClientRect()
        */
        //by
       const _ini=this.items.find((_,index)=>index==i-1)
                   .nativeElement.getBoundingClientRect()
       const _fin=x.nativeElement.getBoundingClientRect()

       const ini={width:_ini.width,height:_ini.height,
             left:_ini.left+window.scrollX,top:_ini.top+window.scrollY}
       const fin={width:_fin.width,height:_fin.height,
             left:_fin.left+window.scrollX,top:_fin.top+window.scrollY}

       const _ini=this.items.find((_,index)=>index==i-1)
                   .nativeElement.getBoundingClientRect()
       const _fin=x.nativeElement.getBoundingClientRect()

       const ini={width:_ini.width,height:_ini.height,
                  left:_ini.left-wrapper.left,top:_ini.top-wrapper.top}
       const fin={width:_fin.width,height:_fin.height,
                  left:_fin.left-wrapper.left,top:_fin.top-wrapper.top}

       if (ini.top==fin.top)
       {
         path.push(`M${ini.left+ini.width+add} ${ini.top+ini.height/2+add}
                    H${fin.left-add}
                    M${fin.left-7-add} ${fin.top+fin.height/2-4-add}
                    L${fin.left-add} ${fin.top+fin.height/2+add}
                    M${fin.left-7-add} ${fin.top+fin.height/2+4+add}
                    L${fin.left-add} ${fin.top+fin.height/2+add}`)
       }
       else
       {
         const step=6; //(fin.top-ini.top-ini.height)/2
         path.push(`M${ini.left+ini.width/2+add} ${ini.top+ini.height+add}
                    V${ini.top+ini.height+step+add}
                    H${fin.left+fin.width/2+add}
                    V${fin.top-add}
                    M${fin.left+fin.width/2+4+add} ${fin.top-7-add}
                    L${fin.left+fin.width/2+add} ${fin.top-add}
                    M${fin.left+fin.width/2-4-add} ${fin.top-7-add}
                    L${fin.left+fin.width/2+add} ${fin.top-add}`
         )
       }
      }
    })
    return path
  }

A: As the arrows are just visual clues we can use pseudo elements to depict them.
You can 'draw' the lines and arrow heads by putting a pseudo after element on an item with background color black and cutting it using clip-path.
We need two clip-paths, one for the horizontal lines/arrows and one for the one going from the end item in each row to the first of the next row.
This snippet uses settings of some CSS variables to make it easier to change to suit a particular use case.
Here is the result:

* {
  margin: 0;
  padding;
  0;
  box-sizing: border-box;
}

.container {
  --gap: 10vmin;
  /* set this to what you want the gap to be - absolute units */
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr 1fr 1fr;
  width: 100vw;
  /* set this to whatever you want */
  padding: var(--gap);
}

.container>* {
  border: solid 1px black;
  width: 100%;
  --ar: 3 / 1;
  /* set this to what you want the aspect ratio of a button to be */
  aspect-ratio: var(--ar);
  position: relative;
}

.container>*::after {
  content: '';
  width: var(--gap);
  --arrow: 20px;
  /* set this to the height of the arrowhead  */
  --ha: calc(var(--arrow) / 2);
  /* half the height of an arrowhead */
  --line: 2px;
  /* set this to the width (height) of the lines */
  --hl: calc(var(--line) / 2);
  /* half the height of a line */
  height: var(--arrow);
  background-color: black;
  clip-path: polygon(0 calc(var(--ha) - var(--hl)), calc(100% - var(--ha)) calc(var(--ha) - var(--hl)), calc(100% - var(--ha)) 0, 100% 50%, calc(100% - var(--ha)) 100%, calc(100% - var(--ha)) calc(var(--ha) + var(--hl)), 0 calc(var(--ha) + var(--hl)));
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: calc(-1 * var(--gap));
}

.container>*:nth-child(3n)::after {
  width: calc(200% + (2 * var(--gap)) + var(--line));
  height: var(--gap);
  transform: translateY(0);
  top: 100%;
  right: calc(50% - (var(--hl)));
  clip-path: polygon( 100% 0, 100% calc(50% + var(--hl)), calc(var(--ha) + var(--hl)) calc(50% + var(--hl)), calc(var(--ha) + var(--hl)) calc(100% - var(--ha)), var(--arrow) calc(100% - var(--ha)), var(--ha) 100%, 0 calc(100% - var(--ha)), calc(var(--ha) - var(--hl)) calc(100% - var(--ha)), calc(var(--ha) - var(--hl)) calc(50% - var(--hl)), calc(100% - var(--line)) calc(50% - var(--hl)), calc(100% - var(--line)) 0);
}

.container>*:last-child::after {
  display: none;
}

  <button></button><button></button><button></button><button></button><button></button><button></button><button></button><button></button><button></button>