Skip to content

Instantly share code, notes, and snippets.

Carlos Souza caike

Block or report user

Report or block caike

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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);
caike /
Last active Sep 24, 2019
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')\" >";

caike / main.go
Created Aug 22, 2019
Go web server example with support for URL matching on regular expressions
View main.go
package main
import (
type route struct {
pattern *regexp.Regexp
handler http.Handler
caike / fifa-world-cup-winners.json
Last active Aug 21, 2019
List of FIFA World Cup winners
View fifa-world-cup-winners.json
{ "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 /
Last active Aug 14, 2019
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 / hoc-demo.js
Created May 9, 2019
Higher Order Component demo
View hoc-demo.js
function App(props){
return `Message ${props.classes.button} ${props.classes.isActive}`;
const styles = {
button: "btn-primary",
isActive: "is-active"
const styledProps = withStyles(styles);
caike / go.go
Last active May 6, 2019
Unlearning Rubyisms
View go.go
// first stab
const defaultPort = "8080"
func getPort() string {
portEnv := os.Getenv("PORT")
if portEnv != "" {
return portEnv
return defaultPort
caike / Dockerfile
Created Jan 8, 2019
Dockerfile template for Rails app
View Dockerfile
# Change Ruby version accordingly
FROM ruby:2.3-stretch
LABEL maintainer=""
RUN apt-get update
RUN apt-get install -y git
RUN mkdir /myapp
WORKDIR /myapp
caike /
Created Nov 18, 2018
solving raspberry.local issue

Found this solution to address the problem where raspberry.local can't be found on the network. Run:

dscacheutil -q host -a name raspberrypi.local

Then try it again shrug

You can’t perform that action at this time.