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
Osmosisch
Sep 9, 2007

I shall make everyone look like me! Then when they trick each other, they will say "oh that Coyote, he is the smartest one, he can even trick the great Coyote."



Grimey Drawer

Yeah, we ran into this a while back when we tried to render images from an R web worker on a different host into a canvas so we could have a 'save' button next to them. What a mess.

Adbot
ADBOT LOVES YOU

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Shaggar posted:

thats fine until you go to deploy it to the next environment at which point you have to pick out which individual objects you want to migrate since your checkin will contain objects from different applications/work in progress

already got a solution to this: make the changes in a release specific branch then the deploy pack becomes a Git diff of the branch vs master. running parallel conflicting branches could still be an issue but 1)the app is small enough that this is manageable and 2) that really only affects running multiple change sets on the same environment which would get cleaned up pre-deploy

i mean yeah it will still get hosed up somehow but that's just programming in general

necrotic
Aug 2, 2005
I owe my brother big time for this!

Shaggar posted:

javascript is the worst thing

the new safari release is caching arrays
https://stackoverflow.com/questions/52390368/array-state-will-be-cached-in-ios-12-safari-is-bug-or-feature/52392901

white sauce
Apr 29, 2012

by R. Guyovich
let's say I want to make a program that inputs the number of days, weeks, and years and outputs that time into minutes. I wrote this thing

quote:

import java.util.Scanner;

