Skip to content

Instantly share code, notes, and snippets.

View skyksit's full-sized avatar

Richard skyksit

View GitHub Profile
@skyksit
skyksit / package.json
Created April 16, 2021 01:52 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@skyksit
skyksit / authorize.js
Created June 9, 2020 22:49
serverless api gateway auth
const _ = require('lodash');
const jwt = require('jsonwebtoken');
const utils = require('../lib/utils');
const authorizeUser = (userScopes, methodArn) => {
console.log(`authorizeUser ${JSON.stringify(userScopes)} ${methodArn}`);
const hasValidScope = _.some(userScopes, scope => _.endsWith(methodArn, scope));
return hasValidScope;
};
@skyksit
skyksit / response.js
Created May 27, 2020 00:31
javascript http response util function
module.exports.ok = function (body, headers) {
return {
statusCode: 200,
body: JSON.stringify(body),
headers: headers || {}
}
}
module.exports.notFound = function (message) {
return {
@skyksit
skyksit / dynamodb.js
Created May 27, 2020 00:13
dynamodb connection function
const AWS = require('aws-sdk');
const dynamoDb = new AWS.DynamoDB.DocumentClient();
module.exports.scan = function (table) {
return new Promise((resolve, reject) => {
const params = {
TableName: table
}
'use strict';
const _ = require('underscore'); // 1.7.0
const AWS = require('aws-sdk'); // 2.2.46
const delay = 3000;
let deletedIamUsers = 0;
let creds = {
accessKeyId: '<insert your accessKeyId>',
@skyksit
skyksit / updateNpm.bat
Created November 28, 2019 00:07
npm version update on windows's nvm
rem see https://github.com/coreybutler/nvm-windows/issues/300
@echo off
SETLOCAL EnableDelayedExpansion
if [%1] == [] (
echo Pass in the version you would like to install, or "latest" to install the latest npm version.
) else (
set wanted_version=%1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/main.css"/>
</head>
<%
let date = new Date();
%>
var express = require("express");
var ejs = require("ejs");
var app = express();
app.set("views", __dirname + "/views");
app.set("view engine", "ejs");
app.engine("ejs", ejs.renderFile);
app.use(express.static("public"));
var express = require("express");
var ejs = require("ejs");
var app = express();
app.set("views", __dirname + "/views");
app.set("view engine", "ejs");
app.engine("html", ejs.renderFile);
app.use(express.static("public"));
module.exports = function(app){
let html = "<!DOCTYPE html>"
+ "<html>"
+ "<head>"
+ "<meta charset='UTF-8'>"
+ "<title>Insert title here</title>"
+ "<link rel='stylesheet' href='css/aaa.css'/>"
+ "</head>"
+ "<body>"
+ " <h1 class='c1'>ROOT.html</h1>"