Skip to content

Instantly share code, notes, and snippets.

View phellipeandrade's full-sized avatar
🏡
Working from home

Phellipe Andrade phellipeandrade

🏡
Working from home
  • São Paulo - Brazil
View GitHub Profile
View gist:866ae4fac9d137e41f35d8822e9c1435
#include <Arduino.h>
#include <IRremote.h>
#define onOffReceived 49 // 1
#define energyRcv 50 // 2
#define avMode 51 // 3
#define input 52 // 4
#define tvRad 53 // 5
#define list 54 // 6
#define quickView 55 // 7
View search.js
const sample = [
[
[
[
[
[
{
foo: [{ rate: 2.18 }],
},
],
@phellipeandrade
phellipeandrade / [FEDORA] gitkraken
Created July 21, 2018 22:34 — forked from aelkz/[FEDORA] gitkraken
How to install gitkraken on Fedora [25,26,27] + launcher icon
View [FEDORA] gitkraken
#!/bin/bash
# Download GitKraken
wget https://release.gitkraken.com/linux/gitkraken-amd64.tar.gz
# copy the downloaded file into /opt directory
cp gitkraken-amd64.tar.gz /opt/
cd /opt
@phellipeandrade
phellipeandrade / install-rabbitmq.sh
Created June 18, 2018 18:58 — forked from yetanotherchris/install-rabbitmq.sh
RabbitMQ on Docker with admin UI
View install-rabbitmq.sh
# AWS specific install of Docker
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# exit the SSH session, login again
# Docker
docker run -d --hostname my-rabbit --name some-rabbit -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq
@phellipeandrade
phellipeandrade / gist:895718ea5679532ac2195d687a6b1421
Created March 14, 2018 21:45 — forked from solenoid/gist:1372386
javascript ObjectId generator
View gist:895718ea5679532ac2195d687a6b1421
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@phellipeandrade
phellipeandrade / ultimate-ut-cheat-sheet.md
Created February 27, 2018 04:34 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon
View ultimate-ut-cheat-sheet.md
@phellipeandrade
phellipeandrade / async-foreach.js
Created February 25, 2018 04:35 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
View async-foreach.js
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@phellipeandrade
phellipeandrade / repo-reset.md
Created February 6, 2018 14:58 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands
View repo-reset.md

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@phellipeandrade
phellipeandrade / mongodb-s3-backup.sh
Created January 12, 2018 14:40 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
View mongodb-s3-backup.sh
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@phellipeandrade
phellipeandrade / docker-cleanup-resources.md
Created December 20, 2017 13:35 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks
View docker-cleanup-resources.md

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm