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.
 
  • Locked thread
akadajet
Sep 14, 2003

Shaggar posted:

I liked knockout but the SPA routing poo poo is always super unmanageable. luckily steve sanderson has moved on from knockout and is working on fixing browsers forever with blazor

https://www.youtube.com/watch?v=MiLAE6HMr10&t=1860s

best thing ever is at 33:08

yeah, because .net in the browser was a smashing success last time around.

Adbot
ADBOT LOVES YOU

akadajet
Sep 14, 2003

show my post vBulletin!

Shaggar
Apr 26, 2006

Shinku ABOOKEN posted:

hey all can anyone tell me what i'm doing wrong here in this pom.xml? i want to try out jetty but maven tries to download a non-existent jar (https://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-project/9.4.7.RC0/jetty-project-9.4.7.RC0.jar)
XML code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 [url]http://maven.apache.org/xsd/maven-4.0.0.xsd[/url]">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>project</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-project</artifactId>
            <version>9.4.7.RC0</version>
        </dependency>
    </dependencies>


</project>
e: i'm using intellij's built in maven 3

you wouldn't add jetty as a dependency unless you're doing development on a jetty extension or something. Also that doesn't look like a valid jetty version.

you want to use the jetty plugin to have maven run your project on jetty during development and testing. I also added the servlet-api in here if that's what you're using jetty for. if not you can remove that dependency.


XML code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 [url]http://maven.apache.org/xsd/maven-4.0.0.xsd[/url]">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>project</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
             <groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1</version>
			<scope>provided</scope>
        </dependency>
    </dependencies>
	<plugins>
		
		<plugin>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-maven-plugin</artifactId>
			<version>9.4.6.v20170531</version>
		</plugin>
	</plugins>


</project>

after adding the plugin you'll be able to run the goals it provides. You can get more info on that from the plugin website here but if you just run your project with jetty:run it will first download all the reqs for the plugin including the jetty runtime and then start jetty with your project's output as the home dir.

JewKiller 3000
Nov 28, 2006

by Lowtax

MALE SHOEGAZE posted:

slick is bullshit. gently caress slick.

here's the basic sql query I'm trying to write in slick:

code:
select invoice.id, sum(item.price) 
	from public."INVOICE" as invoice 
	join public."INVOICE_ITEM" as item on invoice.id = item.invoice_id 
	group by invoice.id;
here it is in slick!

code:
    val joined = invoiceTable join invoiceItemTable on (_.id === _.invoice_id)
    val grouped =
      joined.groupBy(_._1).map { case (invoice, grouped) => (invoice, grouped.map(_._2.price).sum) }

    db.run(grouped.result)
      .map(_.map { case (invoice, price) => invoice.copy(price = price.getOrElse(0)) })
i'm not going to post the generated code because it sucks but also it doesn't even properly parameterize poo poo so there's an attack vector there. it may be that it doesn't parameterized UUIDs because in theory a parsed UUID is injection safe but idk. i jsut dont know.

oh and it has an escape hatch in the form of plain sql queries. but guess what? it doesn't support interpolation of traversable types so you cant even do IN properly.

I'm switching to scalalike and I should have done so last week when gonadic io mentioned it.

you already have the sql query so just use the sql query

i have yet to see a sql translation layer that 1. actually has all the features you need, and 2. is any better than sql in any way whatsoever. like yeah ok "object relational impedance mismatch! embedded strings of code written in another language! blah blah blah" who cares just use the sql

Shaggar
Apr 26, 2006

MALE SHOEGAZE posted:

slick is bullshit. gently caress slick.

here's the basic sql query I'm trying to write in slick:

code:
select invoice.id, sum(item.price) 
	from public."INVOICE" as invoice 
	join public."INVOICE_ITEM" as item on invoice.id = item.invoice_id 
	group by invoice.id;
here it is in slick!

code:
    val joined = invoiceTable join invoiceItemTable on (_.id === _.invoice_id)
    val grouped =
      joined.groupBy(_._1).map { case (invoice, grouped) => (invoice, grouped.map(_._2.price).sum) }

    db.run(grouped.result)
      .map(_.map { case (invoice, price) => invoice.copy(price = price.getOrElse(0)) })
i'm not going to post the generated code because it sucks but also it doesn't even properly parameterize poo poo so there's an attack vector there. it may be that it doesn't parameterized UUIDs because in theory a parsed UUID is injection safe but idk. i jsut dont know.

oh and it has an escape hatch in the form of plain sql queries. but guess what? it doesn't support interpolation of traversable types so you cant even do IN properly.

I'm switching to scalalike and I should have done so last week when gonadic io mentioned it.

use mybatis and stop wasting your time with stupid crap.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

JewKiller 3000 posted:

you already have the sql query so just use the sql query

i have yet to see a sql translation layer that 1. actually has all the features you need, and 2. is any better than sql in any way whatsoever. like yeah ok "object relational impedance mismatch! embedded strings of code written in another language! blah blah blah" who cares just use the sql

i agree in principal but i need the following features:

1) proper query parameterization
2) something that handles the quirks of jdbc for me
3) something that handles connections
4) something that presents an asynchronous Future based API.

also gently caress scalalike doesn't support futures so there goes that.

also there's really something to be said for making sure your code doesn't compile whenever your schema changes.

DONT THREAD ON ME fucked around with this message at 23:45 on Aug 30, 2017

Workaday Wizard
Oct 23, 2009

by Pragmatica

Shaggar posted:

you wouldn't add jetty as a dependency unless you're doing development on a jetty extension or something. Also that doesn't look like a valid jetty version.

you want to use the jetty plugin to have maven run your project on jetty during development and testing. I also added the servlet-api in here if that's what you're using jetty for. if not you can remove that dependency.


XML code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 [url]http://maven.apache.org/xsd/maven-4.0.0.xsd[/url]">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>project</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
             <groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1</version>
			<scope>provided</scope>
        </dependency>
    </dependencies>
	<plugins>
		
		<plugin>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-maven-plugin</artifactId>
			<version>9.4.6.v20170531</version>
		</plugin>
	</plugins>


</project>

after adding the plugin you'll be able to run the goals it provides. You can get more info on that from the plugin website here but if you just run your project with jetty:run it will first download all the reqs for the plugin including the jetty runtime and then start jetty with your project's output as the home dir.

thank you :glomp:

my goal is to have a server that i can drop somewhere behind an nginx. will this accomplish my goal? will the maven-plugin be included in the final artifact? (i am not familiar with the specifics of java servers)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Shaggar posted:

use mybatis and stop wasting your time with stupid crap.

i would but I really don't know java very well and I don't want to gently caress around with making it work with our codebase.

gonadic io
Feb 16, 2011

>>=

MALE SHOEGAZE posted:

i agree in principal but i need the following features:

1) proper query parameterization
2) something that handles the quirks of jdbc for me
3) something that handles connections
4) something that presents an asynchronous Future based API.

also gently caress scalalike doesn't support futures so there goes that.

Future.apply

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

Future.apply

I could probably sneak that by my lead honestly. I don't personally care about all actions being non-blocking but he definitely does (but I don't think he'd realize that Future.apply doesn't do that).

DONT THREAD ON ME fucked around with this message at 23:10 on Aug 30, 2017

gonadic io
Feb 16, 2011

>>=

MALE SHOEGAZE posted:

I could probably sneak that by my lead honestly.

honestly i don't get the difference between putting it into future threads yourself and the "proper" async future solution

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

honestly i don't get the difference between putting it into future threads yourself and the "proper" async future solution

Maybe scala futures work different but with Twitter futures (what we use) Future.apply won't dispatch in a thread pool -- the argument is evaluated eagerly so you're not really accomplishing anything. it's just for lifting values into futures. i think this is because the twitter future's are event based so you need a promise with a poll function and poo poo in order to be asynchronous.

but yeah, ultimately I can just run it inside a thread and convert it to a twitter future and it wont be hard so that's what I'll do. this is essentially all we're doing in other places.

DONT THREAD ON ME fucked around with this message at 23:24 on Aug 30, 2017

gonadic io
Feb 16, 2011

>>=
so twitter's Future.apply is like scala's Future.successful? that's p stupid imo.

but my question is more what's the difference between starting the computation in a thread vs the "proper" async way with library support?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

but my question is more what's the difference between starting the computation in a thread vs the "proper" async way with library support?

no you're absolutely right. I can't think of a reason it really matters.

quote:

so twitter's Future.apply is like scala's Future.successful? that's p stupid imo.

yeah like I said (after editing my post a bunch), twitter's future implementation is not thread based so it works pretty differently. it's like tokio in that if you want a real proper twitter future you need to make your task pollable. i've never actually done it so i'm not super clear on how it works.

if you want to just run some work in a thread, you use a FutureTask, which runs work in a thread and then resolves when it's done.

DONT THREAD ON ME fucked around with this message at 23:34 on Aug 30, 2017

Shaggar
Apr 26, 2006

Shinku ABOOKEN posted:

thank you :glomp:

