Skip to content

Instantly share code, notes, and snippets.

View dashawk's full-sized avatar

Jason Panugaling dashawk

  • Cebu City, Philippines
View GitHub Profile
@dashawk
dashawk / authorize.js
Created January 24, 2021 03:36 — forked from kndt84/authorize.js
Sample code: how to refresh session of Cognito User Pools with Node.js and Express
const AWS = require('aws-sdk');
const CognitoUserPool = require('amazon-cognito-identity-js-node').CognitoUserPool;
const CognitoUserSession = require('amazon-cognito-identity-js-node').CognitoUserSession;
const CognitoUser = require('amazon-cognito-identity-js-node').CognitoUser;
const CognitoIdToken = require('amazon-cognito-identity-js-node').CognitoIdToken;
const CognitoAccessToken = require('amazon-cognito-identity-js-node').CognitoAccessToken;
const CognitoRefreshToken = require('amazon-cognito-identity-js-node').CognitoRefreshToken;
const cfg = require('config').config;
const COGNITO_IDENTITY_POOL_ID = cfg.COGNITO_IDENTITY_POOL_ID;
@dashawk
dashawk / cors.js
Created June 19, 2020 04:15 — forked from balupton/cors.js
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);
var chalk = require('chalk')
const { exec } = require('child_process');
var version = require('../version')
var type = process.argv[2],
moduler = process.argv[3],
message = process.argv.slice(4, process.argv.length).join(' '),
commands = [
"git add .",
"git commit -m \"" + type + "@" + version.pro_version + "(" + moduler + "): " + message + "\"",
// reference https://gist.github.com/GuillermoPena/9233069#gistcomment-2636187
// sha-cli.js
const filename = process.argv[2];
const crypto = require('crypto');
const fs = require('fs');
const hash = crypto.createHash('sha256');
const input = fs.createReadStream(filename);
input.on('readable', () => {
const data = input.read();
@dashawk
dashawk / gist:1679fc60cdbbc4945831fcc0d00d0d4f
Created February 28, 2019 06:06 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
var points = [{x:1,y:1}, {x:2,y:5}, {x:3,y:1}];
var scaleFactor = canvas2width/canvas1width;
var scaledPoints = points.map(function(p) {
return {
x:p.x*scaleFactor,
y:p.y*scaleFactor
};
});
@dashawk
dashawk / Configuration.h
Created July 18, 2018 13:48 — forked from istepanov/Configuration.h
Marlin Anet A8 config
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext("2d");
var myPoints = [
[37.772,-122.214],
[21.291, -157.821],
[-18.142, 178.431],
[-27.467, 153.027]
]
@dashawk
dashawk / node-part-1.md
Last active February 9, 2018 06:55
Run NodeJS with Systemd Part 1
@dashawk
dashawk / node-part-2.md
Created February 9, 2018 06:54
Run NodeJs with Systemd Part 2