Skip to content

Instantly share code, notes, and snippets.

View damiancipolat's full-sized avatar
💭
Creating amazing things!

DamCipolat damiancipolat

💭
Creating amazing things!
View GitHub Profile
stages:
- test
- build
- deploy
- notify
run_test:
stage: test
image: node:10.16.0-alpine
script:
import 'dart:convert';
void main(){
var nombre = 'Damian';
var empresa = 'My drugs';
int precio = 100;
double pi = 3.141592;
bool activado = true;
@damiancipolat
damiancipolat / busyWait.js
Created May 26, 2020 04:44
Make a busy wait in JS
/**
* Create a sleep function using promise.
* @param {number} ms - duration time in milliseconds.
*/
const sleep = (ms) => new Promise(resolve => setTimeout(()=>resolve({time:ms}), ms));
/**
* Loop until have the success condition.
* @param {function} condition - boolean function that return the condition.
* @param {number} timeout - limit execution time.
@damiancipolat
damiancipolat / busyWait.js
Created May 26, 2020 04:44
Make a busy wait in JS
/**
* Create a sleep function using promise.
* @param {number} ms - duration time in milliseconds.
*/
const sleep = (ms) => new Promise(resolve => setTimeout(()=>resolve({time:ms}), ms));
/**
* Loop until have the success condition.
* @param {function} condition - boolean function that return the condition.
* @param {number} timeout - limit execution time.
@damiancipolat
damiancipolat / aws-rekognition-decode-image64.js
Created May 14, 2020 14:35
Aws rekognition lambda - read image from encoded image using base64
const AWS = require('aws-sdk');
const rekognition = new AWS.Rekognition();
//Analyze image.
const analyzeImg = (image) => rekognition.detectFaces(image).promise();
//Decode image.
const decodeImage = (image64)=>{
return {
@damiancipolat
damiancipolat / rekognitionLambda.js
Created May 11, 2020 15:04
Example of use rekognition - detect faces
const AWS = require('aws-sdk');
const rekognition = new AWS.Rekognition();
const s3 = new AWS.S3({apiVersion: "2006-03-01"});
exports.handler = async (event) => {
const params = {
Attributes: ["ALL"],
Image: {
S3Object: {
@damiancipolat
damiancipolat / git_hook_package.json
Created April 30, 2020 00:44
Bash script to control the package.json version in js projects
#!/bin/bash
set -o nounset
set -o errexit
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'
@damiancipolat
damiancipolat / bash-githook.sh
Created March 12, 2020 03:24
Bash script to avoid same package.json version to be used in a githook.
#!/bin/bash
set -o nounset
set -o errexit
REPO_ROOT=$(git rev-parse --show-toplevel)
echo "Git repo is at $REPO_ROOT"
SITE_CHANGES=$(git diff origin/develop -- ./package.json | grep version | wc -l)
echo "Detected $SITE_CHANGES changes"
@damiancipolat
damiancipolat / array_filter_in_worker.js
Created February 26, 2020 04:21
Array file prototype using a worker
const workerpool = require('workerpool');
const pool = workerpool.pool({maxWorkers: 7});
//Define filter prototype for be used into a worker.
const filterWorker = (values,fnStr) => values.filter(eval(fnStr));
//Declare new prototype for array filter into a worker.
Array.prototype.filter = async function(fn){
//Assign the operation in the worker.
@damiancipolat
damiancipolat / awsParamStoreInLambda.js
Created February 18, 2020 00:47
Aws parameter store example into a lambda function
const AWS = require('aws-sdk')
AWS.config.update({
region: 'us-east-1'
})
const parameterStore = new AWS.SSM();
module.exports.get = async (event, context) => {