Skip to content

Instantly share code, notes, and snippets.

@tzd
tzd / nosleep.sh
Created May 5, 2021 22:46
Completely disable sleep on any Mac
# Useful to prevent Macbooks to go to sleep when closing the lid instead of running tools that requires a Kernel Extension (e.g. InsomniaX) and more
# Before doing anything, save your current configuration using
pmset -g
# To disable sleep
sudo pmset -a sleep 0; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 1;
# And to go back to normal
sudo pmset -a sleep 1; sudo pmset -a hibernatemode [original hibernatemode value]; sudo pmset -a disablesleep 0;
@tzd
tzd / datafile.go
Created May 5, 2021 22:45 — forked from scottcagno/datafile.go
DataFile buffered io file wrapper for handling, reading, and writing binary data
package db
import (
"bufio"
"encoding/binary"
"io"
"os"
"path/filepath"
"unsafe"
)
@tzd
tzd / erc20-token-sample.sol
Created May 5, 2021 22:45 — forked from jcmartinezdev/erc20-token-sample.sol
Necessary code to generate an ERC20 Token [fav: true]
pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// Sample token contract
//
// Symbol : LCST
// Name : LCS Token
// Total supply : 100000
// Decimals : 2
// Owner Account : 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe
@tzd
tzd / sane-caching.nginx.conf
Created May 5, 2021 22:45 — forked from philipstanislaus/sane-caching.nginx.conf
Sample Nginx config with sane caching settings for modern web development
# Sample Nginx config with sane caching settings for modern web development
#
# Motivation:
# Modern web development often happens with developer tools open, e. g. the Chrome Dev Tools.
# These tools automatically deactivate all sorts of caching for you, so you always have a fresh
# and juicy version of your assets available.
# At some point, however, you want to show your work to testers, your boss or your client.
# After you implemented and deployed their feedback, they reload the testing page – and report
# the exact same issues as before! What happened? Of course, they did not have developer tools
# open, and of course, they did not empty their caches before navigating to your site.
@tzd
tzd / code-review-checklist.md
Last active May 6, 2021 21:36 — forked from nerandell/code-review-checklist.md
PHP Code Review Guidelines

Make sure these boxes are checked before submitting/approving the PR

General

  • The code works
  • The code is easy to understand
  • Follows coding conventions
  • Names are simple and if possible short
  • Names are spelt correctly
  • Names contain units where applicable
  • There are no usages of magic numbers
@tzd
tzd / ID.js
Created May 5, 2021 22:43
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@tzd
tzd / cors-nginx.conf
Created May 5, 2021 22:43 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@tzd
tzd / 01.bash_shortcuts_v2.md
Created May 5, 2021 22:43 — forked from tuxfight3r/01.bash_shortcuts_v2.md
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@tzd
tzd / nginx-tls.conf
Created May 5, 2021 22:42 — forked from gavinhungry/nginx-tls.conf
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Gavin Lloyd <gavinhungry@gmail.com>
# Desc: Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Enables HTTP/2, PFS, HSTS and OCSP stapling. Configuration options not related
# to SSL/TLS are not included here.
#
# Additional tips:
#
@tzd
tzd / NuxtServer.ts
Created May 5, 2021 22:40 — forked from ShaggyTech/NuxtServer.ts
Setup files needed for Nuxt TypeScript Runtime - working hot module reloading, automatic browser updates [fav: false]
// ./server/NuxtServer.ts
import express from 'express'
import consola from 'consola'
import { Nuxt, Builder } from 'nuxt-edge'
import config from '../nuxt.config'
import { PORT } from './'
export class NuxtServer {