public class Minutes{

public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Puny mortal, tell me the number of days, weeks, and years you'd like to convert to minutes: ");
int days;
days = input.nextInt();
int weeks;
weeks = input.nextInt();
int years;
years = input.nextInt();

// Now do calculations
int minutesinDays = days * 1440 ;
int minutesinWeeks = weeks * 10080 ;
int minutesinYears = years * 525949 ;
int totalminutes = (minutesinDays + minutesinWeeks + minutesinYears);

//Now present results
System.out.println("The answer is " + totalminutes + " minutes, now scram...");


The code runs, but I'm concerned that the result could be more accurate, since we know that there's 525,949.20 minutes in a year...

should I worry about this decimal in the amount of minutes in a year? How can I fix my code so it works with that fraction?

mystes
May 31, 2006

white sauce posted:

let's say I want to make a program that inputs the number of days, weeks, and years and outputs that time into minutes. I wrote this thing


The code runs, but I'm concerned that the result could be more accurate, since we know that there's 525,949.20 minutes in a year...

should I worry about this decimal in the amount of minutes in a year? How can I fix my code so it works with that fraction?
Don't write your own date/time handling code. The number of minutes in a year varies.

white sauce
Apr 29, 2012

by R. Guyovich

mystes posted:

Don't write your own date/time handling code. The number of minutes in a year varies.

this is ignoring leap years and other things

GenJoe
Sep 15, 2010


Rehabilitated?


That's just a bullshit word.

mystes posted:

Don't write your own date/time handling code. The number of minutes in a year varies.

specifically, use the java calendar api. it handles all of this poo poo for you: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html

your implementation is okay as a general approximation, but in practice "convert days/weeks/years into minutes" isn't an actual question you can solve, you can only really say "give me the minutes between date X and date Y", because like that dude said the # of minutes in a year will vary depending on which year you're looking at

The_Franz
Aug 8, 2003

mystes posted:

Don't write your own date/time handling code.

i'm guessing the op's teacher won't accept that

gonadic io
Feb 16, 2011

>>=
yeah if you are determined not to use a library your code is fine as a dumb programming exercise

if you were interested in making your code more accorate you need to use a library. date time programming is really hard and not just due to leap years

AggressivelyStupid
Jan 9, 2012

time is evil

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

white sauce posted:

let's say I want to make a program that inputs the number of days, weeks, and years and outputs that time into minutes. I wrote this thing


The code runs, but I'm concerned that the result could be more accurate, since we know that there's 525,949.20 minutes in a year...

should I worry about this decimal in the amount of minutes in a year? How can I fix my code so it works with that fraction?

when you say year, are you referring to a calendar year or the period of the Earth's orbit about the sun?

if you're talking about calendar years etc-- the number of minutes in a calendar year depends on what year it is-- thanks leap years. if you want to always give the precise number of minutes in an interval of so many years, weeks, and days, you should require the user to say when that interval begins so that you may correctly calculate how many leap days are in your interval

Re: handling fractional values, find some resources about the `float` and `double` primitive data types. You should learn that they are not perfect.

code:
double big = (1L<<53);
double notbigger = big+1;
System.out.println(notbigger-big); //this does not print 1.0

mystes
May 31, 2006

The_Franz posted:

i'm guessing the op's teacher won't accept that
OK, I guess if it's a homework assignment that's different, but this is one of those things that people should know that they shouldn't try to implement themselves in real life.

It's like trying to roll your own crypto.

GenJoe
Sep 15, 2010


Rehabilitated?


That's just a bullshit word.
you might end up with a worse answer if you use floats to represent fractions of a minute because floats tend to round off larger numbers (read about it). most date/time APIs work in milliseconds, so if you really want sub-minute precision, use the long datatype and multiply all of your inputs by the # of milliseconds in each, and then divide by (1000 * 60) for you final answer in minutes

edit: if you try to do this with the int datatype, everything will break if your # of milliseconds exceeds 2,147,483,647, because that's the maximum value an int datatype can be (approx 2^32). long solves this problem because its max value is approx 2^64 which is like infinitely bigger

GenJoe fucked around with this message at 20:08 on Sep 19, 2018

Chalks
Sep 30, 2009

Yeah, milliseconds is the way to go, very few time representations deal with sub millisecond precision.

Main Paineframe
Oct 27, 2010

prisoner of waffles posted:

I'm sure the actual requirements for your task were way more concrete than your quick sketch description but yeah, push push push back hard

its already been implemented. at the time, it seemed weird but manageable

now it's been tested and I have to fix the bugs

turns out just slamming arbitrary user-supplied javascript into the global context can cause weird phantombugs that are nigh-impossible to debug

The_Franz
Aug 8, 2003

GenJoe posted:

long solves this problem because its max value is approx 2^64 which is like infinitely bigger

unless you are using c or c++ on windows, then it's always 32 bits

Chalks posted:

Yeah, milliseconds is the way to go, very few time representations deal with sub millisecond precision.

(almost?) all of them do

posix time functions deal with either timespec (seconds + nanoseconds) or timeval (seconds + microseconds). windows uses a clunk as the basic unit of time, each of which is 100ns

white sauce
Apr 29, 2012

by R. Guyovich

mystes posted:

OK, I guess if it's a homework assignment that's different, but this is one of those things that people should know that they shouldn't try to implement themselves in real life.

It's like trying to roll your own crypto.

Yea, this is just getting us to try out simple arithmetic and naming integers and stuff on Java, it's not meant to be actual code that will be used by people


GenJoe posted:

you might end up with a worse answer if you use floats to represent fractions of a minute because floats tend to round off larger numbers (read about it). most date/time APIs work in milliseconds, so if you really want sub-minute precision, use the long datatype and multiply all of your inputs by the # of milliseconds in each, and then divide by (1000 * 60) for you final answer in minutes

edit: if you try to do this with the int datatype, everything will break if your # of milliseconds exceeds 2,147,483,647, because that's the maximum value an int datatype can be (approx 2^32). long solves this problem because its max value is approx 2^64 which is like infinitely bigger

thank you :hai:

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

Main Paineframe posted:

turns out just slamming arbitrary user-supplied javascript into the global context

can do a lot worse than

Main Paineframe posted:

cause weird phantombugs that are nigh-impossible to debug

AggressivelyStupid
Jan 9, 2012

Is there something about c that forces you to dump 40 some odd c and h files into a single directory, with vaguely cryptic names, and file lengths reaching to 5k lines (not generated) or are the people that wrote this broken

I know enough c to be very dangerous but my work with other languages is telling me this is a pile of codesmell I've fallen into

cZk
Oct 6, 2014

i am a flight risk
and i am in flight

AggressivelyStupid posted:

Is there something about c that forces you to dump 40 some odd c and h files into a single directory, with vaguely cryptic names, and file lengths reaching to 5k lines (not generated) or are the people that wrote this broken

I know enough c to be very dangerous but my work with other languages is telling me this is a pile of codesmell I've fallen into

still better than node_modules

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

web pages are for displaying information so this seems like a perfectly reasonable optimization to me

of course a better optimization would be to just disable JavaScript entirely

AggressivelyStupid
Jan 9, 2012

cZk posted:

still better than node_modules

ive barely had the pleasure but thats a real low bar to clear

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Maximum Leader posted:

I’m still on my free student IntelliJ Ultimate but community really isn’t bad if you don’t need JavaScript

let's face it no one needs jarvascript

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

cZk posted:

still better than node_modules

that's more akin to ~/.m2 than the literal source dir of your project tho???

Main Paineframe
Oct 27, 2010

prisoner of waffles posted:

can do a lot worse than

oh, absolutely. but that's the only part I actually have to give a poo poo about

i don't think anyone is ever actually going to use this feature in its current form and the environment is somewhat limited, so I'm not really worried about the horrid risks to security, performance, etc. it just has to work well enough for demos

if you've ever wondered why enterprise software sucks, it's because of people like me

white sauce
Apr 29, 2012

by R. Guyovich
I guess they did want us to figure out the issue of leap years

quote:

A year with 366 days is called a leap year. Leap years are necessary to keep the calendar synchronized with the sun because the earth revolves around the sun once every 365.25 days. Actually, that figure is not entirely precise, and for all dates after 1582 the Gregorian correction applies. Usually years that are divisible by 4 are leap years, for example 1996. However, years that are divisible by 100 (for example, 1900) are not leap years, but years that are divisible by 400 are leap years (for example, 2000). Write a program that asks the user for a year and computes whether that year is a leap year. Provide a class Year with a method isLeapYear. Use a single if statement and Boolean operators.

that single "if" statement lol

gonadic io
Feb 16, 2011

>>=
don't forget leap seconds, or timezone changes, or historical timezone changes, or relativistic effects, or those 11 days everybody agreed didn't happen

white sauce
Apr 29, 2012

by R. Guyovich

gonadic io posted:

don't forget leap seconds, or timezone changes, or historical timezone changes, or relativistic effects, or those 11 days everybody agreed didn't happen

:waycool:

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
time is probably the most difficult thing there is to represent computationally and it seems really dumb to be phrasing frosh comp Sci problems in terms of time. it just invites over or underthinking and will likely lead to them missing the point you're actually trying to teach.

H2Eau
Jun 2, 2010

cZk posted:

still better than node_modules

i don't think this is true, you shouldn't ever have to look at your node_modules directory

it's me, i'm the js cultist

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
i don't think this is true, you shouldn't have to ever look at the visage of cthulhu

it's me, i'm the fishman cultist

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

Powerful Two-Hander posted:

yeah this is what I've already done, I was just looking for a way to avoid having butts.table.sql, butts.table.v1.sql, butts.Table.v2.sql etc to capture the initial create and then incremental alters but whatever you use it basically ends up being that so I'll embrace it

i think we've misunderstood each other. i'm suggesting that you use a sql server database project, which does *not* involve storing sequential alter scripts.

Shaggar posted:

thats fine until you go to deploy it to the next environment at which point you have to pick out which individual objects you want to migrate since your checkin will contain objects from different applications/work in progress

no, database projects support this scenario just fine. if you have two logically disjoint applications living in the same database (which you shouldn't), then regardless each application gets its own separate database project. during deployment, ensure that "drop objects not in source" is disabled, and you can deploy changes to either application at any time.

in another scenario, you have logically disjoint applications and, in addition, some stored procedures that aggregate data from both. here you can add a third database project that contains the stored procedures, and have that database project reference the other database projects in "same database" mode.

in another scenario, you have applications that share some parts of the data model and not others. in this case the common parts of the data model can live in their own, unified database project, while the non-shared parts still each get their own sqlproj and reference the common sqlproj.

contra your previous suggestion, the visual studio database tools team that created database projects was very well aware of scenarios involving multiple apps in one database.

distortion park
Apr 25, 2011


Fiedler posted:

i think we've misunderstood each other. i'm suggesting that you use a sql server database project, which does *not* involve storing sequential alter scripts.


no, database projects support this scenario just fine. if you have two logically disjoint applications living in the same database (which you shouldn't), then regardless each application gets its own separate database project. during deployment, ensure that "drop objects not in source" is disabled, and you can deploy changes to either application at any time.

in another scenario, you have logically disjoint applications and, in addition, some stored procedures that aggregate data from both. here you can add a third database project that contains the stored procedures, and have that database project reference the other database projects in "same database" mode.

in another scenario, you have applications that share some parts of the data model and not others. in this case the common parts of the data model can live in their own, unified database project, while the non-shared parts still each get their own sqlproj and reference the common sqlproj.

contra your previous suggestion, the visual studio database tools team that created database projects was very well aware of scenarios involving multiple apps in one database.

What happens if you have non-.net users of the database. Or users accessing the db directly from their own sql. This sort of thing is great if you have a super structured and locked down development process, but for some (a lot?) of places the dbs are designed first for an unknown number of eventual consumers and it would just me much better if ssms /sql server supported that use case with versions, tracing, object reference paths etc. You can roll your own versions of some of those but it would be so much nicer if they were built in

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

pointsofdata posted:

What happens if you have non-.net users of the database. Or users accessing the db directly from their own sql. This sort of thing is great if you have a super structured and locked down development process, but for some (a lot?) of places the dbs are designed first for an unknown number of eventual consumers and it would just me much better if ssms /sql server supported that use case with versions, tracing, object reference paths etc. You can roll your own versions of some of those but it would be so much nicer if they were built in

i'm not understanding your point. sql server database projects are not related to .net. in fact they're entirely unrelated to database access, and are just about defining and deploying the database schema.

distortion park
Apr 25, 2011


surely you're using the projects in your. Net solutions though, otherwise what's the point of splitting them up into n^2 different projects?

Shaggar
Apr 26, 2006

Fiedler posted:

i think we've misunderstood each other. i'm suggesting that you use a sql server database project, which does *not* involve storing sequential alter scripts.


no, database projects support this scenario just fine. if you have two logically disjoint applications living in the same database (which you shouldn't), then regardless each application gets its own separate database project. during deployment, ensure that "drop objects not in source" is disabled, and you can deploy changes to either application at any time.

in another scenario, you have logically disjoint applications and, in addition, some stored procedures that aggregate data from both. here you can add a third database project that contains the stored procedures, and have that database project reference the other database projects in "same database" mode.

in another scenario, you have applications that share some parts of the data model and not others. in this case the common parts of the data model can live in their own, unified database project, while the non-shared parts still each get their own sqlproj and reference the common sqlproj.

contra your previous suggestion, the visual studio database tools team that created database projects was very well aware of scenarios involving multiple apps in one database.

this doesn't work at all since you cant easily split a database across multiple projects both because the tool cant do it well and applications share objects in the database.

Also the idea that multiple applications shouldn't use the same db is dumb as poo poo and its the core reason for the vs db tools being mostly useless for all but the most simple applications.

Shaggar
Apr 26, 2006
also related to dbs and .net, why in the gently caress is the .net team still promoting entity framework? Its so loving awful. Is the vs/.net team just totally incompetent when it comes to databases?

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

Shaggar posted:

also related to dbs and .net, why in the gently caress is the .net team still promoting entity framework? Its so loving awful. Is the vs/.net team just totally incompetent when it comes to databases?

afaik the teams at microsoft fight each other tooth and nail it might be incompetence through infighting.

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

i tihnk its about time for mononcqc to dunk on everything

Adbot
ADBOT LOVES YOU

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

pointsofdata posted:

surely you're using the projects in your. Net solutions though, otherwise what's the point of splitting them up into n^2 different projects?

the point of splitting into separate projects is to allow different deployment cadences. i'm not talking about entity framework. you can't use a database project in your .NET code.

Shaggar posted:

this doesn't work at all since you cant easily split a database across multiple projects both because the tool cant do it well and applications share objects in the database.

Also the idea that multiple applications shouldn't use the same db is dumb as poo poo and its the core reason for the vs db tools being mostly useless for all but the most simple applications.

yes, you actually have to manually move files into the correct project when initially setting things up. the tools aren't magically able to figure out which parts are shared. shared objects, though, work fine and i mentioned the appropriate project structure above.

and no, two logically disjoint applications (by which i mean two applications whose data models are entirely separate, as in no shared database objects) don't belong in the same database. multiple applications that share parts of their data model in the same database is, of course, fine.

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