Skip to content

Instantly share code, notes, and snippets.

View anachronic's full-sized avatar

Nicolás Salas V. anachronic

View GitHub Profile
@anachronic
anachronic / jwtest.py
Created March 5, 2019 03:44
JWT creation and verification using python-jose
from jose import jwt
from jose.jwt import JWTClaimsError, JWTError, ExpiredSignatureError
from datetime import datetime, timedelta
import time
key = 'secret#%$sdfasdkflj@#%RFsaior82340-fweASDFSD928354940k'
expdelta = timedelta(seconds=10)
now = datetime.utcnow()
exp = now + expdelta
(use-package js2-mode
:ensure t
:mode "\\.js\\'"
:config
(setq js2-basic-offset 2)
(setq-default js2-mode-show-parse-errors nil
js2-mode-show-strict-warnings nil
js2-idle-timer-delay 0.4)
(with-eval-after-load 'dumb-jump
(define-key js2-mode-map (kbd "M-.") 'dumb-jump-go)
@anachronic
anachronic / init-javascript.el
Last active August 24, 2022 13:07
A hydra for js2-refactor in emacs
(defhydra js2-refactor-hydra (:color blue :hint nil)
"
^Functions^ ^Variables^ ^Buffer^ ^sexp^ ^Debugging^
------------------------------------------------------------------------------------------------------------------------------
[_lp_] Localize Parameter [_ev_] Extract variable [_wi_] Wrap buffer in IIFE [_k_] js2 kill [_lt_] log this
[_ef_] Extract function [_iv_] Inline variable [_ig_] Inject global in IIFE [_ss_] split string [_dt_] debug this
[_ip_] Introduce parameter [_rv_] Rename variable [_ee_] Expand node at point [_sl_] forward slurp
[_em_] Extract method [_vt_] Var to this [_cc_] Contract node at point [_ba_] forward barf
[_ao_] Arguments to object [_sv_] Split var decl. [_uw_] unwrap
[_tf_] Toggle fun exp and decl [_ag_] Add var to globals
import os
whitelist = ('a', 'b', 'c.ext', '.gitignore')
curpath = os.getcwd()
for file in os.listdir(curpath):
if file not in whitelist:
os.remove(os.path.join(curpath, file))
// En http://localhost:8000/sculpt.html
app._stateManager.reset()
// Pintar lo que sea
var w = app._stateManager.getUndoAndRedoStates()
// Deshacer todos los cambios
app._stateManager._redos.length = 0; app._stateManager._curUndoIndex = -1; app._stateManager._undos.length = 0;
app._stateManager.restoreFromDict(w)
;; navigating hydra
(defhydra hydra-text (:columns 3)
"Movement and text manipulation hydra"
("i" previous-line "up")
("k" next-line "down")
("j" backward-char "back")
("l" forward-char "forward")
("dd" kill-whole-line "kill the whole line")
("de" kill-line "kill until the end of the line")
("da" my/kill-to-line-beg "kill until beginning of line")
@anachronic
anachronic / integracion.c
Created November 1, 2015 20:25
Ojo! esta tarea hace un montón de cosas que __no tienen que ver con integración__
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define ERROR_ACEPTABLE (0.00001)
double segundointegrando(double x){
return (1+(x*x))*log((x*x))*log((x*x))*2*sqrt((x*x))/((1-(x*x)*(x*x)*(x*x)));
}
@anachronic
anachronic / tablas.sql
Created October 28, 2015 17:16
export de tablas MySQL (sustentabilidad)
CREATE TABLE `alertas_alarma` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`formula` longtext NOT NULL,
`email` varchar(100) NOT NULL,
`dispositivo_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `a_dispositivo_id_46651386577e44c9_fk_dispositivos_dispositivo_id` (`dispositivo_id`),
CONSTRAINT `a_dispositivo_id_46651386577e44c9_fk_dispositivos_dispositivo_id` FOREIGN KEY (`dispositivo_id`) REFERENCES `dispositivos_dispositivo` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@anachronic
anachronic / models.py
Last active October 28, 2015 00:18
modelo de inge 2
from django.db import models
class TipoDato(models.Model):
magnitud = models.CharField(max_length=100)
unidad = models.CharField(max_length=100)
class Datos(models.Model):
timestamp = models.DateTimeField()
valor = models.IntegerField()
\documentclass[12pt,letterpaper]{report}
\usepackage[spanish]{babel}
\usepackage[ansinew]{inputenc}
\usepackage[right=2cm,left=3cm,top=2cm,bottom=2cm,headsep=0cm,footskip=0.5cm]{geometry}
\usepackage{graphicx}
\usepackage{wrapfig} %Inclusión de gráficos al lado de texto
\title{\Huge Título \\ Bajada \\ Informe}
\author{Nicolás Salas V.}