Skip to content

Instantly share code, notes, and snippets.

@mrroot5
mrroot5 / bs4_vertical_centered.html
Created September 10, 2018 14:28
Boostrap 4 centrado vertical
<!-- Ejemplo: https://jsfiddle.net/mrroot5/Ldkmn2y5/ -->
<div class="container-fluid">
<div class="row">
<div class="d-flex justify-content-center align-items-center">
<p>Con <strong>justify-content-center</strong> centramos horizontalmente. Mientras que con <strong>align-items-center</strong> centramos verticalemente.</p>
</div>
</div>
</div>
@mrroot5
mrroot5 / current_exec_path.py
Created June 20, 2018 09:34
Python: ruta de ejecución actual del fichero
import os
print(os.getcwd())
@mrroot5
mrroot5 / last_modified.py
Created June 19, 2018 08:56
Python: get file last modified
import os.path, time, datetime
file_path = "path/to/file.txt"
string_date_format = "%a %b %d %H:%M:%S %Y"
# Get last modified
string_date = time.ctime(os.path.getmtime(file_path)
print(string_date)
# Convert last modified string to datetime
@mrroot5
mrroot5 / capitalize.js
Last active September 26, 2019 11:42
Javascript title case capitalize
function titleCase(text) {
if (typeof text !== 'string') return ''
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
}
var myString = "my awesomE String";
titleCase(myString);
// My awesome string
@mrroot5
mrroot5 / bootstrap4viewpoint.js
Last active May 22, 2019 10:10
Determina el grid / viewpoint de bootstrap 4 (bs4): xs, sm, md, lg o xl
// Tested on bootstrap 4 - 4.1
function bs4Env() {
var envs = ['xs', 'sm', 'md', 'lg', 'xl'],
classToAdd = '',
$el = $('<div>'),
i = 0,
env;
$el.appendTo($('body'));
@mrroot5
mrroot5 / AESCipher.py
Created June 5, 2018 12:48 — forked from swinton/AESCipher.py
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class FloatingBtn {
constructor(element=undefined, options={}) {
try {
if (typeof element === "undefined") {
throw "Error: HTML not found"
}
this.element = document.querySelector(element);
this.button = undefined;
this.options = options;
#!/usr/bin/python
# Based on https://gist.github.com/provegard/1536682, which was
# Based on getifaddrs.py from pydlnadms [http://code.google.com/p/pydlnadms/].
# Only tested on Linux!
from socket import AF_INET, AF_INET6, inet_ntop
from ctypes import (
Structure, Union, POINTER,
pointer, get_errno, cast,
@mrroot5
mrroot5 / check_platform.py
Created May 25, 2018 16:45 — forked from zhreshold/check_platform.py
Check OS/Python/Cpu Info and Network connections
"""Diagnose script for checking OS/hardware/python/pip/mxnet/network.
The output of this script can be a very good hint to issue/problem.
"""
import platform, subprocess, sys, os
import socket, time
try:
from urllib.request import urlopen
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
@mrroot5
mrroot5 / snackbar.css
Last active December 23, 2019 21:49
Bootstrap 4 snackbar toast
.snackbar {
visibility: hidden;
min-width: 100px;
/* Dividimos el min-width por 2 para el
centrar el elemento */
margin-left: -50px;
border-radius: 5px;
position: fixed;
z-index: 10;
/* Centramos la snackbar en la pantalla */