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
susan b buffering
Nov 14, 2016

Thermopyle posted:

I don't really know where to ask this...

Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable?

I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output.

I could write this easily enough, but it seems like something that'd just exist already.

You can use CGI with bash to do this. You’ll have to parse the query string which is available as $QUERY_STRING.

I highly recommend not doing this unless you understand the risks involved and are ok with them, but it is basically what you’re asking for.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Yeah, I know how to securely-as-possible roll my own it just seems like something someone would've wrote a wrapper for already.

In fact, I won't even roll my own as I'll do this another way if there's not a pre-built solution out there.

I was really looking for something like...magiccommandserver ls that would start a HTTP server that would run ls with whatever arguments and return the results.


Volmarias posted:

It's been a while since we've seen a hand rolled arbitrary execution exploit being made

It'd be neat to see someone exploit this thing running on a raspberry pi running off of a solar panel and battery in the middle of the woods with no internet connection.

Thermopyle fucked around with this message at 03:08 on Dec 24, 2019

susan b buffering
Nov 14, 2016

Thermopyle posted:

Yeah, I know how to securely-as-possible roll my own it just seems like something someone would've wrote a wrapper for already.

In fact, I won't even roll my own as I'll do this another way if there's not a pre-built solution out there.

I was really looking for something like...magiccommandserver ls that would start a HTTP server that would run ls with whatever arguments and return the results.

Put this in a file:
PHP code:
<?php
echo `{$_GET['command']} {$_GET['args']}`;
?>
Run this in the same directory:
Bash code:
php -S localhost:8000
There's your very unsafe wrapper.

huhu
Feb 24, 2006
Cross posting this - what fields use computational photography? The obvious would be camera companies (Nikon, Canon), phone manufacturers (LG, etc.) , and robotics. Are there other fields to look at?

hot cocoa on the couch
Dec 8, 2009

The Fool posted:

:justpost:

Maybe updates once you get started should go in project.log, but feel free to ask for advice or questions or whatever.

So I’ve taken it upon myself to create a program to automate the administration of a betting game my friends and I play. Currently it’s basically a full time job for 1 or 2 administrators for ~20 participants for 3 hours or so, and imo can be easily automated. Here’s the concept:

- The whole game lasts some number of rounds (say 25, but variable), and each bettor can choose 2 options for each round (say 0 and 1). An administrator will control when voting is open or closed. Scores are tracked and displayed in real time to the administrator.
- The players will use their phone or some other browser capable device to access a website hosted on a local server at my house. They’ll be given unique user names and passwords to login to ensure there are no mixups. The user interface will have the following items:
-- A header displaying the current round, and whether voting is open or closed, and what their current vote is
-- 2 buttons to vote for one option or the other (buttons labeled 0 and 1, say)
-- Some autovote toggle that allows the player to automatically vote for one option until turned off, to allow people to walk away to smoke/bathroom without entirely removing themselves from the game

- There will also be an administrator on a device that will control the rounds (I’ll be admin for the foreseeable future, will use a laptop as my interface)
-- The admin screen will also have a header displaying the current round, and whether voting is open or closed (for control)
-- 2 buttons, a “voting open”, and “voting closed” button
-- When the “voting open” button is pressed (IE the round ends, and a winner is determined), the admin is prompted to enter whether 0 or 1 won
-- The running scoreboard/table
-- Maybe some tools to make manual edits if necessary? Like restart round, go back a round, or maybe just have the running scoreboard/table stored as an excel file that can be edited on the fly or something. This is the bit I’m least certain of what will be necessary and I’ll probably build the admin toolset during testing I guess

Conceptually the program is pretty simple, but I lack any knowledge/experience building something that will be interacted with in a multi-user environment/local network so that’s what I’m not really sure about. For background, I’m a mechanical engineering student, I’m on a co-op where I’ve been building automation tools using VB/VBA. In high school (10 years ago) I took CS/CEng every year, did a lot in Java, Perl, C/C++, other languages and could probably pick them up again fairly easily. I remember using HTML and CSS to do some stuff when I had built an HTPC/usenet setup 5-6 years ago for my exwife, but it was mostly copy-paste type poo poo so I didn’t learn too much. I can mostly visualize the program build in my head using VB (probably because it’s all I use these days), but I doubt that’s the best tool for the job.

I have googled around a bit but just figured I’d come and try to tap the goon resource for tips/advice/resources before I set out on my own. Thanks.

mystes
May 31, 2006

huhu posted:

Cross posting this - what fields use computational photography? The obvious would be camera companies (Nikon, Canon), phone manufacturers (LG, etc.) , and robotics. Are there other fields to look at?
You really mean computational photography specifically and not computer vision?

huhu
Feb 24, 2006

mystes posted:

You really mean computational photography specifically and not computer vision?

