Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
pseudorandom
Jun 16, 2010





Yam Slacker

Sri.Theo posted:

Hi all, a bit of a weird one here. Someone called Tom Forth (@thomasforth) recently published this tool called parkulator which calculates the amount of land area used for car parks in an area, it's a really useful tool if you're interested in urban design, affordable housing or economics.

Unfortunately it doesn't calculate the amount of land used for on street parking as that's marked differently on Open Street maps. My first instinct was to mark out the areas I care about as shapes on Open Street map but it seems like that's not how they want to do it.

He has posted the source on GitHub and said others are welcome to submit changes.

Is it possible to amend the current code to also pull the data for on street parking as well?


It sounds like he's using existing software and isn't using his own code.

quote:

Method

This tool uses osmconvert, osmfilter, and raw open street map downloads from Geofabrik. As such all data is Copyright of The Open Street Contributors.

I do six things,

  1. Download an osm.pbf file from Geofabrik (I picked Great Britain but this method will work for anywhere). Extraction date was 2019-05-10. The process will need re-running to include updates to OSM.
  2. Convert it from pbf to o5m format using osmconvert great-britain-latest.osm.pbf -o=great-britain-latest.osm.o5m.
  3. Use osmfilter to extract "amenity=parking" tags only using osmfilter great-britain-latest.osm.o5m --keep="amenity=parking" -o=great-britain-parking.osm.
  4. Load the osm file into QGIS and resave as GEOJSON.
  5. Download The OECD functional economic area shapefile for the UK and select my eight cities of interest.
  6. Use the clip function in QGIS to retain only the parking in those cities. A full file of all parking Great Britain is also provided. Both are exported in GEOJSON format and available for download in this repository.

You can download the referenced software, duplicate the process for your own locality, and then all you need to change is step 6. I don't know QGIS myself, but I would assume this is just a matter of changing some filter value for the clip function.

Adbot
ADBOT LOVES YOU

ephphatha
Dec 18, 2009






Step 3 is the important one. This command is used to discard all the map data except parking areas:
code:
osmfilter great-britain-latest.osm.o5m --keep="amenity=parking" -o=great-britain-parking.osm
To get what you're after you'd need to also keep roads with the parking:lane:* tags having a value of parallel, perpendicular, or diagonal (to cover the most common cases). Then you'd need to work out some way of calculating area based on the parking type which as far as I can tell OSM doesn't provide.

Sri.Theo
Apr 16, 2008


Thanks both, that’s really helpful.

Master Twig
Oct 25, 2007

I want to branch out and I'm going to stick with it.


A bit of a crosspost from the Raspberry Pi thread. I was hoping someone could help me program a simple countdown timer that I can run. I'm doing a homemade Escape Room for friends, and the goal is to shut down a self destruct sequence.

It will need to run on a raspberry pi. A simple HTML/Java or CSS page is probably the best way to do this. Ideally something I can just put on the Pi, run it, and off it goes.

I would want it to show a message that says: "Countdown to Self Destruct" with a countdown timer below that. Then, on the bottom would be an input. Text would read "Enter deactivation code to stop sequence:" with a cursor to enter a password. The timer would start at an hour and countdown to zero.

If the right password is entered, the sequence stops and the players win. It would display a message like "Sequence Deactivated" and the time remaining. If an incorrect password is entered, it instead takes 2 minutes off of the timer. If it reaches zero, it would flash red with a message saying they have died.

Players would have access to only a numeric keypad. I would have a keyboard and mouse that I could use to stop/start it that the players wouldn't have access to.

Any goons willing to take this on? Happy to provide an SA gift cert or Steam bux for help.

alexandriao
Jul 20, 2019

"What're quantum mechanics?"
"I don't know. People who repair quantums, I suppose."


Master Twig posted:

A bit of a crosspost from the Raspberry Pi thread. I was hoping someone could help me program a simple countdown timer that I can run. I'm doing a homemade Escape Room for friends, and the goal is to shut down a self destruct sequence.

It will need to run on a raspberry pi. A simple HTML/Java or CSS page is probably the best way to do this. Ideally something I can just put on the Pi, run it, and off it goes.

