background preloader

Web

Facebook Twitter

Déployer notre code. JavaScript Promises. The JavaScript Promise API is awesome but can be made amazing with async and await!

JavaScript Promises

While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready? Promises are becoming a big part of the JavaScript world, with many new APIs being implemented with the promise philosophy. Let's take a look at promises, the API, how it's used! Promises in the Wild. Sequelize Table Associations (Joins)

This post goes step-by-step through a basic example (a blog with users, posts, and post comments) of associating tables using the Node ORM, Sequelize.

Sequelize Table Associations (Joins)

I will include the data used in the examples, as well as a GET API endpoint that interacts with our tables, sending back beautifully transformed responses. Three POST endpoints are found in the accompanying repo, but will not be covered here. The examples below use Node version 6, and Sequelize 3.24.1. I encourage you to clone the aforementioned repo for reference. The Sequelize docs on associations can be found here. Introduction Sequelize is a Node package that allows the developer to interact with a variety of SQL databases using a single API. This means you, the developer, can write object-oriented code and Sequelize will translate it into a SQL dialect. Sequelize is promise-based, which is awesome! If you'd like a nice overview of JavaScript promises, I suggest you check out David Walsh's post on the topic. Models Users Posts. MarshallOfSound/electron-routes: Express like API for hosting content inside an Electron app. Using Express inside Electron.

I'm going to be honest, this was a bait and switch title.

Using Express inside Electron

Mainly because in my opinion you should never use Express inside Electron. There are a number of reasons for this, so in no particular order. You would be opening up a publicly accessible port on your users machine. Any program on that machine or any website loaded in a browser could connect to your local express instance.It won't work on some user's machines due to their firewall settings. It simply won't let you open the port.Express doesn't make much sense in the world of Electron. Well that's an easy question to answer, they like it, the api is simple and it means they can make REST based web apps inside Electron with an architecture they are used to. So I got bored one day and made a tool called electron-router. Here is a super simple example of what you can do with electron-router. Now from the renderer process we can use our router API like any other HTTP endpoint, just with our custom scheme out the front.

Les variables CSS - CSS : Feuilles de style en cascade. Les variables CSS sont des entités définies par les développeurs ou les utilisateurs d'une page Web, contenant des valeurs spécifiques utilisables à travers le document.

Les variables CSS - CSS : Feuilles de style en cascade

Elles sont initialisées avec des propriétés personnalisées (par exemple --main-color: black;) et accessibles en utilisant la notation spécifique var() (par exemple : color: var(--main-color);). Utilisation simple Voici comment on déclare une variable : Et voici comment on l'utilise Problématique Lors de l'élaboration de sites de grande envergure, leurs auteurs font parfois face à des soucis de maintenabilité. Le problème peut s'aggraver en utilisant les frameworks CSS puisque modifier une couleur demande de modifier le framework lui-même.

Le deuxième avantage de ces variables vient du fait que le nom lui-même contient des informations sémantiques. Utilité des variables CSS Dans les langages de programmation impératifs, comme Java, C++, ou encore JavaScript, le fonctionnement peut être tracé à travers la notion de variables. Dwightjack/vue-types: Vue Prop Types definitions. A SQLite Tutorial with Node.js. In this tutorial I will be demonstrating how to use SQLite in combination with JavaScript inside the Node.js environment with the help of the sqlite3 Node.js driver.

A SQLite Tutorial with Node.js

For those not familiar with SQLite, it is a simple single file relational database that is very popular among smart devices, embedded systems, and even small web application. Setup and Installation I will begin by creating a new npm package using npm init inside an empty directory called node-sqlite-tutorial. Next I will need to install sqlite3 package via npm like so: $ npm install --save sqlite3 In addition to sqlite3 I am going to install Bluebird so that I can use the familiar promise functionality in my database programming. $ npm install --save bluebird I now will create an empty file right next to the package.json file called database.sqlite3 that SQLite will store data in. Designing the Database The application has projectsEach project can have one or more tasks to complete projects table tasks table Creating the Database.

Sequelize/sequelize-auto: Automatically generate bare sequelize models from your database. How To Zoom on Hover with CSS.