notepad++ – Is there a way to break lines that match a string pattern, but only if that pattern falls between matching strings?

I’m using the code below to break lines that match a pattern:

Find what: ((0-9)) ((A-Z))
Replace with: 1n2

so that …

Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3

… becomes

Super Bowl 3,1:56.2 
Armbro Goal 3,1:54.3

But I have to do it manually because I have tens of thousands of lines and if I use Replace All it will break lines in areas I do not want broken.

Specifically, I want to break lines that match the pattern in areas that lie between “zyxl” and “1st Dam”, but not break any lines with matching patterns between “1st Dam” and “zyxl”

The following code will find the areas where I want lines broken:
(?s)^tzyxl(.|rn)?1st Dam

And this code will find areas where I don’t want code broken:
(?s)^t1st Dam (.|rn)?zyxl

Is there a way, either by combining these methods, or otherwise, to rearrange the text so that …

zyxl
QUEENB BLUE CHIP  
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3 Grassbed 2,1:59.1  
1st Dam 
RICHESSE OBLIGE Varenne. 13 wins, 2 thru 5. This is her first foal. 
zyxl

VENERATE 
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3 Grassbed 2,1:59.1  
1st Dam RICHESSE OBLIGE 13 wins, 2 thru 5. This is her first foal. 
Zyxl

… becomes

zyxl
QUEENB BLUE CHIP  
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
Grassbed 2,1:59.1  
1st Dam 
RICHESSE OBLIGE Varenne. 13 wins, 2 thru 5. This is her first foal. 
zyxl

VENERATE 
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
Grassbed 2,1:59.1  
1st Dam RICHESSE OBLIGE 13 wins, 2 thru 5. This is her first foal. 
zyxl

And yes, “1st Dam” sometimes begins a long line, and sometimes it is the only text on a line, but it always precedes the area that I need untouched by line breaks (followed by “zyxl”).

Thank you in advance for your time and assistance.

machine learning – How to use classify to separate lines and circles

I generated lines and circles:

lines = Table[
   Graphics[
    Line[{{RandomInteger[{0, 10}], 
       RandomInteger[{0, 10}]}, {RandomInteger[{0, 10}], 
       RandomInteger[{0, 10}]}}], ImageSize -> 10], {x, 1, 20}];
circles = 
  Table[Graphics[
    Circle[{RandomInteger[{0, 10}], RandomInteger[{0, 10}]}, 
     RandomInteger[{0, 20}]], ImageSize -> 10], {x, 1, 20}];

and put them into a classifier

c = Classify[{lines -> "lines", circles -> "circles"}]

the training was successful with no errors, but when trying to test the classifier with:

test = Graphics[Line[{{0, 1}, {0, 2}}], ImageSize -> 10]
c[test]

I get the error:

ClassifierFunction::mlbddataev: The data being evaluated is not
formatted correctly.

And I do not understand what the problem is. Can somebody tell me, how to correctly format the data?

javascript – Raycasting – weird lines on walls when ray is facing up or right

I am trying to make a raycasting game. Everything is rendered correctly except when the ray is facing up (angle > PI) or facing right(angle > 0.5PI and < 1.5PI) lines are drawn on walls. I am not sure what is causing it to happen but I know that the lines are not affected by the rotation of the player only by the players position. I also tried rounding the rays position but that did not help.

Right and up ray walls.
Text

The walls up close.
Text

Left and down ray walls.
Text

Code:

        let rayX, rayY, rayAngle, rayDeltaX, rayDeltaY

        for (let i = 0; i < this.screen.width; i ++) {
            rayAngle = this.angle - this.fov / 2 + i * (this.fov / this.screen.width)
            
            if (rayAngle < 0) {
                rayAngle += Math.PI * 2
            }
            else if (rayAngle > Math.PI * 2) {
                rayAngle -= Math.PI * 2
            }

            rayX = this.x
            rayY = this.y

            let stepY

            if (rayAngle > Math.PI) {
                stepY = -this.tileSize
                rayY = Math.floor(rayY / this.tileSize) * this.tileSize - 1
            }
            else {
                stepY = this.tileSize
                rayY = Math.floor(rayY / this.tileSize) * this.tileSize + this.tileSize
            }

            rayX = this.x  + (rayY - this.y) / Math.tan(rayAngle)
         
            rayDeltaY = stepY
            rayDeltaX = stepY / Math.tan(rayAngle)

            while(true) {
                if (this.Map.map(Math.floor(rayY / this.tileSize) * this.Map.width + Math.floor(rayX / this.tileSize)) == '#') {
                    break
                }

                rayX += rayDeltaX
                rayY += rayDeltaY
            }

            let rayHorizontalX = rayX
            let rayHorizontalY = rayY
            let rayDistanceHorizontal = Math.sqrt((this.x - rayHorizontalX) ** 2 + (this.y - rayHorizontalY) ** 2)

            rayX = this.x
            rayY = this.y

            let stepX

            if (rayAngle > 0.5 * Math.PI && rayAngle < 1.5 * Math.PI) {
                stepX = -this.tileSize
                rayX = Math.floor(rayX / this.tileSize) * this.tileSize - 1
            }
            else {
                stepX = this.tileSize
                rayX = Math.floor(rayX / this.tileSize) * this.tileSize + this.tileSize
            }

            rayY = this.y + (rayX - this.x) * Math.tan(rayAngle)
    
            rayDeltaY = stepX * Math.tan(rayAngle)
            rayDeltaX = stepX

            while(true) {
                if (this.Map.map(Math.floor(rayY / this.tileSize) * this.Map.width + Math.floor(rayX / this.tileSize)) == '#') {
                    break
                }
    
                rayX += rayDeltaX
                rayY += rayDeltaY
            }
            
            let rayVerticalX = rayX
            let rayVerticalY = rayY
            let rayDistanceVertical = Math.sqrt((this.x - rayVerticalX) ** 2 + (this.y - rayVerticalY) ** 2)
            
            let rayFinalDistance

            if (rayDistanceHorizontal < rayDistanceVertical) {
                rayFinalDistance = rayDistanceHorizontal
                ctx.fillStyle = 'darkblue'
            }
            else {
                rayFinalDistance = rayDistanceVertical
                ctx.fillStyle = 'blue'
            }

            let rayCorrectedDistance = rayFinalDistance * Math.cos(rayAngle - this.angle)

            let lineHeight = this.tileSize * (this.screen.width / 2 / Math.tan(this.fov / 2)) / rayCorrectedDistance
            let lineBottom = this.projectionPlane.centerY + lineHeight * 0.5
            let lineTop = this.projectionPlane.height - lineBottom

            ctx.fillRect(i, lineTop, 1, lineHeight)
        }

Any help would be appreciated.

digital – What are these lines in photos when viewed zoomed in on iPhone?

I take photos on my Canon (It happens on both my Canon EOS Rebel t1i and my Canon EOS R) camera then download them onto my iPhone. Then when I zoom in close enough, there are these invisible lines on the image (when you follow them along they form a 3×3 grid on the image).This happens in every single image that I download from my camera to my iPhone. What are they, and if possible, how can I fix them?

Uncropped:

Uncropped

Half-Way Zoomed In:

Half-Way Zoomed In

Fully Zoomed-In:

Fully Zoomed-In

What causes these patchwork lines in the resulting image from my scanner?

I’m trying to scan some old trading cards (AD&D Trading Cards from 1991) and I’m having trouble getting a good scan result on a flat bed scanner.

The issue I’m having is the resulting image appears as a patchwork that is not lined up properly.

Here is a zoomed in portion of a 1200dpi scan on my Canon CanoScan LiDE 210:

enter image description here

I tried buying a more recent scanner, an Epson Perfection V39 with the same problem but with a different representation or place:

