Skip to content

Instantly share code, notes, and snippets.

@gocs
gocs / baud.go
Last active July 19, 2022 06:06
why does usb serial prints unreadable �? identify your usb's BAUD `stty -F /dev/ttyUSB0`
package main
import (
"bufio"
"fmt"
"github.com/tarm/serial"
)
func main() {
@gocs
gocs / .md
Created July 19, 2022 11:42
golang time.Time zero value

What should be the time.Time's zero value?

It should be time.Now()

@gocs
gocs / icann-tld.sh
Created July 29, 2022 03:18
print for available tlds
#!/usr/bin/env bash
curl -SsfL https://data.iana.org/TLD/tlds-alpha-by-domain.txt | sed '/^#/d' - | awk '{print tolower($0)}'
@gocs
gocs / setup.md
Last active October 28, 2022 00:01
Linux setups after initial os boot

update os (DO THIS FIRST)

sudo apt update
sudo apt upgrade -y

enable password authentication for ssh

@gocs
gocs / .md
Last active November 1, 2022 16:12
dayz deer isle alcatraz trap
@gocs
gocs / angular_swal.md
Created February 8, 2023 13:37
ng-sweetalert2 as simple as alert

simple SwalPortalDirective

The following example demonstrates a simple Swal with a button. In this example, you could provide more HTML within your HTML component rather than binding the HTML to an [html]. You would still need to import the SwalPortalTargets in your component.

import { SwalPortalTargets } from '@sweetalert2/ngx-sweetalert2';
export class MyComponent {
 public constructor(public readonly swal_targets: SwalPortalTargets) { }
@gocs
gocs / WRONGPASS.md
Last active March 6, 2023 01:34
if you have "WRONGPASS invalid username-password pair" error

one cause is if you have quotes on your .env file

REDIS_PASSWORD="1_secret_password"

remove the quotes

REDIS_PASSWORD=1_secret_password
@gocs
gocs / .sh
Created March 24, 2023 06:56
new golang mod for open source
go mod init $(git remote -v | head -n 1 | sed -E 's/.*:([^\.]+)\..*/\1/' | awk '{print "github.com/"$1}')
@gocs
gocs / .sh
Last active May 25, 2023 07:23
create angular app
# basic
npx -p @angular/cli ng new myappshop
# create angular app in the current directory especially when the current folder is already a git repo
npx -p @angular/cli ng new $(basename "$PWD") --directory=./ --skip-git
# with scss and defaults
npx -p @angular/cli ng new $(basename "$PWD") --directory=./ --skip-git --style=scss --defaults
# with version 16
@gocs
gocs / .sh
Created April 1, 2023 08:52
get host automatically
ng serve --host $(hostname -I | cut -f1 -d' ')