Isn't computer vision just an application of computational photography?

mystes
May 31, 2006

huhu posted:

Isn't computer vision just an application of computational photography?
There may be some variation in how people use the terms, but I believe that computational photography mostly refers to techniques for processing sensor data to produce images, whereas computer vision mostly refers to processing images to obtain information.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

hot cocoa on the couch posted:

So I’ve taken it upon myself to create a program to automate the administration of a betting game my friends and I play. Currently it’s basically a full time job for 1 or 2 administrators for ~20 participants for 3 hours or so, and imo can be easily automated.

This is something that any web framework made in the last 15 years can handle without breaking a sweat.

If you're not sure which one to pick, I'd start with Django. I'm confident it has everything you need, including well-written documentation. For serving 20 people on a local network, you can use the built-in development server and stick with SQLite and you'll be more than fine. And Django's admin tool will give you a huge head start in setting up the "manual intervention" bits.

I think there's a python thread around here where you could get a hand with Django stuff, or this thread works too.

huhu
Feb 24, 2006
I guess then I'm interested in anything relating to the intersection and surrounding disciplines of photography, image processing, and programming.

Dominoes
Sep 20, 2007

So uh... What's a monad? Or is this Worth Its Own Thesis?

Dominoes fucked around with this message at 18:25 on Dec 24, 2019

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Dominoes posted:

So uh... What's a monad?

A burrito

mystes
May 31, 2006

Dominoes posted:

So uh... What's a monad? Or is this Worth Its Own Thesis?
Unfortunately, no one can be told what a monad is. You'll have to see it for yourself.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Dominoes posted:

So uh... What's a monad? Or is this Worth Its Own Thesis?

Simplified bad answer:

Basically, it's a higher level type like "maybe" that can be used to create types like "maybe int" or "maybe butt", and it comes with a set of functions to do things like finagle using a "maybe int" with a function that just wants a normal int, so (fake syntax) map(square, maybe 2) produces "maybe 4" and map(square, none) produces none.

mystes
May 31, 2006

None of the metaphors are good. You really have to just mess around with it and understand what bind means in different monads for it to click.

Also, trying to understand the significance of the difference between monads and functors is good.

redleader
Aug 18, 2005

Engage according to operational parameters
monads are just the starting point on a long and nuanced journey though functional programming's 500,000 unique and subtly different mathematical objects. strap in.

Dominoes
Sep 20, 2007

I use one-line loop sugar and partial evaluation, and don't inherit data structures; isn't that enough?

dirby
Sep 21, 2004


Helping goons with math

redleader posted:

monads are just the starting point on a long and nuanced journey though functional programming's 500,000 unique and subtly different mathematical objects. strap in.

Diagrams like https://github.com/JordanMartinez/purescript-jordans-reference/blob/latestRelease/41-Ecosystem/Type-Classes/Type-Class-Relationships.svg have a ton.

nielsm
Jun 1, 2009




As far as I can tell from the legend on the right, every single type named on that diagram has usage frequency "Rarely". Good to know.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
If you want a serious answer, read the first three sections ("Functor," "Applicative" and "Monad") of this: https://wiki.haskell.org/Typeclassopedia

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Monad seems like it's basically just a way for you to use optionals but having functions know how to handle empty optionals themselves instead of you having to wrote a lot of if empty and or else statements everywhere

mystes
May 31, 2006

The MUMPSorceress posted:

Monad seems like it's basically just a way for you to use optionals but having functions know how to handle empty optionals themselves instead of you having to wrote a lot of if empty and or else statements everywhere
It's a pattern that comes up all over the place and that's just one example. Lots of languages have started adding syntax for specific cases, but with do syntax you can replace the bespoke syntax for optional types, await, and list comprehensions all at once, plus lots of other stuff.

Await may actually be the clearest example since it's literally just bind (well ignoring implementation details depending on the language).

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Is there a good shuffle algorithm I can use in a declarative/functional language? Basically my problem is that lists/vectors are immutable so any single element "swap" (like in Fisher-Yates) requires building a whole new sequence.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Haskell Wiki has a Random shuffle article. There's an O(n) algorithm that uses I/O and a purely functional algorithm that's O(n log(n)). The I/O based algorithm might be Haskell specific but the other one should be more portable.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The best way to do it from a performance perspective is to have mutable state that's created, used, and discarded inside your shuffle function, and still provide a strongly functional interface to anything interacting with that code.

Most mature functional implementations should have a way to use mutable state internal to a function, without violating any functional guarantees.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Jabor posted:

The best way to do it from a performance perspective is to have mutable state that's created, used, and discarded inside your shuffle function, and still provide a strongly functional interface to anything interacting with that code.

Most mature functional implementations should have a way to use mutable state internal to a function, without violating any functional guarantees.
Whoa, who said anything about "mature"... uh yeah I don't think I have such options.

