Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Dario Garcia dario61081

🎯
Focusing
View GitHub Profile
@dario61081
dario61081 / module.html
Created Aug 29, 2022
como iniciar un mixin de forma externa
View module.html
let mixin_parametros = {
data() {
return {
clave: null,
tipo: 0,
valor_texto: null,
valor_numerico: null,
valor_booleano: false,
descripcion: null
}
@dario61081
dario61081 / console_1.sql
Created Aug 9, 2022
listar dinamicamente fecha usando recursividad en mysql
View console_1.sql
with recursive
p as (
select cast(:fecha_desde as date) fecha_desde ,
cast(:fecha_hasta as date) fecha_hasta
),
fechas as (
select cast(p.fecha_desde as date) fecha
from p
union
select date_add(f.fecha, interval 1 day)
@dario61081
dario61081 / utils.html
Created Aug 5, 2022
macros for jinja templates
View utils.html
{% macro render_field(field) %}
{% if field.type != 'HiddenField' %}
<div class="field {% if field.errors %} error {% endif %}">
{{ field.label }}
<div class="ui input">
{{ field }}
</div>
{% if field.errors %}
<span>{{ field.errors[0] }}</span>
{% endif %}
View schedule_task.py
# programming a scheduled task
import time
import schedule
def main():
pass
if __name__ == '__main__':
task_timeout_min_minutes = 15
task_timeout_max_minutes = 25
@dario61081
dario61081 / json_encodings.py
Last active Mar 29, 2022
Class JsonEncode override for custom date format v1.0.1
View json_encodings.py
class BetterJsonEncode(JSONEncoder):
def default(self, obj):
if isinstance(obj, date):
return obj.isoformat()
if isinstance(obj, datetime):
return obj.isoformat()
if isinstance(obj, decimal.Decimal):
return float(obj)
if hasattr(obj, '__getitem__') and hasattr(obj, 'keys'):
return dict(obj)
@dario61081
dario61081 / filtro_fecha.php
Created Mar 19, 2022
filtro por medio de fechas primer y ultimo dia del mes
View filtro_fecha.php
<?php
$fecha_desde = $_GET['fecha_desde'] ?? date('Y-m-01'); //primer dia del mes
$fecha_hasta = $_GET['fecha_hasta'] ?? date('Y-m-t'); //ultimo dia del mes
@dario61081
dario61081 / android_network.txt
Created Jul 27, 2021
Allow androidnetworking work
View android_network.txt
application
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true"
network_security_config
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
<domain-config cleartextTrafficPermitted="false">
@dario61081
dario61081 / mssql_recovery_suspect_bbdd.sql
Created May 31, 2021
mssql: Recovery database in suspect mode
View mssql_recovery_suspect_bbdd.sql
USE master
GO
ALTER DATABASE milleniumfox SET EMERGENCY
GO
DBCC CHECKDB (milleniumfox )
GO
ALTER DATABASE milleniumfox SET SINGLE_USER WITH ROLLBACK IMMEDIATE
@dario61081
dario61081 / pdo_tools.php
Created Apr 10, 2021
funcion para convertir array o object to json
View pdo_tools.php
function toJsonPDO($resultset)
{
$t = gettype($resultset);
if ($t === 'object') {
return json_encode(get_object_vars($resultset), JSON_NUMERIC_CHECK);
} else if ($t === 'array' && sizeof($resultset) === 1) {
return json_encode($resultset[0], JSON_NUMERIC_CHECK);
} else if ($t === 'array' && sizeof($resultset) > 1) {
return json_encode($resultset, JSON_NUMERIC_CHECK);
} else {
View export_csv.php
<?php
include_once implode(DIRECTORY_SEPARATOR, [__DIR__, 'conector.inc.php']);
const debug=true;
$format=$_GET['format']??'json';
if (debug){
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}