my goal is to have a server that i can drop somewhere behind an nginx. will this accomplish my goal? will the maven-plugin be included in the final artifact? (i am not familiar with the specifics of java servers)


so typically when you create a java web application your output is a .WAR file. This is just a zip file with a specific layout. I forgot to add this to the pom, but you'll want to set the packaging to war which will tell maven to pack a war instead of a jar. so like this:

XML code:
<groupId>com.example</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
in addition to your code,libs, static resources, and any dynamic pages (ex:jsp), the war contains a web.xml that defines a bunch of stuff about the application like servlet mappings or w/e. Because this spec is standard it means you can deploy the war to any servlet container which includes jetty, tomcat, and a few others. jetty is nice cause its easy to configure

The generation of the war by maven is done when you specify the war packaging and is totally independent of the jetty plugin. all the jetty plugin does is give you a local jetty instance in which to run and test your code. At its most simple this is just a way for you to get the server running locally fast and easy. But then you can get into more advanced usage where you can have maven launch jetty so that you can run tests against the running instance.

What makes maven so good is that its designed so that plugins run the same no matter where or how you run them. So if you were to go to a command prompt and run mvn jetty:run in your project it works exactly the same as when you to jetty:run from your ide. It also means if someone else pulls your source out, they can immediately do jetty:run and get exactly what you were seeing. This includes non-humans which means you can get very easy, consistent builds and tests on a build server so you can do CI.

To back up a bit and get a little higher level, a quick distinction:

Dependencies are libraries that your code needs to compile or run. These get packaged and deployed along with your own code in the final output.

Plugins are extensions to maven that add functionality to the build system. In maven this functionality is added as Goals. Goals are basically commands to tell maven to do something like compile or package or clean or whatever else.

When you run the jetty:run goal maven looks for plugins that have matching goals, finds that the jetty plugin handles it, and then passes control off to the plugin to figure out what to do next. In this case of jetty:run this may be cleaning and building the project and then launching an instance of jetty configured to use that compiled output.

There are a number of default plugins that are considered to always be available without you including them. You can consult the maven docs for more info on this.

When you want to deploy it to your server, which might be jetty or tomcat or whatever, you'll run the package goal and it will generate a .war which you can then deploy to the server. You can also do more advanced publishing using maven to have it build and deploy automatically, but it may help you to understand what its doing before getting into that kind of thing.

Lastly, there is another concept in maven called archetypes. Archetypes are basically project templates that contain a prefab pom and related project folder+file layout. You may consider finding an archetype for a web project to get a kickstart in building a web app. Many major frameworks publish archetypes for this purpose. Intellij may also have a default web project template.

Shaggar
Apr 26, 2006
you could then put IIS or nginx or whatever in front of jetty if you want.

redleader
Aug 18, 2005

Engage according to operational parameters
i thought nginx is open source and therefore garbage?

hifi
Jul 25, 2012

redleader posted:

i thought nginx is open source and therefore garbage?

its an open core thing so worse

cinci zoo sniper
Mar 15, 2013




i have gotten to point of doing actual work with mongo and my desire to kill has never been so high, drat

cinci zoo sniper
Mar 15, 2013




MMMOOOOOOOOOOOOONGOOOOOOOOOOOO

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

cinci zoo sniper posted:

i have gotten to point of doing actual work with mongo and my desire to kill has never been so high, drat

it's so bad

Workaday Wizard
Oct 23, 2009

by Pragmatica

this is 100000% more clear than the apache docs

cinci zoo sniper
Mar 15, 2013





how do i traverse a nested substructure with bunch of nested substructures to retrieve all Butt on any of varying levels?

gonadic io
Feb 16, 2011

>>=

cinci zoo sniper posted:

how do i traverse a nested substructure with bunch of nested substructures to retrieve all Butt on any of varying levels?

Sounds like you need a hylofunctor

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

Sounds like you need a hylofunctor

don't haspell me

Shaggar
Apr 26, 2006

redleader posted:

i thought nginx is open source and therefore garbage?

well I wouldn't use it, but he was talking specifically about it. I use IIS as my jetty front ends.

Sapozhnik
Jan 2, 2005

Nap Ghost
i embed jetty in-process, op

also not many people know this but the jvm and indeed jetty itself are compatible with systemd socket activation, so you can restart your application process without bouncing any incoming requests.

cinci zoo sniper
Mar 15, 2013




cinci zoo sniper posted:

how do i traverse a nested substructure with bunch of nested substructures to retrieve all Butt on any of varying levels?

ok, now im at pc and can elaborate

