Skip to content

Instantly share code, notes, and snippets.

:octocat:
Coding

Miguel Mota miguelmota

:octocat:
Coding
View GitHub Profile
@miguelmota
miguelmota / host_regex.js
Created Jul 2, 2020
JavaScript valid host (hostname + port) regex
View host_regex.js
/^([a-zA-Z0-9-_.]){1,253}(:[0-9]+)?$/
@miguelmota
miguelmota / i3-cheat-sheet.md
Last active Jul 2, 2020 — forked from JeffPaine/i3-cheat-sheet.md
i3 Window Manager Cheat Sheet
View i3-cheat-sheet.md

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (window/command or alt by default depending on config)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3
@miguelmota
miguelmota / regex.js
Created Jul 2, 2020
Node.js regex for matching all except a node_module
View regex.js
// returns true if the value doesn't match "/node_modules/mymodule"
/^(?!\/node_modules\/mymodule)/
@miguelmota
miguelmota / download.js
Created Jun 2, 2014
Read in an HTML file, look for images, and download with Node.js
View download.js
var cheerio = require('cheerio');
var fs = require('fs');
var concat = require('concat-stream');
var _ = require('lodash');
var request = require('request');
var stream = fs.createReadStream([__dirname, '/raw.html'].join(''));
var imagesDir = [__dirname, '/images'].join('');
stream.pipe(concat(function(body) {
@miguelmota
miguelmota / .xinitrc
Last active Jun 30, 2020
Arch Linux fix slow startup of GTK or gnome applications (dbus issue) (sometimes caused after installing flatpak)
View .xinitrc
# add to .xinitrc
dbus-update-activation-environment DISPLAY XAUTHORITY
# if the above didn't work, then replace it with this line (uncomment):
# dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS XAUTHORITY
# if the above didn't work, then replace it with this line (uncomment):
# eval `dbus-launch --sh-syntax --exit-with-session`
@miguelmota
miguelmota / remove_tuxera.sh
Last active Jun 30, 2020
Completely uninstall and remove Tuxera NTFS on MacOS (resets trial version)
View remove_tuxera.sh
sudo rm -rf /Applications/Tuxera\ Disk\ Manager.app
sudo rm -rf /Library/Application\ Support/Tuxera\ NTFS
sudo rm -rf /Library/Filesystems/fusefs_txantfs.fs
@miguelmota
miguelmota / ip_address.js
Created Jun 30, 2020
Node.js express ip address
View ip_address.js
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send(req.connection.remoteAddress))
app.listen(port, () => console.log(`Listening on http://localhost:${port}`))
@miguelmota
miguelmota / stdin_example.go
Last active Jun 27, 2020
Golang stdin read line example
View stdin_example.go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
@miguelmota
miguelmota / macos_docker.sh
Last active Jun 27, 2020
Run macOS in Docker container on Arch Linux
View macos_docker.sh
# https://github.com/sickcodes/Docker-OSX
sudo pacman -S qemu libvirt dnsmasq virt-manager bridge-utils flex bison ebtables edk2-ovmf xorg-xhost
xhost +
docker pull sickcodes/docker-osx
xhost +
docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ./OpenCore-Boot.sh
# disk formatting in installer:
@miguelmota
miguelmota / run_build.sh
Created Jun 24, 2020
CircleCI cli run build locally in docker
View run_build.sh
circleci local execute --job build
You can’t perform that action at this time.