enter image description here

What is causing this artifact across manufacturers?

I need to make a shell script that displays config files without the commented and empty lines

This is my code:

#!/bin/bash
echo "Type in your file"
read file
sed -r -e 's/(^(^#)*$) ; s/(^(^;)*$) ; s/(^(^$)*$) ; s/(^(^/)*$) ; s/(^(^ )*$)' $file

This is the output when I give it a file:

sed: -e expression #1, char 31: unknown option to `s’

Why am I getting this error? Would you suggest another way to do it?
Thanks in advance

geometry – A Question from Straight lines

In $triangle ABC$, the coordinates of vertex $A$ are $(4,-1)$, and lines $x-y-1=0$ and $2x-y=3$ are the internal angle bisectors of angles $B$ and $C$. Then, the radius of the incircle of triangle $ABC$ is?

I found out the point of intersection of the angle bisectors because that’s the centre of the circle.

Now can someone please suggest how to proceed further with this problem?
Thanks in advance!

javascript – Leaflet ajax query to get lines from PostGIS problem when loading

I have a strange issue with my Leaflet/Javascript code. I’m trying to refactor my application which was initially getting line data from PostGIS as a certain layer checkbox has been checked:

enter image description here

Then it bound some popups etc. It was working fine, but each time it was collecting all checked boxes values and sending it through ajax to PostGIS query and getting JSON response into queryLayer. So that each time some checkbox has been changed, the current queryLayer has been removed and loaded again with new data.

After my refactor I’m now able to:

  1. Create a dedicated variable for layer as the checkbox is clicked using window(checkboxValue) (which allows me to create var names dynamically) and populate it with PostGIS geometry using ajax.
  2. Once a particular checkbox is unchecked – then I’m removing this window(uncheckedValue) by layer.id var.

My problem is that after checking the second layer checkbox it is added into the map correctly and its popups/click events work fine, but first (previous) layer, although is visible as desired, popups/click events are not possible anymore for it.

NOTE: I’ve tried both:

  • separate layers: window(checkedTrasa)= L.geoJSON(JSON.parse(response), {...}
  • L.featureGroup() and adding/removing layers from group
var myRenderer = L.canvas({ padding: 0.5, tolerance: 20 });
var trasyAll = L.featureGroup();
var R10
var WTR
$('input(name="trasy_checkbox")').click(function() {
        var myRenderer = L.canvas({ padding: 0.5, tolerance: 20 });
        if (!$(this).is(':checked')) {
          mymap.eachLayer(function (layer) {
            if (layer.id === removeTrasa )  {
                mymap.removeLayer(layer)
                var queryTrasy;
            }
        })};
        if ($(this).is(':checked')) {
            $.ajax({
            url:'script.php',
            type:'POST',
            data:{
                wybor_trasy: checkedTrasa
            },
            success: function(response){
                window(checkedTrasa)= L.geoJSON(JSON.parse(response), {
                    onEachFeature: function(feature, layer) {
                        var str = "blahblah";
                        layer.bindPopup(str, {
                            maxWidth: "auto"
                        });
                        layer.setStyle(StanOdcinkaStyle(layer));
                        layer.setStyle({renderer: myRenderer});
                        layer.bindTooltip('<img src="https://stackoverflow.com/images/r10-13.png" height="20"/>');
                        layer.on('mouseover', function () {
                          this.setStyle({
                            opacity: 0.6,
                            weight: 6
                          });
                        });
                        layer.on('mouseout', function () {
                          this.setStyle(StanOdcinkaStyle(this));
                          this.setStyle({
                            opacity: 1,
                            weight: 4
                          });
                        });
                }})
                window(checkedTrasa).id = checkedTrasa;
                window(checkedTrasa).addTo(trasyAll);
            }
            });
       }
   }); 
  trasyAll.addTo(mymap);

Any help or thoughts would be much appreciated!