I would want it to show a message that says: "Countdown to Self Destruct" with a countdown timer below that. Then, on the bottom would be an input. Text would read "Enter deactivation code to stop sequence:" with a cursor to enter a password. The timer would start at an hour and countdown to zero.

If the right password is entered, the sequence stops and the players win. It would display a message like "Sequence Deactivated" and the time remaining. If an incorrect password is entered, it instead takes 2 minutes off of the timer. If it reaches zero, it would flash red with a message saying they have died.

Players would have access to only a numeric keypad. I would have a keyboard and mouse that I could use to stop/start it that the players wouldn't have access to.

Any goons willing to take this on? Happy to provide an SA gift cert or Steam bux for help.

I'm game! wanna dm me? :)

Master Twig
Oct 25, 2007

I want to branch out and I'm going to stick with it.


alexandriao posted:

I'm game! wanna dm me? :)

DM sent. Thanks

Grausherra
Jul 15, 2007

Look into my eyes...

I found this thread way too late.
I was interested in downloading "Directory Image Sorter for mastermenthe, he's my secret boyfriend don'tchaknow? Written by Hoborg, who is totally the god of Klaymen and really not Sevenofnine" but neither the download link nor the source link work right now. I'm hoping some kind goon would have a copy of the software they could upload for me.

Chunjee
Oct 27, 2004



I have no idea how I didn't back that up better, after links died once already.

Grausherra
Jul 15, 2007

Look into my eyes...

Chunjee posted:

I have no idea how I didn't back that up better, after links died once already.

I can relate, I often think that I should backup X, Y, and Z, but by the time I get to it, the links are dead.
Thanks though and here's to hoping some goon grabbed it and ends up visiting this thread.

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

I need a hopefully very simple email parser. Due to corporate policy reasons, I'm not going to be able to use online services to do it.

What I have is an outlook inbox with 17k emails and rising. They are all automatically generated timer warnings. They all look like the attached imaged.

I need to troll through those emails, and extract only the time, machine, and line and output it as a csv or xls for all 17k events whereupon I can do my magic and demonstrate beyond a shadow of a doubt to my overlords that this goddamned monitoring system is a waste of loving time and electrons.

I would be willing to offer gift certs or whatever reasonable recompense.

Only registered members can see post attachments!

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


Disregard, I missed a word.

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


tactlessbastard posted:

I need a hopefully very simple email parser.

This is probably complicated by the fact that you're going to try and parse html that wasn't meant for it, and if someone wants to tackle the whole thing head-on, more power to them.

If by "time", you mean whatever's listed under "Last Check", whoever is doing this will need access to the raw (sanitized) text of one of the e-mails because they'll need to figure out exactly what the HTML rendering that table is.

Otherwise, you can just use a short powershell script like the one below to dump it all out somewhat sanely.

Warnings:
  • This script has zero error checking and isn't suitable for Enterprise deployment as-is. It won't break anything, but don't try to amaze your friends and coworkers with it without trying it first.
  • It will try and write a log file to your C:\tmp directory. If you don't have one or can't write to it, change the location in the script or you won't get any output.
  • It grabs the "Sent On" timestamp from the e-mail because there's no reasonable way to parse the "Last Check" time from a screenshot.
  • Outlook/Exchange are known to artificially limit the number of items returned by a query, especially in situations where your organization may be archiving emails. 17k may be too much for one pass, so if you find that the number of emails you have doesn't match the number of rows you are getting dumped to CSV, you might need to do dumb things like portion out 1k emails at a time into a folder and run queries against just that folder.

