- Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
- Opcional: Si usamos Fetch API en el proyecto:
version: '3.1' | |
services: | |
db: | |
image: mariadb | |
restart: always | |
command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci --init-connect='SET NAMES UTF8;' --innodb-flush-log-at-trx-commit=0 | |
ports: | |
- 3306:3306 |
interface Task {
id: number;
title: string;
completed: boolean;
createdAt: Date;
}
interface CreateTaskDto extends Omit<Task, 'id' | 'createdAt'> {}
interface UpdateTaskDto extends Omit<Partial<Task>, 'id'> {}
function uploadFile(file) { | |
var formData = new FormData(); | |
formData.append("userfile", file); | |
var request = new XMLHttpRequest(); | |
request.onload = function () { | |
if (request.status == 200) { | |
document.location.href='/'; | |
} else { | |
alert('Error! Upload failed'); | |
} |
git config --global alias.logda "log --oneline --graph --decorate --all
git config --global alias.s "status
git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
window.onload = function(){ | |
/** UNSAFE with localStorage **/ | |
let jwt = null | |
onLogin(){ | |
jwt = await login() | |
} | |
onDataFetch(){ |
# ipak function: install and load multiple R packages. | |
# check to see if packages are installed. Install them if they are not, then load them into the R session. | |
ipak <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg)) | |
install.packages(new.pkg, dependencies = TRUE) | |
sapply(pkg, require, character.only = TRUE) | |
} |
Tested on an OpenBSD system using OpenVPN LDAP authentication:
sed -n '/Virtual/,/GLOBAL/{//!p;}' /var/log/openvpn-status.log | awk -F'[,:]' '{print $3}' | while read -r r; do echo -n $r; fgrep $r /var/log/openvpn | fgrep -m 1 username | awk -F\' '{ print " - " $2}' ; done
var arr = ['Sacha', 'Og', 'Haru']; | |
arr[Symbol.iterator] = function *() { | |
var i = this.length - 1; | |
while (i >= 0) { | |
yield this[i]; | |
i--; | |
} | |
} | |
for (var value of arr) { |
#!/bin/bash | |
#https://virtualzero.net/blog/how-to-create-a-bash-script-to-update-ubuntu-18.04-lts | |
# NVM lazy loading script | |
# | |
# NVM takes on average half of a second to load, which is more than whole prezto takes to load. | |
# This can be noticed when you open a new shell. | |
# To avoid this, we are creating placeholder function | |
# for nvm, node, and all the node packages previously installed in the system | |
# to only load nvm when it is needed. |