Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Manuel Canga manuelcanga

🎯
Focusing
View GitHub Profile
@manuelcanga
manuelcanga / host_docker_ip.txt
Created February 26, 2022 08:33
IP address of the docker host for inside of a docker container
View host_docker_ip.txt
This is in `host.docker.internal` hostname and `172.17.0.1` IP for Linux in default network.
@manuelcanga
manuelcanga / backup.sh
Created January 7, 2022 21:48
Create app backup
View backup.sh
#!/bin/sh
#set -x
INSTANCIA=$1
TODAY=$(date -I)
### ------------------------------------------------------------
@manuelcanga
manuelcanga / app_gettext.sh
Last active February 26, 2022 08:28
Searching and creating gettext entries
View app_gettext.sh
APP_ROOT=$1
if [ $# == 2 ]
then
echo "error: app path?"
fi
@manuelcanga
manuelcanga / scripts.js
Last active February 26, 2022 08:26
Upload html5 images to a tree
View scripts.js
(function($) {
jQuery.fn.html5_upload = function(options) {
var available_events = ['onStart', 'onStartOne', 'onProgress', 'onFinishOne', 'onFinish', 'onError'];
var options = jQuery.extend({
onStart: function(event, total) {
@manuelcanga
manuelcanga / info.md
Created January 7, 2022 20:39
Elemento :before o :after no se visualiza
View info.md

Si has añadido una regla :before o :after y parece que no toma los estilos es porque para que estos se necesita el atributo content aunque sea vacío. Es decir:

div.miclase:before {

  content: '';
}
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:27
get size of screen (js)
View scripts.js
trasweb = trasweb | {};
trasweb.getSize = function () {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:27
get position of an element in the web (js)
View scripts.js
trasweb.getPosition = function (el) {
var xPos = 0;
var yPos = 0;
while (el) {
if (el.tagName === "BODY") {
// deal with browser quirks with body/window/document and page scroll
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
var yScroll = el.scrollTop || document.documentElement.scrollTop;
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:26
Cambio de viewport según la orientación
View scripts.js
/** Basado en: https://stackoverflow.com/questions/15040408/achieving-min-width-with-viewport-meta-tag */
document.addEventListener('DOMContentLoaded', function () {
trasweb.orientationchange();
});
trasweb.orientationchange = function (force_orientation) {
var vp = document.getElementById('viewport');
var orientation = window.orientation;
var is_desktop = document.body.classList.contains('desktop');
@manuelcanga
manuelcanga / scripts.js
Created January 7, 2022 19:25
Lazy load de imágenes (con soporte responsive)
View scripts.js
/**
Alternativa de menos de 1kb: https://apoorv.pro/lozad.js/demo/
*/
document.addEventListener('DOMContentLoaded', function () {
var bLazy = new Blazy({
src: 'data-src',
selector: '*[data-src]',
offset: 500,
breakpoints: [