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
Maha
Dec 29, 2006
sapere aude
Is there a simple way to take information from one website as it updates and input it into a form in another? Maybe something with Greasemonkey? I've never programmed anything.

Adbot
ADBOT LOVES YOU

Shaocaholica
Oct 29, 2002

Fig. 5E
So someone at work asked me if saving a jpeg over and over will introduce compounding compression artifacts and I said 'yes' without really thinking. I then decided to do a test where I open an image, save out at 50% jpeg quality, reopen the new image and save out a new copy with 50% quality so on and so forth for a few hundred iterations. I played the image sequence in motion and after the initial pop in quality from the original image to the first 50% quality image the artifacting didn't change at all for the hundreds of frames that followed. Is this normal for jpeg algorithms?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Shaocaholica posted:

So someone at work asked me if saving a jpeg over and over will introduce compounding compression artifacts and I said 'yes' without really thinking. I then decided to do a test where I open an image, save out at 50% jpeg quality, reopen the new image and save out a new copy with 50% quality so on and so forth for a few hundred iterations. I played the image sequence in motion and after the initial pop in quality from the original image to the first 50% quality image the artifacting didn't change at all for the hundreds of frames that followed. Is this normal for jpeg algorithms?

Wiki says: "JPEG is also not well suited to files that will undergo multiple edits, as some image quality will usually be lost each time the image is decompressed and recompressed, particularly if the image is cropped or shifted, or if encoding parameters are changed – see digital generation loss for details. To avoid this..."

Are you sure your procedure "decompressed and then recompressed" the JPEG after the first pass (in which you reduced the quality)?

I am pretty sure that if you make actual changes to a JPEG, re-saving it as JPEG each time, the quality will get progressively worse.

Shaocaholica
Oct 29, 2002

Fig. 5E

Hammerite posted:

Wiki says: "JPEG is also not well suited to files that will undergo multiple edits, as some image quality will usually be lost each time the image is decompressed and recompressed, particularly if the image is cropped or shifted, or if encoding parameters are changed – see digital generation loss for details. To avoid this..."

Are you sure your procedure "decompressed and then recompressed" the JPEG after the first pass (in which you reduced the quality)?

I am pretty sure that if you make actual changes to a JPEG, re-saving it as JPEG each time, the quality will get progressively worse.

I didn't make any changes but I did make sure it wasn't doing anything tricky by saving each iteration as a tif after the compression. I guess I could try altering a random pixel(s) each iteration.

edit:
I was trying to produce something like this (http://vimeo.com/3750507). My current work setup doesn't have the python Image module installed so I resorted to calling 'convert' with the '-quality' flag.

Shaocaholica fucked around with this message at 01:33 on Apr 24, 2012

nielsm
Jun 1, 2009



If you use JPEG encoders and decoders from the same suite for every recompression, chance is they will perform exactly the same quantisation etc. meaning that the image the encoder gets will compress "perfectly" at the given settings. I haven't actually worked out the maths, but I have a hunch it will end up that way.
If you are fine with lots of manual work, try cycling through maybe three different encoders, or just adjust the quality factor a bit each time. For extra fun, start out with a low quality factor and raise it repeatedly, e.g. 50%, 55%, 60% etc., that will probably show progressive degradation.

The Gripper
Sep 14, 2004
i am winner
I'd imagine that if you didn't change any pixels or compression level, the optimal pixels for that compression level would be the existing pixels (as they have been compressed at that level already).

It's possible that there would be slight variations that would probably be more pronounced in pictures with a lot of blended color (this article seems to show that in 10 iterations), though I have no clue if the artifacting could build to a subtle (low) level and from there stay fairly constant, which your "artifacting didn't change at all for the hundreds of frames" seems to hint at.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
If you really wanted to, you could make a lossless JPEG. The only lossy step of JPEG is quantization (well, besides integer roundoff of the DCT components). It comes with a standard quantization table, but you could define your own with the DQT command.

EDIT:

The Gripper posted:

I'd imagine that if you didn't change any pixels or compression level, the optimal pixels for that compression level would be the existing pixels (as they have been compressed at that level already).

That's not how lossy compression works. You're asking it to lossily compress an already lossily compressed source.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
JPEG compression is relatively stable if you decode and then re-encode under the original parameters, because it works by reducing entropy within blocks, and as long as the blocks and thresholds are held fixed, entropy is already going to be pretty low. Very small changes, like shifting the image coordinates by cropping, can force the algorithm to minimize over different block extents and therefore lose more information.

The Gripper
Sep 14, 2004
i am winner

Suspicious Dish posted:

If you really wanted to, you could make a lossless JPEG. The only lossy step of JPEG is quantization (well, besides integer roundoff of the DCT components). It comes with a standard quantization table, but you could define your own with the DQT command.

EDIT:


That's not how lossy compression works. You're asking it to lossily compress an already lossily compressed source.
It's not like its goal is to lose data though, is it not possible that in looking at a series of pixels the best result is "leave them the same"?
Edit; I guess I made it sound like I meant as an absolute "hey it's already done let's not redo it" way, but I just mean that compared to compressing the image the first time, consecutive compression would need to make less changes because things have already been adjusted. (in thinking about it it doesn't make a ton of sense though).

The Gripper fucked around with this message at 02:07 on Apr 24, 2012

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Maha posted:

Is there a simple way to take information from one website as it updates and input it into a form in another? Maybe something with Greasemonkey? I've never programmed anything.

Without knowing what you want to do you can try If This Then That. If you post what you are trying to do you will get more help.

Maha
Dec 29, 2006
sapere aude

gariig posted:

Without knowing what you want to do you can try If This Then That. If you post what you are trying to do you will get more help.

Sure. I'm trying to figure out a way to scrobble a stream to last.fm without having to mess around with Streamripper, so my idea was to find something that could take artist and song information from here and input it to here.
Beautiful Soup with Python's been suggested to me, but, well, I can't code. I'll have a look at If This Then That!

e: ifttt on its own doesn't seem to do what I'm looking for - it can trigger off somafm's twitter feeds, but can't do anything useful with the results.

Maha fucked around with this message at 03:06 on Apr 24, 2012

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

As a note for people thinking of bundling pCap/WinpCap with anything, the binary distribution it gets detected by a lot of anti-spyware/anti-virus stuff out there. Just a note for all the budding network spies out there.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Maha posted:

Sure. I'm trying to figure out a way to scrobble a stream to last.fm without having to mess around with Streamripper, so my idea was to find something that could take artist and song information from here and input it to here.
Beautiful Soup with Python's been suggested to me, but, well, I can't code. I'll have a look at If This Then That!

e: ifttt on its own doesn't seem to do what I'm looking for - it can trigger off somafm's twitter feeds, but can't do anything useful with the results.

Don't use BeautifulSoup. Use lxml.html instead. BeautifulSoup is dead (the author stopped development) and it has various bugs (NavigableString being the main cause of issues). lxml.html can handle most HTML pages, sometimes even better than BeautifulSoup.

Looking through the code for SomaFM (ugh this is not good code), it seems like there's something easily scrapeable here:

http://somafm.com/recent/spacestation.html

Hook that together with the Track.scrobble API from Last.fm. It seems you're new to programming, so if you have any more questions (even if they seem super stupid), just ask them here.

Good luck!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Scaramouche posted:

As a note for people thinking of bundling pCap/WinpCap with anything, the binary distribution it gets detected by a lot of anti-spyware/anti-virus stuff out there. Just a note for all the budding network spies out there.

As it should do. Packet capturing isn't really something that should be necessary for any sort of deployable solution. It's mostly for reverse engineering and debugging.

The Gripper
Sep 14, 2004
i am winner

Suspicious Dish posted:

As it should do. Packet capturing isn't really something that should be necessary for any sort of deployable solution. It's mostly for reverse engineering and debugging.
Any decent AntiVirus will pick up the actual virus, not the libraries it's using. Crappier malware scanners will pick it up with their scorched earth approach (Malwarebytes and SAS both don't, as far as I know), though.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

The Gripper posted:

Any decent AntiVirus will pick up the actual virus, not the libraries it's using. Crappier malware scanners will pick it up with their scorched earth approach (Malwarebytes and SAS both don't, as far as I know), though.

Except that doesn't help target threats against new viruses. Packet sniffers shouldn't ever be running on your computer for legitimate purposes (besides debugging and reverse engineering, but if you're smart enough to do that, you're smart enough to configure your AV tool), so it's worth pointing out the very real possibility and preemptively stopping a threat before it's too late.

Sometimes, a virus scanner may detect a false positive from preemptive unknown threat detection. I think this is a good thing. No good citizen should require capturing all input globally, or sniffing all network traffic globally, so it's good to know that these things are happening on your machine.

The Gripper
Sep 14, 2004
i am winner

Suspicious Dish posted:

Except that doesn't help target threats against new viruses. Packet sniffers shouldn't ever be running on your computer for legitimate purposes (besides debugging and reverse engineering, but if you're smart enough to do that, you're smart enough to configure your AV tool), so it's worth pointing out the very real possibility and preemptively stopping a threat before it's too late.
Well I meant it in the sense that I've had winpcap installed on every machine I've ever used, with AntiVirus, and never had it picked up. AVG, Avast!, ESET Nod32, even Norton all treat it as innocuous, the only tools that don't are ones that as I said take a scorched-earth approach to it and detect legitimate third-party components.

Also, the winpcap network capturing components are installed as a driver (by necessity) so I believe from XP onwards the user will be prompted to install if a malicious application tries to deploy it. Edit; the deployable-without-driver components are used to read from capture files, which would pose no threat.

The Gripper fucked around with this message at 08:42 on Apr 25, 2012

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Suspicious Dish posted:

BeautifulSoup is dead (the author stopped development)

The last release was 11 days ago, so not really. http://www.crummy.com/software/BeautifulSoup/

lxml falls back to BeautifulSoup when it gets handed a shitheap, so it's good that it's not dead

Scaevolus
Apr 16, 2007

Munkeymon posted:

lxml falls back to BeautifulSoup when it gets handed a shitheap, so it's good that it's not dead
BS is only better at encoding detection, and I'm pretty sure lxml only uses it it it's explicitly requested.

Captain Capacitor
Jan 21, 2008

The code you say?
I recently tried to use BeautifulSoup4 for the DWS2 IRC bot and had such trouble with it that I ended up having to go back to version 3.

poverty goat
Feb 15, 2004



I'm a CS major and I'm about to ace my linear algebra final and conclude my business within the math department, can anyone suggest maybe some resources or specific algorithms to look at to bridge the gap from textbook stuff to practical applications in CS?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


gggiiimmmppp posted:

I'm a CS major and I'm about to ace my linear algebra final and conclude my business within the math department, can anyone suggest maybe some resources or specific algorithms to look at to bridge the gap from textbook stuff to practical applications in CS?

Have you taken algorithms yet?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Scaevolus posted:

BS is only better at encoding detection, and I'm pretty sure lxml only uses it it it's explicitly requested.

Could be. They're not terribly specific about when they do it http://lxml.de/lxmlhtml.html#really-broken-pages

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Where is a comment permitted in an HTML page? Can I have one before <html>? After </html>?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Wherever the hell you like, except within a tag.

nielsm
Jun 1, 2009



pokeyman posted:

Wherever the hell you like, except within a tag.

As far as I know, by SGML rules you can even put them in the middle of a tag, using -- as delimiter. Like this:
code:
<div id="foo" -- class="bar" -->
Whether browsers actually understand that as the class="bar" part being a comment, I'm honestly not sure, but I think it's supposed to work that way. The spaces around the -- should not be needed either.
(By this, the usual <!-- --> notation is just a ! element containing a comment.)

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
That'd be cool but I'm not seeing it in the HTML spec nor does it seem to work in WebKit (it just gets ignored and, in your example, the div would have class 'bar').

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

