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
omeg
Sep 3, 2012

JawKnee posted:

Does anyone know what re-sizing algorithm is used by StretchDIBits?

I'm re-sizing a bitmap frame captured from a video using GetCurrentImage, and I need to access the pixel data after the re-sizing, but preferably not by grabbing what's displayed on the screen - I'd rather just grab the same pixels that the algorithm does before the re-sizing happens at all.

I'm confused. If you're doing the resizing doesn't that mean you have the source pixel data?

Adbot
ADBOT LOVES YOU

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line

omeg posted:

I'm confused. If you're doing the resizing doesn't that mean you have the source pixel data?

Yes, I have it in RAM, but not displayed until after resizing - I just need to know how stretchdibits is using the pixel data as I'm going to be performing some changes to the displayed pixels - but I'd rather set up the changes that I want to happen before the pixels are displayed (in essence before the stretch has happened).

So, for example let's say I have a 500x500 image that I'm going to be resizing to 64x64 - I have the pixel data for the larger image in memory, but I want to know which pixel data is going to result from the stretchdibits call before it happens (I hope that makes sense).

It seems like I might be able to explicitly set it using SetStrechBltMode, but I'd like to know what it uses by default.

TheEffect
Aug 12, 2013
I have an .exe file (VB.Net, WinForms) that kicks off to a batch file. This app is on our network for everyone to access. The users who utilize it have no admin rights on the machines they use. A couple questions-

When the .exe file is run the user gets two prompts asking if they want to procees, the first one is "Do you want to allow files from this website to run on your computer?" and the second one is "We can't verify who created this file.". When the batch file is kicked off the users gets another "We can't verify who created this file." prompt.

I Googled around and from what I can tell the only way to suppress these prompts is 1) to become verified (expensive) and 2) to change settings on the individual PCs themselves, one by one. Neither of these things are feasible.

Are those truly my only options?

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!
If your computers are on a domain, I think you can create your own certificate server that you can use to verify your stuff.

nielsm
Jun 1, 2009



Yes you can really always be your own CA and produce and sign your own code certificates, but Windows will only accept them if it has the root certificate installed. The easiest way to ensure that is to have every machine on a domain. If you have that, you can also apply group policy to mark the network location as "Local Intranet" zone, and set files in that zone to not be "tainted".

TheEffect
Aug 12, 2013
We have a CA server but it's managed by Corp IT. Same with Group Policy. I asked about getting the directory added to the IE intranet zone and was told it's a PITA and I'd need to have a meeting with them to discuss the advantages... *sigh*. I was hoping there was something I could do in my code as a work-around.

Thanks for the responses though. At least now I know what route I need to take.

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
A quick (and maybe odd) question:

A professor I have gives us psuedo-code done in Matlab for our assignments (which are c++), and he posted this little snippet which I'm having trouble interpreting:
code:
for col = 1 : 64
	signal = zeros(1,N);
		for row = 1:64
			m = 64-row+1; % row=1 is at the top, but that is "high" frequency.
			ss = sin(2*pi*freq(m)* tt );
			signal = signal + im(row,col) * ss;
		end % for row
	signal = signal / 64; % since im(row,col) could be 1.0 -- is this the best idea?
	sound(signal, Fs);
end % for col
I get most of it, except for how the 'signal' array is being operated on in "signal = signal + im(row, col)*ss", im(row, col) is a single value, so is it being added to every entry in the array? Or is this just a slip-up and he's forgotten to add the array index? (I'm not overly familiar with Matlab).

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


JawKnee posted:

I get most of it, except for how the 'signal' array is being operated on in "signal = signal + im(row, col)*ss", im(row, col) is a single value, so is it being added to every entry in the array? Or is this just a slip-up and he's forgotten to add the array index? (I'm not overly familiar with Matlab).

It's vectorized.

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line

so it seems to just be adding a scalar to a 1xN matrix then, cool.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
Here's a general question for anyone who cares to chime in: Do you name database tables as singular or plural, i.e. "Customer" or "Customers"? I used to do plural because that's what everyone seems to do, but at my work we use singular and ever since I got used to that it just seems so much better. My main argument is that whenever possible I want my entity classes, domain classes, etc. to have the same names as the corresponding database tables, and the classes should clearly be singular. I view the tables not so much as collections of objects as definitions of objects, so just like I wouldn't make a class called "Customers" in my code I wouldn't want a table with that name either, even though it makes the SQL statements read a bit better in some cases. I could see using plurals if somehow some tables were plural and others weren't, but clearly all tables are necessarily plural in nature, making the suffix redundant.

Ahz
Jun 17, 2001
PUT MY CART BACK? I'M BETTER THAN THAT AND YOU! WHERE IS MY BUTLER?!
The cardinality should show the plurality while each record is singular. So singular.

aerique
Jul 16, 2008
Not quite a programming question but: is anyone aware of access to a stream of stock quotes that is free? It is just for playing around, so it doesn't have to be super up-to-date and may only have an update interval of every five minutes or so.

On the other hand, while it is for playing around, I am done with EVE so I would really like it to be real world data.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

aerique posted:

Not quite a programming question but: is anyone aware of access to a stream of stock quotes that is free? It is just for playing around, so it doesn't have to be super up-to-date and may only have an update interval of every five minutes or so.

On the other hand, while it is for playing around, I am done with EVE so I would really like it to be real world data.

Yahoo Finance offers CSV quotes https://code.google.com/p/yahoo-finance-managed/wiki/YahooFinanceAPIs

MrMoo
Sep 14, 2000

aerique posted:

Not quite a programming question but: is anyone aware of access to a stream of stock quotes that is free? It is just for playing around, so it doesn't have to be super up-to-date and may only have an update interval of every five minutes or so.

Anything interesting as I have access to real time quotes :toot: I have someone trying to get 180,000 updates per second (market close) working in a simple Java app with an API that maxes out at 100k.

TheEffect
Aug 12, 2013
Can anyone shed light on why when I run my application and try to overwrite while copying a file it returns a unhandeled exception error?

VB.Net

Code:

code:
                    If File.Exists(FileCopied) = True Then
                        Dim Confirm2 As Integer = MsgBox("A file with that name already exists." & vbCrLf & "Overwrite?", MessageBoxButtons.YesNo, "Duplicate File Found:")
                        If Confirm2 = DialogResult.Yes Then
                            File.Copy(FileCopy, FileCopied, True)
                        Else
                            Exit Sub
                        End If

nielsm
Jun 1, 2009



Begin by figuring out which exception it's throwing. When you know what the error is, avoiding it becomes infinitely easier.

TheEffect
Aug 12, 2013
Oh right, sorry about that. The exception states that the file already exists, but I thought that's the whole point of the parameter "true" in

File.Copy(FileCopy, FileCopied, True)

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

TheEffect posted:

Oh right, sorry about that. The exception states that the file already exists, but I thought that's the whole point of the parameter "true" in

File.Copy(FileCopy, FileCopied, True)

Make sure the file isn't locked. You could put a breakpoint on the File.Copy and try deleting the file yourself. Also, posting the exception would be helpful.

TheEffect
Aug 12, 2013
I was trying to call another file copy, without the overwrite parameter, directly after. Didn't have my code nested right.

Thanks for the help guys.

Morroque
Mar 6, 2013
Lately I've taken to giving a few kids small coding lessons here and there via request from their parents. So far it's just been a lot of messing around in the old non-studio version of Game Maker and me telling random funny stories of glitches gone horribly wrong. It's been alright so far, but I'm kind of running out of ideas. They're not in high school, haven't even learned Algebra in math class yet, so I'm worried if just picking a random topic and running with it will risk being too advanced for the moment.

I thought Game Maker would be good for them because it's what I first used when I was their age, and it offers very immediate feedback. However, they're still using the drag-n'-drop and haven't really made the jump to trying GML code yet. My fear is they'll hit a plateau and not be able to advance much further because they're missing the underlying core concepts, like assigning variables and managing the control flow. The only other thing I can think of that might be easy enough would be writing HTML and some CSS, but I don't know how to make that exciting to them. Their attention spans are about 2 hours maximum before they reach for the nerf guns.

I got into programming first at their age and I was completely self-taught from that point onwards, but that just means I never really had to explain myself before. Has anyone here taught programming stuff to a younger crowd? What are some effective techniques or topics? Is there anything out there that might make things easier?

Morroque fucked around with this message at 23:18 on Oct 24, 2014

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
I don't have any experience teaching younger people, but I was hooked on coding as soon as I realized I could make a simple program with interactive i/o. I didn't understand all the mechanics of the code, but my dad showed me how to use cin and cout and what variables were, and it gave me a concept of what software was like. There is a reasonable amount of things you can do with just basic input and output, and a few if statements. When I first started playing around with this stuff, I didn't know all the formatting rules or about data types or functions or anything, but I could copy and past what already worked. Python is a lot friendlier to get started with than c++, and it looks a lot less intimidating too, so you could always try walking them through "hello world" in python and see if any of them find it interesting.

thegasman2000
Feb 12, 2005
Update my TFLC log? BOLLOCKS!
/
:backtowork:
I am currently trying to teach my autistic brother programming. I got a sense board with my open uni course, like a raspberry pi... Aling stuff light up and stepper motor turn has been fun. It uses the programming language sense which is drag and drop which is cool.

Carthag Tuek
Oct 15, 2005

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



thegasman2000 posted:

I am currently trying to teach my autistic brother programming. I got a sense board with my open uni course, like a raspberry pi... Aling stuff light up and stepper motor turn has been fun. It uses the programming language sense which is drag and drop which is cool.