Dominoes
Sep 20, 2007

Hey dudes. Do you think it would be feasible to make a browser plugin that selectively filters out content that includes, or rewords manipulative phrases, exaggerations etc? Or warn you if a page contains too many? This feels so obvious; I'm surprised I haven't heard of it. The Internet's filled with trash; or, maybe I'm enjoying Neal Stephenson's new book too much.

Do you think social media etc companies would be amenable to allowing users to specify what types of ads they prefer? Seems like a win-win. Despite all FB etc should know about you, the ads are (anecdotally) 95+% awful/irrelevant. What if we just made public a profile they could use to show good ads? I'm missing something, or this would already be a popular thing.

Dominoes fucked around with this message at 06:58 on Dec 27, 2019

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
"Sorry, nobody wants to see your ads." " Okay, but what if we paid you even more money to show our ads to unwilling users?" "loving sold, my friend."

As for your first request, judging tone online is uh not easy.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Dominoes posted:

Hey dudes. Do you think it would be feasible to make a browser plugin that selectively filters out content that includes, or rewords manipulative phrases, exaggerations etc? Or warn you if a page contains too many? This just feels so obvious I'm surprised I haven't heard of this. The Internet's filled with trash; or, maybe I'm enjoying Neal Stephenson's new book too much.

Do you think social media etc companies would be amenable to allowing users to specify what types of ads they prefer? Seems like a win-win. Despite all FB etc should know about you, the ads are (anecdotally) 95+% awful/irrelevant. What if we just made public a profile they could use to show good ads? Seems like a win-win, but again, I'm missing something, or this would already be a popular thing.

1) That sounds quite hard, especially in maintaining the semantics behind the content, if you even want to do that. Now, do it quickly, and also for free.

2) The vast majority of people are either going to block all of the ads, or block none of them. Technically you can tell some of the ad companies what kind of ads you actually want, but that's a crap shoot and pretty much only exists as a fig leaf of self regulation.

Dominoes
Sep 20, 2007

TooMuchAbstraction posted:

"Sorry, nobody wants to see your ads." " Okay, but what if we paid you even more money to show our ads to unwilling users?" "loving sold, my friend."
I'm worried about that. There implication is that people will buy things from ads they think they don't like, or that incentive to push ads anyway wouldn't work. The deal breaker may be that what people think they want doesn't line up with what they actually buy.

quote:

As for your first request, judging tone online is uh not easy.
A hard problem, but not impossible to get somewhere on.


Volmarias posted:

1) That sounds quite hard, especially in maintaining the semantics behind the content, if you even want to do that. Now, do it quickly, and also for free.

2) The vast majority of people are either going to block all of the ads, or block none of them. Technically you can tell some of the ad companies what kind of ads you actually want, but that's a crap shoot and pretty much only exists as a fig leaf of self regulation.
I was hoping another incentive would be a way for advertisers to appeal to people who use ad blockers. But maybe that's a vocal minority.

Overall, I'm worried (like first pt above) people don't really know what they want. Ie I find myself clicking crappy articles and, on some level enjoying them, ie when I'm bored and subconsciously looking for a distraction.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Dominoes posted:

Hey dudes. Do you think it would be feasible to make a browser plugin that selectively filters out content that includes, or rewords manipulative phrases, exaggerations etc? Or warn you if a page contains too many?

https://chrome.google.com/webstore/detail/cloud-to-butt-plus/apmlngnhgbnjpajelfkmabhkfapgnoai?hl=en

Not sure how much more complicated you want to get, but it seems like it's at least a start.

That is, it shows you can reword stuff programmatically. The hard part is getting it to recognize what you think is manipulative/exaggerative, and how to reword it so it's not.

Kilson fucked around with this message at 08:21 on Dec 27, 2019

Walh Hara
May 11, 2012

peepsalot posted:

Is there a good shuffle algorithm I can use in a declarative/functional language? Basically my problem is that lists/vectors are immutable so any single element "swap" (like in Fisher-Yates) requires building a whole new sequence.

If you have a built in sort function you can simply convert each list element a to a tuple of this list element and a random nr and then sort on this random nr.

For example in elixir:
shuffled_list = Enum.map(input_list, fn a -> (a, Enum.random(1..n)) end) |> Enum.sort_by(fn (_,r) -> r end) |> Enum.map(fn (a,_) -> a end)

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Dominoes posted:

I'm worried about that. There implication is that people will buy things from ads they think they don't like, or that incentive to push ads anyway wouldn't work. The deal breaker may be that what people think they want doesn't line up with what they actually buy.


There are impression ads like car ads, where the goal isn't to click through for immediate conversion but to put things in your mind for when you do.

