What about an in-memory table that queries that timestamp every five minutes or so and you just count how many records it has on page load?
Or maybe just log all the timestamps to that in-memory table and prune it every five minutes of old entries. Though, you would need to check for duplicate user id's in that case so probably not worth it.
The dashboard that the Active User widget is going to be on, isn't the same server as the user system.
It's being done using AWS Simple Messaging Service, which is just a pub/sub thing.
My idea was that when the user "last activity" timestamp updates, i'd publish a new message. This message gets pushed out to the React Widget using websockets.
That, is the additional kicker to the whole thing. A lot of "simpler" implementations are native to the web app that they're for. This one isn't. It's more like an admin dashboard to monitor several systems.
And yeah, a lot of the ones i map out i find a lot of redundancy with.
It's being done using AWS Simple Messaging Service, which is just a pub/sub thing.
My idea was that when the user "last activity" timestamp updates, i'd publish a new message. This message gets pushed out to the React Widget using websockets.
That, is the additional kicker to the whole thing. A lot of "simpler" implementations are native to the web app that they're for. This one isn't. It's more like an admin dashboard to monitor several systems.
And yeah, a lot of the ones i map out i find a lot of redundancy with.
How would that stay accurate if there are already users logged in when the client first connects?
Maybe do a one time query for the first load of a session and the then have it update via the pub-sub method you mentioned? That's probably still too expensive for what you want, though.
Maybe do a one time query for the first load of a session and the then have it update via the pub-sub method you mentioned? That's probably still too expensive for what you want, though.
By Kibner Go To PostHow would that stay accurate if there are already users logged in when the client first connects?That's my thought plan at the moment.
Maybe do a one time query for the first load of a session and the then have it update via the pub-sub method you mentioned? That's probably still too expensive for what you want, though.
On load, run the query, but that's the only time it should run for that dashboard.
You'd probably want something like a push/sub system via websockets. As long as the user is "active" on the page, it'll keep them shown as logged on. What you're really looking for here is "presence", like any chat system has, no?
By reilo Go To PostYou'd probably want something like a push/sub system via websockets. As long as the user is "active" on the page, it'll keep them shown as logged on. What you're really looking for here is "presence", like any chat system has, no?I have pub sub coming from system1 already. System1 is the system i want to know how many users are active on. I'm currently using it to track error messages, and some transaction data.
That's simple. Those are singular events.
System2 is a dashboard monitor. It monitors a lot of systems. It has a few ReactJS elements already, that use websockets to subscribe to the published events.
The backbone of that, is done an working.
My Theoretical problem here is several fold
1. how to track a user is active
2. how to store that
3. how to publish that event
4. how to load from the database current active users
5. how to update and refresh that with out burdensome / heavy database queries.
1: easy, that timed variable. Every time a page loads, an event is fired, it checks a variable on the user object "lastTimeActive" and if that's more than 5 minutes old, it updates the variable.
2: if that variable is updated, update the database
3: if the variable is updated and the database, fire a message off to the pub/sub server
4. Don't think there's an easy way around it, a one time on load database query for every timestamp <5 minutes old.
5 ... the tricky part.
5 is the part I haven't fully mapped out yet. The only thing i can think of is maybe some sort of sorted set / map retained in a ReactJS element that updates when a message arrives about new activity. And has a 10 second internal refresh too (that gets restarted everytime it gets a message).
By reilo Go To PostI don't think you should emit that status from the database, imo.I don't either. But it's the best solution i can think of ... immediately.
You can't emit an event from the client to the back-end to make it aware of a user's presence? It would require zero database work and could be achieved via websockets directly.
By reilo Go To PostYou can't emit an event from the client to the back-end to make it aware of a user's presence? It would require zero database work and could be achieved via websockets directly.I can, and that's my intent once the React widget is loaded.
That doesn't let you know about users that were active before you loaded it though. Only after. The DB query is to load those that were active before you loaded it.
A lot (read, all) solutions for this i've seen online actually repeatedly call that query as their solution for constantly updating the status live. I think that's a terrible idea for live updates, running a super expensive DB query on all your users.
By reilo Go To PostWhat do you mean by "active before you loaded it"?If i load an active users widget, i want to know how many users are currently active. And while its being displayed, i want it to update with user counts showing fluctuations in activity.
If i only listen to the pub/sub then i'm only going to get users that have been active since i've loaded the widget. Not people that were already using the system.
Naw, with pub/sub you'd drop the user off after you've determined they have disconnected. Shit like that has been pretty reliably solved with most pub/sub messaging frameworks.
Learned a way to add data annotations to domain classes generated by Entity Framework's db-first or model-first designer. Involved creating buddy metadata classes and invoking them on the partial domain classes.
This was brought about because I needed to create an embedded database for the portable desktop app I mentioned earlier, choosing sqlite, finding out it doesn't support code-first creation of tables (requires sql strings to be executed instead), using a third-party provider to add support for code-first table creation, using model-first designer to generate model because co-worker isn't familiar with code-first, encounter issue with foreign keys for a 1-to-1 relationship creating an exception with sqlite (possibly caused by the third-party provider), and needing to use data annotations to solve the problem.
It works now, btw.
This was brought about because I needed to create an embedded database for the portable desktop app I mentioned earlier, choosing sqlite, finding out it doesn't support code-first creation of tables (requires sql strings to be executed instead), using a third-party provider to add support for code-first table creation, using model-first designer to generate model because co-worker isn't familiar with code-first, encounter issue with foreign keys for a 1-to-1 relationship creating an exception with sqlite (possibly caused by the third-party provider), and needing to use data annotations to solve the problem.
It works now, btw.
Uggh, winforms is bad and ugly.
TIL that Winform apps have a single UI thread and all UI work is done on that single thread. It's easy to make a Winform app do work asynchronously (using await/async, mostly), as long as you do not try to update the UI in that asynchronous thread. If you try to update the UI in a separate thread, the program will lock up.
However, there is a workaround that lets you make UI calls within a different thread without locking up the app. It requires the use of delegates and invocation on the UI thread. Below is some sample code that enables/disables form controls during a long running save operation. Not the most worthwhile scenario, but it works to illustrate the pattern. This is all C#, btw.
The InvokeRequired method checks to see if the thread that is making the method call is on the same thread as the control (i.e. the UI thread). If the thread making the method call is the same thread the control is on, then it sets the .Enabled property.
If not, this function uses the thread the control is on (again, the UI thread) to call the method again. It should now set the .Enabled property on this second time through.
I hate Winforms and I am spoiled by how relatively easy this is with web.
e: i fucked up by not having the EnableFormControls method in this example not being inside a function running on a separate thread. it's been a long day, ok?
TIL that Winform apps have a single UI thread and all UI work is done on that single thread. It's easy to make a Winform app do work asynchronously (using await/async, mostly), as long as you do not try to update the UI in that asynchronous thread. If you try to update the UI in a separate thread, the program will lock up.
However, there is a workaround that lets you make UI calls within a different thread without locking up the app. It requires the use of delegates and invocation on the UI thread. Below is some sample code that enables/disables form controls during a long running save operation. Not the most worthwhile scenario, but it works to illustrate the pattern. This is all C#, btw.
private System.Windows.Forms.Button saveButton;
private async void saveButton_ClickAsync(object sender, EventArgs e)
{
await Task.Run(() => { SomeLongRunningSaveOperation(); });
}
private void SomeLongRunningSaveOperation(){
EnableFormControls(false);
// long running code for saving goes here
EnableFormControls(true);
}
private void EnableFormControls(bool isEnabled)
{
EnableControl(saveButton, isEnabled);
// repeat the above statement for as many form controls as necessary
}
private delegate void EnableControlDelegate(Control control, bool isEnabled);
private void EnableControl(Control control, bool isEnabled)
{
// InvokeRequired is inherited from System.Windows.Forms.Control, which Button and many other classes derive from.
if (control.InvokeRequired)
{
var d = new EnableControlDelegate(EnableControl);
// try calling this method again, but this time from the thread the control is on
control.Invoke(d, control, isEnabled);
}
else
{
control.Enabled = isEnabled;
}
}
The InvokeRequired method checks to see if the thread that is making the method call is on the same thread as the control (i.e. the UI thread). If the thread making the method call is the same thread the control is on, then it sets the .Enabled property.
If not, this function uses the thread the control is on (again, the UI thread) to call the method again. It should now set the .Enabled property on this second time through.
I hate Winforms and I am spoiled by how relatively easy this is with web.
e: i fucked up by not having the EnableFormControls method in this example not being inside a function running on a separate thread. it's been a long day, ok?
Yeah. I mean, that's basically how all desktop apps work. Single UI Thread. TBH, it's how mobile apps work too.
You just usually use MVVM or MVC and it SEEMS like they aren't. But they are.
AFAIK you CAN launch particular elements with their own thread. But not process. But it has to be really explicitly done.
You just usually use MVVM or MVC and it SEEMS like they aren't. But they are.
AFAIK you CAN launch particular elements with their own thread. But not process. But it has to be really explicitly done.
Anyone good with c++?. I have a question about classes. For my homework I have to read data from a file, store it into classes, and push them to a vector of pointers. The final goal being to format them nicely and print them out. I made a Customer and Date class. I have to store the data from the files into the Customer class with one of the member variables of that class being Date DateJoined. I have getters and setters but the one I'm focused on is the Customer.setDateJoined( ) setter.
I set all of it's member functions to equal the result of all the read data in this case is 3 customers. I made a new pointer instance of Customer with one of it's member variables and pushed that back into the vector. What I'm having trouble is with the last 3 pieces of customer data which are the dates stored as ints. I have to convert three ints like 3 30 2018 into "3/30/2018" which I currently have a working member function for. It prints out a string with the dashes separating the month/day/year. Problem is I have no idea how to store the result of that function into Customer.setDateJoined( ) then couting that with Customer.getDateJoined( ). The dateJoined function has to accept a Date variable according to the diagram the teacher gave us.
Besides that issue everything is working how it's supposed to afaik and if I can figure this out I think I can do the rest of the assignment.
I set all of it's member functions to equal the result of all the read data in this case is 3 customers. I made a new pointer instance of Customer with one of it's member variables and pushed that back into the vector. What I'm having trouble is with the last 3 pieces of customer data which are the dates stored as ints. I have to convert three ints like 3 30 2018 into "3/30/2018" which I currently have a working member function for. It prints out a string with the dashes separating the month/day/year. Problem is I have no idea how to store the result of that function into Customer.setDateJoined( ) then couting that with Customer.getDateJoined( ). The dateJoined function has to accept a Date variable according to the diagram the teacher gave us.
Besides that issue everything is working how it's supposed to afaik and if I can figure this out I think I can do the rest of the assignment.
I don't know how your Date class looks, so I can't really help much. If you just meant creating a native date/time variable in c++, then something similar to this should work: https://stackoverflow.com/a/26739240
By Kibner Go To PostI don't know how your Date class looks, so I can't really help much. If you just meant creating a native date/time variable in c++, then something similar to this should work: https://stackoverflow.com/a/26739240
It looks like this. All the variables have to be private. Also looking it up seems I need to overload << ?!. I think I got my function accepting the date but now I can't cout it and googling led me to overload which I was avoiding since we haven't learned it yet lol. Online easy way out seems to be use friend but teacher said do not do that at all costs so I'm following the book and other examples. Still can't figure it out ;_;.
Date::Date() {
// TODO Auto-generated constructor stub
Year = 00;
Month = 01;
Day = 01;
}
Date::~Date() {
// TODO Auto-generated destructor stub
}
int Date::getYear(void) {
return Year;
}//getYear
int Date::getMonth(void) {
return Month;
}//getMonth
int Date::getDay(void) {
return Day;
}//getDay
string Date::getStringDate(void) {
return to_string(Month) + "/" + to_string(Day) + "/" + to_string(Year);
}
bool Date::setYear(int inputYear) {
if (inputYear == 0 ) {
return false;
}//if
else {
this->Year = inputYear;
return true;
}//else
}//setYear
bool Date::setMonth(int inputMonth) {
if (inputMonth == 0 ) {
return false;
}//if
else {
this->Month = inputMonth;
return true;\
}
}//setMonth
bool Date::setDay(int inputDay) {
if (inputDay == 0 ) {
return false;
}//if
else {
this->Day = inputDay;
return true;
}
}//setDay
Whats the best SQL book, or maybe even better, recommended online courses? I'm a newbie to this but I'm ready to dig in as it possibly could open up some opportunities for me in my current career. I've been watching some YouTube tutorials but I need more structure.
Yeah I don't get this at all. Prompt says to store the dates in the Customer date variable.
I'm reading them like this.
Then storing them like this.
Compiler doesn't throw any errors with that code but it bugs out when I try to cout the date since it can't read the Date data type. So I'm either storing it wrong or I can't figure out how to overload <<. I The other standard data types work just fine. I have 3 Customers that match the 3 Customers in the text file in my vector and I can print out the specific data I need with the getters.
I'm reading them like this.
inputFile >> readYear;
inputFile >> readMonth;
inputFile >> readDay;
Then storing them like this.
Customer* newCustomer = new Customer();
Date readDate;
readDate.setMonth(readMonth);
readDate.setDay(readDay);
readDate.setYear(readYear);
readDate.getStringDate();
newCustomer->setDateJoined(readDate)
Compiler doesn't throw any errors with that code but it bugs out when I try to cout the date since it can't read the Date data type. So I'm either storing it wrong or I can't figure out how to overload <<. I The other standard data types work just fine. I have 3 Customers that match the 3 Customers in the text file in my vector and I can print out the specific data I need with the getters.
By CruzAzul Go To PostWhats the best SQL book, or maybe even better, recommended online courses? I'm a newbie to this but I'm ready to dig in as it possibly could open up some opportunities for me in my current career. I've been watching some YouTube tutorials but I need more structure.Most of the usual tutorial sites for programming probably have some tutorials. I just googled "sql tutorial" and found this generic one: https://www.tutorialspoint.com/sql/index.htm
I'm sure you know this, but it is important to be able to mess with things yourself to really learn. So find a free SQL server and an editor for it. The most popular one, iirc, is MySQL. That website I mentioned earlier has a tutorial specific for it and its SQL dialect: https://www.tutorialspoint.com/mysql/index.htm
By Nelo Ice Go To PostYeah I don't get this at all. Prompt says to store the dates in the Customer date variable.Is readMonth/Day/Year returning a string or an int? I assume it is reading from a text file.
I'm reading them like this.
Then storing them like this.
Compiler doesn't throw any errors with that code but it bugs out when I try to cout the date since it can't read the Date data type. So I'm either storing it wrong or I can't figure out how to overload <<. I The other standard data types work just fine. I have 3 Customers that match the 3 Customers in the text file in my vector and I can print out the specific data I need with the getters.
By Nelo Ice Go To PostIt’s just reading from a text file.I'm not familiar with how c++ handles types, but do you need to convert the string you are reading from the file into an int? 12 is different from "12".
By Kibner Go To PostI'm not familiar with how c++ handles types, but do you need to convert the string you are reading from the file into an int? 12 is different from "12".Yeah I thought they were into since I made each read month/day/year ints before I read them from the file. Then the set functions would accept and only return an int.
The function that converts them to a string works perfectly when I cout it but I run into issues when I try counting it from the vector as a date variable. Compiler just throws an error telling me it can’t read the Date data type or if I’m storing it wrong can’t convert a string to a Date.
Looked it up and I thought I narrowed down the issue to overloading but that doesn’t seem to work either even with the friend keyword which I’m avoiding otherwise. So yeah got no clue how to print out the converted string as a date since the whole point was the Date class is gonna be used again in another class.
Also I don’t think I can add or edit anything in the classes based on the uml diagram. So yeah I have to return a date and somehow cout it.
Edit: well guess I just needed to set everything in setdatejoined using the date class.
Speaking of C++, it's not especially refined, but back in the fall I had to do a semester-spanning Arduino project and ended up with this. It started by riffing on Conor Nishijima's Volume2 library, although by the end of it the only function from it that was left was the one that handles adjusting PWM on the fly. It uses two custom structs for instrument presets (i.e. waveform and ADSR envelope settings), and for the actual musical arrangements in a tracker-esque format.
As a formality for the project itself, I incorporated a colored light sensor to switch between different styles of arrangement depending on the dominant light color. The arrangement is broken up into 9-10 chunks which each have a trio of sub-arrangements (styled after liquid DnB, chiptune/demoscene, and jazz fusion), and at the end of each chunk, it'll switch to a different respective genre if there's a change in dominant color. There's a quick little example of it here.
As a formality for the project itself, I incorporated a colored light sensor to switch between different styles of arrangement depending on the dominant light color. The arrangement is broken up into 9-10 chunks which each have a trio of sub-arrangements (styled after liquid DnB, chiptune/demoscene, and jazz fusion), and at the end of each chunk, it'll switch to a different respective genre if there's a change in dominant color. There's a quick little example of it here.
By CruzAzul Go To PostWhats the best SQL book, or maybe even better, recommended online courses? I'm a newbie to this but I'm ready to dig in as it possibly could open up some opportunities for me in my current career. I've been watching some YouTube tutorials but I need more structure.PostgreSQL's manual-slash-documentation on their website.
Good god. I was so close to dropping my CS class but at the last minute the due date was pushed back a day. Used the day to go to what turned out to be cancelled class but a few of my classmates showed up. Got some help and with some much needed new perspectives I was finally able to conquer the hw and for once I feel confident I did it right.
Does unity count? couldn't find an OT for gamedev.
Let me just say that Unity is absolutely horrible for doing pixel-perfect games, that said, this is where I am with it currently.
https://i.imgur.com/cxGzyUo.png
Let me just say that Unity is absolutely horrible for doing pixel-perfect games, that said, this is where I am with it currently.
https://i.imgur.com/cxGzyUo.png
By giririsss Go To PostWhat's Unity?Game development engine, uses JS or C#, just been working with C# for the project im working on.
All types of programming are welcome here.
By Futaba Go To PostGame development engine, uses JS or C#, just been working with C# for the project im working on.Yeah, felt like i knew the name. But there are so many "unfiying" projects i lose track.
interesting.
One thing i'd really like to do one day is learn more about game engines. I have theories about how they work in my head. But never had the time to dig into the reality.
By giririsss Go To PostYeah, felt like i knew the name. But there are so many "unfiying" projects i lose track.Unreal Engine 4
interesting.
One thing i'd really like to do one day is learn more about game engines. I have theories about how they work in my head. But never had the time to dig into the reality.
Unreal Tournament built using the UE4 engine
By Futaba Go To PostDoes unity count? couldn't find an OT for gamedev.I admire anyone with the patience to do the artwork for their own game. I just can't.
Let me just say that Unity is absolutely horrible for doing pixel-perfect games, that said, this is where I am with it currently.
https://i.imgur.com/cxGzyUo.png
By Kibner Go To PostUnreal Engine 4UE4 is probably where i would have started ... or one of the older id engines that are now free.
Unreal Tournament built using the UE4 engine
Feel like there should be a few courses on youtube or something about it too.
One day.
By giririsss Go To PostUE4 is probably where i would have started … or one of the older id engines that are now free.In uni, we used a third-party renderer and sound-engine to create our own game engine for senior project. It was then I learned that game dev just wasn't for me. So fucking much to keep track of. You are building a world simulator, essentially.
Feel like there should be a few courses on youtube or something about it too.
One day.
UE4 has a bunch of documentation available now which makes things (relatively) easy. It's C++, and I started working in it via the Blueprint visual scripting component back in late summer of 2016 at which point it was just a monstrosity made of stock engine assets. Following a couple iterations due to a mix of starting up new engine versions and losing stuff to corruption, it was more or less in the same place but with the added benefit of feature creep roughly a year after in summer of 2017.
Starting in fall 2017 I started over again and began working on, like, actual assets in tandem with the core mechanics, so as least as far as environments and stuff go this is where I'm at now.
Starting in fall 2017 I started over again and began working on, like, actual assets in tandem with the core mechanics, so as least as far as environments and stuff go this is where I'm at now.
By gravitygauntlet Go To PostUE4 has a bunch of documentation available now which makes things (relatively) easy. It's C++, and I started working in it via the Blueprint visual scripting component back in late summer of 2016 at which point it was just a monstrosity made of stock engine assets. Following a couple iterations due to a mix of starting up new engine versions and losing stuff to corruption, it was more or less in the same place but with the added benefit of feature creep roughly a year after in summer of 2017.0_o nice.
Starting in fall 2017 I started over again and began working on, like, actual assets in tandem with the core mechanics, so as least as far as environments and stuff go this is where I'm at now.
By Futaba Go To PostGame development engine, uses JS or C#, just been working with C# for the project im working on.Did you really mean "JS or C#" or did you mean "JS and C#"?
That's pretty good if JS can be all you need.
By giririsss Go To PostASFOUN fuck fucking around with VM's and VirtualBox.My NUC came in today and I'm installing Debian on it right now exactly so I don't have to fuck with that shit.
Such annoying shit.
Well, I finished up work early today, so now I'm fucking around with my new build server and remembering just how little *nix I know. I got SSH installed so I can run the server headless but I forgot so many simple terminal commands. lol
By gravitygauntlet Go To PostUE4 has a bunch of documentation available now which makes things (relatively) easy. It's C++, and I started working in it via the Blueprint visual scripting component back in late summer of 2016 at which point it was just a monstrosity made of stock engine assets. Following a couple iterations due to a mix of starting up new engine versions and losing stuff to corruption, it was more or less in the same place but with the added benefit of feature creep roughly a year after in summer of 2017.this is cool stuff. got any resources you'd recommend for learning UE4? I've been wanting to get into it for a while, mainly for vr ui development
Starting in fall 2017 I started over again and began working on, like, actual assets in tandem with the core mechanics, so as least as far as environments and stuff go this is where I'm at now.
Anyone have any experience retrieving data from an external HDD that is connecting but showing as unallocated in the disk management? Just randomly happened while I was moving files from my PC and I'm stumped on how to go about getting the data off before reformatting which I'm also not sure how go about doing as that option was grayed out. It's a 1TB Seagate if that matters.
By GQman2121 Go To PostAnyone have any experience retrieving data from an external HDD that is connecting but showing as unallocated in the disk management? Just randomly happened while I was moving files from my PC and I'm stumped on how to go about getting the data off before reformatting which I'm also not sure how go about doing as that option was grayed out. It's a 1TB Seagate if that matters.Try "testdisk" . I could do a step by step but a quick google will probably give you better info or a video.