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
Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

PainBreak posted:

With no coding experience to speak of, what is the best programming language to learn the basics nowadays? My little brother is a CS major, and is taking C++ right off the bat. Is that going to be biting off way more than he can chew?

The things about C++ that make it tough/annoying aren't taught in school. Like, in a C++ class, you might actually use <iostream> and be able to follow relatively simple string examples. Then you get to the real world and have to do something useful with strings and it becomes a research project just to figure out what the names of the functions you should use are.

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Zombywuf posted:

Pointers are a traditional source of confusion, made worse by the fact that some people try to pretend they don't exist as if that made it easier. They're pretty simple once you get the hang of them though.

When I was interviewing for a job as a C++ programmer, I noticed a lot of interview questions that would consist of a bunch of pointer arithmetic and questions asking "what does this do?"

These questions always used to strike me as bullshit - then I got a job doing maintenance on an ancient C++ codebase, the highlight being a method consisting of 500 lines of pointer arithmetic... Plus a few of 'Goto' statements thrown in for good measure.

gently caress that.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Dolemite posted:

I'm not sure whether to ask this here or in the Cavern of COBOL reading thread. I have a two-fold problem being a newer developer without a computer science background.

First: In writing my first Java / Android app, I believe my design is okay, but I just don't know. I feel that I've created solid classes that make sense in how much of certain responsibilities each one will handle. And how different classes (and objects created from them) will interact with each other. But, I'd like to really read up on software design methods so that I can go back and make things more efficiently designed.

Second: To solve the first problem, I'm not sure what I'm looking for. In my research, there seems to be two kind of tracks: Books/sites talking about software development things like Agile development, etc. Or, things that talk about design principles such as making use of factories, singletons, etc.

Now, I think what I'm looking for is closer to the design pattern type stuff. In reading more about methods like Agile development, it looks like that deals more with how a team will deliver/develop software for a client. But, I'm the only developer on this project and the client just gave us a loose spec. It doesn't really look like books on development methods will benefit me (at this time).

So if I'm looking for readings on design methods, what are good, trusted sites or authors in the industry? In my case, what is less likely to be entirely over my head? Unfortunately, I feel like I'm the most dangerous kind of developer: I can learn a language fairly quickly and have an app written for you in no time. But, I'm noticing that my apps tend to have growing pains until I spend a solid chunk of time rewriting the code to smoothly adopt the new requirement changes.

I REALLY want to avoid my vicious cycle of:

--*FURIOUS TECHNO AND CAFFEINE CODE BINGE*,

--working application,

--"Oh poo poo, I didn't think of these pitfalls",

--*FURIOUS TECHNO AND CAFFEINE CODE BINGE*,

--test app - find bugs,

--"Oh poo poo, to fix it, I need to do X. And in doing so, I should best rewrite these classes Y and Z to work with fixes to X. And now the the classes that Y and Z depend on need to be rewritten...",

--*FURIOUS TECHNO AND CAFFEINE CODE BINGE*

And so on and so forth. :(

The only development methodology that I've found really useful for improving the quality of the design is test driven development - essentially, write unit tests first, get the tests to pass, then refactor once you get stuff working.

I think it's counter-productive to sit down and try to come up with an elaborate, over-arching design - if you write the unit tests first, and force yourself to go entirely TDD, there will at least be enough discipline so that whatever you come up with will be testable, and the likelihood of coming up with an design that isn't viable is greatly reduced - and should the design suck, it's MUCH easier to refactor if you have working unit tests.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Dolemite posted:

Thanks all for the advice on programming design. :)

Regarding the one bit of advice to use testing to work out code: Sadly, I haven't really used unit testing all that much. I primarily work in PHP (*waits for laughter to end*) and should probably sit down and try out the testing frameworks I've heard about. I've worked at three places now that don't use any kind of unit testing. But in here and in companies that seem worth working for, I've noticed a lot of unit testing goes on.

Things I've noticed about unit testing in addition to previous comments:
1. It forces developers to use object oriented programming. If your 'design' isn't object-oriented, you're going to have a bitch of a time writing unit tests.
2. It forces developers to properly mock objects and write scaffolding code - say you're writing a program that displays CR images on a screen, and you use a DLL from another company to do the image processing (sharpening/edge enhancement). And say you need to swap out the old DLL for a new one. If you haven't written unit tests that mock out the component and scaffolding code, then you're in for a hell of a time doing guess and check when people start blaming the new module for issues QA is finding.
3. The unit tests themselves serve as MUCH better documentation than documentation. They're all example code demonstrating how the system works, and should cover every capability - rather than having to page through a reference, you have sample code exercising all the intended code of a module sitting right in front of you - that is huge.
4. Good unit tests make continuous integration worthwhile - if you make your CI tool run the unit tests, and you have good unit tests, you can instantly figure out who broke the build.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

ante posted:

Back in the nineties, I've got fond memories of loading up my hex editors and other script kiddie tools and hacking in shortcuts to my Mac OS 9 application menus.

What's the modern method of adding hotkeys to my XP or windows 7 application file/edit/view menus?

Use auto-it or autohotkey, it's loving amazing at adding shortcuts to things that don't have shortcuts.

Anotehr habit I've picked up is using greasemonkey to modify shortcuts on websites - I wrote a greasemonkey plugin that makes it so if I press left/right arrow, it goes back and forward in a thread (except if I'm typing a reply) by figuring out that there's a link called "next" or "prev" on the page and binding it to left and right unless there's an edit text box on the page. It's actually pretty ludicrously complex now, but here's an excerpt (I have keys for going up forums, smooth scrolling through posts, etc)

code:
var ma = $("textarea[name=message]"); 
if(ma.length)
{
	exit(); //disable navigation on reply pages
}
(function() {

jQuery(document).keydown(function(e) {
	switch(e.which){
	case 39: //right arrow
		
		var a = $("a:contains('Next')"); //does the link say next?
		if(a.length)
		{
			window.location.href=a.attr("href");
		}
		return false;
	break;		
	case 37: //left arrow
		
		var a = $("a:contains('Prev')");
		if(a.length)
		{
			window.location.href=a.attr("href");
		}
		return false;
	break;	
	}	   
}
)
})();

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Fruit Smoothies posted:

I have no idea what I want to be honest. Just a nice, happy, flexible language. I wish everything was like PHP / Javascript. But I'm probably alone in my thoughts, and also wrong.

Is C# the way, then?

C# gives me the fewest "what the gently caress were these idiots thinking" moments of any language I've ever used.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

KARMA! posted:

And yet you never have to touch any of it! Amazing.

Except when something breaks and the debugger pops up with crazy poo poo that's not in "your" code. Your boss isn't going to be "jolly well then, it's not your fault, can't be helped."

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Sab669 posted:

This is really a dumb question, but I've never really thought about it before.

What's the general consensus on what data type to use to store an encrypted password? Still just varchar? And what length should you allow, then. I suppose that probably varies depending on the type of encryption?
The one big gotcha I ran into with encryption is serialization. If your API is giving you back a bit array and you want to message pass using strings, you need to base64 encode the cyphertext before you pass the message or you'll have problems (don't encode ciphertext or hashes as unicode or ascii, it'll get mangled). The data type for storage doesn't matter as long as the whole internet can't see it though.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

shrughes posted:

It seems you get corruption on the Ruby side when the IV has characters 128 or higher. And it corresponds exactly to the position of the character.

Whenever I see a problem involving 128, I start looking around everywhere I see ascii encoding if it involves encryption.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

gandlethorpe posted:

I writing a macro in AutoIt that automatically fills forms by sending javascript commands to an IE browser. AutoIt is mainly for handling loops and page loads. I'm 99% done, but I'm having a problem with page transitions. I need to find a way to detect when a page or frame changes before the next one begins to load. Form submissions can take anywhere from a few milliseconds to several seconds, so I can't just tell it to sleep for a while then start waiting for the next page to load. Anyone familiar with AutoIt scripting?

