Q: Wallet style with multiple cells border Swift How do I make only the last cell with round corner and black border color? and the rest of the cell will only have left and right border?
This is the design of the cell. The pink part is the section header, the white part is the cell. In the image I have 6 cells and I want the 6th one to have round corner and black border. Cell 1-5 will only have left and right border.
My tableview will contain few sets of todo please see the image under.
Thank you.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         .
         .
         .

    cell.view.clipsToBounds = true

    if indexPath.row == todoList.count - 1 {
        cell.view.layer.cornerRadius = 10
        cell.view.layer.maskedCorners = [.layerMinXMaxYCorner,.layerMaxXMaxYCorner]
        cell.view.layer.borderColor = UIColor.black.cgColor   //not working it makes all cell has border
        cell.view.layer.borderWidth = 1

    } else {
        //only want left and right with black border
    }
        .
        .
        .
}

A: @PpppppPppppp, I managed to get the result with some hacks. Do post if you found another way to do it. Here's the final result:

Instead of setting left and right borders for cell, set black colour to cell's contentView and place a view inside with leading and trailing constraints to make it look like it has a border.
Then provide a viewForHeaderInSection and a viewForFooterInSection with masked corners as required in your UI. Some hacks required in the footer to hide the top border.
I didn't use any custom UITableViewCell or UITableViewHeaderFooterView since this is only for demo. FInd the whole code for table view below.
extension ViewController: UITableViewDataSource, UITableViewDelegate {

    func numberOfSections(in tableView: UITableView) -> Int {
        return 4
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 6
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = "index: \(indexPath.row)"
        return cell
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let header = UIView(frame: .init(x: 0, y: 0, width: tableView.bounds.width, height: 70))
        header.backgroundColor = .white

        let innderView = UIView(frame: .init(x: 0, y: 20, width: header.bounds.width, height: 50))
        header.addSubview(innderView)

        innderView.backgroundColor = .lightGray
        innderView.layer.cornerRadius = 8
        innderView.layer.borderColor = UIColor.black.cgColor
        innderView.layer.borderWidth = 2
        innderView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
        return header
    }

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 70
    }

    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let footer = UIView(frame: .init(x: 0, y: 0, width: tableView.bounds.width, height: 20))
        let innerView = UIView(frame: .init(x: 2, y: 0, width: footer.bounds.width-4, height: footer.bounds.height-2))
        footer.addSubview(innerView)

        innerView.backgroundColor = .white
        innerView.layer.cornerRadius = 8
        innerView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]

        footer.backgroundColor = .black
        footer.layer.cornerRadius = 8
        footer.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
        return footer
    }

    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 20
    }
}

A: I do think @Jithin answer using adding a subview is the easiest and greatest answer, but if you really want to draw your own border line, we can use UIBezierPath to achieve this. (which I think is a little bit overkill for this).
extension ViewController: UITableViewDataSource {
    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {

        let cornerRadius: CGFloat = 10.0
        let lineWidth: CGFloat = 2

        // deduct the line width to keep the line stay side the view
        let point1 = CGPoint(x: 0.0 + lineWidth / 2, y: view.frame.height)
        let point2 = CGPoint(x: 0.0 + lineWidth / 2, y: 0.0 + cornerRadius + lineWidth / 2)
        let point3 = CGPoint(x: 0.0 + cornerRadius + lineWidth / 2, y: 0.0 + lineWidth / 2)
        let point4 = CGPoint(x: view.frame.width - cornerRadius - lineWidth / 2, y: 0.0 + lineWidth / 2)
        let point5 = CGPoint(x: view.frame.width - lineWidth / 2, y: 0.0 + cornerRadius + lineWidth / 2)
        let point6 = CGPoint(x: view.frame.width - lineWidth / 2, y: view.frame.height - lineWidth / 2)

        // draw the whole line with upper corner radius
        let path = UIBezierPath()
        path.move(to: point1)
        path.addLine(to: point2)
        path.addArc(withCenter: CGPoint(x: point3.x, y: point2.y),
                    radius: cornerRadius,
                    startAngle: .pi,
                    endAngle: -.pi/2,
                    clockwise: true)
        path.addLine(to: point4)
        path.addArc(withCenter: CGPoint(x: point4.x, y: point5.y),
                    radius: cornerRadius,
                    startAngle: -.pi/2,
                    endAngle: 0,
                    clockwise: true)
        path.addLine(to: point6)
        path.addLine(to: point1)

        let topBorder = CAShapeLayer()
        topBorder.path = path.cgPath
        topBorder.lineWidth = lineWidth
        topBorder.strokeColor = UIColor.purple.cgColor
        topBorder.fillColor = nil

        // add the line to header view
        view.layer.addSublayer(topBorder)
        }

        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "testingCell", for: indexPath) as! TableViewCell

        cell.cellLabel.text = "\(mockData[indexPath.section][indexPath.row])"
        cell.backgroundColor = .green

        if indexPath.row == mockData[indexPath.section].count - 1 {
            cell.setAsLastCell()
            // we can add a mask to cut those area outside our border line
            let maskPath = UIBezierPath(roundedRect: cell.bounds, byRoundingCorners: [.bottomLeft, .bottomRight], cornerRadii: CGSize(width: 10, height: 10))
            let maskLayer = CAShapeLayer()
            maskLayer.path = maskPath.cgPath
            cell.layer.mask = maskLayer
        } else {
            cell.setAsNormalCell()
            cell.layer.mask = nil
        }

        return cell
    }
}

And here is the UITableViewwCell:
class TableViewCell: UITableViewCell {

    @IBOutlet weak var cellLabel: UILabel!

    let leftBorder = CALayer()
    let rightBorder = CALayer()
    let bottomBorder = CAShapeLayer()
    let cornerRadius: CGFloat = 10
    let lineWidth: CGFloat = 2

    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        leftBorder.frame = CGRect(x: 0, y: 0, width: lineWidth, height: self.frame.height)
        leftBorder.backgroundColor = UIColor.blue.cgColor
        self.layer.addSublayer(leftBorder)

        rightBorder.frame = CGRect(x: self.frame.width - lineWidth, y: 0.0, width: lineWidth, height: self.frame.height)
        rightBorder.backgroundColor = UIColor.blue.cgColor
        self.layer.addSublayer(rightBorder)

        // same idea as drawing line in the header view
        let point1 = CGPoint(x: 0.0 + lineWidth / 2, y: 0.0)
        let point2 = CGPoint(x: 0.0 + lineWidth / 2, y: self.frame.height - cornerRadius - lineWidth / 2)
        let point3 = CGPoint(x: cornerRadius + lineWidth / 2, y: self.frame.height - lineWidth / 2)
        let point4 = CGPoint(x: self.frame.width - cornerRadius - lineWidth / 2, y: self.frame.height - lineWidth / 2)
        let point5 = CGPoint(x: self.frame.width - lineWidth / 2, y: self.frame.height - cornerRadius - lineWidth / 2)
        let point6 = CGPoint(x: self.frame.width - lineWidth / 2, y: 0.0)

        let path = UIBezierPath()
        path.move(to: point1)
        path.addLine(to: point2)[![enter image description here][1]][1]
        path.addArc(withCenter: CGPoint(x: point3.x, y: point2.y),
                    radius: cornerRadius,
                    startAngle: .pi,
                    endAngle: .pi/2,
                    clockwise: false)
        path.addLine(to: point4)
        path.addArc(withCenter: CGPoint(x: point4.x,y: point5.y),
                    radius: cornerRadius,
                    startAngle: .pi/2,
                    endAngle: 0,
                    clockwise: false)
        path.addLine(to: point6)

        bottomBorder.path = path.cgPath
        bottomBorder.strokeColor = UIColor.red.cgColor
        bottomBorder.lineWidth = lineWidth
        bottomBorder.fillColor = nil
        self.layer.addSublayer(bottomBorder)
    }

    func setAsNormalCell() {
        leftBorder.isHidden = false
        rightBorder.isHidden = false
        bottomBorder.isHidden = true
    }

    func setAsLastCell() {
        leftBorder.isHidden = true
        rightBorder.isHidden = true
        bottomBorder.isHidden = false
    }

}

And of course, the above code is just for testing purposes and maybe a bit messy, but I hope it can explain a bit about drawing a line.
The result:

A: You can give corner radius to your tableview.
tableView.layer.cornerRadius = 10
tableView.layer.borderColor = UIColor.black.cgColor
tableView.layer.borderWidth = 1

A: I have a UICollectionView extension however it should work the same for UITableView
  @objc func addBorder(fromIndexPath:IndexPath, toIndexPath:IndexPath, borderColor:CGColor, borderWidth:CGFloat){

    let fromAttributes = self.layoutAttributesForItem(at: fromIndexPath)!
    let toAttributes = self.layoutAttributesForItem(at: toIndexPath)!

    let borderFrame = CGRect(x: fromAttributes.frame.origin.x
                             ,y: fromAttributes.frame.origin.y
                             ,width: fromAttributes.frame.size.width
                             ,height: toAttributes.frame.origin.y + toAttributes.frame.size.height - fromAttributes.frame.origin.y)

    let borderTag = ("\(fromIndexPath.row)\(fromIndexPath.section)\(toIndexPath.row)\(toIndexPath.section)" as NSString).integerValue

    if let borderView = self.viewWithTag(borderTag){
        borderView.frame = borderFrame
    }
    else{
        let borderView = UIView(frame: borderFrame)
        borderView.tag = borderTag
        borderView.backgroundColor = UIColor.clear
        borderView.isUserInteractionEnabled = false
        borderView.layer.borderWidth = borderWidth
        borderView.layer.borderColor =  borderColor

        self.addSubview(borderView)
    }
}


Q: How can I change the directory that "cd \" goes to in git? When I enter cd \ git goes into a different directory than I would like to.
How can I change it so that cd \ takes me to
C:\Users\J P\Dropbox\Git Bash

A: cd \ takes you to the root directory of the current drive. That is a function of Windows, not a function of git.
If you want to change it, you'll have to use Windows to do that, not git.
One route might be to use a separate drive letter (e.g. Z:) bound to C:\Users\J P\Dropbox\Git Bash. In DOS the SUBST command did that. It appears to work with XP, and here's a way to make it persistent. The easiest appears to be:
 net use z: "\\computerName\c$\Users\J P\Dropbox\Git Bash" /persistent:yes

Then if you change to drive z:, cd \ will take you to z:'s root, which will be the right place.
There's probably a different/better Windows way to do that.


Q: Gorilla WebSocket WriteMessage errors - Go Lang I am currently experimenting with Gorilla WebSocket package. When sending a message using WriteMessage, if an error is returned, what should I do? Should I start the Closing Handshake or assume that if there is a problem it will be caught using the ReadMessage method and simply log the error?

A: If WriteMessage returns an error, then the application should close the connection. This releases resources used by the connection and causes the reader to return with an error.
It is not possible to send a closing handshake after WriteMessage returns an error. If WriteMessage returns an error, then all subsequent writes will also return an error.


Q: xamarin forms Scrollview VerticalScrollBarVisibility does not visible for android only its working in IOS I have tried Xamarin forms Scrollview VerticalScrollBarVisibility="always", but it does not visible for android,Its Showing in IOS devices.I need Scrollbar visible in android device also.Can anybody help me? Thank you in advance.
my Code:<ScrollView   Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" VerticalScrollBarVisibility="Always"><Grid></Grid></ScrollView>


