Skip to content

Instantly share code, notes, and snippets.

View imedadel's full-sized avatar
🏗️
Building something

Imed Adel imedadel

🏗️
Building something
View GitHub Profile
@imedadel
imedadel / docker-run-command-shell.md
Last active May 9, 2020 13:37
How to run a shell command inside a running Docker container
  1. Get the container's name (this is different from tag or id)
docker ps
  1. Run the command
docker exec -it NAME_OF_CONTAINER sh
  1. ???
  2. Profit
.layout > :not(:last-child) {
margin-bottom: 10px;
margin-right: 10px;
}
/* or */
.layout > * + * {
margin-bottom: 10px;
margin-right: 10px;
@imedadel
imedadel / README.md
Created April 26, 2020 23:22 — forked from Rich-Harris/README.md
Testing array.splice vs array.pop vs set.delete

You have an array. Its sort order doesn't matter. You want to remove an item from this array.

The obvious thing to do would be to use splice:

function remove(array, item) {
  const index = array.indexOf(item);
  array.splice(index, 1);
}
@imedadel
imedadel / index.js
Created April 26, 2020 22:05 — forked from digitalkaoz/index.js
gatsby in aws lambda
const AWS = require("aws-sdk");
const {link} = require("linkfs");
const mock = require('mock-require');
const fs = require('fs');
const tmpDir = require('os').tmpdir();
exports.handler = (event, context) => {
rewriteFs();
invokeGatsby(context);
}
COUNT=0
for arg in $(ls); do
rm -rfv $arg
COUNT=$(($COUNT + 1))
if [$COUNT -ge 10]; then
break
fi
done
// taken from https://jsperf.com/array-remove-by-index
// splice: 6,957,292 ops/sec
// swap: 85,501,603 ops/sec (NB. changes order)
// shift: 70,903,814 ops/sec
// btw. don't actually modify the Array prototype. Create a separate function instead.
Array.prototype.mySwapDelete = function arrayMySwapDelete(index) {
this[index] = this[this.length - 1];
this.pop();
};
echo '> Updating packages'
sudo yum update -y
echo '> Installing Git'
sudo yum install git -y
echo '> Installing Docker'
sudo amazon-linux-extras install docker
sudo usermod -a -G docker ec2-user
sudo chkconfig docker on
@imedadel
imedadel / micro-heroku.md
Created December 22, 2019 19:45
Zeit Micro deployment on Heroku