You're using the COM interface right? Take a look at this page and see if waiting on the ready state would work http://www.autoitscript.com/autoit3/docs/functions/ObjEvent.htm

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

gandlethorpe posted:

I have been avoiding that, as it's confusing as hell to me right now. It looks like there is an event under WebBrowser that will help me, though (Navigated). How do I go about detecting this event?

If you do an objconnect to the running browser you should be able to just be like
while($foo.readystate == whatever)

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Zhentar posted:

That's because there's not much value to it, not because it's too hard. You can't functionally depend on that much memory without cutting off 2/3rds of the market, so you're limited to doing things like extra caching (much of which the OS will do with unused RAM anyway) for small performance gains on top end systems, at the cost of added testing & support costs.


It is likely that we'll start seeing more 64-bit PC games with the introduction of these new consoles, but only because it increases the value of designing something that actually takes advantage of that much memory, not because it's going to force them through some supposedly costly transition.

The holdup is probably the engine or DLLs that the game depends on - I do windows dev and we had a large legacy app that needed to be converted to 64-bit, and once we got DLLs for everything that worked in both 32-bit and 64-bit, the actual porting effort was maybe three man months for about 500k LOC, and there were only a handful of bugs. The problem is for games, there's no business justification for doing a 64-bit port - worse, if you support both 64-bit and 32-bit, you have to QA both, which is expensive. The 64-bit benefits for performance/memory utilization are negligible on the windows platform - the only real-world advantage to 64-bit windows app right now is that 64-bit apps don't crash when you hit 2 gb of virtual address space, which is not a very compelling reason cut 64-bit support (gently caress your app if you hit 2 gb of VAS).

I was hoping Windows 8 would cut 32-bit support altogether but I guess that's another thing microsoft hosed up.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Hadlock posted:

My friend actually writes software for medical devices. From the stories he told me, there's no way my code would make it through the auditing process at the FDA.

You can write poo poo code and have it end up in medical devices. The FDA is looking primarily for documentation - you have to have a quality system, and the steps of the design process have to be documented. You have to have processes, and you have to follow those processes in the course of designing the product. This generally leads to a lot of forms and paperwork.

The FDA is looking for the 'existence' of a process, and that we 'follow' the process, not whether or not the code is any good. At the high level, you'll have your design, then your software, then your design verification - but it's not as if the auditors are actually really testing your product, they're just making sure that a) you have a process, b) the forms corresponding with the process have been filled out, and c) your company appears compliant with the process. The design verification stage can be passed with "does this component do what it says it is supposed to do" type testing - there's no imperative (suggestions, but no imperative) that you do say, a code review, or unit testing, negative testing, or security testing, or anything really but functional testing under simulated/actual device conditions. You may recognize this as 'the bare minimum necessary to get a product out the door if you expect it to work.'

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Thermopyle posted:

What type of software has a million or 20 million lines? Not doubting you, I'm just curious.

I work on fifteen year old medical software - we're at 6 million LOC, probably about 3 million of it in C++. I know where pretty much everything is.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

UnfurledSails posted:

I'm an undergrad majoring in CS. Right now I've finished taking the core courses that teach the methodology of programming, as well as data structures and some stuff that's a little more in depth like reading assembly language.

I'm interested in spending my summer doing some studying on my own. I'm especially interested in computer security and want to learn how programs are exploited/defended against exploits. Can anyone point me towards a book or another resource that I can use for this?

I found that the quickest way of getting up to speed on security is to just go to a bunch of conventions - check out say, Summercon (http://www.summercon.org) or Defcon (http://www.defcon.org). Conventions will generally have student discounts. You might not really understand the subject material presented but I learned a poo poo-ton just by googling stuff I heard people talking about at Summercon. The problem with learning from books is that computer security is a rapidly changing field and the textbook stuff will be super out-of-date.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Jared592 posted:

Yeah I know, I just don't feel like crapping out a program for such a simple change.

you do realize you can do what you're suggesting in like 4 loc in most languages right if you use a parser?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

baby puzzle posted:

I have an idea for a project but I don't know where to start. I want to create virtual keyboard and mouse devices that look like a regular USB devices to programs. And then be able to control this device via scripts.

Where do I even start to learn how to create a fake device? My target platform is Windows 8.

The end goal is to create scripts to help with accessibility for games and general PC stuff, without the weird limitations of autohotkey, and also using a "real" scripting language.

Alternatively, is this work already done somewhere? I am having a hard time finding anything.

Edit: I guess I should indicate that I already know how to program c++.. or at least the people that pay me think I do.

What you want to do is a total bitch. There is no universal solution - you need to know what API the game is using for input, and there are many possibilities. If the game responds to window messages from the mouse and keyboard like an ordinary windows application should, just use autohotkey/autoit and call it a day.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

baby puzzle posted:

It seems like this might have been the case. I guess I will try each option until I run into walls. I have already run into many issues with autohotkey.. I assume that ahk is flakey because of the difficulty of the problem. So I will probably try autoit next.

I might look into the Arduino option just to have something to gently caress around with (since that is the real point of having a project). Thanks for the suggestions.

Autohotkey is actually really good if you learn how to use it - if you're experiencing flakiness, there is stuff you can do to compensate by using SendRaw etc, and worst comes to worse if you think you've found a bug in their functions, you can make direct calls to the API. I actually wrote an 'analog automation tool' (aka keylogger) in it that would record any keyboard/mouse moves that you would make, replay it, and generate a graph of what the user did with screenshots.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

bobua posted:

Generic question, and I probably have terminology wrong, but hopefully I can get this across.

How does something like an 'event' or callback work without threading? I'm working with an API right now that stirred up the question. Maybe their software is threaded and it's just hidden from me, but I register a listener for a device and it gets called when the device sends some data, so I basically have a function that runs randomly outside of what I think of as the normal flow of the program... I'm not concerned with this exact example so much as just wrapping my head around asynchronous software that doesn't involve threading. If they are using a separate thread, does that mean the function I've registered as a callback is running in a separate thread from the rest of my code?

In javascript, all asynchronous events go into an event queue - take a look at this link and it might be helpful for wrapping your head around the asynchronous stuff in generalhttp://javascript.info/tutorial/events-and-timing-depth

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Seashell Salesman posted:

2 and 3 sound like you are talking about some boundary between code being managed by a runtime (eg. the CLR or the JVM) and native code in the program? This does introduce some overhead but I'm not really sure if it's a significant source of slowdown in a 3D game. I'd expect people writing games in C++ to be using libraries built on other libraries built on OS provided APIs, not so much calling into the kernel explicitly or anything like that.
Well in modern systems the overhead really isn't that big a deal anymore - hell you can get decent 3d gaming performance using loving javascript nowadays.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Pollyanna posted:

So after reading up on the different kinds of paradigms it has come to my attention that I have never done functional programming. :psyduck: I was under the impression that it meant defining functions in a program and then using them later. In that case, what's the difference between functional programming and object oriented programming?

Functional programming, in its simplest form "programming without using assignment operators." Your program consists of functions - these functions are supposed to have referential transparency, meaning that same function, same arguments gives same result (no out parameters) hence why you don't need assignment operators. You can write like this in any language given enough effort, but it's generally done in languages like Haskell/Scala/Erlang/F#/etc (note that this is an ideal, not an absolute rule.)

This is the complete opposite of object oriented programming because in OOP, your functions live in objects, and those objects have state.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Shinku ABOOKEN posted:

Hello all,

What's the simplest most bare-bone way to do request/response for a client/server architecture assuming I want TLS and that I have full control over the client and server? Can one get away with not using HTTP? If so, is that a good idea?

I am asking this for a PC/mobile app I'm making. Server language doesn't matter (as long as I can use C libraries).

It depends on what you want to secure. If you're just serving up web pages or using a web service, you can just configure your web server to require TLS in apache/IIS/whatever configuration. Then when client connects to the web server using a browser, the browser handles all the details.

You can do TLS on any application specific protocol like FTP, etc - doesn't have to be HTTP. If you have your own application specific protocol, you can add TLS support to it on client/server using 3rd party libraries, but I would honestly take the route of serving the data that needs to be secured using apache/IIS with special configuration settings, and having your app use a web browser type control and piggy-back off the client authentication code from that, because doing it that way is way easier to not gently caress up.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Hughmoris posted:

I stepped in it.

After someone higher up discovered my hacked together script that I created using AutoIt's Record tool, I've been asked something way beyond my knowledge.

They want to create several virtual machines, and have a script execute at the same time on all VMs in order to stress test a network application. Essentially, simulating multiple users using an application. Is that something that AutoIt can handle? Can I load up a VM, start an AutoIt script that simulates mouse movements and key strokes, then start up another VM and do the same thing?

The script would essentially simulate checking boxes and typing in blank fields.

*I'm not a programmer or an IT guy. I'm a nurse who recently started a clinical informatics position. I'm thinking I flew too close to the sun. My objections about having no clue what I'm doing went unheeded.

If you really had to, you could make a VM where autoit would run when you booted the VM (just put it in the startup items folder), and you could use powershell or puppet or whatever to spin up the VMs.


However, step back from the technical. You're focused on one of the questions. There are three:

a) What are you measuring, and why?
b) How are you going to collect it?
c) Who wants the data, and why?

You're focused on b). I'd worry more about a) and c).

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Hughmoris posted:

To answer your question:
A) What are you measuring, and why? We are testing the application responsiveness and network latency for this medication module when multiple users are on at the same time.
B) How are you going to collect it? We will use a stop watch to measure the amount of time it takes the live testers to run through a script, while the VMs "users" act as additional loads on the module.
C) Who wants the data, and why? The higher ups want the data, to show the physicians that the fixes to the medication module have improved the latency and response time.

There are multiple problems:
a) You can't rely on stopwatch measurements. Taking a bunch of numbers with a stop watch is really boring, and you won't get consistent results even with same person, different day, exact same scenario. If you get a bunch of different people, half won't understand the direction.
b) It's going to be very difficult to repeat the results with some autoit script that bangs on the keyboard anyway, to say nothing about using VMs and lack of controlled environments. You'll get different numbers every day of the week.
c) There is no scenario where the physicians are going to give a gently caress about your numbers. You probably don't have enough information to know if you're even reproducing the problem or not, so it's unlikely that your script is going to reproduce the problem in the old version, and demonstrate that the problem goes away in the new version.

What you need to do is get the impact analysis of the fix - e.g. what did the vendor say was the problem? What was the fix? How did they test it?

I work for a pretty major medical software company, I used to do this kind of testing for them for a living - if you don't have a dedicated group doing software testing in your hospital, your IT department is going to end up with serious problems when they install all this bullshit medical software that doesn't work.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Kuule hain nussivan posted:

How does $("#h1").length work in JavaScript? Does it count the number of h1 elements present, or the length of the content in the first h1 element present?

JQuery selectors that return by id only return one element. "#h1" is a jquery selector that returns the element with "id" h1. It will always select one element (id should be unique in a document). If you want to return all h1 elements, use selector "h1" (e.g. $("h1").length. Read this: https://api.jquery.com/category/selectors/

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

AuxPriest posted:

As far as I know, anything that begins with a $ is jquery.

Angular uses the $ in front of a lot of crap, but $. is jquery namespace.

I give people a free pass because it's kinda hard to google "what does $(whatever) do"?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Faith For Two posted:

background: I have a semester-or-so of computer science knowledge, and am not pursuing a degree or career in computer science. Most of the programming i've done is simple c++/java or matlab scripts (proof of concept programs for using certain functions or features of the language).

I think it would be useful to learn how to write code that interacts with programs programs/files like microsoft office, adobe pdfs, web browsers, etc.

here's an example problem that i'd like to know how to do:
=================================================================================================
>I have a webpage or pdf with a table in it that has words & numbers.
>>I want to copy it into microsoft excel and change some values of it

>the text is in german and i need it to be translated to english
>>a script puts the german words into google translate and puts the translation into the excel spreadsheet appropriately

>The numbers in the table are in kilograms and they need to be changed to lbs.
>>a script puts the numbers into matlab or wolfram alpha and puts the correct number into the excel spreadsheet
(yes, in this example it'd be better to use excel's built in math stuff, but what if I had to do something that's more convenient to do in matlab/wolfram than excel?)
=================================================================================================

Something like this is doable without programming but it's a tedious task if the table is very large. What language/tools/books/tutorials would be useful in solving problems this way?

Microsoft Excel/Office are very easy to automate using OLE automation. A good resource to start would be:
http://blogs.technet.com/b/heyscriptingguy/archive/2006/09/08/how-can-i-use-windows-powershell-to-automate-microsoft-excel.aspx. It doesn't have to be powershell, you can use OLE automation from pretty much any programming language.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Reik posted:

I am not a programmer, I am an actuary, but I have a project I'm working on that involves automation of testing on a government website. The process we have in place from last year involved just running the site through Internet Explorer using VBA to fill out forms, push button, and pull text dumps from the pages in question. Unfortunately this year they updated the website and it appears our version of Internet Explorer, IE8, no longer works with this website. We do have access to Chrome thank god, but the VBA code we use only works in IE. I've looked up solutions to this problem and it looks like there are multiple simple solutions out there, but I'm trying to find one that meets the following restrictions:

1. Can't upgrade IE version.
2. Can't install any new software or plugins as these require approval from IT.

Is there any possible way to automate testing using VBA with Google Chrome? I know this isn't a hard problem, I just have some serious limitations due to Corporate America. I've recommended we request access for Firefox, the Selenium IDE plugin for Firefox, and the Selenium VBA plugin for Excel as a solution to this project, but I don't know if and when that can get approved.

Are there any solutions to this problem within my limitations? Is there some way to trick VBA in to thinking Chrome is actually Internet Explorer so that I can use the built-in objects and code stuff to automate Chrome?
You can't do OLE automation with Chrome.

Did you try playing with the compatibility view settings in IE to see if you could get the site to work, or changing the user agent string? It's extremely rare that something would have changed between IE versions that would break a site between IE6 and 8, yet work in Chrome at the same time - the site may just be checking browser versions and saying it doesn't work.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

mystes posted:

I have a windows/C++ related question (I'm not sure if there's a more specific thread this would fall under?): For a really dumb reason, I want to modify a method in a C++ COM library DLL but that isn't included in the COM interface by which the DLL will actually be used. In the unlikely event that I'm understanding how this stuff works correctly, can I theoretically just create a replacement DLL that in its DllGetClassObject substitutes another method and returns the result of the all get class object function from the original DLL?

Edit: oh I see. This won't work because only the methods exposed through com interfaces go through virtual function tables. Hmm. I guess this is getting to the point where I would need to know assembly to start messing around with it.

You can use Microsoft detours to do this. See "http://www.codeproject.com/Articles/30140/API-Hooking-with-MS-Detours" - it's possible to detour arbitrary functions if you know the address of the function.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

mystes posted:

Thanks. This is exactly what I need.

I was able to figure out the address of the function by mucking around in IDA Pro and comparing the dll with another dll I compiled with debugging symbols from source that I know the first DLL is based on. Now I just need to make sense of the examples for hooking C++ member functions. It's annoyingly a bit more complicated than C functions, but I think I'll be able to figure it out.

Unfortunately, I've realized I don't actually understand how computers/compilers actually work at all. This is probably an embarrassingly dumb question, but here it goes: I want to open a file when the DLL I create is loaded and I hook the function. Then I want to write to the file when my replacement function is called. But how can I give the file handle to my replacement function? Can I just use a global variable? Will this actually be accessible from within the replacement function?

(Are global variables just assigned a specific memory address rather than being on the stack?)

I mean you could just declare a global file handle and pass it, but you're cruising for a bad time trying to do file IO in a trampoline function. Like if you don't know what you're doing, just use ::outputdebugstring function whenever you need to log and run dbgview.exe to collect the logs if you need it.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Sedro posted:

People are moving away from JQuery.

It''s mainly a compatibility shim for older browsers, which is not so relevant any more as the everyone drops support for IE6/7/8. Also modern tools like react offer much better solutions to DOM manipulation.

There are some anti-jquery movements even:
http://vanilla-js.com/
http://youmightnotneedjquery.com/

Also, the JQuery event handling library is bullshit.
a) Whenever a jquery event fires, it normalizes it (as back in the old days, properties for events were not common between browsers, so jquery tries to make the properties consistent.) The code that does this is slow as gently caress.
b) JQuery has to track the event handlers in its own internal event handler cache - so an event fires, it's raised in JQuery object itself rather than execution context where the event was defined. This is infuriating to read in the memory profiler, and also has other consequences - like, in vanilla js, if you define an event handler on a div, and remove the div, it goes away, but in JQuery, the event handler lives on in the event handler cache.
c) The only thing that you can't easily do in vanilla JS that you can do in JQuery is event delegation (e.g. bind an event to fire on a selector.) However, just adding the event to whatever element you would want is actually a problem because vanilla JS event handling isn't garbage slow.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Fancy Corndog posted:

Not really a technical question, but here goes:

I've been shopping around for a new junior .NET role, it will be my second professional programming job and I've got about 1.5 years of experience right now. I got an offer, and it comes with a substantial raise.

I haven't pulled the trigger yet because something feels slightly off to me. I don't know how to explain it other than to say that I didn't walk into their office and feel like, "This is right." I'm not sure if this is because I've become so comfortable at my current job and the thought of change makes me uneasy, or if there are some intangible qualities about the company that are causing it. It's worth mentioning that I did make a visit to two other companies, and one of them did feel "right" but unfortunately I did not get an offer.

My questions, without adding too many more details, are whether or not these feelings are normal and whether or not I should base decisions off of them. Can anyone with more experience switching employers weigh in for me? I'm wondering if I may be aiming too high right now, and if I should focus more on taking the right step than worrying about finding a perfect environment for the long-term.

I feel like any place that hires for .NET has a higher-than-average chance of being a weird hellhole. I like visual studio and TFS and C# and .NET and think they're great tools, but it's really easy to find companies that were dumb enough to be Microsoft shops back when people were writing desktop apps in C++ using MFC and just kept buying whatever microsoft releases, and then you end up working with a bunch of old people who don't know what the internet is. That said, what's the worst that can happen, another 20k raise in a year and a half?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

baby puzzle posted:

This is kinda a programming question. I'm wondering how to handle this build process.

I have a lot of wav files that I want to convert to ogg. Using some kind of build system seems appropriate, because I want to be able to do an incremental build and save a lot of time.

But which one should I use? There are so many, and they all seem so terrible. I'm on Windows 10 and using Visual Studio for my code. We used jam at my old job and it was incomprehensible to me.

I want to basically say: for each wav in these folders (recursive of course), create an ogg in the corresponding target folder, if the ogg file doesn't exist or is out of date. Also, delete any oggs that don't correspond to a wav (in case I delete a wav). So obviously I need to be able to create my own rules for the build (for the wav to ogg conversion).

Also there are other miscellaneous asset files that I just want to automate copying over to the proper destinations. I just want to automate the whole process of building the non-executable part of my program.

I could do this in C++ because that's what I am familiar with.. but that doesn't seem like the right tool for this job.

Make a batch file that does this and have visual studio call it as a post-build event https://msdn.microsoft.com/en-us/library/h7dhf0ty.aspx.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Doghouse posted:

Anyone have any opinions on mongodb? I've been learning it for a personal side project and it seems awesome in some ways, but there seems to be a sentiment around the internet that it's awful.