That all said, here's a sample script:
code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($body -match "Machine Name: (.*)") {
            $payload.Machine = $matches.1
        }
        if($body -match "Line Number: (.*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

Toshimo posted:

This is probably complicated by the fact that you're going to try and parse html that wasn't meant for it, and if someone wants to tackle the whole thing head-on, more power to them.

If by "time", you mean whatever's listed under "Last Check", whoever is doing this will need access to the raw (sanitized) text of one of the e-mails because they'll need to figure out exactly what the HTML rendering that table is.

Otherwise, you can just use a short powershell script like the one below to dump it all out somewhat sanely.

Warnings:
  • This script has zero error checking and isn't suitable for Enterprise deployment as-is. It won't break anything, but don't try to amaze your friends and coworkers with it without trying it first.
  • It will try and write a log file to your C:\tmp directory. If you don't have one or can't write to it, change the location in the script or you won't get any output.
  • It grabs the "Sent On" timestamp from the e-mail because there's no reasonable way to parse the "Last Check" time from a screenshot.
  • Outlook/Exchange are known to artificially limit the number of items returned by a query, especially in situations where your organization may be archiving emails. 17k may be too much for one pass, so if you find that the number of emails you have doesn't match the number of rows you are getting dumped to CSV, you might need to do dumb things like portion out 1k emails at a time into a folder and run queries against just that folder.

That all said, here's a sample script:
code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($body -match "Machine Name: (.*)") {
            $payload.Machine = $matches.1
        }
        if($body -match "Line Number: (.*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation

By time I did mean the time the email was sent. Thanks, I'll test this tonight and report back.

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

Got it to run, and it is pulling time and placing that in the csv but it is not pulling machine or line. It is creating those columns but not making entries.

alexandriao
Jul 20, 2019

"What're quantum mechanics?"
"I don't know. People who repair quantums, I suppose."


you can parse the headers for the timestamp. you could also compile a windows version of lynx and use that to parse the html from the email, used with --dump you can feed to unix tools or python

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


tactlessbastard posted:

Got it to run, and it is pulling time and placing that in the csv but it is not pulling machine or line. It is creating those columns but not making entries.

That means it's probably using HTML #nbsp; for spaces or something. I'd need to see a plaintext dump of the message body to correct the regexes.

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

Toshimo posted:

That means it's probably using HTML #nbsp; for spaces or something. I'd need to see a plaintext dump of the message body to correct the regexes.


code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head>
<body><br>Defects found at:<br>Work Order: 285780<br>Machine Name: PACKER<br>Quality Check Type: PACKER - Case Check<br>Line Number: 08<br><br><table border="1"><tr><td><b>Check Type</b></td><td><b>Line Number</b></td><td><b>Work Order</b></td><td><b>Item SKU</b></td><td><b>Last Check</b></td><td><b>Check Interval</b></td><td><b>Time Elapsed</b></td><td><b>Last Tester Name</b></td></tr> <tr> &#160;<td>Packer - Case Check</td> &#160;<td>08</td> &#160;<td>285780</td> &#160;<td>71608010</td> &#160;<td>2020-12-17 18:00:15.0</td> &#160;<td>30 minutes</td> &#160;<td>00:45:01</td> &#160;<td>REDACTED</td></tr></table></body></html>

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


Updated regexes:

code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($body -match "Machine Name: ([^<]*)") {
            $payload.Machine = $matches.1
        }
        if($body -match "Line Number: ([^<]*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

Toshimo posted:

Updated regexes:

code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($body -match "Machine Name: ([^<]*)") {
            $payload.Machine = $matches.1
        }
        if($body -match "Line Number: ([^<]*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation


Thank you so much! However, still getting incomplete pulls. Attaching a screenshot.

Only registered members can see post attachments!

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


tactlessbastard posted:

Thank you so much! However, still getting incomplete pulls. Attaching a screenshot.

Ah yes, silly typo on my part going from my test machine.

code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($email.Body -match "Machine Name: ([^<]*)") {
            $payload.Machine = $matches.1
        }
        if($email.Body -match "Line Number: ([^<]*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

Toshimo posted:

Ah yes, silly typo on my part going from my test machine.

code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($email.Body -match "Machine Name: ([^<]*)") {
            $payload.Machine = $matches.1
        }
        if($email.Body -match "Line Number: ([^<]*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation

Beautiful! Thanks! What's your pleasure?

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

This is possibly something just really silly but I'm having a further hangup. Now that I have the data all extracted, when I try to do anything at all with it in excel (sort, copy, highlight, move) all the values in the cells change from the value to the entire text of the email the value was pulled from.

Now that I have 17k x 3 points of data, generally speaking this crashes excel.

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


There are 2 things I know for certain:

1. Whatever is happening is hilarious.
2. I've got an army of well-paid dudes showing up in 9 hours to move all my poo poo across town.

So, I won't have a chance to look at this until Monday at the earliest. I hope someone ITT can maybe spot the issue before then.

Pikehead
Dec 3, 2006

Looking for WMDs, PM if you have A+ grade stuff


Fun Shoe

tactlessbastard posted:

This is possibly something just really silly but I'm having a further hangup. Now that I have the data all extracted, when I try to do anything at all with it in excel (sort, copy, highlight, move) all the values in the cells change from the value to the entire text of the email the value was pulled from.

Now that I have 17k x 3 points of data, generally speaking this crashes excel.

What does the data look like if you open it in notepad or something like notepad++?

Additionally, how big is the csv file?

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

Pikehead posted:

What does the data look like if you open it in notepad or something like notepad++?

Additionally, how big is the csv file?

Ok, I'm back at work. The first .csv which I ran on 10 emails as I tested the limits of the script (10 emails, 50 emails, 100, 500, 1000, 2000, etc.) Never ran into a show stopping limit before running out of emails to parse.

Anyway, that .csv with 10 emails is 6kb.

If I open them with notepad it shows the whole contents of the email. (Names deleted)

code:
"Line","Time","Machine"
"08


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 08	 288485	 71608001	 2020-12-18 17:40:00.0	 30 minutes	 00:45:03	 	","12/18/2020 17:25","PACKER
Quality Check Type: PACKER - Check Sheet
Line Number: 08


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 08	 288485	 71608001	 2020-12-18 17:40:00.0	 30 minutes	 00:45:03		"
"12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 12	 288665	 20012176	 2020-12-18 17:41:14.0	 30 minutes	 00:45:03	 	","12/18/2020 17:26","PACKER
Quality Check Type: PACKER - Check Sheet
Line Number: 12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 12	 288665	 20012176	 2020-12-18 17:41:14.0	 30 minutes	 00:45:03	 	"
"12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Case Check	 12	 288665	 20012176	 2020-12-18 17:41:16.0	 30 minutes	 00:45:00	 	","12/18/2020 17:26","PACKER
Quality Check Type: PACKER - Case Check
Line Number: 12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Case Check	 12	 288665	 20012176	 2020-12-18 17:41:16.0	 30 minutes	 00:45:00	 	"
"03


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Labeler - Verify Check	 03	 278845	 21000030	 2020-12-18 18:21:03.0	 30 minutes	 00:45:01		","12/18/2020 18:06","LABELER
Quality Check Type: LABELER - Verify Check
Line Number: 03


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Labeler - Verify Check	 03	 278845	 21000030	 2020-12-18 18:21:03.0	 30 minutes	 00:45:01		"
"12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 12	 288665	 20012176	 2020-12-18 18:44:55.0	 30 minutes	 00:45:03		","12/18/2020 18:29","PACKER
Quality Check Type: PACKER - Check Sheet
Line Number: 12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 12	 288665	 20012176	 2020-12-18 18:44:55.0	 30 minutes	 00:45:03		"
"12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 12	 288665	 20012176	 2020-12-18 18:44:55.0	 30 minutes	 00:45:04	 	","12/18/2020 18:30","PACKER
Quality Check Type: PACKER - Check Sheet
Line Number: 12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Check Sheet	 12	 288665	 20012176	 2020-12-18 18:44:55.0	 30 minutes	 00:45:04	 	"
"12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Case Check	 12	 288665	 20012176	 2020-12-18 18:44:58.0	 30 minutes	 00:45:00	 	","12/18/2020 18:29","PACKER
Quality Check Type: PACKER - Case Check
Line Number: 12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Packer - Case Check	 12	 288665	 20012176	 2020-12-18 18:44:58.0	 30 minutes	 00:45:00		"
"08


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Triblock - Red Zone Check	 08	 288485	 71608001	 2020-12-18 19:14:49.0	 30 minutes	 00:45:01	 	","12/18/2020 18:59","TRIBLOCK
Quality Check Type: TRIBLOCK - Red Zone Check
Line Number: 08


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Triblock - Red Zone Check	 08	 288485	 71608001	 2020-12-18 19:14:49.0	 30 minutes	 00:45:01	 	"
"08


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Labeler - Verify Check	 08	 288485	 71608001	 2020-12-18 19:16:02.0	 30 minutes	 00:45:00	 	","12/18/2020 19:01","LABELER
Quality Check Type: LABELER - Verify Check
Line Number: 08


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Labeler - Verify Check	 08	 288485	 71608001	 2020-12-18 19:16:02.0	 30 minutes	 00:45:00		"
"12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Palletizer - Pallet / Depal Check	 12	 288665	 20012176	 2020-12-18 19:22:44.0	 30 minutes	 00:45:00	 	","12/18/2020 19:07","PALLETIZER
Quality Check Type: PALLETIZER - Pallet / Depal Check
Line Number: 12


Check Type	Line Number	Work Order	Item SKU	Last Check	Check Interval	Time Elapsed	Last Tester Name	
Palletizer - Pallet / Depal Check	 12	 288665	 20012176	 2020-12-18 19:22:44.0	 30 minutes	 00:45:00	 	"

Pikehead
Dec 3, 2006

Looking for WMDs, PM if you have A+ grade stuff


Fun Shoe

How big is the data file with all the exported information in it?

That file looks alright, although it does seem to have a bunch of duplication in it.

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


Sorry, my FiOS gets installed tomorrow morning. I'll take another look then.

The problem is that:
(A) using "Pattern: (.*)" returned nothing, which I assumed meant that it was using HTML source and the space after the colon was a special character.
(B) using "Pattern: ([^<]*)" returns the entire rest of the email (but starts in the correct place) which means that it isn't returning some sort of HTML code in the $email.Body property.

If I was doing this with my hand on everything instead of living vicariously through screenshots, I'd have just dumped the body property, figured out exactly what's being returned in what format, and adjusted accordingly, but it's a lot harder without direct access to the data.

The only other thought off the top of my head is that maybe < needs to be escaped in the regex because it's a special character.

Toshimo fucked around with this message at 05:25 on Dec 23, 2020

pseudorandom
Jun 16, 2010





Yam Slacker

tactlessbastard posted:

Ok, I'm back at work. The first .csv which I ran on 10 emails as I tested the limits of the script (10 emails, 50 emails, 100, 500, 1000, 2000, etc.) Never ran into a show stopping limit before running out of emails to parse.

Anyway, that .csv with 10 emails is 6kb.

If I open them with notepad it shows the whole contents of the email. (Names deleted)

I believe the $email.Body property is returning the cleartext body (without HTML) if I'm understanding the docs correctly. Since the current regex is looking for an HTML tag, I think you might be able to edit it to just look for whitespace (and new lines). I think this will work as long as the Machine Name and Line Number do not have spaces in them.

code:
$mailbox = 'yourname@company.com'
$searchphrase = '^ALERT - Timer'
$outfile = "C:\tmp\timer_alerts_$(get-date -UFormat “%Y_%m_%d_%H_%M_%S”).csv"

$outlook = New-Object -comobject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
$store = $namespace.Stores[$mailbox]
$inbox = $store.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$root = $store.GetRootFolder()

$data = @()

Foreach ($email in $inbox.Items) {
    if($email.Subject -match $searchphrase) {
        $payload = @{ Time = ""; Machine = ""; Line = ""}
        if($email.Body -match "Machine Name: ([^<\s\r\n]*)") {
            $payload.Machine = $matches.1
        }
        if($email.Body -match "Line Number: ([^<\s\r\n]*)") {
            $payload.Line = $matches.1
        }
        $payload.Time = $email.SentOn | Get-Date -UFormat "%m/%d/%Y %R"

        $data += $payload
    }
}

$data | % {New-Object psobject -Property $_ } | Export-CSV $outfile -NoTypeInformation

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

I'll try those out when I get back to work in the new year, thanks!

tactlessbastard
Feb 4, 2001

Godspeed, post


Fun Shoe

You beautiful bastards, it worked perfectly! Toshimo, pseudorandom, please name your desire!

Sri.Theo
Apr 16, 2008


Is it possible to set up a script that will automatically move new downloads from my /Users/name/Downloads into /Users/name/OneDrive/5.Downloads and would someone help me? I want to do it this way as I won't have to change the settings in a bunch of individual apps and some don't work well with one demand folders.

Edit: This is on an up to date MacBook.

susan b buffering
Nov 14, 2016



Sri.Theo posted:

Is it possible to set up a script that will automatically move new downloads from my /Users/name/Downloads into /Users/name/OneDrive/5.Downloads and would someone help me? I want to do it this way as I won't have to change the settings in a bunch of individual apps and some don't work well with one demand folders.

Edit: This is on an up to date MacBook.

If you’re willing to spend a little money, Hazel is intended for this sort of thing. I use it myself for basically the same thing you want and it works perfectly.

You could also probably replace the Downloads folder with a symlink or alias to your OneDrive folder.

e: You can also make a "Folder Action" using Automator to accomplish this. It would look something like this:



susan b buffering fucked around with this message at 19:03 on Jan 9, 2021

Sri.Theo
Apr 16, 2008


skull mask mcgee posted:

If you’re willing to spend a little money, Hazel is intended for this sort of thing. I use it myself for basically the same thing you want and it works perfectly.

You could also probably replace the Downloads folder with a symlink or alias to your OneDrive folder.

e: You can also make a "Folder Action" using Automator to accomplish this. It would look something like this:



45 USD is a little expensive for my needs but automator worked perfectly- thanks!

Spoke Lee
Dec 31, 2004

chairizard lol

I feel dumb not being able to figure this out, but could I get help with a mouse script for glovepie? I am currently using this script to increase my mouse sensitivity above windows max:

code:
Delta(fakemouse.DirectInputX) = Delta(realmouse.DirectInputX)*2
Delta(fakemouse.DirectInputY) = Delta(realmouse.DirectInputY)*2
But I am trying to figure out how I can make it so I can use this as the default sensitivity, but switch to this whenever right click is held down:

code:
Delta(fakemouse.DirectInputX) = Delta(realmouse.DirectInputX)*.5
Delta(fakemouse.DirectInputY) = Delta(realmouse.DirectInputY)*.5
I can't find what the syntax would be in the readme.

greatapoc
Apr 4, 2005


Humble Request
Problem: Powershell to parse XML and return fields from user parameters
Description and requirements:
I'd like to retrieve an XML response from a Palo Alto firewall containing a list of username to IP address mappings. The script should take an input of a username, search through the XML and return the IP address results. The XML response looks like this
code:
<response status="success">
<result>
<entry>
<ip>x.x.x.x</ip>
<vsys>vsys1</vsys>
<type>UIA</type>
<user>domain\username</user>
<idle_timeout>13681</idle_timeout>
<timeout>13681</timeout>
</entry>
<entry>
<ip>x.x.x.x</ip>
<vsys>vsys1</vsys>
<type>UIA</type>
<user>domain\username</user>
<idle_timeout>13851</idle_timeout>
<timeout>13851</timeout>
</entry>
<entry>
<ip>x.x.x.x</ip>
<vsys>vsys1</vsys>
<type>AD</type>
<user>domain\username</user>
<idle_timeout>27139</idle_timeout>
<timeout>27139</timeout>
</entry>
</result>
</response>
The XML is called with the following URL: https://firewall/api/?type=op&cmd=<show><user><ip-user-mapping><all></all></ip-user-mapping></user></show>&key=APIKEY

The only fields I'm concerned about are ip and user. It is possible for users to have multiple IPs so they would all need to be returned. I'd also like to be able to search on both username and domain\username

Basically I see the flow being:

code:
Please enter username: joe.bloggs

joe.bloggs logged in at: <ip addresses>

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


Like this?

code:
Set-StrictMode -Version Latest

[xml]$xml = Get-Content "https://firewall/api/?type=op&cmd=<show><user><ip-user-mapping><all></all></ip-user-mapping></user></show>&key=APIKEY"

$user_mask= Read-Host "Enter a username or domain\username"

$result = Select-Xml "//entry" $xml | Select-Object –ExpandProperty “node” | Where-Object { $_.user -like "*$user_mask" }  | Select @{Name="Username"; Expression={$_.user}},@{Name="IP Address"; Expression={$_.ip}}

if($result){
    $result
} else {
    Write-Output "$user_mask not found."
}

greatapoc
Apr 4, 2005


Toshimo posted:

Like this?

code:
Set-StrictMode -Version Latest

[xml]$xml = Get-Content "https://firewall/api/?type=op&cmd=<show><user><ip-user-mapping><all></all></ip-user-mapping></user></show>&key=APIKEY"

$user_mask= Read-Host "Enter a username or domain\username"

$result = Select-Xml "//entry" $xml | Select-Object –ExpandProperty “node” | Where-Object { $_.user -like "*$user_mask" }  | Select @{Name="Username"; Expression={$_.user}},@{Name="IP Address"; Expression={$_.ip}}

if($result){
    $result
} else {
    Write-Output "$user_mask not found."
}

Perfect! Thank you very much. My attempts were looping through with foreach but this is way better.

tildes
Nov 15, 2018


I have what I think (?) is a relatively small app:

I'd like to have a way to get a list of movies sourced from IMDB (it seems like something like this would be good? Though it doesn't have descriptions, just keywords: https://www.kaggle.com/rounakbanik/the-movies-dataset), go through and select the ones I would want to watch, and then compare it against someone else's list to see where the overlap is. If it's easier, something which outputs a csv of names which I can then compare manually in Excel or R or something would also definitely work.

This might be unreasonably hard to do, I'm not sure. I took a shot at it, but I really only know scientific computing coding stuff and wasn't able to get something working with R Shiny.

Toshimo
Aug 23, 2012

Patron Fae
of
Broken Software


tildes posted:

I have what I think (?) is a relatively small app:

I'd like to have a way to get a list of movies sourced from IMDB (it seems like something like this would be good? Though it doesn't have descriptions, just keywords: https://www.kaggle.com/rounakbanik/the-movies-dataset), go through and select the ones I would want to watch, and then compare it against someone else's list to see where the overlap is. If it's easier, something which outputs a csv of names which I can then compare manually in Excel or R or something would also definitely work.

This might be unreasonably hard to do, I'm not sure. I took a shot at it, but I really only know scientific computing coding stuff and wasn't able to get something working with R Shiny.

I'm not trying to tell you how to live your best life, but this is one of the primary use cases of Letterboxd, so see if that doesn't cover you before reinventing the wheel.

Adbot
ADBOT LOVES YOU

Takes No Damage
Nov 20, 2004

The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of infinity, and it was not meant that we should voyage far.
:cthulhu:



Grimey Drawer

Humble Request
Problem: This is really just Bash shell ignorance on my part, but the nature of my issue makes it difficult to Google.
Description and requirements: I'm trying to set up a script to move some files around based on a string in the filename, trouble is there are characters immediately following the 'search string' bit and I don't know how to call a variable as part of a string without including trailing characters.

Example: I'm trying to key off of a year as part of a datestamp yyyymm i.e. 199810blablabla would be October 1998. So I've got a bunch of files from October 1998 and I want to move them into an October folder inside a 1998 folder. Typing the command manually this would just be:
mv 199810* /1998/October/

But I'm getting tired of doing this 12 times for every year so I want to make a script with a global DATE variable that contains the year, so I can just edit that one bit of the script and run it once for each year, so it would contain something like:

#!/bin/sh
DATE="1998"
mv $DATE10* /$DATE/October/

Of course this fails because I don't know how to separate DATE and 10* without introducing a whitespace. How to do?

Nice to have features:

e:
Of course I only posted this to trick the universe into telling me the answer immediately afterwards, which it did. echo $DATE\blablabla will produce the output 1998blablabla. Didn't know I could 'escape' entire variables :argh:

Takes No Damage fucked around with this message at 21:41 on Mar 30, 2021

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply