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
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
If there's Javascript on the page that needs to be executed, then you may be able to write a script or plugin for a browser that does what you need to do. That'd be the route I'd investigate first (with the grain of salt that I haven't done web-dev in the better part of a decade).

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

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



TooMuchAbstraction posted:

If there's Javascript on the page that needs to be executed, then you may be able to write a script or plugin for a browser that does what you need to do. That'd be the route I'd investigate first (with the grain of salt that I haven't done web-dev in the better part of a decade).

You'd use http://casperjs.org/ if you have this sort of requirement. I haven't used it in a while but it was alright. No loving clue why they're using NPM to distribute it, though. JFC

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

PRADA SLUT posted:

I have a text file with lines of data. I want a script that will enter the first line into a text box on a website, hit enter, wait 5 seconds, enter the second line, wait, etc.

What's the best way going about this, and how would I learn to code such a thing? I know basic C++ but am unsure what the best option is.

Selenium Webdriver, or Selenium IDE. Selenium IDE allows you to define/record/playback actions in Firefox; Selenium Webdriver allows you to create applications in most popular programming languages.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I am writing a program that needs real-time audio mixing. I am using C++ on windows. Right now I am using the SDL library, but the latency is too low.

It involves implementing this callback which is called in an audio thread:

void audio_callback( void*, Uint8 *_stream, int _length )
{
// write audio into the given buffer
}

The smallest buffer size I can use is 512 samples (of 44100 hz stereo sound). Any smaller, and I get stuttering, even if the callback function is not doing any work. This buffer size is too big because I get about 11ms of latency, which is too much.

Which library or subsystem or whatever should I use? Maybe I should not be doing my own mixing at all?

Certainly many video games play sound effects with nearly no latency!!! How can I get that? Maybe what I need is much simpler than what I am making it out to be.

There is a thing called DirectSound which seems to be deprecated. What is its replacement?

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

baby puzzle posted:

I am writing a program that needs real-time audio mixing. I am using C++ on windows. Right now I am using the SDL library, but the latency is too low.

It involves implementing this callback which is called in an audio thread:

void audio_callback( void*, Uint8 *_stream, int _length )
{
// write audio into the given buffer
}

The smallest buffer size I can use is 512 samples (of 44100 hz stereo sound). Any smaller, and I get stuttering, even if the callback function is not doing any work. This buffer size is too big because I get about 11ms of latency, which is too much.

Which library or subsystem or whatever should I use? Maybe I should not be doing my own mixing at all?

Certainly many video games play sound effects with nearly no latency!!! How can I get that? Maybe what I need is much simpler than what I am making it out to be.

There is a thing called DirectSound which seems to be deprecated. What is its replacement?

Just saw this the other day, it might have some insight - four common mistakes in audio development

PRADA SLUT
Mar 14, 2006

Inexperienced,
heartless,
but even so
I'm not completely certain about this, but I believe that audio stream buffers are different than game sound effects and the like, for the reason that an audio stream has unknown future input, but something like a game just accesses pre-existing files for playback (and usually runs some effects over them).

I know when using some recording software, too little live audio buffer gives a "cracking" sound, even though it's far less "input" than loading up a bunch of samples for playback with the same buffer.

nielsm
Jun 1, 2009



baby puzzle posted:

There is a thing called DirectSound which seems to be deprecated. What is its replacement?

Windows Core Audio, aka. WASAPI
https://msdn.microsoft.com/en-us/library/windows/desktop/dd370802(v=vs.85).aspx

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.

Thank you. This is probably what I want. It looks like it isn't just a simple API, though.

nielsm
Jun 1, 2009



baby puzzle posted:

Thank you. This is probably what I want. It looks like it isn't just a simple API, though.

It looks overwhelming, but it does do lots of things. On the other hand, the functionality is very compartmentalized into separate COM interfaces, so you do avoid seeing most of the features you don't need.

The basic idea is that you get an IMMDevice object some way, it can be as simple as querying for the default playback device. You then call Activate on that and ask for an IAudioClient object, which you can query for various properties, and eventually call Initialize on to set your playback parameters. For realtime audio mixing you may want to ask for an exclusive mode stream, and a short buffer should also be an option then. Then you basically just call Start on the IAudioClient and feed it data.

Of course, this being "simple" is very much a question of being comfortable with COM programming.

fankey
Aug 31, 2001

baby puzzle posted:

Thank you. This is probably what I want. It looks like it isn't just a simple API, though.

If you are willing to use c# NAudio can be configured to use WASAPI for low latency audio playback.

ufarn
May 30, 2009
I'm using an external GitHub repo for my npm dependencies, but how do I install them in a way that will let Travis CI use the package? When I do an `npm install [-g] me/myrepo`, Travis can't find the commands for the different packages.

What're the best ways to let Travis figure it out? Locally, the packages seem to be installed just fine with the commands available in the CLI.

Pryor on Fire
May 14, 2013

they don't know all alien abduction experiences can be explained by people thinking saving private ryan was a documentary

Is this "machine learning" fad the reason google search results and netflix suggestions keep getting shittier and shittier?

ufarn
May 30, 2009

Pryor on Fire posted:

Is this "machine learning" fad the reason google search results and netflix suggestions keep getting shittier and shittier?
Netflix's online search interface has always been complete garbo.

mystes
May 31, 2006

Pryor on Fire posted:

Is this "machine learning" fad the reason google search results and netflix suggestions keep getting shittier and shittier?
When you're trying to find the best way to select 50 movies to display out of a catalog of 50 movies, machine learning is not a huge help.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


You need to know which ten to put first. That's something where ML can help.

Suspicious Dish
Sep 24, 2011

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

odi3
Dec 17, 2003
I am having difficulty adding conditional background formatting to a matrix in an SSRS Report in Visual Studio 2013.

A simple version of report display looks like this:

The report has Three Fields fields
"Data", "Group", "Amount"

The Data looks like this:
Data Group Amount
Datavalue1 GroupValue1 1
Datavalue2 GroupValue2 4
Datavalue1 GroupValue2 3
Datavalue2 GroupValue1 2



The report in design mode looks like this:

Group
Data =sum(amount)


The displayed Matrix in preview mode looks like this:


GroupValue1 GroupValue2
DataValue1 | 1 | 3
DataValue2 | 2 | 4


When the report is displayed, I would like the background for items under groupValue1 to display as red if the corresponding item under groupvalue2 equals 3.
The problem is that in design mode, I dont know how to differentiate between referencing fields under groupvalue1 or groupvalue2

Anyone know some code I can put in the BackgroundColor Properties of the value field that could accomplish this?

Any help is greatly appreciated!!

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I thought the directive to generate 32 bit code in 64 bit masm was "bits 32" but I guess it's not. I think that's for nasm...

How can I tell masm to mix 32 and 64 bit code? Should I just be careful? I'm doing it in order to swap out a clunky bootloader for grub.

Nvm, it's pretty easy to mush them together using the linker maps.

dougdrums fucked around with this message at 18:46 on Jun 25, 2016

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.

nielsm posted:

It looks overwhelming, but it does do lots of things. On the other hand, the functionality is very compartmentalized into separate COM interfaces, so you do avoid seeing most of the features you don't need.

The basic idea is that you get an IMMDevice object some way, it can be as simple as querying for the default playback device. You then call Activate on that and ask for an IAudioClient object, which you can query for various properties, and eventually call Initialize on to set your playback parameters. For realtime audio mixing you may want to ask for an exclusive mode stream, and a short buffer should also be an option then. Then you basically just call Start on the IAudioClient and feed it data.

Of course, this being "simple" is very much a question of being comfortable with COM programming.

I am trying this today. I have only had a little bit of luck.

This is my attempt at a program that should simply spit out a sine wave. It doesn't work. It generates a (incorrect pitch) tone for about .25 seconds, but I get nothing but random pops and noise after that.

There are two problems:
- I do not know what format the audio data is supposed to be in.
- I have no idea what is going in inside the loop in AudioThread(). I copied this stuff from https://msdn.microsoft.com/en-us/library/windows/desktop/dd316756(v=vs.85).aspx but it is all meaningless to me.

I am looking everywhere and I cannot find just a simple loving example of how to use this stuff. I mean, if this code was working, I would love to post it somewhere and put this problem out of its misery for everybody.


code:
#include "stdafx.h"

#include <stdint.h>

#include <mmdeviceapi.h>
#include <objbase.h>
#include <Audioclient.h>
#include <Windows.h>

#include <cmath>


const int FREQUENCY = 44100;


void audio_callback( void*, uint8_t *buffer, int length )
{
	// so.. what exactly goes in here?
	// My best guess is that the buffer is formatted as pairs of 16-bit ints
	// one for each stereo channel.
	// but that doesn't work.

	static uint32_t currentSample;

	uint32_t* samples = ( uint32_t* )buffer;
	int sampleCount = length / sizeof( uint32_t );

	for ( int i = 0; i < sampleCount; i++ )
	{
		// generate a siney value
		int16_t value = (int16_t)( sin( ( (float)currentSample / (float)FREQUENCY ) * 500.0f ) * 5000.0f );

		// put the value into both the left and right channels
		samples[ i ] = value | ( value << 16 );

		currentSample++;
	}
}


DWORD WINAPI AudioThread( LPVOID lpParam )
{
	IMMDeviceEnumerator* enumerator = NULL;

	CoInitialize( nullptr );

	const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
	const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
	HRESULT hr = CoCreateInstance(
		CLSID_MMDeviceEnumerator, NULL,
		CLSCTX_ALL, IID_IMMDeviceEnumerator,
		(void**)&enumerator);

	IMMDevice* myDevice = NULL;
	IAudioClient* myAudioClient = NULL;
	IAudioRenderClient *myAudioRenderClient = NULL;

	BYTE* buffer;
	DWORD flags = 0;

	if ( enumerator )
	{
		hr = enumerator->GetDefaultAudioEndpoint( eRender, eMultimedia, &myDevice );
	}

	if ( myDevice )
	{
		hr = myDevice->Activate( __uuidof(IAudioClient), CLSCTX_ALL, NULL, reinterpret_cast< void** >( &myAudioClient ) );
	}

	// IAudioClient::Initialize() fails if I use this WAVEFORMATEX
	//WAVEFORMATEX* format = NULL;
	//hr = myAudioClient->GetMixFormat( &format );

	uint32_t bufferFrameCount = 0;
	uint32_t numFramesPadding = 0;
	uint32_t numFramesAvailable = 0;

	if ( myAudioClient )
	{
		WAVEFORMATEX hello;
		hello.wFormatTag = WAVE_FORMAT_PCM;
		hello.nChannels = 2;
		hello.nSamplesPerSec = FREQUENCY;
		hello.nAvgBytesPerSec = FREQUENCY * 4;
		hello.nBlockAlign = 4;
		hello.wBitsPerSample = 16;
		hello.cbSize = 0;
		hr = myAudioClient->Initialize( AUDCLNT_SHAREMODE_EXCLUSIVE /*AUDCLNT_SHAREMODE_SHARED*/, 0, 10000000, 0, &hello, NULL );
	}

	hr = myAudioClient->GetBufferSize( &bufferFrameCount );
	hr = myAudioClient->GetService( __uuidof(IAudioRenderClient), reinterpret_cast< void** >( &myAudioRenderClient ) );

	hr = myAudioClient->Start();

	// Each loop fills about half of the shared buffer.
	while (flags != AUDCLNT_BUFFERFLAGS_SILENT)
	{
		// See how much buffer space is available.
		hr = myAudioClient->GetCurrentPadding( &numFramesPadding );

		numFramesAvailable = bufferFrameCount - numFramesPadding;

		// Grab all the available space in the shared buffer.
		hr = myAudioRenderClient->GetBuffer( numFramesAvailable, &buffer );

		audio_callback( NULL, buffer, numFramesAvailable );

		// Get next 1/2-second of data from the audio source.
		hr = myAudioRenderClient->ReleaseBuffer(numFramesAvailable, flags);
	}

	return NULL;
}

int main( int argc, char* argv[] )
{
	HANDLE threadHandle;
	DWORD threadId;
	threadHandle = CreateThread( 
		NULL,                   // default security attributes
		0,                      // use default stack size  
		AudioThread,       // thread function name
		0,          // argument to thread function 
		0,                      // use default creation flags 
		&threadId);   // returns the thread identifier

	// all of the actual work happens in the audio thread
	while ( 1 )
	{
		Sleep( 100 );
	}

	return 0;
}

