Skip to content

Instantly share code, notes, and snippets.

@gocs
gocs / format_phone.php
Last active October 7, 2021 05:27
validate or format phone number in php
/**
* FormatPhone formats phone number
* @param string $number phone number
*
* @return int formatted phone number
*
*/
function FormatPhone($phone)
{
$rx = "/
@gocs
gocs / form-select-onchange-onsubmit.html
Created October 8, 2021 10:42
add function before FROM SELECT ONCHANGE ONSUBMIT;
<form method="post" onchange="post_to_popup(this);this.submit();">
<select></select>
</form>
@gocs
gocs / fixed-header-and-scrollable-contents.html
Last active December 1, 2021 07:15
example of fixed header and scrollable contents using flexbox
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>fixed header and scrollable contents</title>
<style>
body {
margin: 0;
@gocs
gocs / cdn.md
Last active February 27, 2022 13:49
i.i.i.imamamamagecddn-unseodable

image

image

@gocs
gocs / auth\auth.go
Created June 3, 2022 06:47
simple auth web app
package auth
import (
"errors"
"html/template"
"log"
"net/http"
"time"
"github.com/go-chi/jwtauth/v5"
@gocs
gocs / glyph_test.sh
Created June 27, 2022 06:22
enable UTF-8 support in the Linux console?
#!/bin/sh
# https://unix.stackexchange.com/a/303713
# send character-string to enable UTF-8 mode
if test ".$1" = ".off" ; then
printf '\033%%@'
else
printf '\033%%G'
fi
@gocs
gocs / support for password authentication was removed.md
Last active July 2, 2022 13:26
remote: Support for password authentication was removed

got this error when using gh?

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/<user>/<repo>/'

my approach is to re-authenticate gh

@gocs
gocs / README.md
Last active July 17, 2022 02:53
signal cancel and timeout on an infinite loop go golang

golang program to gracefully terminate on SIGTERM signal or timeout in a loop

ctrl + c gracefully terminates the app using the current terminal

terminate app from different terminal

the program output its pid

@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() {