• 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

cyborg009

Banned
I just use Sublime Text, works for me.

I use it too but I guess what I really meant to say is how do I make my website look it was made in 2004.

edit: Also if you want I can send you what I did for my class assignments to look at and give me pointers.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
So is dreamweaver the best tool to use while making a website? Also should I get android studio I've used IntelliJ last year and liked it. I want to finish some old projects this semester break.

I use it too but I guess what I really meant to say is how do I make my website look it was made in 2004.

To your first question, yes if you are interested in Android dev you should at least try out Android Studio and see if it works for you.

For the second question, you should look into CSS frameworks and CSS preprocessors. Front end dev has come a long way and you can make a very nice looking website without relying on tools like Dreamweaver.

There are tons of frameworks out there, but Bootstrap and Foundation are probably the most popular. You can use something like Flat UI or Pure if you are looking for a certain style as well.
Preprocessors are very useful now. These include things like SASS and LESS.

All this can be done through Sublime Text, or my new favorite, WebStorm.
Android Studio has no business using 1GB+ of memory, god damn.

edit: 20 mins to start the emulator, lol. It'd be faster to buy a phone at the local mall.

Do you have the Intel x86 Emulator Accelerator installed through the SDK Manager?
edit: Just tested and my emulator boots an app in 32 seconds. There must be some settings wrong with your's, or your computer is just slow with the emulator.
 

NotBacon

Member
It's just bits of information that the program reads

Code:
Monarch
M141
16
6
10.5
10.5
20
20
20
30

Princess
P103
18
5
40
45
45
60
80

Empire
E77
24
7
20
20
20
20
20
20
50

Crown
C110
14
10
10
15
15
15
15
16.3
16.3
15
30
32

Bootle
B2618
4
1
9

Try adding a
Code:
inFile.nextLine();
after your for-loop. It's probably reading the empty line as the next ship name and throwing off your inputs.

While you're at it, change your inFile.next() calls to inFile.nextLine() also. next() only reads until white space, nextLine() will read the whole line.
 

nOoblet16

Member
Try adding a
Code:
inFile.nextLine();
after your for-loop. It's probably reading the empty line as the next ship name and throwing off your inputs.

While you're at it, change your inFile.next() calls to inFile.nextLine() also. next() only reads until white space, nextLine() will read the whole line.

Nope that didn't work
 

Sharp

Member
PSA: Everyone who sees this, please watch this video on linearizability by Kyle Kingsbury.

Seriously one of the best technology related videos I've ever seen (and I usually hate technology videos). It explains exactly what the CAP theorem means, how modern distributed systems (including microprocessors in a concurrent environment) work, what you can do about it, how to measure it... and then he actually goes ahead and shows how and why many existing distributed systems fail. And he concludes by telling you how to test it yourself. As a side bonus, he also shows how to use functional programming for massive performance wins. Again, everyone who has some interest (professional or otherwise) in computing should watch this video.

Kyle is also known as aphyr, of Jepsen fame. Jepsen is the project he discusses in the video--an ongoing effort to hold database providers accountable for their marketing claims. It's an amazing series and, again, I really think everyone who works with computers should at least read a few of the articles there.

If you've watched / read the above and are interested in the state of the art, I recommend reading two recent papers by Peter Bailis. In the first paper, Scalable Atomic Visibility with RAMP Transactions, he develops a new technique that allows linearly scalable, partition tolerant foreign keys, secondary indexes, and materialized views. In the second paper, summarized in this blog post, he develops a formal definition for determining which constraints require synchronization, then uses these techniques to smash the old record for TPC-C performance by a factor of 25 (this is kind of a big deal--TPC-C is the gold standard for measuring transactional performance for relational databases).

I am really excited for this stuff and want to make sure as many people see it as possible. The first requirement for writing great software is knowing what's already out there.
 
MSSQL's database diagram designer itself is broken garbage. Does anybody have any good recommendations for generating database diagrams from a MSSQL server? Schema already exists, just need something that will make pretty pictures quickly and easily.
 
Ok this is a simple java code and I really should have no trouble with it but I don't know why the scanner is giving me a token mismatch error. Any takers? :p

Code:
			for (int i = l; i <= s; i++); {  // HERE IS THE PROBLEM ; THAT IS WRONG
				rate = inFile.nextFloat();
				totalwages = (totalwages + (rate * l));
			}

Yatta!!
 
Well, I put together a lookup table and it worked ok. I'm sure I could have done better, but it was a small improvement.

