Skip to content

Instantly share code, notes, and snippets.

View sergsoares's full-sized avatar

Sergio Soares sergsoares

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script>
function countdown(time) {
setTimeout( ()=> {
if(!time && time == '00:00') {
return
}
@sergsoares
sergsoares / firebase-notification-with-curl.sh
Created April 23, 2018 00:21
Simple curl to send a notification to firebase with a deviceID.
curl -d '{
"to": DEVICE_ID,
"notification": {
"title" : " This is my title new ",
"body" : " This is the body of my message "
}
}' \
-i -H "Application/json" \
-H "Content-type: application/json" \
-H "Authorization: key=YOUR_AUTH_KEY \
const assert = require('assert')
const BLUEBIRD = require('bluebird')

const nameAsync1 = async (name) => name
const nameAsync2 = (name) => Promise.resolve(name)
const nameAsync3 = (name) => BLUEBIRD.resolve(name)
const nameSync = (name) => name

const isPromise1 = (value) => Promise.resolve(value) === value
@sergsoares
sergsoares / Dockerfile
Created October 31, 2018 02:10
Dockerfile para criar container com php7.2 e extensões
FROM ubuntu:xenial
LABEL Description="PHP-FPM v7.2"
LABEL Version="1.0.0"
ENV TIME_ZONE America/Sao_Paulo
RUN apt-get update -yqq \
&& apt-get install -yqq \
ca-certificates \
@sergsoares
sergsoares / .bash
Last active January 18, 2019 12:51
Snippet para criar um PR para a master da sua branch atual. Necessário instalar o pacote HUB do github https://github.com/github/hub
#!/usr/bin/sh
pr() {
git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
hub pull-request -b master -m $@
}
alias new-feature="git reset --hard HEAD && git checkout master && git pull origin master && git checkout -b $@"
@sergsoares
sergsoares / create-statuses.bash
Created March 16, 2019 20:54
POST para o Github Statuses de um projeto
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"state": "failure",
"target_url": "https://example.com/build/status",
"description": "The build failed!",
"context": "continuous-integration/jenkins"
}' \
"https://api.github.com/repos/${OWNER}/${REPOSITORY}/statuses/${SHA_PROVIED}?${ACCESS_TOKEN}"
@sergsoares
sergsoares / ArrayAssertTrait.php
Last active April 22, 2019 11:42
Trait to mimic test method [assertJsonStructure](https://laravel.com/docs/5.8/http-tests#assert-json-structure) with Array.
<?php
namespace YOUR_NAME_SPACE;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Http\Response;
trait ArrayAssertTrait
{
public function assertArrayStructure($resultData = null, array $structure = null)
@sergsoares
sergsoares / docker-compose.yml
Created May 2, 2019 16:18
Docker Compose simples para subir Elasticsearch e Kibana
---
version: "2"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
container_name: sales_sync_elasticsearch
ports:
- "9200:9200"
environment:
discovery.type: "single-node"
#!/bin/bash
docker run \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--volume=data:/data \
--env=DRONE_GIT_ALWAYS_AUTH=false \
--env=DRONE_GITLAB_SERVER=localhost \
--env=DRONE_GITLAB_CLIENT_ID=CLIENT_ID \
--env=DRONE_GITLAB_CLIENT_SECRET=CLIENT_SECRET \
--env=DRONE_RUNNER_CAPACITY=2 \
@sergsoares
sergsoares / gist:dc431eabebf8ad1df9de975fa8310f2d
Created June 2, 2019 22:01
Simple container with terraform
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y unzip
RUN apt-get install -y curl
RUN curl -O -L https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
RUN unzip terraform_0.11.13_linux_amd64.zip
RUN mv terraform /usr/local/bin