language-agnostic

Tutorial or Framework for a Very Simple Chatbot?

I've been doing some research into writing my own chatbot, and I've read quite a few posts on stackoverflow about them. However, none really seem to answer my somewhat basic question - is there a pre-built framework where I can simply type in something like "if user enters 'mother', respond with 'tell me more about your family'". My ques...

Algorithms for testing a poker hand for a straight draw (4 to a straight)?

Hi Folks, I'm in the throes of writing a poker evaluation library for fun and am looking to add the ability to test for draws (open ended, gutshot) for a given set of cards. Just wondering what the "state of the art" is for this? I'm trying to keep my memory footprint reasonable, so the idea of using a look up table doesn't sit well b...

which content magement system to use, if any

hi I am required to design a website where displaying content is the key functionality. This is a similar site, so you can imagine the amont of content. Of course the design depends on preferences. As i am planing the design I was thinking if such a website would require some kind of content management system (as I would imagine th...

Name for factoring out repeated code into separate function

I'm trying to find research/advice on a particular code refactoring pattern, but I'm finding it hard to locate, since I'm not sure whether there's a good name for it. It's very similar to factoring out repeated code, except the code wasn't repeated in the first place: it was just stashed away in a conditional branch of a larger function...

How are text editors generally implemented?

This question is probably going to make me sound pretty clueless. That's because I am. I'm just thinking, if I were hypothetically interested in designing my own text editor GUI control, widget, or whatever you want to call it (which I'm not), how would I even do it? The temptation to a novice such as myself would be to store the conte...

Wrapping my head around hardware representations of numbers: a hypothetical two's complement question

This is a super naive question (I know), but I think that it will make for a good jumping off point into considering how the basic instruction set of a CPU actually gets carried out: In a two's complement system, you cannot invert the sign of the most negative number that your implementation can represent. The theoretical reason for thi...

The type system in Scala is Turing complete. Proof? Example? Benefits?

There are claims that Scala's type system is Turing complete. My questions are: Is there a formal proof for this? How would a simple computation look like in the Scala type system? Is this of any benefit to Scala - the language? Is this making Scala more "powerful" in some way compared languages without a Turing complete type system? ...

Better pattern to handle nested code conditions?

I have a webpage that needs to selectively show or hide a substantial number of controls. Each control's visibility is determined based on which of 3 conditions are true. So, for example, given the conditions A, B, and C; Control1 needs to be visible only when A and B are true and C is false. Control2 needs to be visible only when B a...

Programatically rip text from a PDF File (by hand) - Missing some text

Sample PDF file that I cannot parse (2.6MB Zip File) Note: I am not interested in using a parsing library. This is for my own entertainment. I've been experimenting with ripping text out of PDF files for a search gizmo, but am unable to extract text from some pdf files. Note that this is a much easier problem than straight up parsing...

How do you describe new to a new CS student?

In OOP, there are entities (e.g. Person) which has attributes (e.g. name, address, etc) and it has methods. How do you describe new? Is it a method or just special token to bring an abstract entity to real one? ...

Pushing data changes vs. pulling data changes within an application.

Suppose you have an application that consists of two layers: A: A data layer that stores all the data loaded from a database or from a file B: A layer that shows the data in a nice user interface, e.g. a graphical report Now, data is changed in layer A. We have 2 approaches to make sure that the reports from layer B are correctly up...

How to design a unit test for generating a PDF document?

I'm late to the party with regards to using unit testing... trying to figure best practices and the such. My question is, given a class which is responsible for generating a PDF (or Doc/Html/Xml/etc.), how would I go about testing the final output file is correct? I figure a text based file (xml), I could just see if the strings match,...

Calculating geospatial distance with radians

I have a method in an API that takes a lat/long coordinate and will find other coordinates within a specified distance. That distance is in radians. All the math I do these days deals with accounting or maybe x,y coordinates for laying out UI elements, so I appreciate some help validating these numbers. Lets ignore people in buildin...

How do I move printing position up one line in terminal.

I'm already aware of using \b and \r to move back one character and to the beginning on the line respectively. But is there a way, (specifically in python,) to move the cursor position up 1 line? I'm trying to avoid using curses, but if this is the best option then so be it. ...

What is the single most ineffective thing you did for your programming skills?

I saw this question: http://stackoverflow.com/questions/76364/what-is-the-single-most-effective-thing-you-did-to-improve-your-programming-skill. I thought to myself, Yes I agree with a lot of it. but then I thought, what should I NOT do? what of the things you did turn out to be just a waste of time, or worse, take your skills to a wrong...

Book for type systems

Is there any book which explains type systems in programming languages? If it has mathematical account of type systems,that is much preferred. ...

Approaching porting a (Java) library (to Objective-C): Methodology?

I am an iOS developer and I found a great library that handles all kinds of astronomy related calculations for me. The problem is that it's written in Java. Although I have enough experience with languages close to Java, I can't run Java on iOS. I'd like to port it, but being that I've never ported anything before. Like I said, I don't ...

variable precision gui slider control

I'm looking for information of a ui slider control whos step size is influenced by the distance between the ui control, and the users mouse pointer. For example: You have a slider control which slides horizontally. It has a value range of 0 to 1000. It occupies about 100 pixels on the screen. So, when you slide the control using the mou...