nielsm
Jun 1, 2009



Looks fine for the most part, except that your inner loop seems to not wait on anything.

quote:

C++ code:
	// IAudioClient::Initialize() fails if I use this WAVEFORMATEX
	//WAVEFORMATEX* format = NULL;
	//hr = myAudioClient->GetMixFormat( &format );
Fails, what HRESULT does it give?
Also keep in mind this paragraph on the manual page for GetMixFormat:

quote:

The mix format is the format that the audio engine uses internally for digital processing of shared-mode streams. This format is not necessarily a format that the audio endpoint device supports. Thus, the caller might not succeed in creating an exclusive-mode stream with a format obtained by calling GetMixFormat.

After your GetBuffer call, make sure to check the result, that is actually succeeds.

You should probably add a short Sleep call (half or quarter buffer length) to your audio playback loop, otherwise it will be too tight.
Consider passing AUDCLNT_STREAMFLAGS_EVENTCALLBACK to IAudioClient::Initialize, then use the Win32 CreateEvent function to create a simple auto-reset event object, which you can then give to IAudioClient::SetEventHandle. Then in your audio loop, instead of calling Sleep, you can call WaitForSingleObject on the event handle, and have the audio system signal your thread when it's ready for new data.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
Thanks.

I think I need to copy that example I linked to more verbatim. I've got stuff from a few different places.

The wait seemed odd because I want things to run as fast as possible, but maybe I don't quite understand what is going on yet. I'll add it in.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I added the same delay in the example that I copied, but it didn't change anything:

Sleep((DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2));


With this code I get error 0x88890008 AUDCLNT_E_UNSUPPORTED_FORMAT:

hr = myAudioClient->Initialize( AUDCLNT_SHAREMODE_EXCLUSIVE, 0, hnsRequestedDuration, 0, pwfx, NULL );


If I change EXCLUSIVE to SHARED then I get no error, but I also get no sound (as opposed to the garbled sound).

If I use my own cute WAVEFORMATEX, it works with exclusive mode, but the audio doesn't work quite right. That was the original problem. I don't know if my WAVEFORMATEX is right.. i just found it somewhere.

So, I can use shared mode or specify my own WAVEFORMATEX for IAudioClient::Initialize() to work. I have no preference either way right now. I literally just want sound coming out of the speakers right now.

I still have no idea how to actually fill the buffer.



Edit: Ok I found a working program here. http://gyabo.sakura.ne.jp/prog/wasapi.cpp I can probably figure it out from here.

Edit: And another working example if anybody cares: http://www.jdmcox.com/WASAPI.cpp

baby puzzle fucked around with this message at 01:48 on Jun 27, 2016

Pollyanna
Mar 5, 2005

Milk's on them.


Is there a resource for developing and designing applications independent of languages and platforms? I can code stuff up in Ruby, Elixir and Clojure as much as I want, but I never really learned how to make something. I don't know much about making a (non-web/REST) API, for example.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Pollyanna posted:

Is there a resource for developing and designing applications independent of languages and platforms? I can code stuff up in Ruby, Elixir and Clojure as much as I want, but I never really learned how to make something. I don't know much about making a (non-web/REST) API, for example.

I would look into Requirements Analysis or Business Analysis. You need to figure out what you want first, then you can go about making it.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Pollyanna posted:

Is there a resource for developing and designing applications independent of languages and platforms? I can code stuff up in Ruby, Elixir and Clojure as much as I want, but I never really learned how to make something. I don't know much about making a (non-web/REST) API, for example.

Have you read books like The Mythical Man Month, Code Complete, etc?

Peanut and the Gang
Aug 24, 2009

by exmarx
A piece of a tool I'm working on needs to be able to read and do operations based on pass/fail counts for selenium tests. Is there a json reporter for it that works in java and python? The reporters I've found so far are usually java-only and do ugly console output or build html files, which I'm not excited about parsing. Ideally would be able to also check if certain tests pass by name lookup. Pretty much what i want is similar output to what `mocha -R json` would do, which looks like this:

code:
{
  "stats": {
    "suites": 0,
    "tests": 0,
    "passes": 0,
    "pending": 0,
    "failures": 0,
    "start": "2016-07-01T14:36:48.020Z",
    "end": "2016-07-01T14:36:48.020Z",
    "duration": 0
  },
  "tests": [],
  "pending": [],
  "failures": [],
  "passes": []
}
Where those arrays are filled in with the tests that pass/fail/etc.

Peanut and the Gang
Aug 24, 2009

by exmarx
Ah, just realized selenium itself isnt the testing framework. It's a tool that can be used inside of junit/etc. So we can do handlers for junit, python unittest, etc. and be good.

Pollyanna
Mar 5, 2005

Milk's on them.


Bob Morales posted:

Have you read books like The Mythical Man Month, Code Complete, etc?

I've been meaning to read them but never got around to getting them. Purchased off of Amazon now :)

Skandranon posted:

I would look into Requirements Analysis or Business Analysis. You need to figure out what you want first, then you can go about making it.

Good point. I know only very little about either, even though I went to a design/industry-focused engineering university...plus, it might be different for software. But it will help me fend off dumb decisions from higher ups, at least.

or just make me question why i do what i do even more than usual

Strong Sauce
Jul 2, 2003

You know I am not really your father.





There is no AWS related thread here, and none I could find in the main SH/SC forum so I'll ask here.

I'm trying to deploy a stupid twitter bot using AWS Lambda. I have a script with twitter oauth keys that generates a tweet.

This part works fine. If I make test calls for this function, I get a tweet.

However I also need it to just run it every 15 minutes. Okay so I attached a CloudWatch event to the Lambda and save it.

I pretty much don't get any new tweets. I see from the logging/metrics that the file _is_ running every 5 minutes but it's not outputting anything.

After investigating it looks like CloudWatch caches the results? So it tries to tweet the same thing but twitter doesn't allow for that so I end up seeing nothing.

Is CloudWatch caching Lambda scripts, and if so is there anyway to tell it not to?

edit: figured out that aws lambda may or may not reuse the same container to execute code so any code/vars outside of the handler function may be reused again.

Strong Sauce fucked around with this message at 08:08 on Jul 3, 2016

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
I have a security/best practices question.

Background: With two-factor authentication using TOTP (Time-Based One Time Passwords), the typical way to let users set up the 2FA is by showing them a QR code that they can scan with a TOTP-enabled app such as Google Authenticator. Once they've proven that they've scanned the code by entering an example one-time password you can store the secret key used to generate the QR code alongside the rest of their user data. Later when they're prompted to provide a one-time password you verify that they have the right code by using the same secret key on the backend.

My question is simple: Is it a bad idea to let the user see the same QR code again when they've already logged in, so they can for instance rescan it with a different app or device? Since the app that generates the codes is supposed to be a "something you have" factor I can see how allowing the user to scan it again at any time just by being logged in can potentially undermine the two-factor element, but on the other hand, is it any different than multiple people receiving copies of the same key to some door?

I'm asking because I've noticed that at least Google and Microsoft don't seem to let you rescan the QR code, so I guess if you're getting a new device you're supposed to have to remove the 2FA and set it up again from scratch. Google also has SMS-based 2FA as a fallback though, so I guess it's not too bad. I can't think of any other justification for this cumbersome UX choice than that it being for security reasons, but on the other hand I'm not sure I'm seeing how security would be compromised. Am I overlooking something here?

Jables88
Jul 26, 2010
Tortured By Flan
I need a book recommendation.

I've got a master's degree in pure mathematics (with no CS at all) and I've been working as a Java developer for 2-3 years. Increasingly, I feel held back by a lack of understanding of certain underlying concepts in computing, and I'd like to build up an academic understanding of the field.

Can anyone recommend a decent undergraduate first year Computer Science textbook with a fairly broad focus?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


A typical first year CS book is just an introduction to programming, so that may not be as helpful as you want. Can you be a little more specific as to what you're looking for?

In the meantime, you can take a look at the requirements for MIT's CS major and then find the courses on OCW. That'll give you a better idea of what sort of topics you're missing out on.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Jables88 posted:

I need a book recommendation.

I've got a master's degree in pure mathematics (with no CS at all) and I've been working as a Java developer for 2-3 years. Increasingly, I feel held back by a lack of understanding of certain underlying concepts in computing, and I'd like to build up an academic understanding of the field.

Can anyone recommend a decent undergraduate first year Computer Science textbook with a fairly broad focus?

Structure and Interpretation of Computer Programs (SICP) sounds right up your alley. It's legit CS but very skewed for mathy people. As a math major I loved it.

If you want something more "traditional" then The Algorithm Design Manual by Skiena is a thread favorite.


As a math dude who jumped later into programming without CS training I feel like after reading books like those 2 above I'm not much behind an average CS major in uh... "general computer science"? It's specific topics like networking and databases that you need to catch up eventually.

Pollyanna
Mar 5, 2005

Milk's on them.


Seconding SICP. It looks a little scary and dry, but it's a great book and a great explanation of CS fundamentals. Skiena is good for DSA, too.

also my phone autocorrects "Skiena" to "Aliens" :tinfoil:

Jables88
Jul 26, 2010
Tortured By Flan
That's a good enough pair of recommendations for me! Sounds ideal. Thanks.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
SICP is available online for free: https://mitpress.mit.edu/sicp/full-text/book/book.html
If you've got a masters in math you should have no trouble with it. Be sure to install Scheme to follow along.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


SICP is a fantastic book, but if you're coming from a math background, a lot of what you're missing is on the systems side of things. How are your data structures laid out in memory? What's actually happening when you make a connection to a database? How does the OS allocate time between different processes? That stuff is important for a lot of cases, and probably good for everyone to know a little bit about.

Computer Science from the Bottom Up is a good book along those lines, but it's maybe a little bit aimed at C developers working on a Unix platform. It's still worth reading, but there may be better choices for a Java developer.

Gravity Pike
Feb 8, 2009

I find this discussion incredibly bland and disinteresting.

LOOK I AM A TURTLE posted:

My question is simple: Is it a bad idea to let the user see the same QR code again when they've already logged in, so they can for instance rescan it with a different app or device?

Yeah, if you can re-scan the QR code, it just becomes a second thing-you-know. Your users can get phished, and the attacker can gain access to the 2fa secret, at which point they have the ability to log in whenever they want.

If you only show the QR code once, it means that if a user gets phished or mitm'd or something, the attacker has to take advantage of that access right now, or else they lose it. "Right now" access isn't ideal for a variety of reasons: everything has to be completely scripted, so you can't poke around in their account; you know the user is logged in, and might notice any changes to their account; and you can't sell the login on the black market.

Gravity Pike fucked around with this message at 05:51 on Jul 6, 2016

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

Gravity Pike posted:

Yeah, if you can re-scan the QR code, it just becomes a second thing-you-know. Your users can get phished, and the attacker can gain access to the 2fa secret, at which point they have the ability to log in whenever they want.

If you only show the QR code once, it means that if a user gets phished or mitm'd or something, the attacker has to take advantage of that access right now, or else they lose it. "Right now" access isn't ideal for a variety of reasons: everything has to be completely scripted, so you can't poke around in their account; you know the user is logged in, and might notice any changes to their account; and you can't sell the login on the black market.

Thanks for the info. I suspected that was the reason, and your explanation makes sense.

Adbot
ADBOT LOVES YOU

Peristalsis
Apr 5, 2004
Move along.

Jables88 posted:

I need a book recommendation.

I've got a master's degree in pure mathematics (with no CS at all) and I've been working as a Java developer for 2-3 years. Increasingly, I feel held back by a lack of understanding of certain underlying concepts in computing, and I'd like to build up an academic understanding of the field.

Can anyone recommend a decent undergraduate first year Computer Science textbook with a fairly broad focus?

I also have a masters in (mostly) pure math from many years ago, and have been working as a software developer for 19 years. I'm currently working through SICP, and it has been a slow slog (at least in part because I only read it on the bus on the way to or from work). It's interesting, but I'm not sure I recommend it as a first exploration of CS concepts.

Honestly, if you want something fairly quick and easy, I'd suggest learning some C. The syntax will be familiar for a Java programmer, and you'll see at least a little more of how things work underneath the hood than you will with Java or other more modern languages. For example, dealing with pointers explicitly is probably something everyone should do at least once. If C is too easy or high level for you, you could study assembly, instead.

I'm not sure what you mean by "underlying concepts in computing", but coursework on algorithms and data structures might provide a good balance between theory and practical information.

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