• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Fersis

It is illegal to Tag Fish in Tag Fishing Sanctuaries by law 38.36 of the GAF Wildlife Act
I totally forgot about the programming thread and made a thread about an issue im having writing a websocket server on Python.

This is my server code (Example server)
Code:
import cherrypy
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
from ws4py.websocket import EchoWebSocket

cherrypy.config.update({'server.socket_port': 9090})
WebSocketPlugin(cherrypy.engine).subscribe()
cherrypy.tools.websocket = WebSocketTool()

class Root(object):
    @cherrypy.expose
    def index(self):
        return 'some HTML with a websocket javascript connection'

    @cherrypy.expose
    def ws(self):
        # you can access the class instance through
        handler = cherrypy.request.ws_handler

cherrypy.quickstart(Root(), '/', config={'/ws': {'tools.websocket.on': True,
                                                 'tools.websocket.handler_cls': EchoWebSocket}})

Now, when a client tries to connect i get this message and the connection is never made
Code:
127.0.0.1 - - [25/Aug/2013:13:39:05] "GET / HTTP/1.1" 200 48 "" "Mozilla/5.0 (Wi
ndows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/
537.36"

I also tried Tornado but i get a weird "Warning:Access.404" everytime the client tries to connect.
 

Gaaraz

Member
Hi guys,

PHP/jQuery/C# .NET developer here... rather jaded in my current job and really hoping to self teach and create a game or two

What platform/framework/language should I start off with? I'm happy to develop for any platform, but due to the app stores I am tempted to aim for the Android/iOS markets...

Thanks!
 

Tamanon

Banned
I totally forgot about the programming thread and made a thread about an issue im having writing a websocket server on Python.

This is my server code (Example server)
Code:
import cherrypy
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
from ws4py.websocket import EchoWebSocket

cherrypy.config.update({'server.socket_port': 9090})
WebSocketPlugin(cherrypy.engine).subscribe()
cherrypy.tools.websocket = WebSocketTool()

class Root(object):
    @cherrypy.expose
    def index(self):
        return 'some HTML with a websocket javascript connection'

    @cherrypy.expose
    def ws(self):
        # you can access the class instance through
        handler = cherrypy.request.ws_handler

cherrypy.quickstart(Root(), '/', config={'/ws': {'tools.websocket.on': True,
                                                 'tools.websocket.handler_cls': EchoWebSocket}})

Now, when a client tries to connect i get this message and the connection is never made
Code:
127.0.0.1 - - [25/Aug/2013:13:39:05] "GET / HTTP/1.1" 200 48 "" "Mozilla/5.0 (Wi
ndows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/
537.36"

I also tried Tornado but i get a weird "Warning:Access.404" everytime the client tries to connect.

This might seem silly, but are you appending the 9090 to the IP address when entering in the browser? So 127.0.0.1:9090 ?
 
Hi guys,

PHP/jQuery/C# .NET developer here... rather jaded in my current job and really hoping to self teach and create a game or two

What platform/framework/language should I start off with? I'm happy to develop for any platform, but due to the app stores I am tempted to aim for the Android/iOS markets...

Thanks!

I'm currently learning Monogame, which is an open source implementation of XNA. Microsoft has stopped supporting XNA, but Monogame I believe is going to become even better than XNA ever was. It has support for Android, iOS, PS mobile, and many others. There are plans to support Xbone and PS4. From what I read, all the documentation, tutorials, code, etc. for XNA is 99.9% applicable to Monogame.

Also, Cocos-2dxna is a port of the widely used Cocos-2d framework. And from my research learning XNA/Monogame will help you if you ever decide to transition to Unity.
 

Fersis

It is illegal to Tag Fish in Tag Fishing Sanctuaries by law 38.36 of the GAF Wildlife Act
BTW i fixed my websocket server issue, (Tornado) i was using a tcp socket handler instead of a websocket handler.

SOWWY!!!!
 
I'm going through some project euler challenges and one of them (#26) is asking for the value that has longest recurring decimal cycle with 1/d being the format and d < 1000 (E.X. 1/3 is 1 with 0.6666 and 1/7 is 6 with 0.142857). I'm assuming the longest it can be is 8 since doubles are precise only to 16 digits but the implementation is tripping me up.

For C++ how would one go about combing through the decimal for repetition without putting the answer in a string and using various string techniques? My knowledge is pretty limited of various library functions and my google search skills are failing me :/
 

