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
theadder
Dec 30, 2011


cutting edge cmd.exe itt

Adbot
ADBOT LOVES YOU

Necc0
Jun 30, 2005

by exmarx
Broken Cake

Scorponok
May 13, 2002

No... not without incident.

Jonny 290 posted:

lemme know when you guys wanna try an actual professional email provider

Who would that be? We've tried mandrill and sendgrid, which are enough for our 40k emails / month

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
the latter would be a good start

bucketmouse
Aug 16, 2004

we con-trol the ho-ri-zon-tal
we con-trol the verrr-ti-cal

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?

Shaggar posted:

current hobby project status:


is that a powershell cmdlet?

PleasureKevin
Jan 2, 2011

Jonny 290 posted:

the latter would be a good start

go on.

inquiring terrible programmer minds need to know

jesus WEP
Oct 17, 2004


triple sulk posted:

is ur actual name shaggar
the names shaggar

james shaggar

licence to .dll

PleasureKevin
Jan 2, 2011

it's samuel haggar

PleasureKevin
Jan 2, 2011

pronounced hay-gar

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Corla Plankun posted:

python-pcyopg2 wants me to put a plaintext password in my python script to connect to a database

whats the best way to not do that

put pw in file only readable by the user script runs as. also add file to ur git/svn ignore

PleasureKevin
Jan 2, 2011

code:
SomeSchema.pre( 'update', function () {
// ... stuff
})
is not a thing you can do in mongoose come on

tef
May 30, 2004

-> some l-system crap ->

Necc0 posted:

in case anyone missed this thread:

http://forums.somethingawful.com/showthread.php?threadid=3701595

it's short and sweet and rly funny

i dunno it looks like every thread full of dickwaving programmers

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD
i found out today that devenv 2013 has 64 bit EAC so hopefully we can upgrade soon

also for anyone else who is sick of R# generated properties you can use the built in control+period instead which works much better

PleasureKevin
Jan 2, 2011

wow and I nearly started a node thread myself. dodged a bullet.

I do front and back development and node owns for that.

tef
May 30, 2004

-> some l-system crap ->
promises are pretty neat :3:

Stringent
Dec 22, 2004


image text goes here

tef posted:

promises are pretty neat :3:

promises are amazing, but out of curiosity who started this? i was introduced to it through the javascript community.

PleasureKevin
Jan 2, 2011

yeah I use promise s. no dumb callbacks. well, less.

MononcQc
May 29, 2007

Stringent posted:

promises are amazing, but out of curiosity who started this? i was introduced to it through the javascript community.

It evolved from logic variables and Wikipedia says Concurrent Prolog had the first 'proper' concurrency-oriented implementation.

Stringent
Dec 22, 2004


image text goes here

MononcQc posted:

It evolved from logic variables and Wikipedia says Concurrent Prolog had the first 'proper' concurrency-oriented implementation.

if that's it, then the javascript community has something to congratulate itself for.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

what are promises and how are they related to and/or better than callbacks?

Stringent
Dec 22, 2004


image text goes here

fart simpson posted:

what are promises and how are they related to and/or better than callbacks?

just a convention unfortunately, but if adhered to religiously they make writing asynchronous code much, much, much less painful

Stringent
Dec 22, 2004


image text goes here
like, you must serve your promise as you would serve your god

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

fart simpson posted:

what are promises and how are they related to and/or better than callbacks?

basically a 'promise' is an object that calls a callback when some operation has finished (or failed).

