Skip to content

Instantly share code, notes, and snippets.

View Agoreddah's full-sized avatar

Tomas Agoreddah

  • Kleidi, s.r.o
  • Slovak Republic
View GitHub Profile
@Agoreddah
Agoreddah / awscdn-invalidation.sh
Created May 22, 2019 14:30
AWS Cloudfront (CDN) invalidation script
#!/bin/bash
#================================================================
# HEADER
#================================================================
#% SYNOPSIS
#+ ${SCRIPT_NAME} --distributionId "argument" [--help]
#%
#% DESCRIPTION
#% Function to run AWS CDN invalidation and finishes when invalidation status is set to Completed. Invalidation path is set to '/*' by default.
@Agoreddah
Agoreddah / encrypter.js
Last active October 2, 2024 07:13
Laravel encrypt & decrypt in Node.js
// load variables
require('dotenv').config();
// load dependencies
const crypto = require('crypto');
'use strict';
const APP_KEY = process.env.APP_KEY;
@Agoreddah
Agoreddah / getSimpleToken.js
Last active November 29, 2018 13:30
Simple token generator with bin2hex in node.js
const crypto = require('crypto');
/**
* Convert binary to hex.
* @param {Number} bytesLength
*/
function bin2hex( bytesLength ){
let bin = crypto.randomBytes( bytesLength );
return new Buffer( bin ).toString( "hex" );
}
@Agoreddah
Agoreddah / gist:c4815261a5d08d7b226f80296702f4af
Created June 6, 2018 09:10
Installing MongoDB specific 3.4. verion on Ubuntu 16.04
#!/bin/sh
# Αdd GPG public key
echo "adding gdp public key"
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Create MongoDB list file in /etc/apt/sources.list.d/
echo "creating mongo list file"
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-3.4.list
@Agoreddah
Agoreddah / gist:cb65b72e6c7a35691b4a5dc179ec2759
Created August 3, 2017 08:54
Calculate price with mongo aggregate query - Evaluate array of dates with array of prices
// Simple document example
// Every boat contains array of prices for different days
// We decided to use simple concatenated date int to evaluate date ranges, f.e. date '2017-08-24' becomes integer 20170824
// If user wants to reservate boat in dates when prices is not defined, it will not be shown in results
Boat = {
_id : ObjectId("100000000000000000000001"),
prices : [
// price available for august
{
price : NumberInt(100),