I used mongo in a toy project once. There is/was a bug where if you use a 32-bit mongo, the database is limited to 2gb in size (for "code simplicity"). You know what happens when the database reaches 2gb? It just motherfucking stopped like... storing more data. You'd execute the commands to store your data... but it wouldn't come back later, no exception, no logged error.

Apparently it keeps the whole database in RAM and since there's a 2gb address space limit on windows....

Like why loving make a 32-bit version at all if it can't have a database bigger than 2gb?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Honest Thief posted:

I worked at a place one time where the dev lead wanted me to implement a reverse proxy for a specific use that to this day confounds me, he basically wanted people to access Z through Y, so simple enough that's a reverse proxy, people go to Y and are actually going to Z! Seems simple..
Only Z hosted an api and it used a CSRF token solution to avoid attacks, so this meant that the client should send a forgery token that was returned by Z.. only the client doesn't know it was accessing Z, so it never sent the token back for refreshing and it's not like the proxy at Y could figure out on its own how to do it. So what was the solution in this case? Have the cross site request forgery being handled by the proxy?!

Yeah, we ran into the same problem (except with oauth) and had to implement it in the reverse proxy itself.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
Generally I like to go with testing the public api instead of private functions, but one thing you can do is break up the complicated private functions into static methods - static methods are the easiest thing in the world to test.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Caganer posted:

Is there an easy way to convert an image from png to gif?

With google images dropping "view image" I had a hacky idea:

Take screenshot

Run a script that converts most recent screenshot from png (usually huge for anything photographic) to a high quality jpg (like a 9 on the photoshop slider)

is this possible in say, python?

download imagemagick, just do

code:
magick convert rose.png rose.jpg
efb

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

strange posted:

If I want to render SPA DOM code on the server am I stuck with a something running on Node? Can I get any of the big front-end frameworks to hook into my server-rendered DOM + state object?

i'm almost inclined to say that if you want to render SPA on the server, you could like, consider not making an SPA. SPA is a specific technical term meaning "bloated website that uses a twenty megabyte of js framework to solve the challenging technical problem of making it so if the data in your model changes, your view should also update."

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

CzarChasm posted:

Cross Posting from Stupid Questions thread
I'm trying to build a form that will import data in several variables and give them proper case. So for example JANE SMITH run through this code will change to Jane Smith. Likewise, jane smith becomes properly capitalized.

print @str.substring($customer.firstname,0,1);
print @str.substring(@str.tolower($customer.firstname),1) & " ";
print @str.substring($customer.lastname,0,1);
print @str.substring(@str.tolower($customer.lastname),1);

This works fine. I'm trying to do the same thing for addresses, and those are stored as 123 fake st and I want them to be 123 Fake St
The problem is I don't know how long the numerical part of the address is, so I can't just say skip the first three characters, plus a space, and then capitalize like above.

So, what I was thinking was to make a loop that would stop at each space and effectively break the line into however many parts the street address is, and then capitalize the first character in each part. But again, I don't recognize this language and I did not find any examples of doing what I want.

What you're looking for in general called a regular expression (regex). In javascript, doing something like:

code:
function camelize(str) {
  return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
    if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
    return index == 0 ? match.toLowerCase() : match.toUpperCase();
  });
}
Would go through the string and make the first letter uppercase.

Unfortunately, I don't recognize the language in the file, either. The string concatenation operator is &, which is strange. Do you have more context clues about the language (like, a filename extension)? Also, is the text of the script exactly as in the original file?

My best guess from looking at http://rigaux.org/language-study/syntax-across-languages.html#StrngStrnCnct is that it might be awk, based on the names of the methods and sigils present in the variable names. In that case, this might work: https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Carecat posted:

As someone who has an intermediate understanding of C# , which textbook would be good for web development? I'm going through the W3 schools material at the moment.

"Learning PHP, MySQL & JavaScript" sounded like what I'm after but the reviews are about 3/5 for some bad practices and hit or miss on what it focuses on or doesn't cover enough.

Php, mysql and w3 schools are all trash and javascript is a necessary evil. You want to pick up something about asp.net mvc .net core, something about typescript, and something about react.

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