Skip to content

Instantly share code, notes, and snippets.

@rogeriochaves
rogeriochaves / gist:7119372e33668083ccb4de2073b4659e
Last active October 15, 2018 09:51
Applescript to switch to airpods
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
click bt
tell (first menu item whose title contains "AirPods van Rogerio") of menu of bt
click
tell menu 1
if exists menu item "Connect" then
click menu item "Connect"
else
key code 53
@rogeriochaves
rogeriochaves / heroku-docker-deploy.sh
Created June 2, 2018 01:38
Release last docker image with heroku
curl -n -X PATCH https://api.heroku.com/apps/APP_NAME/formation \
-d '{
"updates": [
{
"type": "web",
"docker_image": "$(docker inspect registry.heroku.com/APP_NAME/web --format={{.Id}})"
}
]
}' \
-H "Content-Type: application/json" \
const path = require('path');
const fs = require('fs');
const express = require('express');
const React = require('react');
const App = require('./transpiled/App.js').default;
const { renderToString } = require('react-dom/server');
const server = express();
server.get('/', (req, res) => {
@rogeriochaves
rogeriochaves / index.js
Created June 16, 2017 21:51
Redux implementation, basically
const React = require("react");
const ReactDOM = require("react-dom");
const reducer = (state, action) => {
switch (action) {
case "INCREMENT":
return state + 1;
case "DECREMENT":
return state - 1;
default:
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@rogeriochaves
rogeriochaves / brunch-config.coffee
Last active June 16, 2017 10:38
Brunch vs Webpack
exports.config =
files:
javascripts:
joinTo: 'app.js'
stylesheets:
joinTo: 'app.css'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Microfrontends Homepage</title>
<link href="header" rel="import" async />
<link href="products-list" rel="import" async />
<link href="cart" rel="import" async />
</head>
<body>
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
class Header extends HTMLElement {
attachedCallback() {
ReactDOM.render(<App />, this.createShadowRoot());
}
}
<div id="cart-main"></div>
<script src="dist/bundle.js"></script>
var app = Elm.Cart.embed(document.getElementById('cart-main'));
window.addEventListener('addToCart', (event) => {
app.ports.addToCartEvents.send(event.detail);
}, false);