You may need to configure a proxy server if you're having trouble cloning
or fetching from a remote repository or getting an error
like unable to access '...' Couldn't resolve host '...'.
Consider something like:
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Index</title> | |
| <script type="text/javascript"> | |
| window.open ("popup.html","mywindow", "width=350,height=250"); | |
| // Create IE + others compatible event handler |
| var aws = require('aws-sdk'); | |
| var BUCKET = 'node-sdk-sample-7271'; | |
| aws.config.loadFromPath(require('path').join(__dirname, './aws-config.json')); | |
| var s3 = new aws.S3(); | |
| var params = { | |
| Bucket: 'node-sdk-sample-7271', | |
| Delete: { // required | |
| Objects: [ // required | |
| { |
| "use strict"; | |
| var crypto = require("crypto"); | |
| var EncryptionHelper = (function () { | |
| function getKeyAndIV(key, callback) { | |
| crypto.pseudoRandomBytes(16, function (err, ivBuffer) { | |
| var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ; |
#Understanding closures, callbacks and promises
For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.
10 months into my full-time dev career, and I would struggle to explain these words to a peer.
So I decided it was time to face my fears, and try to get my head around each concept.
Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.
| import { createCipheriv, createDecipheriv, randomBytes } from "crypto"; | |
| const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters) | |
| const IV_LENGTH: number = 16; // For AES, this is always 16 | |
| /** | |
| * Will generate valid encryption keys for use | |
| * Not used in the code below, but generate one and store it in ENV for your own purposes | |
| */ | |
| export function keyGen() { |
| const price = 1234.567; | |
| const formattedPrice = price.toLocaleString('en', { | |
| style: 'currency', | |
| currency: 'USD' | |
| }); | |
| console.log(formattedPrice); // "$1,234.57" |
| const cors = require('cors')({origin: true}); | |
| exports.sample = functions.https.onRequest((req, res) => { | |
| cors(req, res, () => { | |
| res.send('Passed.'); | |
| }); | |
| }); |
Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.
To learn more about migrations, check out this article on the different types of database migrations!
| // Copyright (c) 2017, Ben Noordhuis <info@bnoordhuis.nl> | |
| // | |
| // Permission to use, copy, modify, and/or distribute this software for any | |
| // purpose with or without fee is hereby granted, provided that the above | |
| // copyright notice and this permission notice appear in all copies. | |
| // | |
| // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
| // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
| // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
| // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |