Skip to content

Instantly share code, notes, and snippets.

@pjanuario
pjanuario / toCamelase.js
Created June 5, 2017 15:04
Module to do a deep conversion of a object into a camelCase
import _ from 'lodash';
export default function toCamelCase(obj) {
if (!_.isObject(obj)) { return obj; }
if (_.isArray(obj)) {
return obj.map(toCamelCase);
}
return _.reduce(obj, (memo, value, key) => {
@pjanuario
pjanuario / Node.js HTTP Server
Created May 23, 2018 09:15
Simple HTTP server to output request url and post body
// content of index.js
const http = require('http')
const port = 3000
const requestHandler = (request, response) => {
console.log("URL: %s", request.url)
if (request.method === 'POST') {
let body = '';
request.on('data', chunk => {
body += chunk.toString(); // convert Buffer to string
@pjanuario
pjanuario / sunset_automation.yaml
Created April 6, 2020 21:26
Homeassistant sunset automation
# 15m after the sunrise
# - Open the covers
# - Turn off ligths
- id: sunrise
alias: 'Sunrise automation'
trigger:
- platform: sun
event: sunrise
offset: '00:15:00'
action:
@pjanuario
pjanuario / view_energy.yaml
Created August 14, 2020 12:53
Homeassistant Energy View
title: Energia
icon: mdi:transmission-tower
path: energy
background: var(--background-image)
cards:
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: entities
@pjanuario
pjanuario / index.js
Created August 21, 2020 11:06 — forked from amiantos/index.js
Zip Multiple Files from S3 using AWS Lambda Function
// Lambda S3 Zipper
// http://amiantos.net/zip-multiple-files-on-aws-s3/
//
// Accepts a bundle of data in the format...
// {
// "bucket": "your-bucket",
// "destination_key": "zips/test.zip",
// "files": [
// {
// "uri": "...", (options: S3 file key or URL)