Q: Browser Issue/Difference for pdfs defined within  The following html code has been used to experiment with how different browsers handle a pdf created through the  html control.  Below is a very basic html page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <object data="http://www.dol.gov/ebsa/pdf/401kfefm.pdf" type="application/pdf" width="500" height="300">

Missing PDF plugin for this browser.
            Click here to download the PDF file.

        </object>

The pdf file will load properly in all of the browsers I have tested; Firefox 5, IE 8, Chrome 12.x, Safari 5.  However the size of the control seems to vary between IE and the other browsers.  Between the other three browsers the size is consistent but I ideally would like the control to be the same size on all browsers.
The picture below shows the size difference between Chrome and IE.

Thanks for the help.

A: Something is probably going on wrong with the pixels size. Try set the '500px' instead of '500' or percentage ('20%')
Hope this helps


Q: Appcelerator tableView font color How can you set the color of the font for the rows in tableView?
I DO NOT want to set it row by row like this:
var table_data = [
    {title:'Row 1', color: 'black'},
];

I have tried adding font:{colour:'black'} to the table var but it does not seem to work. Like this:
var table1 =  Titanium.UI.createTableView({
  data:table_data,
  separatorColor:'black',
  font:{color:'black'}
});

I want to be able to set it so any row in the table has a set color. Specifically as I will be adding items to the table and I want them to be 'black' not the default white/grey. So when I add new items they will be black...
I am sure this is simple but I cant seem to find anything that is assisting me hence the question here
Thanks in advance.

A: here you go.Add a lable in tableview row and set it according to your own desire
var self = Ti.UI.createWindow({
    backgroundColor : 'white',
    title : 'Saved Locations'
});
var data = [];
var tabLoc = Ti.UI.createTableView({
});
self.add(tabLoc);
var row = Titanium.UI.createTableViewRow({
    height : '60dp',
    className : "tableRow",
});
var labTitle = Ti.UI.createLabel({
    color : 'black',
    font : {
        fontSize : '12dp',
        fontWeight : 'bold'
    },
    height : Ti.UI.SIZE,
    text : 'There is no location yet saved',
    textAlign : 'center'
});

row.add(labTitle);
data.push(row)
tabLoc.setData(data);
self.open()

Thanks


Q: Scripts not running in FF and Chrome I am using javascript alert message to show validation messages. In Firefox and Chrome first time working fine,second time for same alert same its asking message like "Prevent this page from creating additional dialogs" with check box. After select that check box, Next time button click scripts not executing. How to block that message?

A: Use a JavaScript Modal popup! eg. JQuery UI Modal Popup

A: its a browser property for the client,if he doesnt want to view these alerts. you cant remove that check box and message.
if this message is shown then what the problem, leave it for the user.
why you want to force him to view these alerts,
it must be user's wish to see or not see these alerts.
for better user experience and for your purpose you can use fancybox or facebox
fancy box fiddler check this http://jsfiddle.net/BJNYr/

A: This is a browser matter, so you as a developer cant do anything with that behavior.
Here is a similar question
already answered here

A: unfortunately you can't be sure that user has his browser settings with javascript alerts popup on ( that called with 'alert('...') function').
You should use javascript dialog plygin instead.
For example:
http://fancybox.net/


Q: renaming a file while creating zip file through Maven-assembly plugin i am using maven-assembly plugin to create the zip , how can i rename some files while zipping using the same plugin??
Update:
This is the profile in pom
    <profile>
        <id>D1</id>
        <activation>
            <property>
                <name>D1</name>
                <value>true</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.2.2</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <descriptors>
                                    <descriptor>assembly/online-distribution.D1.xml</descriptor>
                                </descriptors>
                                <appendAssemblyId>false</appendAssemblyId>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

This is Assembly.xml
<?xml version="1.0" encoding="UTF-8" ?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-
    plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
    <format>tar.gz</format>
</formats>
<id>online</id>
<includeBaseDirectory>false</includeBaseDirectory>
    <dependencySet>
        <outputDirectory>resources</outputDirectory>
        <unpack>true</unpack>
        <includes>
            <include>${project.groupId}:core-config:jar</include>
        </includes>
        <unpackOptions>
            <includes>
            <include>coresrv/env-config.D1.properties</include>
            </includes>
        </unpackOptions>
    </dependencySet>
    <files>
    <file>
        <source>${project.groupId}/core-config.jar/coresrv/env-config.D1.properties</source>
        <outputDirectory>/</outputDirectory>
        <destName>env-config.properties</destName>
    </file>
</files>
</assembly>

i am getting that jar and unpacking it, then renaming a file and zipping it again.
Thanks

A: Answering an old post for posterity... and next time I ask Google and get sent here.
Renaming used to be a pain in Maven, this plugin does what is says on the tin:
copy-rename-maven-plugin
(available in Maven central)
Easy to use:
        <plugin>
            <groupId>com.coderplus.maven.plugins</groupId>
            <artifactId>copy-rename-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
                <execution>
                    <id>copy-properties-file</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <sourceFile>source.props</sourceFile>
                        <destinationFile>destination.properties</destinationFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Note: the rename goal will move file(s) in target/

A: I faced with same problem, I need to use unpack with renaming some files and as solution we can use two executions of maven-assembly-plugin.
During first execution we will use format dir instead of one of archive formats and will prepare files content and as result will have folder with all needed files.
During second execution we will use folder from previous execution as source in fileSets with files and we will have ability to rename any file using files.file.destName, and as format for second execution we can use archive format like zip to create final archive.

A: You can use
 <outputFileNameMapping>...</outputFileNameMapping>

which sets the mapping pattern for all dependencies included in this assembly uses
default value:
${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}.

A: You just need to add it in assembly plugin executions like below;
<executions>
 <execution>
  <configuration>
    <finalName>  you can give any name you want  <finalName>
  <configuration>
 </execution>
</executions>


Q: CMake not finding boost_python lib with brew (macOS) I think I'm going crazy. For some weird reason, I cannot get cmake to find boost_python. I've always used the same CMakeList and the same steps for installing Boost with Boost-Python support on macOS. On GNU/Linux and Windows I usually just build the library manually and it works just fine. Several months ago it also just worked perfectly fine on macOS by issuing the following commands:
brew install python2 boost boost-python

(I'm specifically using python2 and not python3)
I've no idea what's causing this issue because I've never had it before... perhaps it can't find the boost-python library from brew? (/usr/local/Cellar/boost-python/1.67.0/lib/). But then again, I never bothered with changing search paths for cmake or anything like that. This CMakeList always worked both under Linux and macOS.
my CMakeList.txt
cmake_minimum_required(VERSION 3.6)
project(game-client)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-std=c++1z -Wall -Wextra -Wno-unused-parameter -pthread")

# configure boost
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)

find_package(Boost COMPONENTS filesystem system python REQUIRED)
if (NOT Boost_FOUND)
  MESSAGE(FATAL_ERROR "Could not find boost library")
endif ()

# configure python
find_package(PythonLibs 2.7 REQUIRED)
if (NOT PYTHONLIBS_FOUND)
  MESSAGE(FATAL_ERROR "Could not find python library")
endif ()

include_directories(${Boost_INCLUDE_DIRS})
include_directories(${PYTHON_INCLUDE_DIRS})

# configure preprocessor flags for internal classlogs
add_definitions(-DDUMP_GOOD_PACKETS)
# add_definitions(-DCLASSLOG)

set(SOURCE_FILES src/main.cpp src/Config.cpp include/Config.hpp     src/SequenceTable.cpp include/SequenceTable.hpp
        include/Singleton.hpp include/Logger.hpp src/NetworkStream.cpp include/NetworkStream.hpp
    include/packets/incoming/in.hpp include/packets/outcoming/out.hpp src/Buffer.cpp include/Buffer.hpp
    include/Packet.hpp src/PacketHandler.cpp include/PacketHandler.hpp src/Core.cpp
    include/Core.hpp src/Cipher.cpp include/Cipher.hpp src/KeyAgreement.cpp include/KeyAgreement.hpp
    src/AuthInput.cpp include/AuthInput.hpp src/MainInput.cpp include/MainInput.hpp include/PythonManager.hpp
    src/PythonManager.cpp include/PythonInstance.hpp src/PythonInstance.cpp include/packets/common/common.hpp
    src/Entity.cpp include/Entity.hpp include/Item.hpp src/Item.cpp src/Environment.cpp include/Environment.hpp)
add_executable(game-client ${SOURCE_FILES})
target_link_libraries(game-client ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}     cryptopp)

cmake output:
memcpys-MBP:build memcpy$ cmake ..
-- The C compiler identification is Clang 6.0.0
-- The CXX compiler identification is Clang 6.0.0
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ --     works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at     /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:2044     (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.67.0

  Boost include path: /usr/local/include

  Could not find the following static Boost libraries:

          boost_python

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or     BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)

CMake Error at CMakeLists.txt:12 (MESSAGE):
  Could not find boost library

-- Configuring incomplete, errors occurred!
See also "/Users/memcpy/git-repos/game-    client/build/CMakeFiles/CMakeOutput.log".

I run cmake with with following options as suggested in the comments:
cmake -DBoost_DEBUG=ON ..

-- The C compiler identification is Clang 6.0.0
-- The CXX compiler identification is Clang 6.0.0
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1121 ] _boost_TEST_VERSIONS = 1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1123 ] Boost_USE_MULTITHREADED = ON
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1125 ] Boost_USE_STATIC_LIBS = ON
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1127 ] Boost_USE_STATIC_RUNTIME =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1129 ] Boost_ADDITIONAL_VERSIONS =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1131 ] Boost_NO_SYSTEM_PATHS =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1199 ] Declared as CMake or Environmental Variables:
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1201 ]   BOOST_ROOT =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1203 ]   BOOST_INCLUDEDIR =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1205 ]   BOOST_LIBRARYDIR =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1207 ] _boost_TEST_VERSIONS = 1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1282 ] Include debugging info:
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1284 ]   _boost_INCLUDE_SEARCH_DIRS = PATHS;C:/boost/include;C:/boost;/sw/local/include
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1286 ]   _boost_PATH_SUFFIXES = boost-1_67_0;boost_1_67_0;boost/boost-1_67_0;boost/boost_1_67_0;boost-1_67;boost_1_67;boost/boost-1_67;boost/boost_1_67;boost-1_66_0;boost_1_66_0;boost/boost-1_66_0;boost/boost_1_66_0;boost-1_66;boost_1_66;boost/boost-1_66;boost/boost_1_66;boost-1_65_1;boost_1_65_1;boost/boost-1_65_1;boost/boost_1_65_1;boost-1_65_0;boost_1_65_0;boost/boost-1_65_0;boost/boost_1_65_0;boost-1_65;boost_1_65;boost/boost-1_65;boost/boost_1_65;boost-1_64_0;boost_1_64_0;boost/boost-1_64_0;boost/boost_1_64_0;boost-1_64;boost_1_64;boost/boost-1_64;boost/boost_1_64;boost-1_63_0;boost_1_63_0;boost/boost-1_63_0;boost/boost_1_63_0;boost-1_63;boost_1_63;boost/boost-1_63;boost/boost_1_63;boost-1_62_0;boost_1_62_0;boost/boost-1_62_0;boost/boost_1_62_0;boost-1_62;boost_1_62;boost/boost-1_62;boost/boost_1_62;boost-1_61_0;boost_1_61_0;boost/boost-1_61_0;boost/boost_1_61_0;boost-1_61;boost_1_61;boost/boost-1_61;boost/boost_1_61;boost-1_60_0;boost_1_60_0;boost/boost-1_60_0;boost/boost_1_60_0;boost-1_60;boost_1_60;boost/boost-1_60;boost/boost_1_60;boost-1_59_0;boost_1_59_0;boost/boost-1_59_0;boost/boost_1_59_0;boost-1_59;boost_1_59;boost/boost-1_59;boost/boost_1_59;boost-1_58_0;boost_1_58_0;boost/boost-1_58_0;boost/boost_1_58_0;boost-1_58;boost_1_58;boost/boost-1_58;boost/boost_1_58;boost-1_57_0;boost_1_57_0;boost/boost-1_57_0;boost/boost_1_57_0;boost-1_57;boost_1_57;boost/boost-1_57;boost/boost_1_57;boost-1_56_0;boost_1_56_0;boost/boost-1_56_0;boost/boost_1_56_0;boost-1_56;boost_1_56;boost/boost-1_56;boost/boost_1_56;boost-1_55_0;boost_1_55_0;boost/boost-1_55_0;boost/boost_1_55_0;boost-1_55;boost_1_55;boost/boost-1_55;boost/boost_1_55;boost-1_54_0;boost_1_54_0;boost/boost-1_54_0;boost/boost_1_54_0;boost-1_54;boost_1_54;boost/boost-1_54;boost/boost_1_54;boost-1_53_0;boost_1_53_0;boost/boost-1_53_0;boost/boost_1_53_0;boost-1_53;boost_1_53;boost/boost-1_53;boost/boost_1_53;boost-1_52_0;boost_1_52_0;boost/boost-1_52_0;boost/boost_1_52_0;boost-1_52;boost_1_52;boost/boost-1_52;boost/boost_1_52;boost-1_51_0;boost_1_51_0;boost/boost-1_51_0;boost/boost_1_51_0;boost-1_51;boost_1_51;boost/boost-1_51;boost/boost_1_51;boost-1_50_0;boost_1_50_0;boost/boost-1_50_0;boost/boost_1_50_0;boost-1_50;boost_1_50;boost/boost-1_50;boost/boost_1_50;boost-1_49_0;boost_1_49_0;boost/boost-1_49_0;boost/boost_1_49_0;boost-1_49;boost_1_49;boost/boost-1_49;boost/boost_1_49;boost-1_48_0;boost_1_48_0;boost/boost-1_48_0;boost/boost_1_48_0;boost-1_48;boost_1_48;boost/boost-1_48;boost/boost_1_48;boost-1_47_0;boost_1_47_0;boost/boost-1_47_0;boost/boost_1_47_0;boost-1_47;boost_1_47;boost/boost-1_47;boost/boost_1_47;boost-1_46_1;boost_1_46_1;boost/boost-1_46_1;boost/boost_1_46_1;boost-1_46_0;boost_1_46_0;boost/boost-1_46_0;boost/boost_1_46_0;boost-1_46;boost_1_46;boost/boost-1_46;boost/boost_1_46;boost-1_45_0;boost_1_45_0;boost/boost-1_45_0;boost/boost_1_45_0;boost-1_45;boost_1_45;boost/boost-1_45;boost/boost_1_45;boost-1_44_0;boost_1_44_0;boost/boost-1_44_0;boost/boost_1_44_0;boost-1_44;boost_1_44;boost/boost-1_44;boost/boost_1_44;boost-1_43_0;boost_1_43_0;boost/boost-1_43_0;boost/boost_1_43_0;boost-1_43;boost_1_43;boost/boost-1_43;boost/boost_1_43;boost-1_42_0;boost_1_42_0;boost/boost-1_42_0;boost/boost_1_42_0;boost-1_42;boost_1_42;boost/boost-1_42;boost/boost_1_42;boost-1_41_0;boost_1_41_0;boost/boost-1_41_0;boost/boost_1_41_0;boost-1_41;boost_1_41;boost/boost-1_41;boost/boost_1_41;boost-1_40_0;boost_1_40_0;boost/boost-1_40_0;boost/boost_1_40_0;boost-1_40;boost_1_40;boost/boost-1_40;boost/boost_1_40;boost-1_39_0;boost_1_39_0;boost/boost-1_39_0;boost/boost_1_39_0;boost-1_39;boost_1_39;boost/boost-1_39;boost/boost_1_39;boost-1_38_0;boost_1_38_0;boost/boost-1_38_0;boost/boost_1_38_0;boost-1_38;boost_1_38;boost/boost-1_38;boost/boost_1_38;boost-1_37_0;boost_1_37_0;boost/boost-1_37_0;boost/boost_1_37_0;boost-1_37;boost_1_37;boost/boost-1_37;boost/boost_1_37;boost-1_36_1;boost_1_36_1;boost/boost-1_36_1;boost/boost_1_36_1;boost-1_36_0;boost_1_36_0;boost/boost-1_36_0;boost/boost_1_36_0;boost-1_36;boost_1_36;boost/boost-1_36;boost/boost_1_36;boost-1_35_1;boost_1_35_1;boost/boost-1_35_1;boost/boost_1_35_1;boost-1_35_0;boost_1_35_0;boost/boost-1_35_0;boost/boost_1_35_0;boost-1_35;boost_1_35;boost/boost-1_35;boost/boost_1_35;boost-1_34_1;boost_1_34_1;boost/boost-1_34_1;boost/boost_1_34_1;boost-1_34_0;boost_1_34_0;boost/boost-1_34_0;boost/boost_1_34_0;boost-1_34;boost_1_34;boost/boost-1_34;boost/boost_1_34;boost-1_33_1;boost_1_33_1;boost/boost-1_33_1;boost/boost_1_33_1;boost-1_33_0;boost_1_33_0;boost/boost-1_33_0;boost/boost_1_33_0;boost-1_33;boost_1_33;boost/boost-1_33;boost/boost_1_33
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1306 ] location of version.hpp: /usr/local/include/boost/version.hpp
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1330 ] version.hpp reveals boost 1.67.0
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1416 ] guessed _boost_COMPILER =
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1426 ] _boost_MULTITHREADED = -mt
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1502 ] _boost_RELEASE_ABI_TAG = -
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1504 ] _boost_DEBUG_ABI_TAG = -d
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1567 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/include/lib;/usr/local/include/../lib;/usr/local/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG   = /usr/local/include/lib;/usr/local/include/../lib;/usr/local/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1756 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-mt-1_67;boost_filesystem-mt;boost_filesystem
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:400 ]  Boost_LIBRARY_DIR_RELEASE = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1809 ] Searching for FILESYSTEM_LIBRARY_DEBUG: boost_filesystem-mt-d-1_67;boost_filesystem-mt-d;boost_filesystem-mt;boost_filesystem
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:400 ]  Boost_LIBRARY_DIR_DEBUG = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1756 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-mt-1_67;boost_system-mt;boost_system
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:400 ]  Boost_LIBRARY_DIR_RELEASE = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1809 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-mt-d-1_67;boost_system-mt-d;boost_system-mt;boost_system
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:400 ]  Boost_LIBRARY_DIR_DEBUG = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1756 ] Searching for PYTHON_LIBRARY_RELEASE: boost_python-mt-1_67;boost_python-mt;boost_python
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:400 ]  Boost_LIBRARY_DIR_RELEASE = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1809 ] Searching for PYTHON_LIBRARY_DEBUG: boost_python-mt-d-1_67;boost_python-mt-d;boost_python-mt;boost_python
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:400 ]  Boost_LIBRARY_DIR_DEBUG = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:1883 ] Boost_FOUND = 1
CMake Error at /usr/local/Cellar/cmake/3.11.4/share/cmake/Modules/FindBoost.cmake:2044 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.67.0

  Boost include path: /usr/local/include

  Could not find the following static Boost libraries:

          boost_python

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)

CMake Error at CMakeLists.txt:12 (MESSAGE):
  Could not find boost library

-- Configuring incomplete, errors occurred!
See also "/Users/memcpy/git-repos/game-client/build/CMakeFiles/CMakeOutput.log".

A: @Tsyvarev this. I needed to change the COMPONENTS as "python27". This behavior definitely changed over the time. I don't remember having to do this at boost release >= 1.65 <= 1.67. Thanks.


Q: MLFlow creates a new experiment run when logging manually along with autolog I am using MLFlow to log metrics and artefacts in the AzureML workspace. With autolog, tensorflow training metrics are available in the experiment run in the AzureML workspace. Along with auto-logging of metrics - I want to log extra metrics and plots in the same experiment run. Doing it with MLFlow - it is creating a new experiment run.
Auto logging:
mlflow.autolog()
Manual logging:
mlflow.log_metric(f"label-A", random.randint(80, 90))

Expected:
Manually logged metrics are available in the same experiment run.

A: Instead of using the module method call mlflow.log_metric to log the metrics, use the client MlflowClient which takes run_id as the parameter.
Following code logs the metrics in the same run_id passed as the parameter.
from mlflow.tracking import MlflowClient
from azureml.core import Run

run_id = Run.get_context(allow_offline=True).id
MlflowClient().log_metric(run_id, "precision", 0.91)


Q: Why is my SVG sprite id reference not loading the corresponding svg? I am using the SVG Sprite system in vanilla JS to load two SVGs on to my page. I have contained both SVGs in one icons.svg file using https://svgsprit.es/ service:

<svg width="0" height="0" class="hidden">
  <symbol viewBox="0 0 0 0" id="delete">
    <symbol viewBox="0 0 0 0" id="delete">
      <symbol fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="edit">
        <path d="M 18.414062 2 C 18.158062 2 17.902031 2.0979687 17.707031 2.2929688 L 15.707031 4.2929688 L 14.292969 5.7070312 L 3 17 L 3 21 L 7 21 L 21.707031 6.2929688 C 22.098031 5.9019687 22.098031 5.2689063 21.707031 4.8789062 L 19.121094 2.2929688 C 18.926094 2.0979687 18.670063 2 18.414062 2 z M 18.414062 4.4140625 L 19.585938 5.5859375 L 18.292969 6.8789062 L 17.121094 5.7070312 L 18.414062 4.4140625 z M 15.707031 7.1210938 L 16.878906 8.2929688 L 6.171875 19 L 5 19 L 5 17.828125 L 15.707031 7.1210938 z"></path>
      </symbol>
    </symbol>
  </symbol>
  <symbol viewBox="0 0 0 0" id="edit">
    <symbol fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="edit">
      <path d="M 18.414062 2 C 18.158062 2 17.902031 2.0979687 17.707031 2.2929688 L 15.707031 4.2929688 L 14.292969 5.7070312 L 3 17 L 3 21 L 7 21 L 21.707031 6.2929688 C 22.098031 5.9019687 22.098031 5.2689063 21.707031 4.8789062 L 19.121094 2.2929688 C 18.926094 2.0979687 18.670063 2 18.414062 2 z M 18.414062 4.4140625 L 19.585938 5.5859375 L 18.292969 6.8789062 L 17.121094 5.7070312 L 18.414062 4.4140625 z M 15.707031 7.1210938 L 16.878906 8.2929688 L 6.171875 19 L 5 19 L 5 17.828125 L 15.707031 7.1210938 z"></path>
    </symbol>
  </symbol>
</svg>

When I add the HTML through dynamic JS I use:

const container = document.createElement('div');

//add edit icon
const editIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
editIcon.classList.add('icon');
const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'images/icons.svg#edit');
editIcon.appendChild(use);

//add delete icon
const deleteIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
deleteIcon.classList.add('icon');
const use2 = document.createElementNS("http://www.w3.org/2000/svg", "use");
use2.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'images/icons.svg#delete');
deleteIcon.appendChild(use2);

container.appendChild(editIcon);
container.appendChild(deleteIcon);

but only the edit icon appears successfully? I notice that the delete SVG has two symbol tags each with an id - am I referencing it wrong in my JS?
**and yes I know xlink:href is deprecated! this is just a small project for learning so browser compatibility is not highly important

A: Your sprite file is wonky.  You should not have multiple nested <symbol> elements.
  <symbol viewBox="0 0 0 0" id="delete">
    <symbol viewBox="0 0 0 0" id="delete">

Each icon should only have one.
The reason your "delete" icon is not showing is because, when the browser tries to find the "delete" symbol, it has two that have id="delete". That is illegal for a start, because id attributes must be unique.
It will choose one of them. In this case it doesn't matter which one it chooses. That's because all that either "delete" symbol contains is a <symbol> element. Which is effectively nothing, because <symbol> elements by themselves are not rendered. They are only rendered when referenced by a <use>.
You got lucky with the "edit" symbol, because you have three of those.  But luckily your browser is probably picking the first id match it finds.  And for id="edit" the first one is three levels down inside the nested <symbol id="delete"> ones.
In other words, your sprite file looks like this to the browser
<svg width="0" height="0" class="hidden">
  <symbol viewBox="0 0 0 0" id="delete">
  </symbol>
  <symbol fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="edit">
    <path d="M 18.414062 2 C 18.158062 2 17.902031 2.0979687 17.707031 2.2929688 L 15.707031 4.2929688 L 14.292969 5.7070312 L 3 17 L 3 21 L 7 21 L 21.707031 6.2929688 C 22.098031 5.9019687 22.098031 5.2689063 21.707031 4.8789062 L 19.121094 2.2929688 C 18.926094 2.0979687 18.670063 2 18.414062 2 z M 18.414062 4.4140625 L 19.585938 5.5859375 L 18.292969 6.8789062 L 17.121094 5.7070312 L 18.414062 4.4140625 z M 15.707031 7.1210938 L 16.878906 8.2929688 L 6.171875 19 L 5 19 L 5 17.828125 L 15.707031 7.1210938 z"></path>
  </symbol>
</svg>

Fix the nested symbol problem. It looks like you are passing, to that utility, SVG files that already contain only symbols. So it is simply wrapping symbols in other symbols.
I expect you should be passing renderable SVGs to that utility.
If your SVG files don't render anything when opened with a browser, they are probably already a "sprite sheet". Only use SVGs that display something when opened in a browser.
For your immediate problem, try this manually fixed file instead.

<svg width="0" height="0" class="hidden">
  <symbol fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="delete">
    <path d="M 18.414062 2 C 18.158062 2 17.902031 2.0979687 17.707031 2.2929688 L 15.707031 4.2929688 L 14.292969 5.7070312 L 3 17 L 3 21 L 7 21 L 21.707031 6.2929688 C 22.098031 5.9019687 22.098031 5.2689063 21.707031 4.8789062 L 19.121094 2.2929688 C 18.926094 2.0979687 18.670063 2 18.414062 2 z M 18.414062 4.4140625 L 19.585938 5.5859375 L 18.292969 6.8789062 L 17.121094 5.7070312 L 18.414062 4.4140625 z M 15.707031 7.1210938 L 16.878906 8.2929688 L 6.171875 19 L 5 19 L 5 17.828125 L 15.707031 7.1210938 z"></path>
  </symbol>
  <symbol fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="edit">
    <path d="M 18.414062 2 C 18.158062 2 17.902031 2.0979687 17.707031 2.2929688 L 15.707031 4.2929688 L 14.292969 5.7070312 L 3 17 L 3 21 L 7 21 L 21.707031 6.2929688 C 22.098031 5.9019687 22.098031 5.2689063 21.707031 4.8789062 L 19.121094 2.2929688 C 18.926094 2.0979687 18.670063 2 18.414062 2 z M 18.414062 4.4140625 L 19.585938 5.5859375 L 18.292969 6.8789062 L 17.121094 5.7070312 L 18.414062 4.4140625 z M 15.707031 7.1210938 L 16.878906 8.2929688 L 6.171875 19 L 5 19 L 5 17.828125 L 15.707031 7.1210938 z"></path>
  </symbol>
</svg>


Q: Reorder Time/Location data to list point to point trips I have a df that the first and last recorded time at a particular location. Example raw data linked in code below.
df <- read.csv('https://raw.githubusercontent.com/smitty1788/Personal-Website/master/example.csv', header = T)

    address                                   fuel  name    Long        Lat Time
1   625-627 S St NW, Washington, DC 20001, USA  87  EC6502  -77.02081   38.91411    5/18/2017 13:36
2   625-627 S St NW, Washington, DC 20001, USA  87  EC6502  -77.02081   38.91411    5/18/2017 15:28
3   1301-1327 Howard Rd SE, Washington, DC 20020, USA   87  EC6502  -76.99312   38.86101    5/18/2017 16:03
4   1301-1327 Howard Rd SE, Washington, DC 20020, USA   87  EC6502  -76.99312   38.86101    5/18/2017 20:17
5   821 Whittier Pl NW, Washington, DC 20012, USA   81  EC6502  -77.02542   38.97149    5/18/2017 21:03
6   821 Whittier Pl NW, Washington, DC 20012, USA   81  EC6502  -77.02542   38.97149    5/19/2017 8:35
7   1327 Allison St NW, Washington, DC 20011, USA   81  EC6502  -77.03118   38.94508    5/19/2017 8:50
8   1327 Allison St NW, Washington, DC 20011, USA   81  EC6502  -77.03118   38.94508    5/19/2017 8:55
9   815 Whittier Pl NW, Washington, DC 20012, USA   81  EC6502  -77.02481   38.97148    5/19/2017 9:11
10  1655-1699 N Rhodes St, Arlington, VA 22201, USA 100 EP0253  -77.08  38.89306    5/18/2017 13:36
11  1655-1699 N Rhodes St, Arlington, VA 22201, USA 100 EP0253  -77.08  38.89306    5/18/2017 15:02
12  2617 N Stuart St, Arlington, VA 22207, USA  100 EP0253  -77.11257   38.9066 5/18/2017 15:28
13  2617 N Stuart St, Arlington, VA 22207, USA  100 EP0253  -77.11257   38.9066 5/18/2017 16:54
14  1432-1488 N Quincy St, Arlington, VA 22201, USA 100 EP0253  -77.10842   38.8887 5/18/2017 17:14
15  1432-1488 N Quincy St, Arlington, VA 22201, USA 100 EP0253  -77.10842   38.8887 5/18/2017 18:30
16  1020-1028 N Stafford St, Arlington, VA 22201, USA   84  EP0253  -77.11047   38.88278    5/18/2017 23:15
17  1020-1028 N Stafford St, Arlington, VA 22201, USA   84  EP0253  -77.11047   38.88278    5/19/2017 13:53

The data would indicate that there was a trip between rows 2 and 3, 4 and 5, 6 and 7 and so on for each individual plate in column "name".
I and trying to figure out an efficient way to reorganize the data so that one row would show starting location and ending location (end_address, end_fuel, end_long, end_lat, end_time). Essentially, each row is one trip made. Ideally the new df would be organized like this
name, st_address, st_fuel, st_long, st_lat, st_time, end_address, end_fuel,  end_long,  end_lat,  end_time

Would someone be able to help me identify a way to do this? Thanks!

A: A dplyr solution which relies on group_by to identify vehicle names.
library(dplyr)

# code each pair with a trip id by dividing by 2 - code each trip as 1 = from, 0 = to
df <- df %>%
  group_by(name) %>%
  mutate(trip_id  = (1 + seq_along(address)) %/% 2,
                    from_to  = (seq_along(address) %% 2))

# seprate into from and to
df_from <- df %>% filter(from_to %% 2 == 1) %>% select(-from_to)
df_to   <- df %>% filter(from_to %% 2 == 0) %>% select(-from_to)

# join the result
result <- inner_join(df_from, df_to, by = c("name", "trip_id"))

A: library(tidyverse)
library(lubridate)

df <- read.csv('https://raw.githubusercontent.com/smitty1788/Personal-Website/master/example.csv',
           header = T)

# Remove 1st and Last row of each group
df_clean <- df %>%
  mutate(Time = mdy_hm(Time)) %>%
  group_by(name) %>%
  arrange(name, Time) %>%
  filter(row_number() != 1,
         row_number() != n())

df_tripID <- df_clean %>%
      group_by(name) %>%
      mutate(trip_id  = (1 + seq_along(address)) %/% 2,
             from_to  = (seq_along(address) %% 2))

# seprate into from and to
df_from <- df_tripID %>%
  filter(from_to %% 2 == 1) %>%
  select(-from_to)
df_to   <- df_tripID %>%
  filter(from_to %% 2 == 0) %>%
  select(-from_to)

# join the result
car2go_trips <- inner_join(df_from, df_to, by = c("name", "trip_id"))


Q: Oracle SQL - Define the year element of a date dependent on the current month I am trying to create a view in SQL Developer based on this statement:
SELECT * FROM ORDERS WHERE START_DATE > '01-JUL-2020'
The year element of the date needs to set to the year of the current date if the current month is between July and December otherwise it needs to be the previous year.
The statement below returns the required year but I don't know how to incorporate it (or a better alternative) into the statement above:
select
    case
      when month(sysdate) > 6 then
        year(sysdate)
      else
        year(sysdate)-1
    end year
  from dual

Thanks

A: Oracle doesn't have a built-in month function so I'm assuming that is a user-defined function that you've created.  Assuming that's the case, it sounds like you want
where start_date > (case when month(sysdate) > 6
                         then trunc(sysdate,'yyyy') + interval '6' month
                         else trunc(sysdate,'yyyy') - interval '6' month
                      end)

A: Just subtract six months and compare the dates:
SELECT *
FROM ORDERS
WHERE trunc(add_months(sysdate, -6), 'YYYY') = trunc(start_date, 'YYYY')

This compares the year of the date six months ago to the year on the record -- which seems to be the logic you want.


Q: Attempt to index field (a nil value) I am trying to make simple object container in Lua ( to practice a language a little)
Container = {}
Container.__index = Container

function Container.create( maxNumber )
   local c = {}             -- our new object
   setmetatable(c, Container)
   c.maxNumberOfRecords = maxNumber
   c.cont = {}
   return c
end

function Container:add(index, val)
         self.cont[index] = val
end

function Container:getAt(index)
    return self.cont[index]
end

return Container

but I always get error Attempt to index field 'cont' (a nil value) when I try to add to container. Can anyone tell me what is a problem ?
I am totally new to lua but I looked at code at documentation http://lua-users.org/wiki/SimpleLuaClasses

A: Can you show an example of code that does not work? It looks OK to me:
> Container = require "Container"
> c = Container.create(5)
> c:add(2, 42)
> =c:getAt(2)
42


Q: Explanation for why allocating a second time changes performance I was testing some micro benchmarks on dense matrix multiplication (as a curiosity), and I noticed some very strange performance results.
Here is a minimal working example:
#include <benchmark/benchmark.h>

#include <random>

constexpr long long n = 128;

struct mat_bench_fixture : public benchmark::Fixture
{
  double *matA, *matB, *matC;

  mat_bench_fixture()
  {
    matA = new double[n * n];
    matB = new double[n * n];
    matC = new double[n * n];
    benchmark::DoNotOptimize(matA);
    benchmark::DoNotOptimize(matB);
    benchmark::DoNotOptimize(matC);
#if 0
    delete[] matA;
    delete[] matB;
    delete[] matC;
    benchmark::DoNotOptimize(matA);
    benchmark::DoNotOptimize(matB);
    benchmark::DoNotOptimize(matC);
    matA = new double[n * n];
    matB = new double[n * n];
    matC = new double[n * n];
    benchmark::DoNotOptimize(matA);
    benchmark::DoNotOptimize(matB);
    benchmark::DoNotOptimize(matC);
#endif
  }

  ~mat_bench_fixture()
  {
    delete[] matA;
    delete[] matB;
    delete[] matC;
  }

  void SetUp(const benchmark::State& s) override
  {
    // generate random data
    std::mt19937 gen;
    std::uniform_real_distribution<double> dis(0, 1);
    for (double* i = matA; i != matA + n * n; ++i)
    {
      *i = dis(gen);
    }
    for (double* i = matB; i != matB + n * n; ++i)
    {
      *i = dis(gen);
    }
  }
};

BENCHMARK_DEFINE_F(mat_bench_fixture, impl1)(benchmark::State& st)
{
  for (auto _ : st)
  {
    for (long long row = 0; row < n; ++row)
    {
      for (long long col = 0; col < n; ++col)
      {
        matC[row * n + col] = 0;
        for (long long k = 0; k < n; ++k)
        {
          matC[row * n + col] += matA[row * n + k] * matB[k * n + col];
        }
      }
    }
    benchmark::DoNotOptimize(matA);
    benchmark::DoNotOptimize(matB);
    benchmark::DoNotOptimize(matC);
    benchmark::ClobberMemory();
  }
}

BENCHMARK_REGISTER_F(mat_bench_fixture, impl1);

BENCHMARK_MAIN();

There is an #if 0 block in the constructor of the fixture which can be toggled to #if 1 for the two different scenarios I'm testing. What I've noticed is that for some reason when I force a re-allocation of all the buffers, for some reason on my system the time it takes for the benchmark to run magically improves by about 15%, and I have no explanation why this is happening. I was hoping someone could enlighten me on this. I would also like to know if there are any additional micro-benchmarking "best practices" suggestions for avoiding weird performance anomalies like this in the future.
How I'm compiling (assuming Google Benchmark has been installed somewhere it can be found):
$CC -o mult_test mult_test.cpp -std=c++14 -pthread -O3 -fno-omit-frame-pointer -lbenchmark
I've been running this with:
./mult_test --benchmark_repetitions=5
I'm doing all my testing in Ubuntu 18.04 x64 (Kernel version 4.15.0-30-generic)
I've tried several different variations of this code, and they all give the same basic result over multiple runs (it's surprising how consistent the results are for me):

*

*Move allocation/initialization inside of the benchmark "SetUp" phase (non-timed part) so that the allocation/deallocation happens every new sample point

*Switched compilers between GCC 7.3.0 and Clang 6.0.0

*Tried different Computers with different CPU's (Intel i5-6600K, and one with dual socket Xeon E5-2630 v2)

*Tried different methods for implementing the benchmark framework (i.e. not using Google Benchmark at all and manually implementing timing via std::chrono)

*Forcing all buffers to be aligned to several different boundaries (64 bytes, 128 bytes, 256 bytes)

*Forcing a fixed number of iterations in each sample timing period

*Tried running with a much higher number of repetitions (20+)

*Forced a constant CPU clock frequency using the performance governor

*Tried different compiler flags for optimization options (removed no-omit-frame-pointer, tried -march=native)

*I've tried using std::vector for managing the storage, using new[]/delete[] pairs, and malloc/free. They all give similar results.

I've compared the assembly of the hot portion of the code, and it's identical between the two test cases (screenshot from perf for one of the cases):
40:
  mov 0xc0(%r15),$rcx
  mov 0xd0(%r15),%rdx
  add $0x8,$rcx
  move 0xc8(%r15),%r9
  add %r8,%r9
  xor %r10d,%r10d
  nop
60:
  mov %r10,%r11
  shl $0x7,$r11
  mov %r9,%r13
  xor %esi,%esi
  nop
70:
  lea (%rsi,%r11,1),%rax
  movq %0x0,(%rdx,%rax,8)
  xordp %xmm0,%xmm0
  mov $0xffffffffffffff80,%rdi
  mov %r13,%rbx
  nop
90:
  movsd 0x3f8(%rcx,%rdi,8),%xmm1
  mulsd -0x400(%rbx),%xmm1
  addsd %xmm0,%xmm1
  movsd %xmm1,(%rdx,%rax,8)
  movsd 0x400(%rcs,%rdi,8),%xmm0
  mulsd (%rbx),%xmm0
  addsd %xmm1,%xmm0
  movsd %xmm0,(%rdx,%rax,8)
  add $0x800,%rbx
  add $0x2,%rdi
  jne 90
  add $0x1,%rsi
  add $0x8,%r13
  cmp $0x80,%rsi
  jne 70
  add $0x1,%r10
  add $0x400,%rcx
  cmp $0x80,%r10
  jne 60
  add $0xffffffffffffffff,%r12
  jne 40

Here is a representative screenshot of perf stat for not performing a re-allocation:
Running ./mult_test
Run on (4 X 4200 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 256K (x4)
  L3 Unified 6144K (x1)
----------------------------------------------------------------------
Benchmark                               Time           CPU Iterations
----------------------------------------------------------------------
mat_bench_fixture/impl1           2181531 ns    2180896 ns        322
mat_bench_fixture/impl1           2188280 ns    2186860 ns        322
mat_bench_fixture/impl1           2182988 ns    2182150 ns        322
mat_bench_fixture/impl1           2182715 ns    2182025 ns        322
mat_bench_fixture/impl1           2175719 ns    2175653 ns        322
mat_bench_fixture/impl1_mean      2182246 ns    2181517 ns        322
mat_bench_fixture/impl1_median    2182715 ns    2182025 ns        322
mat_bench_fixture/impl1_stddev       4480 ns       4000 ns        322

 Performance counter stats for './mult_test --benchmark_repetitions=5':

       3771.370173      task-clock (msec)         #    0.994 CPUs utilized
               223      context-switches          #    0.059 K/sec
                 0      cpu-migrations            #    0.000 K/sec
               242      page-faults               #    0.064 K/sec
    15,808,590,474      cycles                    #    4.192 GHz                      (61.31%)
    20,201,201,797      instructions              #    1.28  insn per cycle           (69.04%)
     1,844,097,332      branches                  #  488.973 M/sec                    (69.04%)
           358,319      branch-misses             #    0.02% of all branches          (69.14%)
     7,232,957,363      L1-dcache-loads           # 1917.859 M/sec                    (69.24%)
     3,774,591,187      L1-dcache-load-misses     #   52.19% of all L1-dcache hits    (69.35%)
       558,507,528      LLC-loads                 #  148.091 M/sec                    (69.46%)
            93,136      LLC-load-misses           #    0.02% of all LL-cache hits     (69.47%)
   <not supported>      L1-icache-loads
           736,008      L1-icache-load-misses                                         (69.47%)
     7,242,324,412      dTLB-loads                # 1920.343 M/sec                    (69.34%)
               581      dTLB-load-misses          #    0.00% of all dTLB cache hits   (61.50%)
             1,582      iTLB-loads                #    0.419 K/sec                    (61.39%)
               307      iTLB-load-misses          #   19.41% of all iTLB cache hits   (61.29%)
   <not supported>      L1-dcache-prefetches
   <not supported>      L1-dcache-prefetch-misses

       3.795924436 seconds time elapsed

Here is a representative screenshot of perf stat for forcing a re-allocation:
Running ./mult_test
Run on (4 X 4200 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 256K (x4)
  L3 Unified 6144K (x1)
----------------------------------------------------------------------
Benchmark                               Time           CPU Iterations
----------------------------------------------------------------------
mat_bench_fixture/impl1           1862961 ns    1862919 ns        376
mat_bench_fixture/impl1           1861986 ns    1861947 ns        376
mat_bench_fixture/impl1           1860330 ns    1860305 ns        376
mat_bench_fixture/impl1           1859711 ns    1859652 ns        376
mat_bench_fixture/impl1           1863299 ns    1863273 ns        376
mat_bench_fixture/impl1_mean      1861658 ns    1861619 ns        376
mat_bench_fixture/impl1_median    1861986 ns    1861947 ns        376
mat_bench_fixture/impl1_stddev       1585 ns       1591 ns        376

 Performance counter stats for './mult_test --benchmark_repetitions=5':

       3724.287293      task-clock (msec)         #    0.995 CPUs utilized
                11      context-switches          #    0.003 K/sec
                 0      cpu-migrations            #    0.000 K/sec
               246      page-faults               #    0.066 K/sec
    15,612,924,579      cycles                    #    4.192 GHz                      (61.34%)
    23,344,859,019      instructions              #    1.50  insn per cycle           (69.07%)
     2,130,528,330      branches                  #  572.063 M/sec                    (69.07%)
           331,651      branch-misses             #    0.02% of all branches          (69.08%)
     8,369,233,786      L1-dcache-loads           # 2247.204 M/sec                    (69.18%)
     4,206,241,296      L1-dcache-load-misses     #   50.26% of all L1-dcache hits    (69.29%)
       308,687,646      LLC-loads                 #   82.885 M/sec                    (69.40%)
            94,288      LLC-load-misses           #    0.03% of all LL-cache hits     (69.50%)
   <not supported>      L1-icache-loads
           475,066      L1-icache-load-misses                                         (69.50%)
     8,360,570,315      dTLB-loads                # 2244.878 M/sec                    (69.37%)
               364      dTLB-load-misses          #    0.00% of all dTLB cache hits   (61.53%)
               213      iTLB-loads                #    0.057 K/sec                    (61.42%)
               144      iTLB-load-misses          #   67.61% of all iTLB cache hits   (61.32%)
   <not supported>      L1-dcache-prefetches
   <not supported>      L1-dcache-prefetch-misses

       3.743017809 seconds time elapsed

Here is a minimal working example which doesn't have any external dependencies, and allows for testing memory alignment issues:
#include <random>
#include <chrono>
#include <iostream>
#include <cstdlib>

constexpr long long n = 128;
constexpr size_t alignment = 64;

inline void escape(void* p)
{
  asm volatile("" : : "g"(p) : "memory");
}
inline void clobber()
{
  asm volatile("" : : : "memory");
}

struct mat_bench_fixture
{
  double *matA, *matB, *matC;

  mat_bench_fixture()
  {
    matA = (double*) aligned_alloc(alignment, sizeof(double) * n * n);
    matB = (double*) aligned_alloc(alignment, sizeof(double) * n * n);
    matC = (double*) aligned_alloc(alignment, sizeof(double) * n * n);
    escape(matA);
    escape(matB);
    escape(matC);
#if 0
    free(matA);
    free(matB);
    free(matC);
    escape(matA);
    escape(matB);
    escape(matC);
    matA = (double*) aligned_alloc(alignment, sizeof(double) *n * n);
    matB = (double*) aligned_alloc(alignment, sizeof(double) *n * n);
    matC = (double*) aligned_alloc(alignment, sizeof(double) *n * n);
    escape(matA);
    escape(matB);
    escape(matC);
#endif
  }

  ~mat_bench_fixture()
  {
    free(matA);
    free(matB);
    free(matC);
  }

  void SetUp()
  {
    // generate random data
    std::mt19937 gen;
    std::uniform_real_distribution<double> dis(0, 1);
    for (double* i = matA; i != matA + n * n; ++i)
    {
      *i = dis(gen);
    }
    for (double* i = matB; i != matB + n * n; ++i)
    {
      *i = dis(gen);
    }
  }
  void run()
  {
    constexpr int iters = 400;
    std::chrono::high_resolution_clock timer;
    auto start = timer.now();
    for (int i = 0; i < iters; ++i)
    {
      for (long long row = 0; row < n; ++row)
      {
        for (long long col = 0; col < n; ++col)
        {
          matC[row * n + col] = 0;
          for (long long k = 0; k < n; ++k)
          {
            matC[row * n + col] += matA[row * n + k] * matB[k * n + col];
          }
        }
      }
      escape(matA);
      escape(matB);
      escape(matC);
      clobber();
    }
    auto stop = timer.now();
    std::cout << std::chrono::duration_cast<std::chrono::nanoseconds>(
                   stop - start)
                     .count() /
                   iters
              << std::endl;
  }
};

int main()
{
  mat_bench_fixture bench;
  for (int i = 0; i < 5; ++i)
  {
    bench.SetUp();
    bench.run();
  }
}

To compile:
g++ -o mult_test mult_test.cpp -std=c++14 -O3

A: In my machine, I can reproduce your case by using different alignments for pointers. Try this code:
mat_bench_fixture() {
    matA = new double[n * n + 256];
    matB = new double[n * n + 256];
    matC = new double[n * n + 256];

    // align pointers to 1024
    matA = reinterpret_cast<double*>((reinterpret_cast<unsigned long long>(matA) + 1023)&~1023);
    matB = reinterpret_cast<double*>((reinterpret_cast<unsigned long long>(matB) + 1023)&~1023);
    matC = reinterpret_cast<double*>((reinterpret_cast<unsigned long long>(matC) + 1023)&~1023);

    // toggle this to toggle alignment offset of matB
    // matB += 2;
}

If I toggle the commented line in this code, I got 34% difference on my machine.
Different alignment offsets cause different timings. You can play with offsetting the other 2 pointers too. Sometimes the difference is smaller, sometimes bigger, sometimes there's no change.
This must be caused by a cache issue: by having different last bits of the pointers, different collision patterns occur in the cache. And as your routine is memory intensive (all the data doesn't fit into L1), cache performance matters a lot.


Q: Javascript Apexchart title of x axis always in the wrong position I'm having some issues with the positioning of the title of the x axis in my column chart.
Depending on the range of the y values, the title is always in a different position, like in the examples:
Example 1
Example 2
Here's my code:
  var options = {
    chart: {
      type: 'bar'
    },
    series: [{
      name: 'Elevation',
      data: dict["values"],
      color: "#e0bf51"
    }],
    xaxis: {
      title: {
        text: 'Elevation (m)',
          //  offsetY: +120,
            floating: true,
      },
        categories: newkeys,
        tickAmount: 10,

    },
    dataLabels: {
        enabled: false
    },
    yaxis: {
      title: {
        text: 'Percentage (%)',
        offsetX:  10,
        floating: true,
      },
      axisBorder: {
        show: true
      },
      labels: {
        show: false,
        formatter: function (val) {
          return val + "%";
        }
      }
    },
    stroke: {
      colors: ["transparent"],
      width: 2
    },
    plotOptions: {
      bar: {
        columnWidth: "100%",
        rangeBarOverlap: true,
        rangeBarGroupRows: false
      }
    },
    tooltip: {
      x: {
        formatter: (value) => { return String(value) + '-' + String((parseInt(value)+9)) + " m" },
    },
    y: {
      title: {
          formatter: (seriesName) => "Percentage of land:",
      },
  },
  }
  }

  var chart = new ApexCharts(document.getElementById(elementId), options);

  chart.render();

I tried changing the offset values, but as the title is always in a new position this approach doesn't work.

A: It is not ideal, but you can downgrade a bit the version of ApexCharts.
This bug appeared with v3.36.1, so it was not in v3.36.0.

let options = {
  series: [{
    name: 'Series',
    data: [10, 20, 15]
  }],
  chart: {
    type: 'bar',
    height: 350
  },
  dataLabels: {
    enabled: false
  },
  xaxis: {
    categories: ['Category 1', 'Category 2', 'Category 3'],
    title: {
      text: 'Axis title'
    }
  }
};

let chart = new ApexCharts(document.querySelector('#chart'), options);
chart.render();


Q: jQuery event on change() I have a simple form:

      <fieldset>
        <input type="radio" id="radio10" name="color" value="1" />Red

        <input type="radio" name="color" value="2" />Yellow

        <input type="radio" name="color" value="3" />Blue

        <input type="radio" name="color" value="4" />Purple

      </fieldset>

       <fieldset>
        <input type="radio" name="time" value="6" />12

        <input type="radio" name="time" value="7" />11

        <input type="radio" name="time" value="8" />10

        <input type="radio" name="time" value="9" />9

      </fieldset>

What im trying to do here is by using jQuery change() hide off second fieldset.
$("input#radio10").change(function () {
        var checked = true;
        checked = checked && $(this).is(':checked');
        if ($('input#radio10:checked') ) {
            $('.block-cms').show()
            }
        else {
            $('.block-cms').hide();
        }
    });

Not sure what con be wrong here. Can anyone suggest me what should be done different please?

A: Your id shouldn't have the #, that's for the selector, it should just be id="radio10".
Change that, and this is what you should be after:
$(".class_a :radio").change(function () {
  $(".block-cms").toggle($("#radio10:checked").length > 0);
});

You can test it out here.

A: First of all the id on the element should be radio10 and not #radio10.
Then use this code
$("input[name='color']").change(function () {
    if ($('input#radio10').is(':checked') ) {
            $('.block-cms').show()
            }
        else {
            $('.block-cms').hide();
        }
    });

A: Here's another solution (IMO having an id on an <input type="radio"> seems a bit wrong to me):
$("input[name='color']").change(function () {
        if ($(this).val() == 1) {
            $('.block-cms').show()
            }
        else {
            $('.block-cms').hide();
        }
    });


Q: What is a reliable way to know if libcurl finished downloading a file? I have written this basic class:
class SteamHTTP
{
public:
    SteamHTTP();
    virtual  ~SteamHTTP();

    void DownloadAllGames(const wxString& username, wxGauge* progress);

private:
    CURL* m_curl;
    std::stringstream m_currentRequestString;

private:
    static size_t write_func(char *ptr, size_t size, size_t nmemb, void *userdata);
    static int progress_func(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
};

SteamHTTP::SteamHTTP()
{
    m_curl = curl_easy_init();
}

SteamHTTP::~SteamHTTP()
{
    curl_easy_cleanup(m_curl);
}

size_t SteamHTTP::write_func(char *data, size_t size, size_t nmemb, void *userdata)
{
    SteamHTTP* ptr = reinterpret_cast<SteamHTTP*>(userdata);
    ptr->m_currentRequestString << data;
    return size*nmemb;
}

int SteamHTTP::progress_func(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
    wxGauge* ptr = reinterpret_cast<wxGauge*>(clientp);
    ptr->SetValue(dlnow * 100.0f / dlnow );
    return 0;
}

void SteamHTTP::DownloadAllGames(const wxString& username, wxGauge* gauge)
{
    std::string url;
    CURLcode result;

    // Build URL
    url = std::string("http://steamcommunity.com/id/") + username.mbc_str() + std::string("/games?tab=all&xml=1");

    // Set URL
    curl_easy_setopt(m_curl, CURLOPT_URL, url.c_str());

    // Follow redirection
    curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, 1);

    // Data Callback
    curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, SteamHTTP::write_func);
    curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, this);

    // Progress Callback
    curl_easy_setopt(m_curl, CURLOPT_PROGRESSFUNCTION, SteamHTTP::progress_func);
    curl_easy_setopt(m_curl, CURLOPT_PROGRESSDATA, gauge);
    curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, FALSE);

    // Perform
    result = curl_easy_perform(m_curl);
    if (result != 0){
        wxMessageBox(curl_easy_strerror(result), wxMessageBoxCaptionStr, wxICON_ERROR|wxOK);
    }
}

What I struggle with is to tell reliably when libcurl is actually finished. Is there a callback for that? I would need that to parse the data downloaded.
What is the best way to tell if libcurl is done and I can process the data?
p.s.: This code is work in progress, checks need yet to be written etc.

A: When curl_easy_perform() returns, it is done. It is as simple as that. Check the return code to figure out if it succeeded or not.

A: in CURLOPTPROGRESSFUNCTION callback there are few parameters:
int function(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);

dltotal is the total bytes to be downloaded, and dlnow is the number of bytes downloaded so far. The download is completed when dltotal == dlnow.

dltotal is the total number of bytes libcurl expects to download in this transfer. dlnow is the number of bytes downloaded so far


Q: How to view metaspace area in heap dump? I got the OutOfMemoryError : Metaspace in my tomcat.
And I got heap dump file of jvm. (I use java8)
So I want to view only metaspace area in heap dump(hprof format), but I can't know how to do that.
I use MAT(Eclipse Memory Analyzer) to analyze the heap dump file.
Can I view only metaspace area?
Thanks.

A: There isn't direct metaspace information in a HPROF file.
Your might have a class loader leak or duplicate classes.
Try reading Permgen vs Metaspace in Java or
The Unknown Generation: Perm