nielsm posted:

As far as I know, by SGML rules you can even put them in the middle of a tag, using -- as delimiter. Like this:
code:
<div id="foo" -- class="bar" -->
Whether browsers actually understand that as the class="bar" part being a comment, I'm honestly not sure, but I think it's supposed to work that way. The spaces around the -- should not be needed either.
(By this, the usual <!-- --> notation is just a ! element containing a comment.)

Uh, no. That's not how SGML comment syntax works, nor does HTML follow that syntax. You see, in SGML comment syntax, <!-- starts a comment block, meaning that the text can contain >, and further appearances of -- toggle between "can have >" and "can't have >" modes. HTML5 doesn't follow this, because browsers, never followed this, and it broke sites when they tried to follow this. How?

code:
<!-------- ADVERTISEMENT BEGIN ------>

Samuel L. Hacksaw
Mar 26, 2007

Never Stop Posting
I posted this over in the Phyiscs questions thread and didn't see a MATLAB thread here so here,

Random Number posted:

I don't know if this question is really a physics question but here goes.

I have a signal, S. That is going to be within a 50m radius of me.

S= (0<=x<=1)/dist^2

I don't know dist or the exact value of the numerator.

I have to use trig and a minimum number of movements to find the position of this source, but I have no idea where to start.

This is a question for my MATLAB class and this is the one part of it I'm hung up on.

I could just move in Y till I'm on axis with the source then move X to the source but that's less than optimal.

Does MATLAB maybe have a function that does this sort of triangulation?

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
The solution you described is 'moving to' the source - not locating it. If you're moving on a lattice, taking the route you described is no longer than zig-zagging in a 'diagonal' line toward the source.

Instead, do you mean that you want to make a minimal number of moves to determine the coordinate of the source, by using the perceived signal strength at whatever position(s) you've inhabited?

Samuel L. Hacksaw
Mar 26, 2007

Never Stop Posting

Newf posted:

The solution you described is 'moving to' the source - not locating it. If you're moving on a lattice, taking the route you described is no longer than zig-zagging in a 'diagonal' line toward the source.

Instead, do you mean that you want to make a minimal number of moves to determine the coordinate of the source, by using the perceived signal strength at whatever position(s) you've inhabited?


I am trying to move to the source (the source is stationary by the way), But I would like to calculate it's position before moving to it. If i can determine the position of the source while remaining stationary, all the better, but I don't see a way to do that.

We're using polar coordinates to move in steps of 1m or less

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



If you only have signal strength you can't get the position. You need to triangulate it out.

Record the strength at starting point x,y. That tells you the distance from that point.

Move some steps in a direction, record new strength. Now you have a distance from two points. This gives you two possible locations for the source.

Move toward either of the possibles, check if signal is fading or getting stronger, and decide whether to keep moving or turn around.

2 fat 4 my lambo
Oct 9, 2003

WEED POOP
Couldn't find a bourne/bash megathread, so hopefully someone here can help me out. Would anyone know why $STATUS returns 2 instead of 1:
code:
[user@host ~]$ cat script.sh
#!/bin/sh

THIS_PROG=`basename $0`
ps -ef| grep -v 'grep' | grep '/bin/sh' | grep -v 'STATUS' | grep -v 'vi' | grep -i $THIS_PROG
ps -ef| grep -v 'grep' | grep '/bin/sh' | grep -v 'STATUS' | grep -v 'vi' | grep -i $THIS_PROG | wc -l
STATUS=`ps -ef | grep -v 'grep' | grep '/bin/sh' | grep -v 'STATUS' | grep -v 'vi' | grep -i $THIS_PROG | wc -l`
echo $STATUS
code:
[user@host ~]$ ./script.sh
alphads  25023 13943  0 10:53 pts/1    00:00:00 /bin/sh ./script.sh
1
2
Linux host 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

The Gripper
Sep 14, 2004
i am winner

Carthag posted:

If you only have signal strength you can't get the position. You need to triangulate it out.

Record the strength at starting point x,y. That tells you the distance from that point.

Move some steps in a direction, record new strength. Now you have a distance from two points. This gives you two possible locations for the source.

Move toward either of the possibles, check if signal is fading or getting stronger, and decide whether to keep moving or turn around.
If he can (accurately) tell distance from source by the signal strength, moving once would probably be enough to locate it i.e. "I've moved 50m east, and strength here shows I'm 2m further from the source" would be an observation that you could calculate the source from with no extra steps as far as I can tell. In practice that's not possible unless you have a signal that can't be affected by any external factors, but for an academic problem the strength may be defined and constant (though it wasn't mentioned in the question he asked).

ToxicFrog
Apr 26, 2008


2 fat 4 my lambo posted:

Couldn't find a bourne/bash megathread, so hopefully someone here can help me out. Would anyone know why $STATUS returns 2 instead of 1:

The use of `` runs the command in a separate process (with fork()) and records the output. While the command is running, there are actually two '/bin/sh script.sh' processes running, as you can see by dropping the | wc -l.

The Gripper posted:

If he can (accurately) tell distance from source by the signal strength, moving once would probably be enough to locate it i.e. "I've moved 50m east, and strength here shows I'm 2m further from the source" would be an observation that you could calculate the source from with no extra steps as far as I can tell. In practice that's not possible unless you have a signal that can't be affected by any external factors, but for an academic problem the strength may be defined and constant (though it wasn't mentioned in the question he asked).

No, it's not sufficient - in your example the source could be to the north or the south.

In effect, one measurement gives you a ring, and the source could lie anywhere on that ring; two measurements gives you two rings, which - unless you are very lucky and moved straight towards or away from the source - will intersect at two points, either of which could contain the source; three measurements gives you three rings, and there will only be one point at which all three intersect.

Now, if you have direction and not distance, you can usually (although not always) find the location with just two measurements.

ToxicFrog fucked around with this message at 16:37 on Apr 27, 2012

2 fat 4 my lambo
Oct 9, 2003

WEED POOP

ToxicFrog posted:

The use of `` runs the command in a separate process (with fork()) and records the output. While the command is running, there are actually two '/bin/sh script.sh' processes running, as you can see by dropping the | wc -l.

:doh: of course. thanks!

The Gripper
Sep 14, 2004
i am winner

ToxicFrog posted:

No, it's not sufficient - in your example the source could be to the north or the south.
*groaaaan* yeah I stupidly let one of the radius escape off the edge of my canvas, didn't give it any extra thought.

ToxicFrog
Apr 26, 2008


2 fat 4 my lambo posted:

:doh: of course. thanks!

What is your actual goal here? I mean, if you're looking for info on the currently running process, it seems like it would be a lot easier to get the pid with $$ and then check /proc or something.

Samuel L. Hacksaw
Mar 26, 2007

Never Stop Posting

Carthag posted:

If you only have signal strength you can't get the position. You need to triangulate it out.

Record the strength at starting point x,y. That tells you the distance from that point.

Move some steps in a direction, record new strength. Now you have a distance from two points. This gives you two possible locations for the source.

Move toward either of the possibles, check if signal is fading or getting stronger, and decide whether to keep moving or turn around.

The equation that calculates the signal strength has a randomized numerator. I get the method you're explaining conceptually, but I don't know how i would go about building the system of equations to solve it.

I just had discussion with my TAs about this problem and they're just horribly frustrating, so maybe I'm just too frustrated to see the obvious solution.

It's three equations that are equal to three measured values, and each equation has 3 variables, Am i on the right track here?

Adbot
ADBOT LOVES YOU

2 fat 4 my lambo
Oct 9, 2003

WEED POOP

ToxicFrog posted:

What is your actual goal here? I mean, if you're looking for info on the currently running process, it seems like it would be a lot easier to get the pid with $$ and then check /proc or something.

you are correct, however it's not my code and I was trying to figure out why it worked in solaris but not linux + how to fix it changing as little as possible

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