Skip to content

Instantly share code, notes, and snippets.

View Daniel-M's full-sized avatar
💻
Coding

Daniel Mejía Raigosa Daniel-M

💻
Coding
View GitHub Profile
@Daniel-M
Daniel-M / segmentArray.js
Last active February 9, 2019 22:48
convert a long input array into an array of smaller arrays segments of a given size
'use-strict'
const longArray = [0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14,
15, 16, 17, 18, 19,
20, 22, 23, 24, 25,
26, 27, 28, 29, 30,
31, 32, 33, 34, 35]
@Daniel-M
Daniel-M / ecosystem.config.js
Created January 24, 2019 05:38
pm2 ecosystem.config.js example file. Refer to https://pm2.io/doc/en/runtime/reference/ecosystem-file/
module.exports = {
apps : [{
name: 'Name shown in pm2 process list',
script: 'index.js',
log: 'process.log',
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
instances: 1,
autorestart: true,
restart_delay: 5000,
watch: false,
@Daniel-M
Daniel-M / non_repeating_random_matrix.py
Created January 23, 2019 02:11
generates a matrix of non-repeating random numbers.
import numpy as np
def get_random(a=0,b=10):
"""
Generates a random number in the range [a,b]
"""
return (b-a)*np.random.rand() + a
def non_repeating_random(m=10,n=10, a=0,b=1, iteration_limit=5000):
@Daniel-M
Daniel-M / Iterator_generator.js
Created December 18, 2018 21:37
Simple example of Iterators and Generators with arrays of promises in nodejs
// arrayToGenerator is a element generator that returns a element iterable
// each iterable.next() returns the next element in the elements array
function* arrayToGenerator(elementArray) {
if (!elementArray){
return null
}
const len = elementArray.length - 1
for (let i = 0; i < len; i++) {
yield elementArray[i]
@Daniel-M
Daniel-M / init.vim
Created December 3, 2018 20:16
My neovim configurations `./config/nvim/init.vim`
" let g:python_host_prog = '/usr/bin/python2'
" let g:python3_host_prog = '/usr/bin/python3'
" *************************************
" PLUGIN SECTION for Vim-Plug
" *************************************
call plug#begin('~/.config/nvim/plugged')
" Make sure you use single quotes
@Daniel-M
Daniel-M / concurrent_blinker.c
Created October 15, 2018 19:09
ESP32 exception log
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
void blink_task(void* pvParameters) {
printf("[task] ******************************************\n");
@Daniel-M
Daniel-M / claudiajs_upload.sh
Last active October 8, 2018 15:24
Updated version of the script
# The AWS region
aws_region="us-east-2"
#DEPLOYMENT_NAME is defined, 100% sure since the script won't execute otherwise
# The names for the groups
lambda_s3_rekog_ec2_cw_ses="$DEPLOYMENT_NAME-lm-s3-rkog-ec2-cw-ses"
# The names for the roles
school_lambda_ses_role="$DEPLOYMENT_NAME-lambda_ses_role"
@Daniel-M
Daniel-M / claudiajs.sh
Created October 5, 2018 22:37
ClaudiaJS create instruction wont work
# Within a bash script, I'm using the following instruction to upload a lambda function using AWS API Gateway
# It won't upload the function under the name I put in the $registerStudent variable
# Also, it won't save the results under the name $DEPLOYMENT_NAME-$registerStudent-claudia.json
# What is going on?
claudia create --region $aws_region \
--api-module index \
--name $registerStudent \
--role $school_lambda_ses_role \
@Daniel-M
Daniel-M / russian_roulete.sh
Created September 3, 2018 18:16
Russian Roulete in bash
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf ~ || echo "click"
@Daniel-M
Daniel-M / etc_pulse_default.pa
Created August 6, 2018 22:46
contents of etc/pulse/default.pa
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but