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
ultrafilter
Aug 23, 2007

It's okay if you have any questions.


the littlest prince posted:

Taking them concurrently would certainly be fine, it's terribly easy to be frank, and you could probably even just skip it altogether and pick it up during algorithms. But in the long term it's probably worth the time to take it.

This. You may need to occasionally look ahead in the discrete math book, but you should be fine as long as you put the work in.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Discrete Math is a very broad category of topics and in practice the class is often basically Remedial Everything since a quarter simply isn't enough time to go into depth in any of them. There's a good chance you already know half of the things that the class will cover, but it won't be the same half as any of the other students.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Does sed not support {M,N} format in a regular expression?

I am trying to get the first 30 characters in between curly braces. so far I have this in sed:

's/{\(.{0,30}\).*}/\1/'

But it doesn't seem to understand {0,30} there as getting up to 30 characters. If I replace that with thirty dots it works fine.

Am I missing some flag in sed that allows this? Is there a better way to handle this?

Carthag Tuek
Oct 15, 2005

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



Strong Sauce posted:

Does sed not support {M,N} format in a regular expression?

It's not really clear from man re_format whether bounds are basic or extended/modern RE syntax. Did you try with sed -E for extended?

ToxicFrog
Apr 26, 2008


Carthag posted:

It's not really clear from man re_format whether bounds are basic or extended/modern RE syntax. Did you try with sed -E for extended?

quote:

Regular expressions ("RE"s), as defined in POSIX.2, come in two forms: modern REs (roughly those of egrep; POSIX.2 calls these "extended" REs) and obsolete REs (roughly those of ed(1); POSIX.2 "basic" REs). Obsolete REs mostly exist for backward compatibility in some old programs; they will be discussed at the end.

[...]

A (modern) RE is one(!) or more nonempty(!) branches, separated by '|'. It matches anything that matches one of the branches.

A branch is one(!) or more pieces, concatenated. It matches a match for the first, followed by a match for the second, etc.

A piece is an atom possibly followed by a single(!) '*', '+', '?', or bound.

It's definitely an ERE feature. Use sed -E.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Yes, sed -E worked. Thanks Carthag/ToxicFrog!

omeg
Sep 3, 2012

Rocko Bonaparte posted:

This is half a programming question but mostly a hardware question, but I figured somebody has done this before. Has anybody ever tried to poll or be asynchronously notified of a wire signal change for something connected to a PC? We test some stuff here and in some scenarios the best we can get for notification are strobing some signal pins.

I'm thinking of getting a cheap-rear end microcontroller with old-school I/O ports and an RS-232 port, and just writing a program to poll the ports and send the pin changes over the RS-232 port. However, I'd prefer to get something off-the-shelf for this if possible. I don't necessarily want to maintain and deploy all these things.

It's very easy to poll the serial port (if you actually have it :v:). Depending on frequencies you may be fine with standard Windows API for it (no idea if you're on Linux). If you need really tight timings you'd probably want a custom driver (I've done that before), but normally just iocontrol calls should be fine.

omeg
Sep 3, 2012

OK, Visual Studio and remote debugging. :smithicide:

I need to debug my software in a VM environment. VM is Server 2008 R2 x64. It's a domain controller and has a lot of poo poo on it that my app integrates with. Host is Win7 x64 pro (no domain). Is it possible at all to do remote debugging in such setup? I've done remote debugging many times but never on a DC.

This page states that:

MSDN posted:

With these restrictions, remote debugging works in various scenarios, including the following:
  • Two domains without two-way trust.
  • Two computers on a workgroup.
  • One computer on a workgroup, and the other on a domain.
  • Running the remote debugging monitor (msvsmon) or Visual Studio as a local account.

Therefore, you must have a local user account on each computer, and both accounts must have the same user name and password. If you want to run msvsmon and Visual Studio under different user accounts, you must have two user accounts on each computer.

How I've done it before: on a VM create a user identical to my host one. Launch msvsmon as that user on the VM. poo poo works.

But here there are problems:
  • Because the VM is a domain controller it can't have local users.
  • I created a user named identically as my host one (but in the VM domain necessarily). Added it to admin groups etc. Trying to "run as" msvsmon as that user results in this:

    Which is loving weird, as the user is a domain admin and has full access to the files. It seems this user can't run any executables. :stare: Why? Didn't see anything relevant in event log (which is spammed to hell by some sharepoint services and other poo poo so I may have missed something).
  • I thought about doing it backwards: to create user on my host that will be identical as the VM's default administrator. But wouldn't that require that my host joins VM's domain? The quote above specifically states: One computer on a workgroup, and the other on a domain.
  • Maybe I'll just install VS on the VM and be done with it. :v:

Any suggestions?

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice

Hot Yellow KoolAid posted:


For reference, I've taken 2 quarters of calc, 1 quarter of linnear algebra, and 2 quarters of statistics.


Edit: There is also a potential option to take discreet math concurrently with algorithms, would this be preferable?

You'll be fine. Unless the class also requires statistics, it is likely that the only math that you are going to do is asymptotic analysis.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

omeg posted:

OK, Visual Studio and remote debugging. :smithicide:

I need to debug my software in a VM environment. VM is Server 2008 R2 x64. It's a domain controller and has a lot of poo poo on it that my app integrates with. Host is Win7 x64 pro (no domain). Is it possible at all to do remote debugging in such setup? I've done remote debugging many times but never on a DC.

This page states that:


How I've done it before: on a VM create a user identical to my host one. Launch msvsmon as that user on the VM. poo poo works.

But here there are problems:
  • Because the VM is a domain controller it can't have local users.
  • I created a user named identically as my host one (but in the VM domain necessarily). Added it to admin groups etc. Trying to "run as" msvsmon as that user results in this:

    Which is loving weird, as the user is a domain admin and has full access to the files. It seems this user can't run any executables. :stare: Why? Didn't see anything relevant in event log (which is spammed to hell by some sharepoint services and other poo poo so I may have missed something).
  • I thought about doing it backwards: to create user on my host that will be identical as the VM's default administrator. But wouldn't that require that my host joins VM's domain? The quote above specifically states: One computer on a workgroup, and the other on a domain.
  • Maybe I'll just install VS on the VM and be done with it. :v:

Any suggestions?

Join your machine to the domain? As long as you have a valid Kerberos ticket (mapping a network drive will do it) you'll be able to access the remote debugger.

Adahn the nameless
Jul 12, 2006
I may have to screen scrape every page of a website to port the content to another platform. This is for a weekend-long charity hackathon thing. Does anyone have an easy, out of the box solution for this? A free bot or something?

het
Nov 14, 2002

A dark black past
is my most valued
possession
I've seen a number of people recommend Beautiful Soup for doing that sort of thing, though I don't think it's just a bot

Suspicious Dish
Sep 24, 2011

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

Pork Pie Hat
Apr 27, 2011
Hello all, I have a small question and I wonder if anyone can help me with it. Before I start, if it turns out this is the wrong thread to ask in, please accept my apologies!

Ok, so I have a music collection that is encoded partly as MP3 and partly as FLAC. Now, say for example I wanted to write a batch file that would go through all the folders of my collection, find the FLAC files and replace them (deleting the FLAC files as is went) with AIFF files instead.

Is this possible? I'm running Windows 7, but have some experience using the command line, so I'm not afraid to get stuck in.

I'm not coming into this thread asking someone to write this for me, far from it. Rather, if it is possible, if someone could give me a few hints/pointers so I could learn how to do it for myself I'd be really grateful.

Thank you in advance for your time!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Do you want to convert them, or do you already have a bunch of AIFF files already made? And why would you convert from a compressed lossless format to an uncompressed lossless format?

Pork Pie Hat
Apr 27, 2011

Suspicious Dish posted:

Do you want to convert them, or do you already have a bunch of AIFF files already made? And why would you convert from a compressed lossless format to an uncompressed lossless format?

Yes, I'd like to convert them from FLAC to AIFF. I'm changing portable MP3 player from one that supports FLAC to one that doesn't. I know I could do it all by hand by feeding the files into FormatFactory, but I though there must be an easier way of doing it.

nielsm
Jun 1, 2009



I'm pretty sure you can do it in a couple of steps with foobar2000 and some clever media library filtering:

1. Create a playlist with all the FLAC files (e.g. using the search expression %codec% IS FLAC).
2. Use the Convert plugin to transcode to the target format, it should be possible to tell it to output each file to the input file's folder.
3. Use the File Operations plugin to move or delete the FLAC files.

Thermopyle
Jul 1, 2003

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

I'm trying to get better at unit testing.

How do I test a function that has results that vary depending upon which machine it's running on? In this specific instance I'm using Python and searching the system for history files for a few different common browsers.

The function returns objects representing the contents of those files.

I mean, I know of ways to test that, but...should the test return actual results from the system its running on, or should I somehow have fake ideal results, or what?

nielsm
Jun 1, 2009



Fake the system, aka. make a mock.

Write something with the same interface as what you use to search the filesystem, and make it enumerate a fake filesystem, probably fed in as a list of filenames with paths. Then you can prepare a bunch of different test systems and be sure you get consistent results every time. (The point of your test is to check whether the history-file-searching function works, not whether the filesystem works, so don't make the filesystem part of the test.)

The Python 3.3 standard library includes a unittest.mock package, for other versions (including 2.7) you'll have to use a third party one.

Phrost
Aug 21, 2004

Your martial art sucks
Hope this is the right place for this question:

I have a wiki that's got a ton of content hosted externally, on a former partner's server. That partner is now repurposing the server for other things, and I won't have access to the hosting. I have all the files, and have uploaded them to my own server.

What is the quickest way, whether through MySQL or some other mechanism, to mass-rewrite all the references to his server, back to mine?

External files might be linked as http://www.oldserver.com/files/investigation.pdf

When they need to be all rewritten to http://www.ourcrap.com /files/investigation1.pdf

Any ideas? I don't know much beyond absolute basic PHP, and of course HTML/CSS.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Are they all in a specific folder, like files/? You can use an Apache configuration to redirect that folder over to your new server.

Phrost
Aug 21, 2004

Your martial art sucks

Suspicious Dish posted:

Are they all in a specific folder, like files/? You can use an Apache configuration to redirect that folder over to your new server.

They've been rehosted on the same server, in a similar directory structure.

ex: files/bob/1.pdf , files/steve/1.pdf

I didn't think you could use .htaccess for outbound links.

nielsm
Jun 1, 2009



Suspicious Dish posted:

Are they all in a specific folder, like files/? You can use an Apache configuration to redirect that folder over to your new server.

As far as I understand, they're completely losing control of that server, and presumably also domain name, so the URLs have to change in the wiki.

Assuming there is only one or very few unique prefixes to the URLs that need to change, and nothing with those prefixes should stay, it's pretty simple to write an SQL UPDATE command to search/replace them.


As an example:
UPDATE table SET field=REPLACE(field,'http://www.oldserver.com/files/','http://www.newserver.com/files/moved/');
That will just replace all instances of the oldserver URL to a somewhat different newserver URL, in a particular field in a particular table. You need to identify which table(s) and field(s) the URLs can occur in first, so you operate on the right ones. Note that the field name occurs twice, and you need to change both occurrences to the right name.

If there's multiple old URLs that need replacing, write an update for each of them.
If there's multiple tables/fields with the URLs in, run the query on all of them.

Make a backup of the database before you run something like this, in case anything goes wrong.

Phrost
Aug 21, 2004

Your martial art sucks

nielsm posted:

As an example:
UPDATE table SET field=REPLACE(field,'http://www.oldserver.com/files/','http://www.newserver.com/files/moved/');
That will just replace all instances of the oldserver URL to a somewhat different newserver URL, in a particular field in a particular table. You need to identify which table(s) and field(s) the URLs can occur in first, so you operate on the right ones. Note that the field name occurs twice, and you need to change both occurrences to the right name.

If there's multiple old URLs that need replacing, write an update for each of them.
If there's multiple tables/fields with the URLs in, run the query on all of them.

Make a backup of the database before you run something like this, in case anything goes wrong.

That might be exactly what we need. Thanks. It's just external links in articles so, although not a perfect solution from a HTML purists' perspective, swapping out the domain name will fix all our problems (especially since the guy's joked about replacing the files with goatse as a means of encouraging us to get this done sooner).

Phrost
Aug 21, 2004

Your martial art sucks
You guys rule, this worked great.

Unrelated question, and I imagine there's some Apache wizardry necessary to make this work:

If I have a cms script running on domain1.com/stuff/cms.php

Is it possible/how can I present the output on domain2.com/cms.php?

Both are hosted on the same physical machines (DB and file servers), and I figured it wouldn't be really hard to do.

nielsm
Jun 1, 2009



Make the Apache Vhost for domain2 have the stuff/ directory as its document root?

Phrost
Aug 21, 2004

Your martial art sucks

nielsm posted:

Make the Apache Vhost for domain2 have the stuff/ directory as its document root?

What has two thumbs and apparently needs to spend a few weeks learning LAMP?

(This guy)

Thanks again.

omeg
Sep 3, 2012

I resolved my cross-domain remote debugging problem. On the host machine I created the same Administrator user as it exists on the VM. Visual Studio running as that user can now correctly attach to remote processes on the VM even if the host isn't on the VM's domain. Slightly annoying that I lost my VS customization because it's run by another user, but I can live with that.

Kenishi
Nov 18, 2010
Are there any databases best suited for dealing with linked data such as social networking maps?
I'm going to be starting a personal project where I need to be able store and hopefully work with the data efficiently.
Data would something like this:

If it was merely the names linking to each other it would be fine, but the link between two objects has a weight to it as well and that needs to be recorded.

I thought I might be able to run 2 tables in an SQLite database one for the people and their data. Then another for the links. But it seems like there would be better ways of doing this.

Carthag Tuek
Oct 15, 2005

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



Sounds like you want a http://en.wikipedia.org/wiki/Graph_database

Kenishi
Nov 18, 2010
That's exactly what I was thinking about! Thanks!

tarepanda
Mar 26, 2011

Living the Dream
I've been doing some searching with zero luck...

Are there any prototyping kits or anything out there for eInk displays of a decent size -- no numeral-only strips or tiny 1x3 strips or anything. Cost isn't really an issue.

I mean, I've seen news about display advances for years, but I've never actually seen a kit or a hack or anything other than people doing things to a Kindle rather than with standalone displays.

Sylink
Apr 17, 2004

This is a weird question so I hope I can phrase it right. Ideally this would be in Python.

I want to mess around with making a simulation. I want this simulation to be able to run and provide feedback in real time (or according to some time multiplier of my choosing).

So say I want to model a tree's height and I have a program that calculates the trees height based on the growth rate.

How do I add a tick rate into a program? I know game libraries often include these to limit the framerate and that is essentially what I need for command line output or something similar. This is because I imagine trying to calculate the time billions of times a second will add in all kinds of crazy errors.

So say I wanted my program my loop to at most calculate something 100 times a second. What is the ideal way to do this ?

I'm working with Python but a pseudo code/concept answer is probably what I need.

Suspicious Dish
Sep 24, 2011

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

Sylink posted:

This is because I imagine trying to calculate the time billions of times a second will add in all kinds of crazy errors.

You imagine wrong. Why?

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

I think billions per second is a bit optimistic.

JawnV6
Jul 4, 2004

So hot ...

Sylink posted:

This is because I imagine trying to calculate the time billions of times a second will add in all kinds of crazy errors.

What kind of crazy errors are you imagining?

Sylink
Apr 17, 2004

Would I not get floating point errors or something if I try to just calculate everything based on a dt recorded for each loop?

Opinion Haver
Apr 9, 2007

taqueso posted:

I think billions per second is a bit optimistic.

I'd kill to get my render loop down to a few instructions.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Sylink posted:

Would I not get floating point errors or something if I try to just calculate everything based on a dt recorded for each loop?

1) what sort of floating point exceptions do you think you are going to encounter here? Subnormals don't raise anything, they're just slow as a turd.

2) How do you think you're going to get cycle-accurate timing information in the first place? Are you familiar with the time-related syscalls on your system and the limitations of rdtsc and friends?

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...
Dear god please use the syscalls

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