What was your previous method? I read a little bit about this sort of thing last weekend and from my limited knowledge, what you want is probably either the Box-Muller transform or the Ziggurat algorithm, both are algorithms for generating samples from a standard normal distribution. (given a source of uniformly distributed pseudo-random numbers) The Ziggurat algorithm is faster bet seems more difficult to implement and statistical methods are always tricky to implement (and especially test) correctly.

edit: Nevermind, those are not approximations, since they sample the actual function to the maximum accuracy that a floating point number allows, so maybe that's not quite what you're looking for.
 

Chris R

Member
MSSQL's database diagram designer itself is broken garbage. Does anybody have any good recommendations for generating database diagrams from a MSSQL server? Schema already exists, just need something that will make pretty pictures quickly and easily.

Visual Studio? Assuming all PK/FK/Relationship stuff is setup you just connect to the database and drag stuff over and it automatically places things in a very UML looking design.
 
Created an interesting program for my image processing class' final project. The idea is that it creates a water reflection effect on the input image.

I used a warp that alternates between sine and cosine for every 15 pixel rows. Then applied a gaussian blur and tonemap to the lower half. (I also applied these to the last 5 pixels of the top half to make it more seamless)

It had a strange bug for the first few rows that grabbed pixels from the wrong side, but the warping formula was pretty rough and I didn't feel like perfecting after spending 30+ hours on group projects this week.

I thought it was pretty neat :)

RWQ8zrV.jpg
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Created an interesting program for my image processing class' final project. The idea is that it creates a water reflection effect on the input image.

I used a warp that alternates between sine and cosine for every 15 pixel rows. Then applied a gaussian blur and tonemap to the lower half. (I also applied these to the last 5 pixels of the top half to make it more seamless)

It had a strange bug for the first few rows that grabbed pixels from the wrong side, but the warping formula was pretty rough and I didn't feel like perfecting after spending 30+ hours on group projects this week.

I thought it was pretty neat :)

What language?
Do you mind sharing it on GitHub?
 

RELAYER

Banned
How can I control two LEDs with one command without using BusOut?

For example, we're making a game and keeping count of score with LEDs.

There are two LEDs for each player, and so a maximum of two points.

I set up a BusOut function that controls two pins for each player, and defined a function that sends binary 0 - 3 (00, 01, 11) when the count goes up to make the proper amount of LEDs.

However we are doing this without the predefined library functions and using direct register access, so I don't know how to do this without BusOut object, or at least, don't know how to define a BusOut object using the registers.

Any ideas?

My professor said something in class about how using BusOut in this case would be overkill, but I don't know any other way of doing it.


edit: hmm nvm, I think I figured it out.

It's actually easier using the registers directly because I can just send a 1 to the individual bit I need to control.
 
Created an interesting program for my image processing class' final project. The idea is that it creates a water reflection effect on the input image.

I used a warp that alternates between sine and cosine for every 15 pixel rows. Then applied a gaussian blur and tonemap to the lower half. (I also applied these to the last 5 pixels of the top half to make it more seamless)

It had a strange bug for the first few rows that grabbed pixels from the wrong side, but the warping formula was pretty rough and I didn't feel like perfecting after spending 30+ hours on group projects this week.

I thought it was pretty neat :)

RWQ8zrV.jpg

Amazing. Post the source code here if you can
 

squidyj

Member
so I have a _vector template, and then a vector and a swizzle template that inherit from _vector for the purposes of allowing me to write one set of function definitions. To that end I have a virtual operator defined in the base class (pure virtual).

My issue is that I have just realized this inheritance model is incurring an additional 4 bytes of storage on my base vectors and are causing my swizzles to require more than 0 bytes of memory as well...

Is there any way for me to sidestep these issues without being forced to define functions for every combination of vector and swizzle?
 

Kyuur

Member
Was wondering if anybody can help me get some clarity on using make_shared vs not with shared and weak pointers (C++). I understand that make_shared only allocates one block (for the object and the reference counter) versus two if you pass a pointer via new or whatever.

My concern is with letting weak_ptr live on after the last shared_ptr to an object is destroyed. For example:

Code:
std::weak_ptr<someClass> wp;

void MakeSharedFunction()
{
	//This is the only shared pointer to this instance
	auto sp = std::make_shared<someClass>();

	wp = sp;
} //Shared pointer destroyed, but memory for instance remains due to weak pointer still needing reference

void NewFunction()
{
	//This is the only shared pointer to this instance
	std::shared_ptr<someClass> sp(new someClass());

	wp = sp;
} //Shared pointer destroyed and with it, the allocation for the instance of someClass. The (small) allocation for reference remains until wp is removed

