Skip to content

Instantly share code, notes, and snippets.

@marcusjack
marcusjack / gen_hmac.js
Created April 7, 2020 09:32 — forked from turret-io/gen_hmac.js
Generate HMAC in NodeJS
var crypto = require('crypto');
var SHARED_SECRET = "sup3rs3cr3t!!";
function signString(string_to_sign, shared_secret) {
var hmac = crypto.createHmac('sha512', shared_secret);
hmac.write(string_to_sign);
hmac.end()
return hmac.read();
}
@marcusjack
marcusjack / client.html
Created April 7, 2020 09:32 — forked from agrueneberg/client.html
HMAC-SHA256 example for verifying both the data integrity and the authentication of a request in Node.js and web browsers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HMAC-SHA256 Example</title>
</head>
<body>
<script src="http://crypto.stanford.edu/sjcl/sjcl.js"></script>
<script>
var sharedSecret, query, signature, hmac, xhr;
@marcusjack
marcusjack / verify_hmac.js
Created April 7, 2020 09:33 — forked from turret-io/verify_hmac.js
Verify HMAC in NodeJS
var crypto = require('crypto');
// Added for safer string equality checking
var bufferEq = require('buffer-equal-constant-time');
var url = require('url');
var SHARED_SECRET = "sup3rs3cr3t!!";
function verifySignature(string_to_sign, signature, shared_secret) {
var hmac = crypto.createHmac('sha512', shared_secret);
hmac.write(string_to_sign);
hmac.end()
@marcusjack
marcusjack / ultimate-ut-cheat-sheet.md
Created May 26, 2020 05:03 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@marcusjack
marcusjack / assume-role-policy.json
Created August 20, 2020 12:27 — forked from clstokes/assume-role-policy.json
Example: Terraform IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@marcusjack
marcusjack / cloudformation-dynamoDB.yml
Created March 22, 2021 23:43 — forked from DavidWells/cloudformation-dynamoDB.yml
Example of dynamo cloudformation with GSI and LSI
---
AWSTemplateFormatVersion: '2010-09-09'
Resources:
myDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: Album
AttributeType: S
- AttributeName: Artist
@marcusjack
marcusjack / android-generate-keystores.md
Created August 7, 2021 20:38 — forked from henriquemenezes/android-generate-keystores.md
Android: Generate Release/Debug Keystores

Android: Generate Release/Debug Keystores

Generate Keystores

Debug Keystore

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
@marcusjack
marcusjack / nginx.conf
Created October 3, 2021 03:35 — forked from scalablescripts/nginx.conf
Docker nginx
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost;
@marcusjack
marcusjack / JobProcessor.ts
Created October 21, 2021 09:10 — forked from Eunovo/JobProcessor.ts
Code describing a system to handle CPU-intensive jobs on NodeJS servers
class JobProcessor {
private assignedJobs = new Map<String, any>();
private queue = new Queue<any>();
private nWorkers = 5;
async loadOutstandingJobs() {
// load 'pending' or 'processing' jobs from DB
const jobs = await services.Job
.findMany({
$or: [
@marcusjack
marcusjack / delete-slack-messages.js
Created March 19, 2023 19:44 — forked from firatkucuk/delete-slack-messages.js
Deletes slack public/private channel messages, private chat messages and channel thread replies.
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = 'SLACK TOKEN';
// Legacy tokens are no more supported.
// Please create an app or use an existing Slack App