Skip to content

Instantly share code, notes, and snippets.

@gengns
gengns / box.css
Last active Aug 18, 2018
Create your own native web component
View box.css
box-element > div {
color: #555;
background: #00BCD4;
width: 100px;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
@gengns
gengns / index.html
Last active Aug 10, 2018
Basic translator using Vanilla JavaScript
View index.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>
<body>
<label class="T">Usuario</label>
<label class="T">Contraseña</label>
<select>
<option value="es">Español</option>
<option value="en">English</option>
@gengns
gengns / swap.js
Last active Jul 8, 2018
Swap the first and last element in an array without temporary variable or ES6 swap method [a, b] = [b, a]
View swap.js
[a.pop(), ...a.slice(1), a.shift()]
@gengns
gengns / get_html_file.js
Last active May 26, 2020
Get a local html file to insert into your Cordova Single Page Application
View get_html_file.js
/**
Get local html files (views/widgets) to insert into your SPA
@param path ex:
path = 'file:///android_asset/www/view/page.html'
@param success
@param failure
*/
function get_html_file(path, success, failure) {
const xhr = new XMLHttpRequest()
@gengns
gengns / get_file.js
Last active Apr 22, 2018
Get local/external raw files without user interface (input file)
View get_file.js
/**
Get local/external files without user interface (input file)
@param path ex:
path = 'file:///storage/emulated/0/Android/data/com.gengns.appname/cache/finn.jpg'
path = 'https://allmyimages.com/jake.jpg'
@param success
@param failure
*/
function getFile(path, success, failure) {