say, mongo entry has as field with a json blob, in which I have bunch of strings each called Butt

repsonse.x.y.z.Butt
repsonse.x.y.z.hello.Butt
repsonse.x.y.z.hello.world.1.Butt
repsonse.x.y.z.hello.world.2.Butt

i can guarantee that all Butts are inside z, but i can not claim that each record has the exactly same position (sublevel depth) and number of Butts within z

is there an elegant-ish solution for this in a javascript select query for mongodb

necrotic
Aug 2, 2005
I owe my brother big time for this!
Shoot the mongo database into a volcano and use a real database.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Also send whoever chose mongo to the volcano.

cinci zoo sniper
Mar 15, 2013




necrotic posted:

Shoot the mongo database into a volcano and use a real database.

necrotic posted:

Also send whoever chose mongo to the volcano.

ive literally been assigned these two tasks, but it takes time and le mongo cant wait. worst case scenario, ill just make like 50 fake joins for most logical structure deviations and throw a "sorry not sorry" comment somewhere

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

necrotic posted:

Shoot the mongo database into a volcano and use a real database.

necrotic posted:

Also send whoever chose mongo to the volcano.

the second step is VERY IMPORTANT, do not neglect it or the problem will re-occur in the future!

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

necrotic posted:

Also send whoever chose mongo to the volcano.

they quit after migrating

i met the dude and was so mad i wouldn't even talk to him

DONT THREAD ON ME fucked around with this message at 18:27 on Aug 31, 2017

JewKiller 3000
Nov 28, 2006

by Lowtax
sup nerds i just wrote a query that has 3 ctes and uses an inner join, a left join, a right join, and two full joins :getin:

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
the people that chose mongo for us were contractors whomst my team replaced, so I just have to be mad at the absentee leads and architects who let a team of contractors start this pile of poo poo.

thank god we're past 1.0 release and can actually rip up this rotting garbage. first to go is the monstrous angular+jquery SPA frontend with some of the worst code I've seen in my life. who knew switch (true) {} was a pattern???

JewKiller 3000
Nov 28, 2006

by Lowtax

cinci zoo sniper posted:

ok, now im at pc and can elaborate

say, mongo entry has as field with a json blob, in which I have bunch of strings each called Butt

repsonse.x.y.z.Butt
repsonse.x.y.z.hello.Butt
repsonse.x.y.z.hello.world.1.Butt
repsonse.x.y.z.hello.world.2.Butt

i can guarantee that all Butts are inside z, but i can not claim that each record has the exactly same position (sublevel depth) and number of Butts within z

is there an elegant-ish solution for this in a javascript select query for mongodb

just imagine, if your documents were in xml, the solution would be the xpath "//Butt" from the z node

Shaggar
Apr 26, 2006

JewKiller 3000 posted:

sup nerds i just wrote a query that has 3 ctes and uses an inner join, a left join, a right join, and two full joins :getin:

ctes are good

cinci zoo sniper
Mar 15, 2013




JewKiller 3000 posted:

just imagine, if your documents were in xml, the solution would be the xpath "//Butt" from the z node

god i wish it was xml, or i had realistic shot at converting json blobs to xml

MononcQc
May 29, 2007

So I'm toying with TUN/TAP devices in FreeBSD along with some custom software in the hopes of writing what is essentially a tiny ethernet firewall that simulates bad network connections.

I've got two working setups:

code:
Making a VM (in virtualbox) fail:

em1 <-+-> tap1 <---> [soft firewall] <---> tap0 <-+-> tap2 <==> VM <==> [driver]
      |                                           |
   bridge1                                     bridge0


Hardware Device (em1 connects to one edge device, and em0 to another one):

em1 <-+-> tap1 <---> [soft firewall] <---> tap0 <-+-> em0
      |                                           |
   bridge1                                     bridge0
This works fine in both cases, where I can inject random packet drops, corruption, delays or blocking, or simulate slow and/or asymmetric networks on failures. The problem I have is I somehow can't manage to make it work with local software, that I really wish I could.

I.e. I'd want to be able to make program A bind to an address on em1, and program B bind to an address on em0, and then get to tell the OS "make the traffic for these go through bridge0 and bridge1", but it appears the OS kind of hard-registers routes for those and always makes them go through the loopback interface, which bypasses my thing. Also all the loving FreeBSD networking resources online are about people trying to set up OpenVPN or something :(

Adbot
ADBOT LOVES YOU

HoboMan
Nov 4, 2010

Shaggar posted:

ctes are good

woo i made a subquery join with different syntax

  • Locked thread