Skip to content

Instantly share code, notes, and snippets.

View ThomRoman's full-sized avatar

ThomRoman

View GitHub Profile
@ThomRoman
ThomRoman / docker-compose.yaml
Created June 29, 2022 20:17 — forked from w0rldart/docker-compose.yaml
MariaDB docker-compose with UTF8 Collation
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
@ThomRoman
ThomRoman / vite-testing-config.md
Created June 20, 2022 03:33 — forked from Klerith/vite-testing-config.md
Vite + Testing + Jest - Completo

Instalación y configuracion de Jest + React Testing Library

En proyectos de React + Vite

  1. Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react 
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
  1. Opcional: Si usamos Fetch API en el proyecto:
interface Task {
  id: number;
  title: string;
  completed: boolean;
  createdAt: Date;
}

interface CreateTaskDto extends Omit<Task, 'id' | 'createdAt'> {}
interface UpdateTaskDto extends Omit<Partial<Task>, 'id'> {}
@ThomRoman
ThomRoman / example.js
Created May 21, 2022 22:21 — forked from magemore/example.js
upload image from clipboard on ctrl+v event on page
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');
}
@ThomRoman
ThomRoman / git-alias.md
Last active February 23, 2022 21:59 — forked from Klerith/git-alias.md
Useful Git Alias

git logda

git config --global alias.logda "log --oneline --graph --decorate --all

git s

git config --global alias.s "status

git sl => super log

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"

git ss => status short

window.onload = function(){
/** UNSAFE with localStorage **/
let jwt = null
onLogin(){
jwt = await login()
}
onDataFetch(){
@ThomRoman
ThomRoman / ipak.R
Created July 13, 2020 06:31 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# 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)
}
@ThomRoman
ThomRoman / openvpn.md
Created July 3, 2020 00:24 — forked from mikej312/openvpn.md
Associate usernames with IP addresses of OpenVPN clients

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) {
@ThomRoman
ThomRoman / lazy-load-nvm.sh
Last active March 22, 2020 03:34 — forked from rtfpessoa/lazy-load-nvm.sh
NVM lazy loading script
#!/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.