Skip to content

Instantly share code, notes, and snippets.

@fedeolto
fedeolto / test.js
Last active March 15, 2018 15:41
chain 2 async calls in a javascript file client side and manage errors per each call and after all submit a form
function chainAjaxCalls(form) {
function a() {
return $.ajax({
url: "https://reqres.in/api/login",
type: "POST",
data: {
email: "function_a",
password: "xyz"
@fedeolto
fedeolto / app.js
Created February 7, 2018 10:15
jQuery DataTable Server-side processing with ExpressJs. In this very basic example let's forget for a moment about filtering and ordering
baseRouter.get('/fruitsList', (req, res) => {
/*
DataTable when Server-side processing is true sends the data it needs in the query string as you can
see in the network tab of any web inspector filtering GET XHR requests.
remember to always parse integer parameters to avoid any possible SQLinjection or XSS attack
(as DataTable Server-side processing documentation recommend too)
*/
var draw = parseInt(req.query.draw);
var start = parseInt(req.query.start);
var length = parseInt(req.query.length);
@fedeolto
fedeolto / Cable.java
Created June 3, 2015 12:30
test in which a statement in Expectations can be totally omitted in FullVerificationsInOrder block without test broke
package com.example;
public class Cable {
private boolean isPluggedIn;
public void plugIn() {
isPluggedIn = true;
}