# safety
set -euo pipefail
# root directory
ROOT_DIR="$(cd $(dirname $0)/.. ; pwd)"
# directory of this script
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
Show hidden characters
{ | |
"compilerOptions": { | |
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | |
"module": "none" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, | |
"allowJs": true /* Allow javascript files to be compiled. */, | |
"checkJs": true /* Report errors in .js files. */, | |
"noEmit": true /* Do not emit outputs. */, | |
"noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */, | |
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, | |
"skipLibCheck": true /* Skip type checking of declaration files. */, |
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 fetch = require('node-fetch'); | |
function request (options, cb) { | |
fetch(options) | |
.catch(cb) | |
.then(res => { | |
return res.body() | |
.then(body => { | |
cb(null, res, body); | |
}, cb); |
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
#!/bin/bash | |
set -euo pipefail | |
set -x | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
# set OLD_DIRECTORY and NEW_DIRECTORY | |
# OLD_DIRECTORY=/Users/your_username/Music | |
# NEW_DIRECTORY=/Volumes/your_external_drive/Music | |
OLD_DIRECTORY= |
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 Layer = require('express/lib/router/layer'); | |
Layer.prototype.handle_request = async function handle(req, res, next) { | |
var fn = this.handle; | |
if (fn.length > 3) { | |
// not a standard request handler | |
return next(); | |
} | |
try { |
event.requestContext.identity.cognitoIdentityId
should be the user id- Cognito User Pools are for handling user registration, authentication, and account recovery
- Cognito Identity Pools (or Cognito Federated Identities) are a way to authorize users to directly use the various AWS services in your account, such as S3, DynamoDB, and, most relevant for APIs, API Gateway
resources:
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
#!/bin/bash | |
# | |
# What is that | |
# ============ | |
# | |
# This script will help you setting up your digital ocean | |
# infrastructure with Ansible v2.0+ and DO API v2 | |
# | |
# Usually, when working with DO, one is supposed to use digital_ocean.py | |
# inventory file, and spin up instances in a playbook. |
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
var fs = require("fs"); | |
var path = require("path"); | |
var outfile = path.resolve(__dirname, "appPrefs.json"); | |
var lockfile = outfile + ".lock"; | |
var data = "some data or other"; | |
// obtain an exclusive read/write file handle on the semaphore file | |
fs.open(lockfile, "wx+", function (err, fd) { | |
if (err) { |
NewerOlder