text:
Q: Express : Shouldn't middleware stop being called once a response is made? I have this issue where inside a router file that returns a router object - middleware is getting called after a response is already made.
I thought middleware placed after a route will never get executed
for that route, I especially thought that would be true if a response
was already given.
Main question:
Middleware should stop being called after the response right?
Ex: When calling the endpoint "/login" and sending a response
    both middleware A and B are called.
Note: I have wrapped the router in a higher order function
(for socket.io functionality but that is beside the point).
Code Example:
var express = require('express');
var router = express.Router();

var wrappedRouter = function(val) {

    router.get('/login', function(req, res) {
        console.log("Inside login route");
        res.sendFile(path.resolve('login.html'))
    }

    router.use(function(req, res, next) {
        console.log("Exectuing middleware A");
    });

    router.use(function(req, res, next) {
        console.log("Exectuing middleware B");
    });

    router.get('/another-route', function(req, res) {
        res.sendFile(path.resolve('login.html'))
    }

    return router;

}
//Prints:
// Inside login route
// Exectuing middleware A
// Exectuing middleware B

A: Your assumption is absolutely correct, if you do not call next, next middleware in chain will never get executed, The problem you are facing is because, as you have already guessed, due to static resources your page is requesting, like favicon or images or anything else (separate requests). To get concrete proof, you can log url while serving express requests and see what requests are made and what gets executed using req.url as shown below
var express = require('express');
var router = express.Router();
var path = require('path');
var wrappedRouter = function(val) {
    router.get('/login', function(req, res) {
        console.log("Inside login route: " + req.url);
        res.sendFile(path.resolve('login.html'))
    });

    router.use(function(req, res, next) {
        console.log("Exectuing middleware A: "  + req.url);
    });

    router.use(function(req, res, next) {
        console.log("Exectuing middleware B: "  + req.url);
    });

    router.get('/another-route', function(req, res) {
        res.sendFile(path.resolve('login.html'))
    });

    return router;
}

module.exports = wrappedRouter({});

Notice req.url in console.log("Inside login route: " + req.url); this will append current req resource and we'll be able to identify whats called and why. As shown below

So now we know whats happening and why, now lets see how we can resolve it.
In express the order in which we register stuff to express app is very important. And I'd suggest registering your middleware separately (first) and then register your routes, this will increase the manageability of your super awesome code!
That being said, coming to the problem at hand, as sequence matters, what is happening in your case it, express tries each and every middleware in sequence and until it runs out of it. So, when server asks for 'favicon' (or some other static resource), it starts executing matching middleware in sequence. "Middleware A" handles the request and generates the output (keep in mind that the favicon is not served, actually nothing happens and the request will keep on handing until you call next or send something in response.
The solution to your problem is registering a static folder in the beginning of your app.js, before anything gets registered. This way when static resources are requested, they are served right away, and other requests which are not entertained by static resource middleware are passed on to your middleware.
It is not advisable to serve files are you are doing, as the app grows you may find it hard to manage, instead you should use view engines / static middleware to get what you are trying to achieve, as shown in below code.
Your app structure should be as follows, and it will resolve your issue.
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

//This will return wrapped routers
var routes = require('./routes/index');
var other = require('./routes/other');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));

app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

//Just after registering all request parsing middleware, register static middleware
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/others', other);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

module.exports = app;

If you are new to express and want to get started and see what works how, I have written a small blog about it, Part one is done, rest are in queue ;)
Get started with Express and build RESTful api
In this part, I show how to scaffold an express app, above code from it. You might find it helpful.
Hope it helps! Please let me know if you need anything else!

A: Express is executing middleware in same order that you defined it and lifecycle does not end with res.send().
You can use them e.g. to postprocess even when request was already satisfied.
var wrappedRouter = function(val) {
    router.use(function(req, res, next) {
        request.startProcessingTime = +(new Date());
        next();
    });

    router.get('/another-route', function(req, res) {
        res.sendFile(path.resolve('login.html'))
    }

    (...)
    router.use(function(req, res, next) {
        req.endProcessingTime = +(new Date());
        next();
    });

    router.use(function(req, res, next) {
        console.log('Processing time:', req.endProcessingTime - req.startProcessingTime)
    });

    return router;

}

A: Another thing I should say, please make sure the next() is called in the router.use() as below.
router.use(function(req, res, next) {
    console.log("Exectuing middleware A");
    next();
});

router.use(function(req, res, next) {
    console.log("Exectuing middleware B");
    next();
});

router.get('/login', function(req, res) {
    console.log("Inside login route");
    res.send('Hello World');
});

Which output
Exectuing middleware A
Exectuing middleware B
Inside login route

If the next() does not invoked in the router.use()
router.use(function(req, res, next) {
    console.log("Exectuing middleware A");
    //next();
});

router.use(function(req, res, next) {
    console.log("Exectuing middleware B");
    //next();
});

router.get('/login', function(req, res) {
    console.log("Inside login route");
    res.send('Hello World');
});

Output:
Exectuing middleware A

And the response is pending in the browser for this request...


text:
IFFR Coverage All Features Hollywood Features International Videos Weird Interviews
September 7 2011, 4:02 AM
ETRANGE 2011: REDLINE review
Contributor; Derby, England
What makes Takeshi Koike's Redline a work of sheer, unalloyed genius is that when you get down to it, it's simply a daft science fiction cartoon about racing cars very, very fast. Seriously, the simple premise is less a compromise of any kind than purity of vision. Koike, a longtime industry veteran is still probably best known in the West for Ninja Scroll, the hyper-stylised, ultra-violent paean to juvenile action fantasies that introduced many a child of the eighties to what anime was capable of, and in several ways Redline is an extension of that. It's an animator's film, not Vanishing Point: Koike doesn't really do depth or subtext per se.
In some far distant future a group of dedicated mavericks still race souped-up, customised autos in lengthy cross-country races on planets the length and breadth of the galaxy, where anything goes if it gets you across the finish line before everyone else. JP (Takuya Kimura) nurses a childhood dream to win the Redline, the last, most prestigious and dangerous of all these cannonball runs. The pretty girl he wants to impress and the ludicrous obstacles along the way are window-dressing, in some respects - we're here to see the hero point the wheel towards the horizon and floor the gas.
But Ninja Scroll was a surprisingly subtle experience beneath the gleefully excessive violence and self-indulgent excess. It wasn't a masterpiece by any lights but for such a juvenile film there was still a real sense of artistry and emotive power to the setpieces, and for such a simple idea it had more effective character development than most blockbusters do today. Redline has that same kind of self-awareness, the feeling of an auteur in control.
Koike and writing partner Katsuhito Ishii (The Taste of Tea, Funky Forest, Sharkskin Man and Peachhip Girl) know precisely what kind of story they're telling, but they're determined to get every last bit of mileage out of that narrow framework. Redline has none of Ninja Scroll's darker elements, its misogyny or exploitation; Koike and Ishii are having fun here, and the result is one of the most purely exhilarating films of any kind in years, both for the pleasure of seeing awesome cars doing impossible, demented things at breakneck speed and for a simple Hero's Journey simultaneously treated with sly, knowing humour and played utterly straight-faced.
The stupefying opening race sets up just how loud and colourful and inventive and breathlessly, thrillingly fast Redline is, but also how thoughtful. JP's a fallen hero whose unflagging loyalty finds him dragging a heavy ball and chain. His longtime partner, engineer Frisbee (Asano Tadanobu) has landed them in hock to a powerful crime syndicate that has the pair continually throwing pole position at the last possible moment for a big payday - enough that Frisbee's prepared to risk killing JP if it looks as if he's about to try to actually win. When a lucky break of sorts means JP ends up qualifying for Redline regardless, his childhood dream seems to be within his grasp.
At the same time this is a film where the final race takes on a planet ruled by fascist, trigger-happy cyborgs determined to crush the intruders with ludicrous, pyrotechnic weaponry like Akira on speed; where racers are introduced with giggling spoofs on every aspect of Japanese pop culture from idol videos to sentai shows and cheesy V-cinema; where studio Madhouse's animators stretch and distort drivers and their vehicles to the point every frame pops with more energy than Lichtenstein's fevered dreams.
And you realise all of it's equally, joyfully entertaining. When JP pops the nitrous and (cartoon) reality fisheyes to a ridiculous degree before he blasts away on a cone of rocket flames, it's fun. Yet so are the moments when his childhood admiration for pretty rival Sonoshee (Aoi Yuu) develops into something more romantic, or where he and Frisbee rediscover their bond through getting JP's Trans Am the power it'll need to win, or even where everyone, good guys and bad, are united by the pull of victory at any cost. Redline's climax is so staggeringly over-the-top as to glue you to your seat, caught between open-mouthed amazement and hysterical laughter, and Koike and Ishii are clearly aware of that.
But for all they're sending themselves up they're plainly caught up with the potential of their story, the drama as much as the sheer spectacle of it. Redline is a daft science fiction cartoon about racing cars very fast, but it treats every aspect of this with so much love, craftsmanship and passion it ends up every bit as fantastically cinematic (arguably more so) than films from Ghibli, Pixar et al with far more polish or budget. Far and away one of the most exciting animated movies of the decade at the very least and a blast of joyful pop-art adrenaline with a heart, Redline comes unhesitatingly recommended.
(Redline was screened as part of the 17th Etrange Film Festival in Paris from 2nd-11th September 2011. There's one more showing at the time of writing - if you're near the Forum Des Images on the 7th, get down there now for a chance to catch this one on a cinema screen.)
More about Redline
REDLINE Blu-ray Review (US)
REDLINE Blu-ray review
REDLINE BluRay Review
Camera Japan Festival 2011: REDLINE review
REDLINE (Takeshi Koike) Pick of the Crop Review

redpajama_set_name: RedPajamaCommonCrawl


text:
The Road to Irrelevance
Trivia literally means "three roads" in Latin. Seven roads led to a Roman education. The scientific routes were arithmetic, astronomy, geometry and music. The literary paths were grammar, rhetoric and logic. Those three roads–the Trivia– were not as esoteric as they seemed. If you were begging Nero for your life, you would want to be grammatical and eloquent.
However, as the Roman Empire disintegrated and was inundated by barbarian invasions, a well-rounded education became irrelevant. The Goths, Vandals and Huns really did not care about proper Latin grammar, and they had felt that brute force had its own logic. Yet, arithmetic remained important; barbarians liked to count what they stole. And music was still esteemed; the Germans always thought that they liked music, although a nation of Wagner fans obviously has more patience than pitch.
But even literacy would eventually revive in the Middle Ages. Someone had to write the place cards for the Round Table. However, the classical standards of literacy had become irrelevant. The Latin language that once linked all of Western Europe had either fragmented into the pidgin dialects of French and Spanish or had been completely eradicated by unappreciative barbarians like the Angle-Saxons. Latin standards for grammar really could not apply to different languages. Rhetoric was too estoric for a society that settled debates with a broadsword. Logic actually could be dangerous; the Medieval Church suspected it led to heresy.
So, by medieval standards the Trivia had become meaningless, irrelevant and questionable. Today, grammar, rhetoric and logic have regained some respectability; but the term "trivia" has not.
Tags: education, etymology, trivia
This entry was posted on Tuesday, April 29th, 2008 at 3:28 pm and is filed under English Stew. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Bob Kincaid says:
Might one argue, Eugene, that, under current circumstances, "trivia" has become "elitist?"
I've never met a moron yet who could stand people who win at "Trivial Pursuit."
Susan Cass says:
That explains why no one will play that game with me! I had wondered!
Peggles says:
It would have been doubly depressing to be thrown to the lions because of a dangling participle.


Cerdim turned his head to glance over his shoulder, in his usual sly and almost lazy demeanor. The Dunmer seemed to consider life itself a jape, a jest, a comedy he'd play along with until his inevitable end would come. There was not much in this world he actually took seriously. So when he saw his companion's giant of a sibling stomp towards the log they had seated themselves upon, he had to grin.
Beside him, Triskele regarded her brother with her characteristic calmth. She did not bother with a reply. Her sibling, the youngest by the looks of it, halted in front of them and pointed a dirty finger at the Dark Elf. Cerdim fixed his one, dark-red eye on it, as if he was looking at a bug.
Cerdim's smirk only grew more broad. The oaf made it sound as if he and his companion did inappropriate things to each other in whatever abandoned cave or shack they ventured across. As entertaining – and rousing – as that thought was to the Dunmer, the truth was as far from that image as it could get. He kept his silence as his one-eyed stare trailed over the short frame of Triskele Grár. Oh yes, the idea of doing exactly that which the world thought they did was more than appealing to him, but he had already lost an eye in his life, and had little interest in losing another along with other parts. Cerdim had traveled with his raven-haired companion many a time, and had yet to see a single male who left an impression on her. She was cold, his slender friend, cold and harsh and calculated, almost as much as he was. It's why he valued her so.
Triskele folded her arms across her chest. Her blue eyes narrowed.
Cerdim smiled, scratching the cloth covering the empty socket that once held an eye. Wrong.
Thorald grabbed her upper arm, but his wits were muddled and what was worse: he had called her 'little'. As soon as his fingers pinched in Triskele's arm, she spat in his face and gave him a hard push. Her tall brother fell with his back in the dirt of the riverbank, and a moment later Triskele jumped on top of him, aiming a clenched fist for his face. Cerdim never dropped his calm, amused smile as he lazily stood up from the log, cracking his neck side to side. He took a deep breath, the cold of night filling his lungs, completely at peace, as if he did not even hear the two siblings behind him in the dirt, beating the living hell out of one another. Cerdim strapped his bow across his back and shot a look over his shoulder.
His companion, held in a firm clench by Thorald's upper arm around her neck, gritted her teeth as she rammed an elbow into her brother's groin. As he let go of her with a wail, she took the moment of respite to give Cerdim a curt nod.
She panted and turned around, just in time to dodge the wooden beam Thorald swung at her. Her brother roared in anger, and the last Cerdim glimpsed was the image of both Triskele and Thorald grabbing each other's hair, pulling and kicking. He smiled, and walked away.
Cerdim did not stop walking, not until dawn. As he quietly scaled the woods, his thoughts were with the barrow. There was no doubt in his mind – nobody had touched the place. If the stories were true, he would come across a very royal amount of bounty, if they would manage to find the doors nobody had found before. He calmly hopped over a small stream, scaring off a wandering deer. His thoughts turned to his short friend. For the past year they had raided tombs together, ever since they had run into each other near the barrows around Windhelm. They had both aimed arrows at one another, and had in the end decided to let the other live, at least until they had made their way to the surface. Luckily for him, she had deemed him worthy of drawing breath as soon as they had crawled out of that pit. As I do her, and I don't think that of many people. He frowned as he thought of their past endeavours. Cerdim was an outcast, an outlaw, a thug without much of a conscience left to him. He was honest about his goals and his purpose – there was no nobility to his cause. That was why he did what he did. But Triskele, she was different.
His trail of thoughts stopped along with his feet. Ahead of him lay the bleak stones he had been looking for. He whistled a song between his teeth as he made his camp under a large sentinel nearby, the smell of pine, dew and snow cheering him up. After a while Cerdim sat down, his back resting against the bark of the tree, his single red eye on the barrow ahead.


text:
Shimanto-gawa Dai 1 bu: Atsuyoshi no natsu
[The Shimanto River, Part 1: Atsuyoshi's Summer]
By Sasayama Kyūzō
Kawade Shobō Shinsha (Kawade Bunko), 1991. 204 pp. ¥500. ISBN 978-4-309-40295-6.
Also published in: n/a
Atsuyoshi, in his third year of elementary school, is the second son among five siblings who live in a mountain village beside the Shimanto River in Kōchi Prefecture. Their parents run a grocery store, so the children help out with the housework as they while away the days in the great outdoors.
One day, Atsuyoshi's pet cat Kii gives birth to kittens. He has experienced many cat births before, but each time his mother Sumi would thin the litter, leaving behind only two kittens. If they raised too many cats, she said, it would interfere with business. This time, three kittens were born, so the smallest, Kuro, might be abandoned. Atsuyoshi, who sympathizes with weaklings, takes covert action, leading the tale to its surprising conclusion.
This epic novel has six volumes. The first volume, Atsuyoshi no natsu, consists of two chapters: "The Black Kitten" and "The Big Snake of Ubagatani Valley." When it appeared in 1988 it resonated with many readers, and a series of sequels were released. The sixth volume was published in 1996, finally completing the epic after nearly a decade.
In the novel, the beautiful natural environment of Shikoku is painted in vivid colors, along with the changing seasons. The ever-changing expressions of the mountains and breathing of the river are depicted in lifelike detail, in tune with the children's laughter that echoes across the river and through the valley, and in touch with the hearts of the people who live there. Without the experience of living on the banks of the Shimanto River, it would be impossible to write this. Against the lush backdrop of Mother Nature, the psychology of a young boy on the cusp of adolescence and the warm human relationships that surround the main characters are expressed in a breezy style of writing. (CK)
Sasayama Kyūzō
Born in Kōchi Prefecture in 1950. Received the Bungei Award in 1987 and the Tsubota Jōji Literary Prize in 1989 for Shimanto-gawa: Atsuyoshi no natsu. Completed the series in 1996 with Shimanto-gawa, dai 6 bu: Kokoro no naka o kawa ga nagareru [The Shimanto River, Part 6: A River Flows Through the Heart]. His other works include Yutaka wa tori ni naritakatta [Yutaka Wanted to Be a Bird] and Haha no Shimanto-gawa [My Mother's Shimanto River].
Kawade Shobō Shinsha Ltd.
2-32-2, Sendagaya, Shibuya-ku, Tokyo
Email: rights@kawade.co.jp


text:
Thu, 28 May, 2020 - 16:48
Cork court: Man will avoid prison if he sticks to drinking beer and avoids spirits
A 57-year-old man who put his wife in fear during a drunken incident will avoid a prison sentence if he confines his drinking to beer and stays clear of spirits.
Judge Con O'Leary said that if the man did drink spirits then he would be putting himself at risk of serving a one-month prison term.
Judge O'Leary imposed that sentence but suspended it on particular terms at an in-camera hearing of Cork District Court today dealing with a breach of domestic violence legislation.
The 57-year-old pleaded guilty to the charge of breaching a safety order by putting his wife in fear on May 8 at the front door of the family home.
After hearing an outline of what happened on that date from Inspector Conor Dillon, Judge O'Leary asked the defendant's wife to step forward in the courtroom.
"What do you want him to do?" the judge asked the complainant.
She replied, "I have nothing against him having a few beers once or twice a week but when spirits come into it, it is a problem."
As soon as the complainant made that comment, Judge O'Leary made the following order: "One month imprisonment suspended on condition that he enters a bond not to consume any alcohol, save beer, for 12 months."
The judge then turned to the complainant and explained the effect of the order.
"I am sentencing him to prison but suspending it on condition he only drinks beer. That is what you are suggesting," Judge O'Leary said to the complainant.
She replied, "Yes, no problem when he only drinks beer."
The judge went on to clarify, "And obviously, he must be of good behaviour and does not damage his own domestic dwelling and assault or threaten his wife. He has to stay off spirits.
"If he does, he goes to prison, for a short period, but he goes," the judge said.
Defence solicitor, Shane Collins-Daly, said the parties continue to reside together and have reconciled since the incident.
"He is pleading guilty to this offence. He openly admits drink would be an issue but he has cut down hugely in recent years," Mr Collins-Daly said.
Inspector Dillon said, "The defendant had been drinking all day and returned home at 9pm. He kicked the front door and was verbally abusive to his wife.
"He put her in fear in her own home. He was arrested in the front garden of the house.
While the defendant had no convictions since 2016 he had a total of 19 convictions for offences including breaches of the Criminal Justice (Public Order) Act.
cork court


i've heard a variety of rumors regarding WKO's being defunct and new regional tourney set ups for qualifying for Nats and then Worlds. Has anyone heard anything definitive?
Nothing definitive has been announced yet, but what you've heard is currently the leading rumor with some solid sources confirming it at a general level (though I've only heard this second/third hand myself).
They should just bite the bullet and copy FFG's OP structure to a T.
Can someone explain what the current system is to someone who has no idea? I remember hearing something about what I think was Canadian Nationals around the time I started really getting in to DM. And I know that Worlds was at Origins, and that there were qualifiers a couple days beforehand, but was there other ways to get into Worlds?
There were two ways to get into Worlds in 2015. The first was to win a national championship (or come in the top two at US nationals). The second was to finish in the top 16 in one of the two qualifying events that occurred at origins on the two days immediately preceding the worlds championships.
i get inklings of information on occasion. There was some word of a possible TCG player affiliation that could result in qualifiers but my source said "to my knowledge there is no affiliation with TCGplayer for DM." I asked WK on FB and they basically confirmed WKO is done and that they are working on a qualifying structure and hope to release it soon. My source also pointed out that at a minimum they currently expect to have US Nationals around the same time next year, no word of the venue staying the same or changing.
I can tell you they will NOT be working with tcgplayer. I think that bridge was already burned. Now tcgplayer may be working on something for dice masters but I haven't heard anything other than that they had looked at it.
And yes, WKO are done. It was said that it was hard for wizkids to get the logistics down for moving that much product around to the stores in the time frame they had. It could be another reason but that's what I recall hearing.
I really hope they announce it. Not always the easiest to make short notice plans in Canada.
Yeah, remember that TCGPlayer is associated with HCRealms, and the HCR/WK relationship hasn't exactly been rosy.
There was an agreement for them to work together in what is now the ROC series. Wizkids actually sponsored them the first year. Then, something happened and they had a falling out and at Gencon that year they officially split with Wizkids wanting more control over things. On one hand, I understand them wanting to keep control over how their product is presented and while I've been on the realms since 2002, it's not the warmest place to visit. The roc however is a great great thing and has only helped grow Heroclix as a game. It's done very well without Wizkids, I can only imagine how well it'd do with their involvement.
WizKids is pleased to announce our first 2015 regional tournament event to be held at Salt Lake Comic Con, September 24th-26th.
Get ready to do damage on the tabletop with HeroClix, Dice Masters and Attack Wing events. Play amazing games, win rare prizes, buy convention exclusives and earn your ticket to the 2015 US National Championships!
More information on dates and locations of WizKids Regional Championships coming soon!
Oh man, I will be at the Great American Beer Festival, no shot I'm making it out to SLC those dates!
Didn't we already have the 2015 US national championships? It seems weird to have it twice in one year.
Edit: Literally impossible for me to plan on something a month in advance because I get paid once a month. WizKids really needs to announce their stuff further in advance. It's impossible for us CDAC guys.
I'd be blown away if there are not NW and Cal regionals.
Here's hoping they announce more reg. Been itching to play another big dicemasters tournament, would be great to play for the regional title of my home turf of cali lol.
Very excited to see some updates. It will be interesting to see where they position these regionals.
"Salt Lake Comic Con 2015 – September 24-26"
Oh, you mean "buy convention exclusives and earn your ticket to the 2015 US National Championships!"
Yeah, LOL! Clearly a typo!
Very exciting! Can't wait to find out where they will be in my area!