Q: A lisp function refinement I've done the Graham Common Lisp Chapter 5 Exercise 5, which requires a function that takes an object X and a vector V, and returns a list of all the objects that immediately precede X in V.
It works like:
> (preceders #\a "abracadabra")
(#\c #\d #r)

I have done the recursive version:
(defun preceders  (obj vec &optional (result nil) &key (startt 0))
  (let ((l (length vec)))
    (cond ((null (position obj vec :start startt :end l)) result)
          ((= (position obj vec :start startt :end l) 0)
           (preceders obj vec result
                      :startt (1+ (position obj vec :start startt :end l))))
          ((> (position obj vec :start startt :end l) 0)
           (cons (elt vec (1- (position obj vec :start startt :end l)))
                 (preceders obj vec result
                            :startt (1+ (position obj vec
                                                 :start startt
                                                 :end l))))))))

It works correctly, but my teachers gives me the following critique:
"This calls length repeatedly. Not so bad with vectors, but still unnecessary. More efficient and more flexible (for the user) code is to define this like other sequence processing functions. Use :start and :end keyword parameters, the way the other sequence functions do, with the same default initial values. length should need to be called at most once."
I am consulting the Common Lisp textbook and google, but there seem to be of little help on this bit: I don't know what he means by "using :start and :end keyword parameters", and I have no clue of how to "call length just once". I would be grateful if you guys could give me some idea how on to refine my code to meet the requirement that my teacher posted.
UPDATE:
Now I have come up with the following code:
(defun preceders (obj vec
                  &optional (result nil)
                  &key (start 0) (end (length vec)) (test #'eql))
  (let ((pos (position obj vec :start start :end end :test test)))
    (cond ((null pos) result)
          ((zerop pos) (preceders obj vec result
                                 :start (1+ pos) :end end :test test))
          (t (preceders obj vec (cons (elt vec (1- pos)) result)
                       :start (1+ pos) :end end :test test)))))

I get this critique:
"When you have a complex recursive call that is repeated identically in more than one branch, it's often simpler to do the call first, save it in a local variable, and then use the variable in a much simpler IF or COND."
Also,for my iterative version of the function:
(defun preceders (obj vec)
  (do ((i 0 (1+ i))
       (r nil (if (and (eql (aref vec i) obj)
                       (> i 0))
                  (cons (aref vec (1- i)) r)
                  r)))
      ((eql i (length vec)) (reverse r))))

I get the critique
"Start the DO at a better point and remove the repeated > 0 test"

A: a typical parameter list for such a function would be:
(defun preceders (item vector
                  &key (start 0) (end (length vector))
                       (test #'eql))
    ...
)

As you can see it has START and END parameters.
TEST is the default comparision function. Use (funcall test item (aref vector i)).
Often there is also a KEY parameter...
LENGTH is called repeatedly for every recursive call of PRECEDERS.
I would do the non-recursive version and move two indexes over the vector: one for the first item and one for the next item. Whenever the next item is EQL to the item you are looking for, then push the first item on to a result list (if it is not member there).
For the recursive version, I would write a second function that gets called by PRECEDERS, which takes two index variables starting with 0 and 1, and use that. I would not call POSITION. Usually this function is a local function via LABELS inside PRECEDERS, but to make it a bit easier to write, the helper function can be outside, too.
(defun preceders (item vector
                  &key (start 0) (end (length vector))
                       (test #'eql))
   (preceders-aux item vector start end test start (1+ start) nil))

(defun preceders-aux (item vector start end test pos0 pos1 result)
  (if (>= pos1 end)
      result
      ...
  ))

Does that help?
Here is the iterative version using LOOP:
(defun preceders (item vector
                  &key (start 0) (end (length vector))
                       (test #'eql))
  (let ((result nil))
    (loop for i from (1+ start) below end
          when (funcall test item (aref vector i))
          do (pushnew (aref vector (1- i)) result))
    (nreverse result)))

A: Since you already have a solution that's working, I'll amplifiy Rainer Joswig's solution, mainly to make related stylistic comments.
(defun preceders (obj seq &key (start 0) (end (length seq)) (test #'eql))
  (%preceders obj seq nil start end test))

The main reason to have separate helper function (which I call %PRECEDERS, a common convention for indicating that a function is "private") is to eliminate the optional argument for the result. Using optional arguments that way in general is fine, but optional and keyword arguments play horribly together, and having both in a single function is a extremely efficient way to create all sorts of hard to debug errors.
It's a matter of taste whether to make the helper function global (using DEFUN) or local (using LABELS). I prefer making it global since it means less indentation and easier interactive debugging. YMMV.
A possible implementation of the helper function is:
(defun %preceders (obj seq result start end test)
  (let ((pos (position obj seq :start start :end end :test test)))
       ;; Use a local binding for POS, to make it clear that you want the
       ;; same thing every time, and to cache the result of a potentially
       ;; expensive operation.
    (cond ((null  pos) (delete-duplicates (nreverse result) :test test))
          ((zerop pos) (%preceders obj seq result (1+ pos) end test))
          ;; I like ZEROP better than (= 0 ...). YMMV.
          (t (%preceders obj seq
                         (cons (elt seq (1- pos)) result)
                         ;; The other little bit of work to make things
                         ;; tail-recursive.
         (1+ pos) end test)))))

Also, after all that, I think I should point out that I also agree with Rainer's advice to do this with an explicit loop instead of recursion, provided that doing it recursively isn't part of the exercise.
EDIT: I switched to the more common "%" convention for the helper function. Usually whatever convention you use just augments the fact that you only explicitly export the functions that make up your public interface, but some standard functions and macros use a trailing "*" to indicate variant functionality.
I changed things to delete duplicated preceders using the standard DELETE-DUPLICATES function. This has the potential to be much (i.e., exponentially) faster than repeated uses of ADJOIN or PUSHNEW, since it can use a hashed set representation internally, at least for common test functions like EQ, EQL and EQUAL.

A: A slightly modofied variant of Rainer's loop version:
(defun preceders (item vector
                  &key (start 0) (end (length vector))
                  (test #'eql))
  (delete-duplicates
   (loop
      for index from (1+ start) below end
      for element = (aref vector index)
      and previous-element = (aref vector (1- index)) then element
      when (funcall test item element)
      collect previous-element)))

This makes more use of the loop directives, and among other things only accesses each element in the vector once (we keep the previous element in the previous-element variable).

A: Answer for your first UPDATE.
first question:
see this
(if (foo)
  (bar (+ 1 baz))
  (bar baz))

That's the same as:
(bar (if (foo)
        (+ 1 baz)
        baz))

or:
(let ((newbaz (if (foo)
                 (+ 1 baz)
                 baz)))
  (bar newbaz))

Second:
Why not start with I = 1 ?
See also the iterative version in my other answer...

A: The iterative version proposed by Rainer is very nice, it's compact and more efficient since you traverse the sequence only one time; in contrast to the recursive version which calls position at every iteration and thus traverse the sub-sequence every time. (Edit: I'm sorry, I was completely wrong about this last sentence, see Rainer's comment)
If a recursive version is needed, another approach is to advance the start until it meets the end, collecting the result along its way.
(defun precede (obj vec &key (start 0) (end (length vec)) (test #'eql))
  (if (or (null vec) (< end 2)) nil
    (%precede-recur obj vec start end test '())))

(defun %precede-recur (obj vec start end test result)
  (let ((next (1+ start)))
    (if (= next end) (nreverse result)
      (let ((newresult (if (funcall test obj (aref vec next))
                         (adjoin (aref vec start) result)
                         result)))
        (%precede-recur obj vec next end test newresult)))))

Of course this is just another way of expressing the loop version.
test:
[49]> (precede #\a "abracadabra")
(#\r #\c #\d)
[50]> (precede #\a "this is a long sentence that contains more characters")
(#\Space #\h #\t #\r)
[51]> (precede #\s "this is a long sentence that contains more characters")
(#\i #\Space #\n #\r)

Also, I'm interested Robert, did your teacher say why he doesn't like using adjoin or pushnew in a recursive algorithm?


Q: im making a golf scorecard program in php but want to use javascript for counting the hits now i have programmed in php to hit a button after every hit you make but thats in php so after hit the button the program takes contact with the server.
i would like to know if it is possible to make the hit calculation via javascrit sothat the program does not upgrade to the server an the hits will be visable in the screen and be upgraded everytime via javascript. sothat after ending the hole i can save the result to the server.
i had made the following for test . but still the computer goes to update via the server.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?
if ($aantalslagen_plus==""){
    $aantalslagen_plus="0";
}
?>

<form method="post" action="" . $_SERVER['PHP_SELF'] . "">

totaal aantal slagen:

<?php
     $aantalslagen_plus = htmlentities($_POST['aantalslagen_plus']);
?>

totaal aantal slagen php:

<?   echo "<input type=\"text\" VALUE=\"$aantalslagen_plus\" name=\"aantalslagen_plus\" id=\"aantalslagen\" size=\"10\">"; ?>
<? echo $aantalslagen_plus; ?>

<button onclick="bereken();"> + </button>
</form>

A: Just initialize aantalslagen to 0 in JavaScript and don't mess with any <form> or POST request or anything like that because you don't need to since it doesn't seem like you're saving the value in some cookie so the value will stay if the user refreshes the page. If you do want the value to stay once the user refreshes, I suggest you look into localStorage.

//The input element:
var input = document.getElementById("aantalslagen-input");
//The td element:
var td = document.getElementById("aantalslagen-td");
//The button element:
var button = document.getElementById("aantalslagen-button");
//The variable:
var aantalslagen = 0;

//When the button is clicked...
button.addEventListener("click", function() {
    //Increment aantalslagen:
    aantalslagen += 1;
    //Update it in the input and td:
    input.value = aantalslagen;
    td.textContent = aantalslagen;
});

totaal aantal slagen:

totaal aantal slagen php:
<input type="text" VALUE="0" name="aantalslagen_plus" id="aantalslagen-input" size="10">
0

<button id="aantalslagen-button"> + </button>

A: Your <button> is inside of a <form> element and the default behaviour is for the form to submit to the server.
Remove the <form> element since it no longer seems to serve any purpose.


Q: How to avoid splitting float numbers while using Wordninja? I am working on cleaning textual data. I have a column that shows description of products. Some words are adjacent. I used wordninja for splitting words.
It worked well but it split the float numbers. I want to use these numbers as it is.
Is there a way to avoid split floats while using wordninja?
import wordninja
def split_adjacent_words(description):
    words = wordninja.split(description)
    return" ".join(words)

df['description_clean'] = df[df['description'].isna()==False]['description'].apply(lambda x : split_adjacent_words(x))


Q: Removing contents of two files at the same time - UNIX I have two files called "fileA.txt" and "fileB.txt".
fileA.txt has the following contents :
1   Arizona   ABDJAQ   224
2   Ohio      AKOGFR   458
3   Wisconsin EFGTAP   871
4   Colorado  NAHBAX   991

The four columns above are "ID", "State", "Pattern", "Number"
fileB.txt has the following contents:
1   Arizona   NKIGAB   763
2   Ohio      BAVYAD   918
3   Wisconsin AUOBAQ   547
4   Colorado  INABEA   622

Again the four columns are "ID", "State", "Pattern", "Number"
Now this is what I want to do:
I want to scan through "fileA.txt" first and remove all records whose "Pattern" column just has one "A". Keep all records that have 2 "A"'s in them. So I would remove Ohio and Wisconsin. (ID "2" and ID "3"). At the same time, I want to simultaneously remove these ID's from "fileB.txt" as well !! (inspite of the fact that in fileB, Ohio and Wisconsin have 2 "A"'s in the pattern).
After this step, my "fileA.txt" should look like :
1   Arizona   ABDJAQ   224
4   Colorado  NAHBAX   991

and my "fileB.txt" should look like :
1   Arizona   NKIGAB   763
4   Colorado  INABEA   622

Next, I want to scan "fileB.txt" to remove any records with patterns having one "A" and delete the corresponding record from "fileA.txt". (in this case Arizona because it has only "A" in fileB and so we remove Arizona from both fileB and fileA.)
After this step, I would be left with only one record in each file :
"fileA.txt" will have:
4   Colorado  NAHBAX   991

and "fileB.txt" will have
4   Colorado  INABEA   622

So, to put it in short, I want to scan both files and keep only those records which have 2 "A"'s in their pattern in BOTH files.
Is there a one-line Unix command or a relatively easy approach to do this ?
appreciate the help !

A: I have written one-liner in a Python(280 characters of code) for this.
python -c"import re,sys;o=lambda f,m:open(f,m);x=lambda h:[i for i in o(h,'r').readlines()];y=lambda s:len(re.findall(r'(\w+)',s)[2].split('A'))>2;z=lambda f,s:o(f,'a'if len(s)else'w').write(s);a,b=sys.argv[1:3];w=zip(x(a),x(b));z(a,'');z(b,'');[(z(a,c),z(b,d))for(c,d)in w if y(c)and y(d)]" a.txt b.txt

Note: this code does not close file descriptors. I assume that OS does that.


Q: JQuery + Fullcalendar - large number of iteration with jquery object I'm trying to render large number of events (about 50, and it's might be more).
                    for (var eventIndex = 0; eventIndex < resp.select_events.length; eventIndex++){
                    var event = resp.select_events[eventIndex];
                    c.fullCalendar('renderEvent',{
                        id: event.id,
                        title: eventName,
                        start: event.event_date,
                        description: eventDesc,
                        write: event.write
                    },true);
                }

It takes several seconds, and sometimes browser asks me for abort scipt execution. So, I think, I need a way to do it somehow like async - parrallel with execution of last part of script. Can you advice some tool or something like that? Thx

A: Modifying the loop itself may help at some degree. Read this article http://jsperf.com/fastest-array-loops-in-javascript/11
Also this https://blogs.oracle.com/greimer/entry/best_way_to_code_a
In general fastest way for your loop is while loop in reverse, with simplified the test condition:
var i = arr.length; while (i--) {/*....*/}

A: Do you have to render one by one? Why dont you setup first an array like a JSON array and add it to eventSources? The best way for your calendar to render large number of events is to let Fullcalendar do the job for you. You are trying ,in my perspective ofc, do what fullcalendar internally already does. Check the example below and this is if you have to do this client side, i would do this server side.
          var jsonarray = [];
          for (var eventIndex = 0; eventIndex < resp.select_events.length; eventIndex++){

               /* c.fullCalendar('renderEvent',{
                    id: event.id,
                    title: eventName,
                    start: event.event_date,
                    description: eventDesc,
                    write: event.write
                },true);*/
               var event = resp.select_events[eventIndex];
               var myevent = {
                    "id": event.id,
                    "title": eventName,
                    "start": event.event_date,
                    "description": eventDesc,
                    "write": event.write
               };
               jsonarray.push(myevent);
            }

            c.fullCalendar('addEventSource', jsonarray);

Let em know if you have any doubt


Q: Combining two MS Access queries I have this query:
SELECT "I1" & "," & "I2" AS Item_set, Round(Sum([T1].Fuzzy_Value)/Count(*),15) AS Support
    FROM (SELECT *
    FROM Prune AS t
    WHERE t.Trans_ID IN

        (SELECT t1.Trans_ID FROM (

         SELECT *FROM Prune WHERE [Nama]="I1")  AS t1
         INNER JOIN (SELECT * FROM Prune WHERE [Nama]="I2")  AS t2 ON t1.Trans_ID = t2.Trans_ID)

    AND t.Nama IN ("I1","I2"))  AS T1;

And ttrans query
SELECT Count([Trans_ID].[Trans_ID]) AS Expr1
FROM Trans_ID;

I need to change Count (*) from :
 SELECT "I1" & "," & "I2" AS Item_set, Round(Sum([T1].Fuzzy_Value)/Count(*),15)

into ttrans query.
I've tried using
SELECT "I1" & "," & "I2" AS Item_set, Round(Sum([T1].Fuzzy_Value)/ttrans.Expr1,15) AS Support
FROM (SELECT *
FROM Prune AS t
WHERE t.Trans_ID IN

    (SELECT t1.Trans_ID FROM (

     SELECT *FROM Prune WHERE [Nama]="I1")  AS t1
     INNER JOIN (SELECT * FROM Prune WHERE [Nama]="I2")  AS t2 ON t1.Trans_ID = t2.Trans_ID)

AND t.Nama IN ("I1","I2"))  AS T1, ttrans;

But I got error like this :
You tried to execute a query that does not include the specified expression
'Round(sum([T1].Fuzzy_Value/ttrans.Expr1,15)' as part of an aggregate function

any idea how to fix it?
Note : I'm trying to find 2 combination of all item in transaction database and get a result like this
ITEM       Support
I1, I2     0.xxxxxxxxx

where support is (total transaction containing item I1 and I2 / total transaction) -> note that I'm using ttrans query to get total transaction value
note2: I'm using MS Access
note3:
Ttrans table will look like this
Expr1
270200

A: Try:
SELECT "I1" & "," & "I2" AS Item_set, Round(Sum([T1].Fuzzy_Value)/ttrans.Expr1,15) AS Support
FROM (SELECT *
FROM Prune AS t
WHERE t.Trans_ID IN

    (SELECT t1.Trans_ID FROM (

     SELECT *FROM Prune WHERE [Nama]="I1")  AS t1
     INNER JOIN (SELECT * FROM Prune WHERE [Nama]="I2")  AS t2 ON t1.Trans_ID = t2.Trans_ID)

AND t.Nama IN ("I1","I2"))  AS T1, ttrans
GROUP BY "I1" & "," & "I2"

A: somehow i find the answer :
i tried using
SELECT "I1" & "," & "I2" AS Item_set, Round(Sum([T1].Fuzzy_Value)/sum(ttrans.Expr1),15)

it worked wonder


Q: Controlling the PTZ function of IP camera using C++ I am working on a project that requires the control of the PTZ function of my IP camera through the UI. I am currently using a D-Link DCS-5020L cloud camera, Microsoft Visual Studio 2017 and OpenCV 3.3 for my setup.
I am still new to c++ and OpenCV but my project requires the use of it. I am able to access the camera feed but I'm not sure how to control the functions of the camera using C++ code through OpenCV or if OpenCV is even needed.
Is there a C++ code to control the PTZ functions of the IP camera?
This is my code for attaining the video output, if necessary.
// VIDEO CAPTURE //

Mat frame;

VideoCapture cap("http://username:password@IPADDRESS:PORT/video.cgi?resolution=640x360&req_fps=30&.mjpg");

if (!cap.isOpened())    //EXIT PROGRAM IF FAILED
{
    cout << "CAMERA UNAVAILABLE" << endl;
    return -1;
}
while (1)
{
    bool bSuccess = cap.read(frame);    //READ NEW FRAME FROM VIDEO

    if (!bSuccess)      //BREAK LOOP IF FAILED
    {
        cout << "UNABLE TO DISPLAY VIDEO" << endl;
        break;
    }
}

Any help is appreciated. Thank you.

A: Usually, PTZ functions are software implemented on the server running in the cam.
Some older cameras used to ship with an activeX control.
These functions can be accessed by getting or posting to a url relative to the camera.
For Your camera, you should be able to post the controls on the following url:
http://<ip>/pantiltcontrol.cgi

Available controls:
POST parameters
PanSingleMoveDegree (default 5)
TiltSingleMoveDegree (default 5)
PanTiltSingleMove

Values for PanTiltSingleMove (based on the web UI controls):
Top 1
Top right   2
Right   5
Bottom right    8
Bottom  7
Bottom left 6
Left    3
Top left    0
Home (reset)    4

So a typical post example using curl to change the pan-tilt, should be similar to this:
curl --user <username>:<password> --user-agent "user" --data "PanSingleMoveDegree=5&TiltSingleMoveDegree=5&PanTiltSingleMove=5" http://<ip>/pantiltcontrol.cgi

For a quick test using your web browser, You should Be able to do the same thing using a get request for the following structured url:
http://<username>:<password>@<ip>/pantiltcontrol.cgi?PanSingleMoveDegree=5&TiltSingleMoveDegree=5&PanTiltSingleMove=5

Now, Back to your question. All you need to control PTZ in C++, is to web query the mentioned urls. So this should be your searching point.
Many Answers for this topic are already on stack overflow. This is the first result I got while googling "c++ http get post".
    How do you make a HTTP request with C++?


Q: Template function that calls itself results in "instantiation depth exceeds maximum of 900" I am trying to create a function that accepts a lambda function callback and some candidate_primes that can be a set or a vector, but it gives the error:

template instantiation depth exceeds maximum of 900

template<class PrimeIter, class Function>
void iter_feasable_primes(
  const PrimeIter& candidate_primes, const uint32_t larger_prime, uint8_t index, Function cb
) {
  std::vector<uint32_t> next_candidate_primes;
  for (const uint32_t p : candidate_primes) {
    // Updates next_candidate_primes
  }
  if (index == 0) {
    // No valid tuples of primes were found
    return;
  }
  for (const uint32_t p : next_candidate_primes) {
    iter_feasable_primes(next_candidate_primes, p, index - 1, [&](std::vector<uint32_t> smaller_primes) {
      smaller_primes.push_back(p);
      cb(smaller_primes);
    });
  }
}

I think the problem is the function uses a lambda to call itself, and the compiler doesn't understand the function itself just has a single lambda callback type.
How can I solve this?
I tried to make index a template parameter to no avail, as the compiler doesn't seem to understand that it'll never get to index = -1, and complains to me that -1 isn't defined. But ideally I don't want index to be a template parameter.

A: Indeed lambda have unique type and so you have to instantiate infinite recursion.
One way to solve that is to give an unique type, either a custom functor, or a type-erased type as std::function
template<class PrimeIter>
void iter_feasable_primes(
  const PrimeIter& candidate_primes,
  uint32_t larger_prime,
  uint8_t index,
  std::function<void(std::vector<uint32_t>)> cb)
{
  std::vector<uint32_t> next_candidate_primes;
  for (const uint32_t p : candidate_primes) {
    // Updates next_candidate_primes
  }
  if (index == 0) {
    // No valid tuples of primes were found
    return;
  }
  for (const uint32_t p : next_candidate_primes) {
    iter_feasable_primes(next_candidate_primes, p, index - 1, [&](std::vector<uint32_t> smaller_primes) {
      smaller_primes.push_back(p);
      cb(smaller_primes);
    });
  }
}


Q: (CSS) Ways to bind element to bottom? Is there a other way to put an HTML element to the bottom except :
position: absolute;
bottom: 0;

and at the parent element:
position: relative

...or setting the margin so that the element fits exactly at the bottom?

A: Well, you can also use position: fixed; bottom: 0;, which will stick the element to the bottom of the window. That means it won't even scroll with the rest of the page.
When you use that for a full-width footer or the like (the most likely use case), you'd then need to add a margin to the rest of the page content so that it doesn't get hidden behind (or hide) the footer.
Other than that you're pretty much stuck with the options you mentioned.
Full documentation on the position property can be found here:
https://developer.mozilla.org/en-US/docs/Web/CSS/position

A: You can also use position: fixed
.elem {
  position: fixed;
  bottom: 0;
}

Or you can use Flex then set your element to align-self: flex-end
e.g.
.container {
  height: 150px;
  width: 150px;
  display: flex;
  display: -webkit-flex;
  -webkit-flex-direction: row;
  flex-direction: row;
   border: 1px solid red;
}

.container div {
  -webkit-align-self: flex-end;
  align-self: flex-end
}

Fiddle