please dont stigmatize him further

Carthag Tuek
Oct 15, 2005

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



if he is hella into programming then i guess buy some 1980s books about cobol 80 or some poo poo idk

thegasman2000
Feb 12, 2005
Update my TFLC log? BOLLOCKS!
/
:backtowork:

Snapchat A Titty posted:

please dont stigmatize him further

Well he is really really into games and wants to make them one day... Also I mentioned he is autistic as it severely reduced the level I had to pitch in at compare to his age.

Kenishi
Nov 18, 2010
I have no experience with autistic individuals, but if coding is something that grabs his focus then start with something for kids maybe? Just google the stuff, they've started creating mountain loads of material for "programming for kids." If this might be something like a "sevant" ability then simply giving him some books and showing him how to compile stuff might be enough.

My suggestion, Lego Mindstorms, if you can get your hands on it.

aerique
Jul 16, 2008

Kenishi posted:

My suggestion, Lego Mindstorms, if you can get your hands on it.

There's also Lego WeDo for the younger crowd. My eight year old daughter had an awesome time last week working with it for the first time.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Is there any performance cost (however small) for declaring a method/class static? Memory cost maybe?

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

In Java, static variables are allocated/filled when the class is loaded. So declaring methods static might add one more object to be initialized. But the way you're asking about static classes I doubt you mean Java.

feedmegin
Jul 30, 2008

carry on then posted:

In Java, static variables are allocated/filled when the class is loaded. So declaring methods static might add one more object to be initialized. But the way you're asking about static classes I doubt you mean Java.

Yeah, which language we're talking about kind of matters here :shobon:

1337JiveTurkey
Feb 17, 2005

Static inner classes are a Java thing. They are the same as normal top level classes except have access to private members of the containing class when an instance is passed to a method or is assigned to a field. Without static, there is also a specific instance of the enclosing class associated with each instance of the inner class. It doesn't need to have an instance of the containing class as a field or parameter because there's a hidden reference to the instance used to construct it. Static inner classes have identical performance to top level classes. Non-static inner classes have an additional word of memory per instance and can prevent the constructing instance from being garbage collected which can increase memory pressure unintentionally.

JawnV6
Jul 4, 2004

So hot ...
I'm using some discontinued hardware for a demo (read: no support for this). I need it to work on an arbitrary machine. There's a "pairing" step where two USB sticks are plugged into the PC at the same time. There's some information exchanged during that step, and the PC learns about the USB dongle it's looking for. Ideally, this demo proceeds without that "pairing" step on arbitrary hardware. So I need to mimic that pairing step without having the hardware present.

There has to be some information stored, but I can't figure out where. du reports the same file sizes on the Program Files directory, so I don't think it's there. I poked at the registry and nothing jumped out.

Where else can Windows stuff information like this?

M.C. McMic
Nov 8, 2008

The Weight room
Is your friend
I'm a Python developer, and I just sat through the first of three days of ITIL Foundations training. What in the loving hell did I just listen to for 6 hours?

omeg
Sep 3, 2012

JawnV6 posted:

I'm using some discontinued hardware for a demo (read: no support for this). I need it to work on an arbitrary machine. There's a "pairing" step where two USB sticks are plugged into the PC at the same time. There's some information exchanged during that step, and the PC learns about the USB dongle it's looking for. Ideally, this demo proceeds without that "pairing" step on arbitrary hardware. So I need to mimic that pairing step without having the hardware present.

There has to be some information stored, but I can't figure out where. du reports the same file sizes on the Program Files directory, so I don't think it's there. I poked at the registry and nothing jumped out.

Where else can Windows stuff information like this?

Is this some sort of hardware DRM?

Sedro
Dec 31, 2008

JawnV6 posted:

Where else can Windows stuff information like this?
Have you tried running Process Monitor?

TheEffect
Aug 12, 2013

M.C. McMic posted:

I'm a Python developer, and I just sat through the first of three days of ITIL Foundations training. What in the loving hell did I just listen to for 6 hours?

I felt the same way. Pay attention to the last day and the review the most. Don't try to memorize or write down everything that is said. That was my mistake. I wrote almost as much notes as there was material in the book, and I ended up failing the test by one question.

JawnV6
Jul 4, 2004

So hot ...

omeg posted:

Is this some sort of hardware DRM?
No, though I can see how it reads that way. It's a wireless usb implementation and I'm going to stuff one of them into a IP67 enclosure. Being able to run on an arbitrary PC without cracking that open is the goal. There are more professional options to get bits out of plastic but I was hoping this would be simpler.

Sedro posted:

Have you tried running Process Monitor?
From the file structure I can guess what's running, but apparently Process Monitor is well suited to monitor file reads. I'll look into it thanks!

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

GrumpyDoctor posted:

The link you posted doesn't deal with multi-word search targets. One way to do that involves building a state machine with each terminal state pointing to some comment text, but I don't know if either VBA or you are up to that task. You might also be able to use a trie, but again, this is possibly outside of your wheelhouse and probably outside of VBA's. (And neither of these solutions will be particularly maintainable unless you build in some initial step to convert a simple mapping list to your state machine or trie.)

A simpler hybrid approach would just use the simple dictionary for single-word targets, and then repeat the approach you've already got for the multi-word ones. Your speedup will be (almost) equal to the percentage of targets that are single-word.

I asked this a long time ago and am now working on a solution, but I need some help with Open XML. I settled on an alternate hybrid approach where I will keep a queue of the last N words where N is the longest key in the dictionary, then each time I load a word also check each string that can be composed of the last 10, 9, ..., 2 words against the dictionary as well. I looked into tries as you suggested, but I don't think it has a huge advantage over a dictionary for this purpose and it didn't solve the problem of arbitrary key lengths, which is what I was struggling with.

Anyway, crossposting this from the .NET thread because I think different folks occupy this thread:

me posted:

C#/OpenXML question. I need to parse through a docx file word-by-word. I'm re-writing someone's horrifying VBA macro that checks for certain common errors and forbidden terms in documents. Their solution used 11,000 lines of code to check for a grand total of 500 errors. It's just 500 repetitions of this:
Visual Basic .NET code:

        Selection.HomeKey Unit:=wdStory
    Selection.Find.Execute Replace:=wdReplaceAll
    Options.DefaultHighlightColorIndex = wdRed
        With Selection.Find
        .Text = "dummy"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        '.MatchWholeWord = False
        '
        '
        '.MatchAllWordForms = False
    If Selection.Find.Execute Then
    Selection.Comments.Add Range:=Selection.Range
    Selection.TypeText Text:= _
        "Use ""replacement"" or ""generic"" instead."
    Selection.Find.ClearFormatting
    Selection.EscapeKey
    End If
    End With
As you might imagine, it takes rather a long time to search an entire document 500 times.

My solution is to instead, using C#, do an algorithm like the following:
code:
psuedocode:
Load a Dictionary<String, String> using a delimited file to load the rules; //I already finished this part

while (words remain in document){
  load next word;
  check if the word is in the dictionary;
  if (word in dictionary) add to a list along with returned value;
  add word to queue; //queue is the length of the longest phrase we check for, oldest item falls off when queue is full.
  loop through queue, checking last 2 words, 3 words, etc against dictionary;
  if (phrase in dictionary) add to a list along with returned value;
}

foreach(dictentry in listOfFoundItems){
  do a find in the document for each instance of the key;
  attach a comment to teach instance with the text from the associated value;
}
This way we're only looping over the document for as many times as is needed to catch rules that have been broken. It should also just straight up run faster by virtue of not being a VBA macro embedded in a docm.

Anyway, my question involves the problem of actually looping over individual words. In all my googling, the deepest level at which you can actually retrieve text from the word document appears to be the paragraph. Am I stuck looping over paragraphs and then using string piecing functions to loop over their words, or is there something clever in the API that I'm not finding with my google queries?

Or hell, does anyone know a better algorithm for doing what I'm trying to accomplish?

M.C. McMic
Nov 8, 2008

The Weight room
Is your friend

TheEffect posted:

I felt the same way. Pay attention to the last day and the review the most. Don't try to memorize or write down everything that is said. That was my mistake. I wrote almost as much notes as there was material in the book, and I ended up failing the test by one question.

Thanks.

I'm not even sure whether or not my boss would care if I failed the exam. I think he realizes that it is in no way relevant to my job.

Overall, this whole course sounds like a bunch of double-talk business bullshit. The primary purpose of which seems to be to create bureaucracy and roadblocks. I can't keep half of the terms straight because everything seems intentionally vague.

On the other hand, I guess it's a free certification that I can put on my resume down the road. So, I can't complain too much.

Adbot
ADBOT LOVES YOU

Fisticuffs
Aug 9, 2007

Okay you a goon but what's a goon to a goblin?
Okay, I think I am an idiot for not just farming this out to someone that knows what they're doing but...

I want to create a streaming service. Nothing revolutionary. But I think if my device is compatible with desktop and mobile devices and my approach to content producers is solid that there may be a niche for me in that realm. But I can't code for poo poo. I know HTML, not well, and C++... again not well.

Is this too gargantuan and complicated a task for me to begin on my own and seek assistance with later? I need to shoot for the buffering, auto-resolution setting type features that ESPN3 uses as this would be live but slightly less lame than Twitch(only slightly though I am still a goon). Would starting this on my own just create problems for the people that I will almost certainly need to clean it up later or should I crack open some books and try and learn some Ruby or what the gently caress ever?

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