Is this understanding correct? From my readings it seems make_shared is generally preferred, but in the situation where you have multiple weak_ptr and you are not sure when they will be destroyed it seems like passing an initial raw pointer would be preferred.
 

Godslay

Banned
MSSQL's database diagram designer itself is broken garbage. Does anybody have any good recommendations for generating database diagrams from a MSSQL server? Schema already exists, just need something that will make pretty pictures quickly and easily.

If you are using Visual Studio just make a empty project that can be deleted later, if you only want the diagram.

Create a C# class library, and add a ADO.Net Entity Datamodel, generating from the database. Put in all the information regarding the connection to the database, and import your tables. You'll end up with a database diagram that looks like this. You don't have to use the classes it creates, it just looks a little better than what SSMS creates.

You'll end up with something like this. Doesn't look too bad considering it's just quick and dirty using what Visual Studio gives you.

B6QehJa.jpg
 

Water

Member
Was wondering if anybody can help me get some clarity on using make_shared vs not with shared and weak pointers (C++).
...
Is this understanding correct? From my readings it seems make_shared is generally preferred, but in the situation where you have multiple weak_ptr and you are not sure when they will be destroyed it seems like passing an initial raw pointer would be preferred.
As far as I can tell, your understanding is correct. The allocation for the shared_ptr control block will stay around no matter what, but if you use make_shared or allocate_shared, the existence of weak_ptrs will prevent the allocation for the actual object from being released. Using shared_ptr without make_shared performs worse and spends more memory in the first place, though, so it should rarely be the better option in practice.
 

r1chard

Member
PSA: Everyone who sees this, please watch this video on linearizability by Kyle Kingsbury.

Seriously one of the best technology related videos I've ever seen (and I usually hate technology videos).
Sorry, but I tried, and 15 minutes in I felt he'd lost me enough times to give up. I think I missed his "concurrency 101" talk maybe? Too many assumed unexplained concepts and acronyms. Diagrams full of acronyms with effecively "see, this is the problem!"
 

RustyO

Member
C# PropertyGrid Using Nested Classes

I've been going round in circles on this one for a bit, and am struggling to find much information / tutorials on manipulating the default PropertyGrid to show nested classes as a flat structure.

I have a couple of classes, Foo and Bar, and have no problem getting the nested classes to display, be editable etc by using
Code:
[TypeConverter(typeof(ExpandableObjectConverter))]

Basically what I have at the moment is this. Where the nested class is displayed and needs to be expanded:

0Ul9l.png


And what I would like is to display both the parent class, and its nested class in a "flat" structure (i.e. without having to expand the Bar class) As far as I understand I would need to write a custom TypeConverter, but am struggling with getting that going and being able to read/write the values, e.g. my current attempt is like such:

aR7LK.png


Foo Class

Code:
[Serializable()]
public class Foo
{
    private string m_Code;
    private Bar m_Bar = new Bar();

    [DisplayName("Code")]
    [Description("The Code of Foo")]
    public string Code
    {
        get { return m_Code; }
        set { m_Code = value; }
    }

    public Bar Bar
    {
        get { return m_Bar; }
        set { m_Bar = value; }
    }
}

Bar class with my attempt at a custom TypeConverter.

Note: I have tried overriding the default ConvertFrom method as well, code is on another machine, will update later..

Code:
[TypeConverter(typeof(BarConverter))]
[Serializable()]
public class Bar
{
    private string m_Name;

    [DisplayName("Name")]
    [Description("The Name of Bar")]
    public string Name
    {
        get { return m_Name; }
        set { m_Name = value; }
    }
}

public class BarConverter : TypeConverter
{
    public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
    {
        Bar _Bar = (Bar)value;
        return _Bar.Name;
    }

}


Naturally the classes are a lot more complicated then just Foo and Bar; Parent class my have a dozen child classes, and of course have a varity of string, ints, bools, enums etc.

Is there a fairly simple / easy way of doing this?

This is just for me / not for distribution. So whilst I would prefer a "flat" scenario, I can live with having the expanded classes scenario, especailly if it requires a massive amount of work to create twenty or so custom TypeConverters.
 
What compiler and compiler options are you using? Using gcc 4.8.3 with the following console command, it works with that header.
Code:
g++ --std=c++11 -Wall -o main main.cpp

Most of your errors are telling you you're using C++11 features which means you're trying to compile to the C++98 standard. Like closer to the edge said, use the 'std=c++11' flag when compiling with gcc as it defaults to 'std=c++98'.

The C++11 compiler messages are only warnings, which makes me think he has -Wextra on, but is still compiling with C++11 support. The only compiler error is in the randint function. The gcc version that ships with Mac OS is pretty ancient IIRC, so I'd guess that's why it's not compiling.
First of all, thanks for helping me to understand the error. It is marked, but I do not know how to fix it. If I assume correctly, I should force the compiler using C++11 features when compiling the source code in terminal.

On the other hand, I am a lazy guy and kind of want to compile the files with pressing on cmd+r in xCode or Textmate. Any idea how to fix it there?
 

Ominym

Banned
I hate to be a bother. But is there a thread to ask questions pertaining to programming? I tried searching but didn't exactly find one. I have a real soft-ball question (just starting out) and wanted to get some help.
 

Ominym

Banned
Hooray, glad I found this then. So, in brief I'm attempting to do a simple geo-location based Layar for a project. I've gotten as far as setting up a database with phpMyAdmin and I've got a server running.

Now my strife comes from attempting to figure out this PHP thing. So, the tutorial gives some sample code I assume that I could use to get a basic geo-Layar up and running. But this is where I get stuck.

1) I'm having issues figuring out exactly which parts I'm supposed to edit. I've been attempting to follow the guide to a T, but it doesn't seem to come out quite right.
2) I'm uncertain how to upload PHP files to my local server. I've looked at a bunch of guides, but everything seems to be how to upload pictures. I'm probably drastically over thinking this portion and there's got to be an easier way.

I apologize for asking here, I've been working on this a bit for a while now and I've exhausted every resource I could find. It's surprisingly sparse for geo-Layar stuff.
 

cyborg009

Banned
Eh, these days it's pretty simple. Bootstrap, decent color choice, decent header image, and decent logo is enough.
It also ensures the site looks nice on all devices too.

To your first question, yes if you are interested in Android dev you should at least try out Android Studio and see if it works for you.

For the second question, you should look into CSS frameworks and CSS preprocessors. Front end dev has come a long way and you can make a very nice looking website without relying on tools like Dreamweaver.

There are tons of frameworks out there, but Bootstrap and Foundation are probably the most popular. You can use something like Flat UI or Pure if you are looking for a certain style as well.
Preprocessors are very useful now. These include things like SASS and LESS.

All this can be done through Sublime Text, or my new favorite, WebStorm.


Do you have the Intel x86 Emulator Accelerator installed through the SDK Manager?
edit: Just tested and my emulator boots an app in 32 seconds. There must be some settings wrong with your's, or your computer is just slow with the emulator.


Thanks guys! since my classes end this week I'll be able to finally be able to take a look at this. Also I tried out Android studio and its pretty amazing i haven't programmed in Android for a little over a year but so much has changed.

edit: Also hear about SASS so I'm going take a look at that too.
 

squidyj

Member
My mind is full of fuck right now.
I was under the impression that using templates, typename and class literally mean the same thing, yet

template<template<typename,int> typename T>
does not compile while

template<template<typename,int> class T>
compiles just fine. What sorcery is this?
 
You guys are throwing me off by using "C++98" when you mean "C++03".
My mind is full of fuck right now.
I was under the impression that using templates, typename and class literally mean the same thing, yet

template<template<typename,int> typename T>
does not compile while

template<template<typename,int> class T>
compiles just fine. What sorcery is this?
They don't mean the same thing at all.

class is like struct, in that it describes an object.
templates are evil. typename is syntactic magic used when doing dark template magic. Ok, this is not that helpful. Let me explain a bit more. Templates are like an entirely different programming language that gets run at compile time to generate more code that you will not see or interact with, unless you do it wrong in which case you will get to read a 500 line compiler error.

My advice to any C++ newcomer, but especially to myself 8 years ago, is to avoid templates (and the rest of the preprocessor) like the plague until you understand the rest of C++ forwards and backwards.

Templates will be useful once you do really know what you're doing, but there's so much other stuff you should learn first when writing C++. Like, the rest of C++.
 

squidyj

Member
You guys are throwing me off by using "C++98" when you mean "C++03".

They don't mean the same thing at all.

class is like struct, in that it describes an object.
templates are evil. typename is syntactic magic used when doing dark template magic. Ok, this is not that helpful. Let me explain a bit more. Templates are like an entirely different programming language that gets run at compile time to generate more code that you will not see or interact with, unless you do it wrong in which case you will get to read a 500 line compiler error.

