using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
nginx: | |
restart: always | |
build: | |
context: . | |
dockerfile: Dockerfile-nginx | |
container_name: nginx-container | |
ports: | |
- "443:443" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
# SSL configuration | |
listen 443 ssl default_server; | |
listen [::]:443 ssl default_server; | |
server_name _; | |
ssl_certificate /etc/nginx/ssl/nginx.crt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <sys/file.h> | |
#include <unistd.h> | |
#include <string.h> | |
struct record { | |
int userid; | |
char username[6]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run my-app — image=gcr.io/some-repo/my-app:v1 — port 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const file = 'sample.txt'; | |
// Execution Starts here | |
// We just want to read some data from a file, update it, write it back and read it again. | |
// This is what it will look like with callbacks - welcome to the Callback Hell! | |
read(file, data => { | |
console.log('READ-1:', data); | |
// Now we'll change the text. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const FILE = 'sample.txt'; | |
// Read the file for the first time and display contents | |
fs.readFile(FILE, 'utf8', (err, data) => { | |
if (err) console.log('Error:', err); | |
console.log(data); | |
// Now write 'Updated content' to the file | |
fs.writeFile(FILE, 'Updated content', err => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const FILE = "sample.txt"; | |
// This function returns a promise that the 'text' we pass into | |
// this function has been asynchrnously written into our FILE. | |
const writePromise = text => { | |
return new Promise((resolve, reject) => { | |
fs.writeFile(FILE, text, err => { | |
if (err) reject(err); | |
else resolve(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myPromise = new Promise((resolve, reject) => { | |
// do something asynchronous which eventually calls either: | |
// | |
// resolve(someValue); // when fulfilled | |
// or | |
// reject("failure reason"); // upon failure or rejection | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const FILE = "sample.txt"; | |
// Writes given text to a file asynchronously. | |
// Returns a Promise. | |
function write(text) { | |
return new Promise((resolve, reject) => { | |
fs.writeFile(FILE, text, err => { | |
if (err) reject(err); | |
else resolve(); |
OlderNewer