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
Toshimo
Aug 23, 2012

He's outta line...

But he's right!
Humble Request

I was gonna put this in SA-Mart but someone pointed me here. I'd definitely kick some coin to whomever could do this, but I'd rather the money go to a goon before I try one of those 3rd-party sites.

I need a quick and dirty frontend for a thing I'm doing.

I want to randomly pick a file from a directory and launch it.

See the image below for the background.

I'd like it to randomly cycle filenames (sans extension) in the blank space with black font at ~200ms/name (whatever is slow enough that the names are briefly visible, but fast enough to convey motion) before selecting a random filename and displaying it in red for 2 seconds and then launching the file using the command from the config file. The filename display should either auto-size the font to the length of the displayed filename or have a fixed size that's appropriate for up to a 64 character filename. UTF-8 support is super appreciated but not mandatory.

In order of preference, I'd like the randomization to start when:
* The spin button in the background is clicked
* Anywhere in the background is clicked
* The app launches

Any one of those is fine, but they are ranked in order of preference.

I'll have a config file that is roughly:
font=Tahoma
workingdir=C:\Temp
command_line=notepad.exe $1 /exec /f

Where:
* font is the name of an installed font (so I can find one that looks to my liking). Idk how whatever language you use is gonna need to address fonts, but just document it and I'll make sure my config file works.
* workingdir is where all the files to pick from are. UNC support is preferred but not mandatory.
* command_line is the command that will be run against the chosen filename.

You can change up any of the formatting or however you need the config file to be formatted (idk if it's JSON or something, whatever works). It just needs to support flags.

Background image:

Adbot
ADBOT LOVES YOU

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
How big a project would it be to have a chrome extension that just adds a gear icon and the ratio to tweets, maybe add a colored border to tweets based on their ratio?

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
Disregard, I missed a word.

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

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

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

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.

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
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

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

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

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
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.

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
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 06:25 on Dec 23, 2020

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
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."
}

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

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.

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

nvrgrls posted:

Humble Request

Problem:
Instagram doesn't let me post text as a main post (Because it does images/video).

Description and requirements:
I want a text-to-image generator where I can paste text into an input box and it spits out that text as an image. Example output could look like this:

Requirements: something I can host myself on a linux server.
It would store the output file on the same machine and return the path of that file to me (or display it).

Nice to have features: web front end

You probably just want Imagemagick: https://legacy.imagemagick.org/Usage/text/

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
lmao I did this the other way around and had it highlight threads on the threadlist, using this bookmarklet: https://pastebin.com/CmtgQGva

It works everywhere BUT yospos because lol yospos.css

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

nvrgrls posted:

Update: got probated

Another goon success story.

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

nvrgrls posted:

I'm looking for an app that already exists and I just don't know what to look for to find it.

What I want: a self-hosted web app that streams video files from the server, similar to internet radio stations that play mp3s from a playlist, but for video.

When I look, I find a lot of info about streaming live video, but that's not what I'm looking for. I want to just play pre-recorded files automatically.

Like goontube?

Adbot
ADBOT LOVES YOU

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

nvrgrls posted:

I don't know because it's not loading for me lol

Edit: yes it's loading and I guess, except I want it to play local files that are stored server side, not youtube. So more like gbs.fm but for video except I don't want people to even interact with a queue.

NOT Plex, because (and sorry I didn't specify this) I want it to auto stream, and have everyone that goes to see the same thing, like television or radio. I don't want visitors to pick what's playing.

Yeah, in the past I've wanted such a thing for group simulwatches and haven't come up with a good solution.

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