My advice to any C++ newcomer, but especially to myself 8 years ago, is to avoid templates (and the rest of the preprocessor) like the plague until you understand the rest of C++ forwards and backwards.

Templates will be useful once you do really know what you're doing, but there's so much other stuff you should learn first when writing C++. Like, the rest of C++.

yes, I realize all this and also that class in a template and class in c++ are in fact two different ideas. It's just that in most use cases typename and class behave the same inside a template. template<class T> describes a primitive like an int just as easily as it does a proper class or struct.

Anyway it's not an issue and now I have the polymorphism I wanted without that blasted vtable pointer adding 4 bytes to every vector.

Edit: If I was using clang I wouldn't even have been an issue as allowing the use of typename in this context is proposed as part of C++1z and it's apparently already implemented in clang.
 

hateradio

The Most Dangerous Yes Man
Android Studio has no business using 1GB+ of memory, god damn.

edit: 20 mins to start the emulator, lol. It'd be faster to buy a phone at the local mall.
Do you have an Intel processor? You can use HAXM to run 32/64-bit Android versions in the emulator at a faster pace than ARM ones.

If you're also taking 20 minutes, I would suggest you use a lower end phone as the device.
 
A question from a person who has very limited programming experience (I coded a few websites in the early 2000's): How difficult would it be to develop a Chrome extension that does the following?

First, for context go here: http://tier2.iema.state.il.us/FOIAHazmatSearch/Default.aspx and enter "Chicago" in the city field and hit search. You'll get a page of 20 items, but 401 pages total.

I'd like to be able to display all 8000+ results on one page instead of having them broke up by 20. Additionally, if possible, I'd like to export that to an Excel document.

I tried to do some Googling, but I had no idea where to begin that search.

Am I in over my head, or could this be a weekend project?
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
A question from a person who has very limited programming experience (I coded a few websites in the early 2000's): How difficult would it be to develop a Chrome extension that does the following?

First, for context go here: http://tier2.iema.state.il.us/FOIAHazmatSearch/Default.aspx and enter "Chicago" in the city field and hit search. You'll get a page of 20 items, but 401 pages total.

I'd like to be able to display all 8000+ results on one page instead of having them broke up by 20. Additionally, if possible, I'd like to export that to an Excel document.

I tried to do some Googling, but I had no idea where to begin that search.

Am I in over my head, or could this be a weekend project?

You're in over your head, but with some research you could eventually get it done.

It would require you to learn how to connect to a database and query it, how to write a Chrome extension, how to interact with the data you receive from the database, how to display that data, and how to export that data to an Excel friendly document.

Off the top of my head I would assume it would involve Javascript + HTML + whatever database language language the information is using. (probably a form of SQL)
 
You're in over your head, but with some research you could eventually get it done.

It would require you to learn how to connect to a database and query it, how to write a Chrome extension, how to interact with the data you receive from the database, how to display that data, and how to export that data to an Excel friendly document.

Off the top of my head I would assume it would involve Javascript + HTML + whatever database language language the information is using. (probably a form of SQL)

I don't really see why you'd need a database for that. I can't access that page but I assume it's some sort of form that you have to fill out and then spits out some data, probably in a table. You probably can't query their database directly (unless they expose some public API which would make it easier). The issue I'm seeing is that the data is probably not completely contained one one page, you'd have to click through all of the pages to to get all the data and I'm not sure if you can do that with plain Javascript.

Personally I'd probably not use a Chrome extension to do this but some sort of web scraper, which is basically a library or a program that simulates a web browser and can collect data from a web page and process it in some form. You can read more about it here. The basic process would be to open the website, fill out the form, click the submit button and then collect the data from all of the pages into one long array of objects that you can then export into a CSV file to open it with Excel.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
I don't really see why you'd need a database for that. I can't access that page but I assume it's some sort of form that you have to fill out and then spits out some data, probably in a table. You probably can't query their database directly (unless they expose some public API which would make it easier). The issue I'm seeing is that the data is probably not completely contained one one page, you'd have to click through all of the pages to to get all the data and I'm not sure if you can do that with plain Javascript.

Personally I'd probably not use a Chrome extension to do this but some sort of web scraper, which is basically a library or a program that simulates a web browser and can collect data from a web page and process it in some form. You can read more about it here. The basic process would be to open the website, fill out the form, click the submit button and then collect the data from all of the pages into one long array of objects that you can then export into a CSV file to open it with Excel.

You're right. I was thinking about the process from the wrong way.
This advice would be better to follow, but I still feel this is fairly involved for a beginner weekend project.
 
Top Bottom