Skip to content

Instantly share code, notes, and snippets.

caike / agent.config.json
Created Jun 1, 2021
AWS CloudWatch agent simple config for CPU and memory monitoring
View agent.config.json
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root"
"metrics": {
"append_dimensions": {
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
caike /
Last active May 11, 2021
XSS attack demo with innerHTML

Tested with Chrome, Firefox and Safari.

The following code will not trigger an alert. target.innerHTML = "<script> alert('XSS Attack'); </script>";

The following code will trigger an alert. target.innerHTML = "<img src=x onerror=\"alert('XSS Attack')\" >";

View installing ruby-1.8.6-p111
Ruby compile error (openssl problem)
TAGS: None
Found these error:
view sourceprint?
compiling openssl
gcc -I. -I../../.ext/include/i686-darwin10.2.0 -I../.././include -I../.././ext/openssl -DRUBY_EXTCONF_H=\"extconf.h\" -fno-common -g -O2 -pipe -fno-common -o openssl_missing.o -c openssl_missing.c
In file included from openssl_missing.c:22:
caike / nome-do-service.service
Created Feb 26, 2021
systemd config example
View nome-do-service.service
Description=O Nome do Service
caike /
Created Dec 21, 2020
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 >> index.html
systemctl start nginx
caike /
Last active Oct 17, 2020
Node.js streams 1 vs. 2

NodeJS Streams

  • Current implementation is known as streams2.
  • Introduced in node v0.10.
  • "suck" streams instead of "spew" streams.
  • Instead of data events spewing, call read() to pull data from source.
  • When there isn't any data to consume, then read() will return undefined.
  • Adding a data event listener will switch the Readable stream into "old mode", where data is emitted as soon as it is available rather than waiting for you to call read() to consume it. This requires you to handle backpressure problems manually.
  • The pipe method helps write less code and handles back-pressure.
  • If you add an end listener and don't ever read() or pipe(), it'll never emit end.
caike / ec2-nginx.yml
Last active Apr 27, 2020
CloudFormation templates. Must use Linux 2 AMI images because of systemd.
View ec2-nginx.yml
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Creates an EC2 instance with Nginx installed and running.'
Description: VPC for the SecurityGroup
Type: AWS::EC2::VPC::Id
caike /
Created Apr 20, 2020
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 / todo.jsx
Created Apr 11, 2015
Simple Todo app demo using React + ES6
View todo.jsx
var React = require("react");
var allItems = []
allItems.push("Buy ingredients for Crock Pot");
allItems.push("Pick up chair at IKEA");
allItems.push("Go see mom");
class TodoList extends React.Component {
caike / timer.js
Last active Oct 1, 2019
Example of updating timer on the fly
View timer.js
$(function() {
const timer = $('.timer');
timer.startTimer({ allowPause: true });
setTimeout(() => {
timer.trigger('click');'timeLeft', 30);
}, 3000);