Skip to content

Instantly share code, notes, and snippets.

@semagarcia
semagarcia / html-content.html
Last active November 9, 2015 09:23
How to convert an image into base64 string
<img id="image" src="http://www.gravatar.com/avatar/90348ht093409g7wetdgf?s=128&d=identicon&r=PG">
<canvas id="canvasElement"/>
<div id="base64string" />
@semagarcia
semagarcia / format_sdcard_on_mac.md
Last active April 22, 2017 02:09
How format a SDCard in OSX

Command

diskutil list

Output command

In the output of previous command, search the sdcard and look for the identifier.

Example

If we want to to format the sdcard to the desired format (FAT32), with the name of "SDCARD", located on /dev/desk1, we should execute the following command:

@semagarcia
semagarcia / generate-cert.sh
Created December 13, 2017 20:04
Generating a certificate
#! /bin/bash
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
# 1. Clone your fork:
git clone <your-forked-repo>.git
# 2. Add remote from original repository in your forked repository:
cd forked-repo
git remote add upstream <your-forked-repo>.git
git fetch upstream
# 3. Updating your forked repo from original one to keep up with their changes:
git pull upstream master
https://docs.google.com/presentation/d/1YWe46QRe5SHJzU_BP66AMWg3pHp-YC0VT_us11xOYbA/edit#slide=id.g62e0a832ab_2_110
@semagarcia
semagarcia / medium-wc-article--hellow-world.js
Created April 14, 2021 19:10
Hello World Web Component example with plan JavaScript (without additional libraries)
<script>
// JavaScript code for creating "my-web-component" custom element
// using HTMLElement as base class from which to extend
customElements.define('my-web-component', class extends HTMLElement {
constructor() {
super();
// Find an HTML snippet (template used by WebComponent)
const template = document.querySelector('#myTpl');
const templateContent = template.content;
@semagarcia
semagarcia / medium-wc-article--hellow-world-template.html
Created April 14, 2021 19:12
Hello World Web Component example with plan JavaScript (without additional libraries)
<!-- HTML file -->
<template id="myTpl">
<h1>Hi, I am a WebComponent!</h1>
</template>
@semagarcia
semagarcia / medium-wc-article--tag-instantiation.html
Created April 14, 2021 19:13
Hello World Web Component example with plan JavaScript (without additional libraries)
<!-- HTML file -->
<my-web-component></my-web-component>
@semagarcia
semagarcia / medium-wc-article--input-example.html
Created April 14, 2021 19:24
Input => data flow goes from the parent (framework component) to its child (web component)
<!-- Template: Angular component containing web component -->
<div>
<h1>I'm an Angular component</h1>
<print-full-name
name="{{ user.name }}"
surname="{{ user.surname }}">
</print-full-name>
</div>
@semagarcia
semagarcia / medium-wc-article--output-example.html
Last active April 14, 2021 19:26
Output => data flow goes from the child (web component) to the parent
<!-- Template: web component inside an Angular component -->
<div>
<h1>I'm an Angular component</h1>
<click-counter id='clickCounter'></click-counter>
</div>