Skip to content

Instantly share code, notes, and snippets.

@caike
caike / agent.config.json
Created June 1, 2021 12:05
AWS CloudWatch agent simple config for CPU and memory monitoring
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root"
},
"metrics": {
"append_dimensions": {
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
@caike
caike / nome-do-service.service
Created February 26, 2021 02:54
systemd config example
[Unit]
Description=O Nome do Service
[Service]
Type=notify
ExecStart=/bin/pra/iniciar/o/service
WatchdogSec=30s
Restart=always
RestartSec=5
@caike
caike / user-data-for-nginx.sh
Created December 21, 2020 17:17
Install nginx on Amazon Linux 2
#!/bin/bash -xe
yum update -y
amazon-linux-extras install nginx1 -y
cd /usr/share/nginx/html
echo "WebServer on instance-id " > index.html
curl http://169.254.169.254/latest/meta-data/instance-id >> index.html
systemctl start nginx
@caike
caike / dope-flan.md
Created April 20, 2020 13:09
Dope Brazilian Flan
  • 3 eggs
  • 1 yolk
  • 2 cans of sweetened condensed milk
  • One of these ☝️ empty cans full of whole milk
  • A pinch of vanilla extract
@caike
caike / ec2-nginx.yml
Last active April 27, 2020 21:34
CloudFormation templates. Must use Linux 2 AMI images because of systemd.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Creates an EC2 instance with Nginx installed and running.'
Parameters:
VPC:
Description: VPC for the SecurityGroup
Type: AWS::EC2::VPC::Id
@caike
caike / timer.js
Last active October 1, 2019 17:41
Example of updating timer on the fly
$(function() {
const timer = $('.timer');
timer.startTimer({ allowPause: true });
setTimeout(() => {
timer.trigger('click');
timer.data('timeLeft', 30);
timer.trigger('click');
}, 3000);
});
@caike
caike / main.go
Created August 22, 2019 19:43
Go web server example with support for URL matching on regular expressions
package main
import (
"net/http"
"regexp"
)
type route struct {
pattern *regexp.Regexp
handler http.Handler
@caike
caike / fifa-world-cup-winners.json
Last active August 21, 2019 14:57
List of FIFA World Cup winners
[
{ "country": "France", "year": 2018 },
{ "country": "Germany", "year": 2014 },
{ "country": "Spain", "year": 2010 },
{ "country": "Italy", "year": 2006 },
{ "country": "Brazil", "year": 2002 },
{ "country": "France", "year": 1998 },
{ "country": "Brazil", "year": 1994 },
{ "country": "West Germany", "year": 1990 },
{ "country": "Argentina", "year": 1986 },
@caike
caike / hoc-demo.js
Created May 9, 2019 12:31
Higher Order Component demo
function App(props){
return `Message ${props.classes.button} ${props.classes.isActive}`;
}
const styles = {
button: "btn-primary",
isActive: "is-active"
};
const styledProps = withStyles(styles);
@caike
caike / Dockerfile
Created January 8, 2019 15:11
Dockerfile template for Rails app
# Change Ruby version accordingly
FROM ruby:2.3-stretch
LABEL maintainer="carloshrsouza@gmail.com"
RUN apt-get update
RUN apt-get install -y git
RUN mkdir /myapp
WORKDIR /myapp