Skip to content

Instantly share code, notes, and snippets.

@natterstefan
natterstefan / README.md
Created February 18, 2020 14:47
Jest | Mock useState

Jest - mock useState

When using import React, { useState } from 'react' in your components, this is how you can mock useState with jest.

@miguelmota
miguelmota / object.ts
Created September 6, 2019 02:19
TypeScript fix error "element implicitly has an 'any' type because expression of type 'any' can't be used to index type"
const someObject : { [key: string]: any } = {}
@i3v
i3v / cdm_fio.sh
Last active February 5, 2024 22:33
Reproducing CrystalDiskMark tests with fio - fixes for https://unix.stackexchange.com/revisions/480191/9
#!/bin/bash
# This script is based on https://unix.stackexchange.com/revisions/480191/9 .
# The following changes proved to be necessary to make it work on CentOS 7:
# * removed disk info (model, size) - not very useful, might not work in many cases.
# * using "bw" instead of "bw_bytes" to support fio version 3.1 (those availible through yum @base)
# * escaping exclamation mark in sed command
# * the ".fiomark.txt" is not auto-removed
LOOPS=5 #How many times to run each test
@gxfxyz
gxfxyz / synology_disk_benchmark.sh
Created October 1, 2018 18:16
A simple script to test Synology NAS disk speed with hdparm, dd and fio
#!/usr/bin/env bash
# =======================================================================================
#
# A simple script to test Synology NAS disk speed with hdparm, dd and fio.
#
# How to use:
#
# 1. Save synology_disk_benchmark.sh and xfio.conf to your Synology NAS
# 2. Make it executable: chmod +x synology_disk_benchmark.sh
@robfe
robfe / about.md
Last active December 20, 2022 21:56
Running localstack in docker for windows with persistence enabled

Running localstack in docker for windows with persistence enabled

Running on Docker for Windows

Localstack comes with a docker-compose file that won't quite work when you're running the (linux) container in docker for Windows.

Two changes need to be made:

The docker.sock volume won't work on windows

We can just comment that line out:

@jamesfreeman959
jamesfreeman959 / keepawake.ps1
Last active May 9, 2024 00:19
A very simple PowerShell script to keep a Windows PC awake and make lync think the user is active on the keyboard
# Useful references:
#
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
# https://ss64.com/vb/sendkeys.html
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
#
# Future enhancements - use events rather than an infinite loop
$wsh = New-Object -ComObject WScript.Shell
while (1) {
@yuan3y
yuan3y / jekyll.service
Last active June 5, 2021 12:57
to make `jekyll serve` a system service and start on boot
# Author: @yuan3y
# Date: 2017-09-29
# Description: to make `jekyll serve` a system service and start on boot
#
# Usage: place this file at `/etc/systemd/system/jekyll.service`
# then run
# sudo systemctl start jekyll.service
# sudo systemctl enable jekyll.service
[Unit]
@avelino
avelino / gist:3188137
Created July 27, 2012 13:49
shell script, como colorir o retorno do seu código
echo -e " \033[0;30m Preto \033[0m --> 0;30 "
echo -e " \033[0;31m Vermelho \033[0m --> 0;31 "
echo -e " \033[0;32m Verde \033[0m --> 0;32 "
echo -e " \033[0;33m Marrom \033[0m --> 0;33 "
echo -e " \033[0;34m Azul \033[0m --> 0;34 "
echo -e " \033[0;35m Purple \033[0m --> 0;35 "
echo -e " \033[0;36m Cyan \033[0m --> 0;36 "
echo -e " \033[0;37m Cinza Claro \033[0m --> 0;37 "
echo -e " \033[1;30m Preto Acinzentado \033[0m --> 1;30 "
echo -e " \033[1;31m Vermelho Claro \033[0m --> 1;31 "