Skip to content

Instantly share code, notes, and snippets.

⌨️
keyboard shredding

Miguel Mota miguelmota

⌨️
keyboard shredding
Block or report user

Report or block miguelmota

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@miguelmota
miguelmota / alacritty.yml
Created Aug 14, 2019
Normal colors for Alacritty terminal
View alacritty.yml
colors:
normal:
black: '0x000000'
red: '0xcc0403'
green: '0x19cb00'
yellow: '0xcecb00'
blue: '0x0d73cc'
magenta: '0x0dcdcd'
cyan: '0x0dcdcd'
white: '0xdddddd'
@miguelmota
miguelmota / is_brave.js
Created Aug 14, 2019
JavaScript check if browser is Brave
View is_brave.js
const res = await (await fetch('https://api.duckduckgo.com/?q=useragent&format=json')).json()
const isBrave = res.Answer.includes('Brave')
console.log(isBrave)
@miguelmota
miguelmota / select_where_time_ago.sql
Created Aug 13, 2019
PostgreSQL select where timestamp is before some time ago
View select_where_time_ago.sql
SELECT * FROM users WHERE created_at >= NOW() - INTERVAL '5 minutes';
@miguelmota
miguelmota / omit_spread.js
Created Aug 13, 2019
JavaScript omit property in object spread example
View omit_spread.js
const props = {foo: 1, bar: 2, qux: 3}
const {foo, ...other} = props
console.log(foo) // 1
console.log(other) // {bar: 2, qux: 3}
@miguelmota
miguelmota / Dockerfile
Created Aug 12, 2019
Dockerfile golang with cgo
View Dockerfile
FROM golang:1.12rc1-alpine3.9
RUN apk --no-cache add gcc musl-dev
COPY . /go/src/github.com/myorg/myapp
WORKDIR /go/src/github.com/myorg/myapp
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o myapp cmd/myapp/main.go
CMD ["./myapp"]
@miguelmota
miguelmota / untar_dir.sh
Created Aug 12, 2019
Bash untar (unzip) contents to directory folder
View untar_dir.sh
tar -zxvf build.tar.gz -C /path/outdir --strip-components=1
@miguelmota
miguelmota / tar_gzip_directory.sh
Created Aug 12, 2019
Bash tar gzip directory folder
View tar_gzip_directory.sh
# tar gzip a folder
tar -cv build/ | gzip > build.tar.gz
# unzip a gzip tarball
tar -zxvf build.tar.gz
View cors_errors.txt
The cors headers in nginx.conf fixes the errors:
# firefox
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://example.com/. (Reason: CORS request did not succeed)
# safari
Failed to load resource: Origin http://example.com/ is not allowed by Access-Control-Allow-Origin.
Fetch API cannot load https:/remote.example.com. Origin http://example.com/ is not allowed by Access-Control-Allow-Origin.
@miguelmota
miguelmota / install_nginx.sh
Last active Aug 9, 2019
Nginx install headers-more-nginx-module (more_set_headers) in Amazon Linux AMI
View install_nginx.sh
#!/usr/bin/env bash
NGINX_VER=1.12.2
HEADERS_MORE_VER=0.33
PWD=`pwd`
cd /usr/local/src
# get nginx source.
wget http://nginx.org/download/nginx-${NGINX_VER}.tar.gz
@miguelmota
miguelmota / webauthn_supported.js
Created Aug 7, 2019
JavaScript check if webauthn api (fido/u2f) is supported in browser
View webauthn_supported.js
const isSupported = () => {
return !(typeof navigator.credentials !== 'object' || typeof navigator.credentials.create !== 'function' || typeof navigator.credentials.get !== 'function')
}
You can’t perform that action at this time.