Skip to content

Instantly share code, notes, and snippets.

View israelalagbe's full-sized avatar

Israel Alagbe israelalagbe

View GitHub Profile

GET and Export all environment variables from elastic beanstalk

Bash Script

declare values="$(/opt/elasticbeanstalk/bin/get-config environment)"
for s in $(echo $values | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ); do
    export $s
done
@israelalagbe
israelalagbe / Readme.md
Created August 13, 2020 20:40 — forked from StefanieD/Readme.md
Install and use Supervisord with AWS Elastic Beanstalk, Symfony 2 and RabbitMq Bundle
  • Place the supervisord.conf under .ebextensions/supervisor/

  • Place the supervisor.config under .ebextensions/

  • Place the data_import_consumer.conf under .ebextensions/supervisor/

@israelalagbe
israelalagbe / getUsersByChunkSize.js
Last active February 26, 2025 01:09
Mongoose Get Decuments In Chunk (MongoDB)
const getUsersByChunkSize = async function * (chunkSize = 10) {
const limit = chunkSize;
let page = 1;
const total = await User.countDocuments({});
for(let startAt = 0; startAt < total; startAt += limit) {
const users = await User.find({}).skip(startAt).limit(limit);
@israelalagbe
israelalagbe / form.jsx
Created May 17, 2022 17:23
Formik Custom component
import React from 'react';
import { Form, Formik } from 'formik';
import * as Yup from 'yup';
import { Button } from '../../../components/buttons';
import { InputField, SelectField } from '../../../components/Input/input';
export function Form() {
return (
@israelalagbe
israelalagbe / currentTimeIsBetween.js
Created May 19, 2022 15:37
Check if current time overlap two time (time range)
import { parse, addDays } from "date-fns";
const currentTimeIsBetween = (startTime, endTime) => {
const currentDate = new Date();
const startTimeDate = parse(startTime, "hh:mm aa", currentDate);
const endTimeDate = parse(endTime, "hh:mm aa", currentDate);
const start = startTimeDate.getTime();
let end = endTimeDate.getTime();
const current = currentDate.getTime();
@israelalagbe
israelalagbe / getWays.js
Last active June 18, 2025 23:49
Coin change problem (algorithm)
function getWays(amount, coins) {
const combinations = Array(amount+1).fill(0);
combinations[0] = 1
for(const coin of coins) {
for(let i = 1; i < combinations.length; i++) {
if(i >= coin) {
combinations[i] += combinations[i - coin];
}
}
@israelalagbe
israelalagbe / convertTime.js
Last active June 18, 2025 23:49
Time Units Converter
const MINUTE = 60
const HOUR = MINUTE * 60
const DAY = HOUR * 24
const WEEK = DAY * 7
function solution(time) {
const result = calculate(time)
if(result===""){
return "0s"
}
@israelalagbe
israelalagbe / Trie.py
Created August 13, 2022 20:51
Search using Trie Data Structure
class TrieNode:
def __init__(self, value):
self.value = value;
self.children = {}
self.is_end = False
def __str__(self):
txt = ""
for key in self.children:
@israelalagbe
israelalagbe / Routing.component.jsx
Created November 21, 2022 09:28
Code Splitting React
import React, { Suspense, useContext } from 'react';
import {
BrowserRouter as Router,
Switch,
Route,
} from 'react-router-dom';
import { routes } from './routes';
import Loading from './RouteLoading.component';
import Guarded from './guards/Guard.component';
import AppContext from '../App.context';
@israelalagbe
israelalagbe / Game.tsx
Created December 13, 2022 17:48
Tic Tac Toe game in react
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
const rowStyle = {
display: 'flex'
}
const squareStyle = {
'width': '60px',
'height': '60px',