How to save each line of text file as array through powershell

The Get-Content command returns each line from a text file as a separate string, so will give you an array (so long as you don’t use the -Raw parameter; which causes all lines to be combined to a single string). [string[]]$arrayFromFile = Get-Content -Path ‘C:\USER\Documents\Collections\collection.txt’ In his excellent answer, mklement0 gives a lot more detail … Read more

Why is drawing a line less than 1.5 pixels thick twice as slow as drawing a line 10 pixels thick?

Summary: Antialiasing subpixel thickness lines is hard work and requires a number of dirty tricks to output what we intuitively expect to see. The extra effort you’re seeing is almost certainly due to antialiasing. When the line thickness is less than one pixel and the line doesn’t sit squarely at the center of a row … Read more

hl-line-mode emacs color change

I use (set-face-background hl-line-face “gray13”). here’s what it looks like with a black background. Very subtle. Mostly I notice it when moving the cursor, which is what I wanted. If you want to see a display of all the various colors, try (list-colors-display). It will show a list of colors in a new buffer. EDIT: … Read more

print every nth line into a row using gawk

To print every second line, starting with the first: awk ‘NR%2==1’ file.txt To print every tenth line, starting with the tenth line: awk ‘NR%10==0’ file.txt To use this in a script, add the following to a file called script.awk: BEGIN { print “Processing file” } NR%10==0 END { print “Finished processing” } Then execute: awk … Read more

3D Line-Plane Intersection

Here is a Python example which finds the intersection of a line and a plane. Where the plane can be either a point and a normal, or a 4d vector (normal form), In the examples below (code for both is provided). Also note that this function calculates a value representing where the point is on … Read more

Plotting numerous disconnected line segments with different colors

use LineCollection: import numpy as np import pylab as pl from matplotlib import collections as mc lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]] c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)]) lc = mc.LineCollection(lines, colors=c, linewidths=2) fig, ax = pl.subplots() ax.add_collection(lc) ax.autoscale() … Read more