Skip to content

Instantly share code, notes, and snippets.

View sonyarianto's full-sized avatar
🙏
Keep learning, stay relevant, relevancy increases value.

Sony AK sonyarianto

🙏
Keep learning, stay relevant, relevancy increases value.
View GitHub Profile
@sonyarianto
sonyarianto / index.js
Created September 14, 2023 13:57
Hello world!
console.log("Hello world!");
@sonyarianto
sonyarianto / read_shoutcast_icecast_metadata.php
Created December 27, 2020 08:35
Read Shoutcast or Icecast Stream Metadata
<?php
function getStreamMetadata($streamUrl) {
$needle = 'StreamTitle=';
$ua = 'Dailymate Radio/1.0';
$opts = ['http' => ['method' => 'GET',
'header' => 'Icy-MetaData: 1',
'user_agent' => $ua]
];
@sonyarianto
sonyarianto / get-local-ip-address.go
Last active December 7, 2018 08:41
Get local IP address
package main
import (
"fmt"
"log"
"net"
)
func main() {
conn, err := net.Dial("udp", "8.8.8.8:80")
@sonyarianto
sonyarianto / template-html-5.go
Last active December 8, 2018 03:52
Go template code - loop data on template
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index4.html
Created December 7, 2018 08:11
Sample of index4.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
<table>
{{range .}}
<tr>
@sonyarianto
sonyarianto / template-html-4.go
Last active December 8, 2018 03:51
Go template code - passing multiple variable
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / template-html-3.go
Last active December 8, 2018 03:51
Go template code - passing multiple variable
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index3.html
Created December 7, 2018 07:44
Sample of index3.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
My name is {{.Name}} and my age is {{.Age}}.
</body>
</html>
@sonyarianto
sonyarianto / template-html-2.go
Last active December 8, 2018 03:50
Go template code - pass simple variable
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index2.html
Created December 7, 2018 04:00
Sample of index2.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
My name is {{.}}.
</body>
</html>