it has sensible semantics (like, if you say "hey call this function when you're done" on a promise that's already been resolved, that function still gets called instead of being forgotten about), and having a common api for every thing-that-calls-a-callback-when-it's-done means that you can get lots of cool utility functions to manipulate promises and avoid your async code turning into callback hell

hobbesmaster
Jan 28, 2008

but what about broken promises

i also hate it when a delegate doesn't actually do anything

fritz
Jul 26, 2003

PleasureKevin posted:

it's samuel haggar

PleasureKevin posted:

pronounced hay-gar

power botton
Nov 2, 2011

PleasureKevin posted:

it's samuel haggar

PleasureKevin posted:

pronounced hay-gar

Shaggar
Apr 26, 2006

eschaton posted:

is that a powershell cmdlet?

lol no. its just a regular console app and I wrote a lot of really terrible stuff for moving the cursor around and clearing lines and sections and stuff its pretty lol

triple sulk
Sep 17, 2014



there's an ms dev that's involved in the corefx development and every time i see his account name i do an lol

Valeyard
Mar 30, 2012


Grimey Drawer

triple sulk posted:

there's an ms dev that's involved in the corefx development and every time i see his account name i do an lol

lol

Share Bear
Apr 27, 2004

The Leck
Feb 27, 2001

PleasureKevin posted:

it's samuel haggar
heir to the mayorship of metro city

PleasureKevin
Jan 2, 2011

fart simpson posted:

what are promises and how are they related to and/or better than callbacks?

here's a bad example probably. sorry of the php tags, wanted some highlighting.

php:
<?
    function upgradeUser () {
        return Q.Promise( function ( resolve, reject, notify ) { // this makes the function return a promise, and passes 3 functions into it
            getUser( req.userToken, function ( err, user ) {
                if ( err )
                    reject( new Error( "Could not find any user." ) // this uses the reject functions passes in above, 
                    // which ends the function and sends this message along
                    
                performUpgrade( user, function( err, success ) {
                    if ( err )
                        reject( new Error( "Could not upgrade this account." ) ) // same as above. but keep in mind 
                        // it doesn't just return this value, it returns it and the status that it failed
                        
                    resolve( success ) // ends the function upgradeUser(), returns the value (same as above) 
                    // BUT with the status that "it worked"
                })
            })
        })
    }
    
    upgradeUser()

    upgradeUser()
    // .then( someOtherFunction ) -- just showing you can add many more functions to the chain, each passing the resolve() value of the last to the next
    .then( function ( success ) { // or pass it into an anonymous function like this
        return res.json( "Account upgraded" )
    }, function ( err ) { // the second function, separated by comma, will be the error, and only triggered if there is a reject() value sent somewhere above
        console.error( err )
        return res.json( err.message )
    })
?>
notice that i've nested the "resolve" and "reject" functions pretty deep in the original upgradeUser() function. usually, without promises, you have to "return" values all the way up the chain of functions. with promises, it doesn't matter where you call resolve(), it will return that value and finish the function.

at the bottom you chain the functions together with the really easy ".then()". unfortunately, though, you have to do this. i can't do

code:
success = upgradeUser()
because .then(), or .spread() or other promise functions, will translate the Promise object being returned into the value put into resolve() only if there is one. if there's an error, it just jumps down the chain of .then()'s to the functions returning the error and shows the first value to be passed into reject().

you can also do

code:
	Q.all( [ saveImage1(), saveImage2() ])
	.spread( function( image1, image2 ) {
		return res.json( { "image1": image1,
		"image2": image2
		})
	})
which will run the two functions saveImage#() in parallel, and actually return the resolve() values from each (they should be promise functions like the one i made above) as an Array. the lovely .spread() function will split the array into separate values, which i then named image1 and image2.

i hope someone likes reading this cause it took me forever to understand promises and i probably still but this is what i wish someone told me from the start

PleasureKevin
Jan 2, 2011

hey what the hell are these addresses like

//il1.soundcloud.com/images/hamster-dance-2015.jpg

i can't resolve them using request() or whatever but i want to

edit: you just add your choice of http or https i guess

PleasureKevin fucked around with this message at 19:54 on Feb 20, 2015

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

PleasureKevin posted:

hey what the hell are these addresses like

//il1.soundcloud.com/images/hamster-dance-2015.jpg

i can't resolve them using request() or whatever but i want to

edit: you just add your choice of http or https i guess

yeah it's like any other relative url. it assumes the scheme of the base url

Shaggar
Apr 26, 2006
oh an interesting thing about the Pandora api is when they deliver an ad a lot fo the time the ad metadata specifies a higher gain than normal songs lol

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

PleasureKevin posted:

go on.

inquiring terrible programmer minds need to know

WARNING: TRANSPARENT SHILL

we are monsters at email and take our services very seriously and don't name them after wacky monkeys. our free tier gives you 400 a day, if you need more beef to test we will work with you most likely. pm or email to username@gmail, I don't get commissions i just like happy customers END SHILL

triple sulk
Sep 17, 2014



Shaggar posted:

oh an interesting thing about the Pandora api is when they deliver an ad a lot fo the time the ad metadata specifies a higher gain than normal songs lol

yeah just like commercials, which was supposed to be illegal now iirc but still happens anyway

suffix
Jul 27, 2013

Wheeee!

tef posted:

promises are pretty neat :3:

eh. proper async/await support is a strictly better interface, but promises at least papers over the callback hell, and with yield they can even be tolerable to write

the big problem with the js promises i've seen is they tend to swallow errors because there's nowhere to raise them
with an async statement you have a call point where you can just raise the exception as normal, with a proper stack trace and everything
promise stack traces tend to suck, when you even get them

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

fart simpson posted:

what are promises and how are they related to and/or better than callbacks?

a promise is sorta lifting the callback into the return argument, so you can compose things through method chaining, rather than nested functions.

i.e

get_a_page().then(do_a_thing).then(some_other_thing)

instead of

get_a_page(function callback(v,e) {do_a_thing(v, function callback2(v,e) { some_other_thing(v) }) })

the reason that it is more than just a future or observable value, is that a promise is something you can pass in to a thing that expects a callback

p = Promise()
get_a_page(p.callback)
p.then(....)

tef fucked around with this message at 00:37 on Feb 21, 2015

  • Locked thread