There's also "CLICK HERE TO CUM INSTANTLY" ads where 99.9% of people will be turned off but that 0.1% who click through will spend $100 and make it worthwhile

Showing you garbage advertising still makes financial sense.

quote:


I was hoping another incentive would be a way for advertisers to appeal to people who use ad blockers. But maybe that's a vocal minority.

Overall, I'm worried (like first pt above) people don't really know what they want. Ie I find myself clicking crappy articles and, on some level enjoying them, ie when I'm bored and subconsciously looking for a distraction.

The number of people who use ad blockers is still a relative minority, and advertisers handle this by paying ad blockers to let a few through and by collecting analytics to sell data on the backend.

People indeed don't know what they want but right now the market rewards eyeballs over meaningful interaction, hence outrageous headlines, click bait, and recipe websites that tell you the author's life story before you can get to the recipe.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Dominoes posted:

A hard problem, but not impossible to get somewhere on.

There are still a lot of PhD theses to be written on figuring out the tone of a post. There is progress, but it's really not clear that what we have now is better than nothing at all.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Walh Hara posted:

If you have a built in sort function you can simply convert each list element a to a tuple of this list element and a random nr and then sort on this random nr.

For example in elixir:
shuffled_list = Enum.map(input_list, fn a -> (a, Enum.random(1..n)) end) |> Enum.sort_by(fn (_,r) -> r end) |> Enum.map(fn (a,_) -> a end)
Thanks, I ended up basically doing this, using a mergesort function I wrote. So yeah N log N is probably best I can do with this. I was hoping to figure out some linear time method, but maybe not possible (or at least not worth the effort finding out) for this.

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
Graphic designer here, hired to do web design, so I have likely broken plenty of rules. I'll apologize for that up front. Currently, my site works great on desktop browsers, but when it comes to mobile chrome, it won't calculate the viewport width correctly. I'm getting 1/5 of the screen on the right side that looks like body padding. No idea what's happening here, and googling at the problem is just getting me warnings to not use 100vh (which I'm currently doing as well, but I'll fix that next)

site is here: http://enrightdesignfoundry.com/dcindex.html

Any ideas would be a huge help. I'm sure I did something obviously flawed to cause this issue, but I'm not experienced enough to understand what it is, and brute force changing poo poo has gotten me nowhere.

Edit - Forgot to mention, the error can be replicated on desktop chrome by going into mobile mode on the inspector.

JesusDoesVegas fucked around with this message at 23:34 on Dec 29, 2019

huhu
Feb 24, 2006

JesusDoesVegas posted:

Graphic designer here, hired to do web design, so I have likely broken plenty of rules. I'll apologize for that up front. Currently, my site works great on desktop browsers, but when it comes to mobile chrome, it won't calculate the viewport width correctly. I'm getting 1/5 of the screen on the right side that looks like body padding. No idea what's happening here, and googling at the problem is just getting me warnings to not use 100vh (which I'm currently doing as well, but I'll fix that next)

site is here: http://enrightdesignfoundry.com/dcindex.html

Any ideas would be a huge help. I'm sure I did something obviously flawed to cause this issue, but I'm not experienced enough to understand what it is, and brute force changing poo poo has gotten me nowhere.

Edit - Forgot to mention, the error can be replicated on desktop chrome by going into mobile mode on the inspector.

https://stackoverflow.com/questions/30358630/html-body-not-filling-complete-width-on-mobile-devices

mobby_6kl
Aug 9, 2009

by Fluffdaddy
I'm making my own GIF decoder and it works fine except...



It adds an extra pixel at the edge of every block. The image data is LZW compressed and stored in variable-length data blocks (usually 255 until the last one). The actual LZW codes are also variable length but here they're always 9 bits. What happens is that I read the blue code without problems. Then the green code gets is interrupted by the block length indicator (or so I think), but I read 0xFF as part of the code:



And this would add an extra pixel basically which shouldn't be there. The problem is that if I do anything else, the LZW decoder breaks. If I toss the incomplete code and start over in the next block, it breaks. If I skip over the 0xFF byte and continue as usual, it breaks (I get code values which shouldn't exist). Maybe the bug is elsewhere, but any idea what is the correct behavior? I've read some documentation and descriptions but it's not super clear.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The LZW-compressed data is a byte stream which is broken down into a stream of length-prefixed blocks of bytes. Codes can cross block boundaries. The block length byte is not part of the data stream.

Adbot
ADBOT LOVES YOU

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy

This looks like it may be my issue. Thanks for the help!

EDIT - Ok, so this worked, and definitely helped. I think my real problem is that I somehow broke my container div, and that was causing the browser to not really know where things go. I doubt anyone reads these threads for info, but if anyone has this problem, maybe that can help.

JesusDoesVegas fucked around with this message at 23:02 on Dec 30, 2019

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