Slavik81

Member
I'm going through some project euler challenges and one of them (#26) is asking for the value that has longest recurring decimal cycle with 1/d being the format and d < 1000 (E.X. 1/3 is 1 with 0.6666 and 1/7 is 6 with 0.142857). I'm assuming the longest it can be is 8 since doubles are precise only to 16 digits but the implementation is tripping me up.

For C++ how would one go about combing through the decimal for repetition without putting the answer in a string and using various string techniques? My knowledge is pretty limited of various library functions and my google search skills are failing me :/

If you use floating point for this, you're going to have a bad time. I don't know if you'd actually run into problems with d<1000, but the fact that floating point numbers are often imprecise could really bite you. Also, I wouldn't assume that double precision is enough unless you could mathematically prove it was.

Do one or two examples by hand, in base 10, like a school boy. Then write a program that does the steps you did. Then modify the program to do each number between 1 and 999.


EDIT: Actually, maybe I'm being dumb... I've not sat down to really think carefully about it, but these values probably can be exactly represented by floating point. Still... In the end, I think you need to do the change of base before the analysis, which as far as I know is not much easier than the division itself.

In short... comparing strings might actually be reasonably efficient. At the very least, it's probably 'good enough'. Though, I'm still not entirely certain your assumption that it will be <8 holds true.
 

tokkun

Member
For C++ how would one go about combing through the decimal for repetition without putting the answer in a string and using various string techniques? My knowledge is pretty limited of various library functions and my google search skills are failing me :/

If you wanted to check if a subnormal double had a cycle of 8 you could do something like this, without needing any special library functions:

Code:
double my_val = <value you want to check>

// Multiply it by 10^16, this is equivalent to a 16 digit decimal left shift.
my_val *= 10e+16;

// Cast it to a 64-bit integer, truncating it.
uint64_t transformed_val = static_cast<uint64_t>(my_val);

//  Separate the decimal digits.
uint64_t upper_8_digits = transformed_val / (10e+8);
uint64_t lower_8_digits = transformed_val % (10e+8);
bool has_8_digit_cycle = (upper_8_digits == lower_8_digits);

There may be some subtlety with the rounding for some decimal representations to deal with, not addressed here.
 
Hey guys, thanks for the answers! I looked at what both of you guys did but I went with Slavik81's idea....doing it by hand. In the end I just did this:
Code:
for(i = 0; i < 30; i++)
	{
		temp = dividend / divisor;
		remainder = dividend % divisor;
		if(i > 0)
		{
			answer[i - 1] = temp;
		}
		dividend = (10 * remainder);
	}
Not the most sophisticated solution but it's a lot simpler than I was making it out to be and I get the results I want. Just set the array high enough and filter through its entries.
 

Bollocks

Member
Hi guys,

PHP/jQuery/C# .NET developer here... rather jaded in my current job and really hoping to self teach and create a game or two

What platform/framework/language should I start off with? I'm happy to develop for any platform, but due to the app stores I am tempted to aim for the Android/iOS markets...

Thanks!

Unity3D, free, really straight forward, C# and one click deploy to Android/iOS
 
MFW when make an elaborate and super secure user management system and client wants to include "some default accounts with simple passwords".

fj1ms.gif


edit: MFW I just got an invitation to a job interview

mpgBk.gif
Yluuv.gif
xSM17.gif
 

Kinitari

Black Canada Mafia
I have an idea for a NeoGAF focused chrome app - basically something that sends a notification when you get quoted, or your username is in a post. I might be getting good enough to make something like that. Might be.
 

usea

Member
I have an idea for a NeoGAF focused chrome app - basically something that sends a notification when you get quoted, or your username is in a post. I might be getting good enough to make something like that. Might be.
Where would the notification come from? What is scanning threads to get the information?
 

usea

Member
That's what I am trying to figure out how to implement actually.

This chrome extension was my inspiration, so I am sure it's possible - I just don't know how to do it.
In that scenario, the browser is the one that's loading the page and scanning for changes. So to get notified when you're quoted, your browser has to periodically load new posts in every thread you've posted in.

To get notified of posts that mention your name, your browser would have to periodically load every new post on the forum.

Every person who runs the extension has their browser loading every post on neogaf.

If you want to be a completionist, to capture mentions in edits of posts you'd have to load every post ever made on neogaf periodically.
 

Kinitari

Black Canada Mafia
In that scenario, the browser is the one that's loading the page and scanning for changes. So to get notified when you're quoted, your browser has to periodically load new posts in every thread you've posted in.

To get notified of posts that mention your name, your browser would have to periodically load every new post on the forum.

Every person who runs the extension has their browser loading every post on neogaf.

If you want to be a completionist, to capture mentions in edits of posts you'd have to load every post ever made on neogaf periodically.

I guess when you frame it like that, I can see how it could be a... strain. I think a light version could just be - every thread you post in (within a time frame, lets say a week), periodically (as in, once every few hours) checks for either a name mention or a quote. I do wonder how that might affect things if everyone has said app.
 
In that scenario, the browser is the one that's loading the page and scanning for changes. So to get notified when you're quoted, your browser has to periodically load new posts in every thread you've posted in.

To get notified of posts that mention your name, your browser would have to periodically load every new post on the forum.

Every person who runs the extension has their browser loading every post on neogaf.

If you want to be a completionist, to capture mentions in edits of posts you'd have to load every post ever made on neogaf periodically.

You could just use the search and search for either the username or [quote="Username like most people do and notify when the search page changes. Of course it's very easy to do manually too, which would make the notifier kinda moot
 

diaspora

Member
I'm looking into getting involved in Android app development. Should I learn Javascript first or just go balls-deep into Android programming tutorials?
 

Tamanon

Banned
I'm looking into getting involved in Android app development. Should I learn Javascript first or just go balls-deep into Android programming tutorials?

There's so much out there for learning Java that you should just dive into that. It's what Android apps are written in.
 
Yeah, Java is what I was referring to, just mixed up the names.

Just curious, you mentioned you are learning Java from MSDN. If that is the version of Java that I'm thinking I would strongly suggest you look for another resource. The official Java tutorials are much better that whatever you can find on MSDN.
 

Gaaraz

Member
Unity3D, free, really straight forward, C# and one click deploy to Android/iOS
This sounds absolutely perfect for me, thank you!

I'm currently learning Monogame, which is an open source implementation of XNA. Microsoft has stopped supporting XNA, but Monogame I believe is going to become even better than XNA ever was. It has support for Android, iOS, PS mobile, and many others. There are plans to support Xbone and PS4. From what I read, all the documentation, tutorials, code, etc. for XNA is 99.9% applicable to Monogame.

Also, Cocos-2dxna is a port of the widely used Cocos-2d framework. And from my research learning XNA/Monogame will help you if you ever decide to transition to Unity.
This sounds good too, thanks Lasthope, but I think it's maybe something I'll hopefully build myself up to when I have more of an idea of what I'm doing. Simple/straightforward/C# of Unity3D sounds great!

(edit) damn, Unity looks inane! Mightily impressive but I think I'd be way out of my depth, to be honest I think I'm better off maybe with something even simpler, ie a 2D puzzle game for my first venture?
 
Has anyone taken Interactive Python on Coursera? Is it any good/worth the time?

There is only one way to find out right? :p

I have taken both Udacity's CS101 and EdX 6.00x courses which also introduce programming with Python. I would say those two are very very good. Of the two, 6.00x feels like a real college class. The pace is unrelenting, it is rigorous and you will learn a lot about CS. A lot of people complain that 6.00x might be too hard, but I would argue that if you can successfully complete the course, you will have all the necessary skills to become a software engineer.
 
There is only one way to find out right? :p

I have taken both Udacity's CS101 and EdX 6.00x courses which also introduce programming with Python. I would say those two are very very good. Of the two, 6.00x feels like a real college class. The pace is unrelenting, it is rigorous and you will learn a lot about CS. A lot of people complain that 6.00x might be too hard, but I would argue that if you can successfully complete the course, you will have all the necessary skills to become a software engineer.

Good point. I'm already signed up for the class, but I thought I'd get opinions in case there is a better option.

I should have given some background. I'm a reasonably experienced programmer, but I haven't done much Python (Unity3D C# mostly at work and some classes in C++ lately). I was considering this class or just going through learn Python the hard way, but this seems a little more fun with the assignments being games.
 
Good point. I'm already signed up for the class, but I thought I'd get opinions in case there is a better option.

I should have given some background. I'm a reasonably experienced programmer, but I haven't done much Python (Unity3D C# mostly at work and some classes in C++ lately). I was considering this class or just going through learn Python the hard way, but this seems a little more fun with the assignments being games.

Gotcha. If you already have programming experience, you should be fine with just the official python tutorial. I also highly recommend the book Quick Python. Las year I was in the same boat as you. That's why signed up for the two classes I mentioned in my previous post, but I didn't really needed them after reading the tutorial. I took them because I was interested in how those two courses compared to the ones I took during undergrad.

Python The Hard Way is ok for beginners, but I feel you will find it pretty trivial.
 

phoenixyz

Member
Imo Python The Hard Way is a good place to learn Python as a programmer. Just skip the assignments which are too easy. You'll probably breeze through it in one sitting (or two "recreational" evenings) and have a pretty good understanding about Python.
 
Imo Python The Hard Way is a good place to learn Python as a programmer. Just skip the assignments which are too easy. You'll probably breeze through it in one sitting (or two "recreational" evenings) and have a pretty good understanding about Python.

This is what I did. I liked his explanations on objects in python, all of his later chapters are good to read through.
 

Soriku

Junior Member
OK I need some serious help...

I'm in school right now and I'm taking an intro to Computer Science class. We're working with C++ in Microsoft Visual Studio 2012. First day of class was two days ago and we just went over the basics and looked at some basic code for a program like Hello World and some Print Name program.

Now we have an assignment due next Tuesday, and I took a look at one of the parts of the assignment and it seems I have to code three things:

1. The end of the year holiday season is approaching, and you have to get gifts for various people. What are the inputs, what processing has to be done to generate the output: each gift recipient joyfully opens his or her gifts?

2. You are an instructor for a course that evaluates the students by means of 4 quizzes and 2 exams; each quiz is worth 10% of the grade, and each exam is worth 30% of the grade. Design an algorithm that produces final grades for each student in the course.

3. Now that you have the final grades for each student in the course, design an algorithms that computes the statistical mean and standard deviation of the set of final grades.

I look at #1 and...literally have no idea how to even start this. I remember taking a C++ class way back in 6th (!) grade and had no idea how to do anything and now I'm having the same problem. What am I supposed to do?

If I don't understand how to even do this I'll have to drop the class ASAP (before 9/4).
 

Nelo Ice

Banned
So I was planning on just taking the Coursera course "Learn to Program: the Fundamentals". But seems like I should try learning python the hard way? Either way I'm looking into trying programming since there's so many free options to learn it online. I'm currently stuck wondering wtf I should do for my career and seems programming is a good option. I've already changed my original major and am currently not in school since I wasn't sure if I was transferring or staying one more semester at my CC. So atm I'm just looking up various possible career options. If I find that I enjoy and understand programming then maybe I can further pursue it as an actual job.
 

Tamanon

Banned
OK I need some serious help...

I'm in school right now and I'm taking an intro to Computer Science class. We're working with C++ in Microsoft Visual Studio 2012. First day of class was two days ago and we just went over the basics and looked at some basic code for a program like Hello World and some Print Name program.

Now we have an assignment due next Tuesday, and I took a look at one of the parts of the assignment and it seems I have to code three things:



I look at #1 and...literally have no idea how to even start this. I remember taking a C++ class way back in 6th (!) grade and had no idea how to do anything and now I'm having the same problem. What am I supposed to do?

If I don't understand how to even do this I'll have to drop the class ASAP (before 9/4).

Are your sure you actually have to code this and not just write answers(especially the algorithm part). Basically, when the question asks what the inputs are, that's the data going in.It's a little weird question you wrote, but it might be something like the person's name, the gift they want, the cost, whatever. The processing is what you have to do to accomplish the goal. The output is what you will end up with after it's done.

Like(to take an example we had in the intro class). If I wanted to measure the average amount of rainfall for an area over a year, my inputs would be the months and the amount of rainfall. The processing would be adding the rainfall up and dividing by 12, and my output would be the answer(average per month).
 
OK I need some serious help...

I'm in school right now and I'm taking an intro to Computer Science class. We're working with C++ in Microsoft Visual Studio 2012. First day of class was two days ago and we just went over the basics and looked at some basic code for a program like Hello World and some Print Name program.

Now we have an assignment due next Tuesday, and I took a look at one of the parts of the assignment and it seems I have to code three things:



I look at #1 and...literally have no idea how to even start this. I remember taking a C++ class way back in 6th (!) grade and had no idea how to do anything and now I'm having the same problem. What am I supposed to do?

If I don't understand how to even do this I'll have to drop the class ASAP (before 9/4).

Number 1 is kind of vague so I wont comment on it.

Do you not know how to solve the problem or write the code?
 

Soriku

Junior Member
OK before the questions was this:

The method of problem analysis presented in this module can be used to design algorithms not all of which are programmable into a computer. In the following exercises use this method to design an algorithm to solve the problem.

So now I'm confused as to whether I have to program anything at all.
 

Tamanon

Banned
OK before the questions was this:



So now I'm confused as to whether I have to program anything at all.

Unless your instructor specifically told you to write it in C++ or pseudocode, this is your first bit that just gets you started on analyzing and solving problems.

Designing an algorithm means you basically write out what you would have to do to solve the problem.
 
OK before the questions was this:



So now I'm confused as to whether I have to program anything at all.

Sounds like more a pseudocode type question then.

For me inputs would be the person and what they got. The process would find the person form some sort of data structure check what gift they wanted and compare it to what they got. If they got what they wanted return a true and some print statement saying they are happy and if not false, they weren't happy.

Dont stress this too much. There is a lot of ways to do it.
 

Soriku

Junior Member
Alright, so...bear with me if I'm being dumb lol. So for #1...

Inputs:

Person A, Person B, Person C, Person D, Person E

Present A, Present B, Present C, Present D, Present E

If satisfied return true
If not satisfied return false

However is there a way to link the people and specific presents, or is the way I wrote this more general (anyone can get any one present)? I feel like I'm doing something wrong.
 
Gotcha. If you already have programming experience, you should be fine with just the official python tutorial. I also highly recommend the book Quick Python. Las year I was in the same boat as you. That's why signed up for the two classes I mentioned in my previous post, but I didn't really needed them after reading the tutorial. I took them because I was interested in how those two courses compared to the ones I took during undergrad.

Python The Hard Way is ok for beginners, but I feel you will find it pretty trivial.

Imo Python The Hard Way is a good place to learn Python as a programmer. Just skip the assignments which are too easy. You'll probably breeze through it in one sitting (or two "recreational" evenings) and have a pretty good understanding about Python.

Thanks, I might go through LPTHW before the course.
 

Tamanon

Banned
So, I'm diving back into my personal Python project and need a good database to hold questions and answers for various tests. I don't necessarily want to host it online as of yet, probably want to start locally. Any recommendations? I've got Microsoft SQL server and see there are various ways to connect it, but I might be able to get by with something simpler.

I'm looking to hold Questions(lot of text generally), Answers, Indicators of which answers are right(writing it so it can dynamically tell if it's multi-answer or not), Chapter number, Question number. I'll basically have it divided into multiple tables by Chapter/Subject.
 
So, I'm diving back into my personal Python project and need a good database to hold questions and answers for various tests. I don't necessarily want to host it online as of yet, probably want to start locally. Any recommendations? I've got Microsoft SQL server and see there are various ways to connect it, but I might be able to get by with something simpler.

SQLite is disk-based, lightweight and relatively simple:

http://docs.python.org/2/library/sqlite3.html

I've got a job interview in couple of hours, hopefully I won't blow it.
 

nan0

Member
I've got a question regarding CVs. I'm currently developing an Android App which is pretty much finished, but missing the final polish and thorough testing for publishing it to the Play Store. Would it be a good idea to put it into the "Projects" section of my CV regardless, and instead of an URL write something like "Prototype, demonstration possible"? So I could theoretically pull out my tablet in an interview and show the App and explain how I implemented certain things (possibly along with code). It's not for an actual interview at the moment, but I plan to apply for a full or part-time job in the next weeks/months.
 
I've got a question regarding CVs. I'm currently developing an Android App which is pretty much finished, but missing the final polish and thorough testing for publishing it to the Play Store. Would it be a good idea to put it into the "Projects" section of my CV regardless, and instead of an URL write something like "Prototype, demonstration possible"? So I could theoretically pull out my tablet in an interview and show the App and explain how I implemented certain things (possibly along with code). It's not for an actual interview at the moment, but I plan to apply for a full or part-time job in the next weeks/months.

Yeah, why not?

My interview went well... I think?
 
Top Bottom