Skip to content

Instantly share code, notes, and snippets.

View stnc's full-sized avatar
🎯
Focusing

TUNC Sam stnc

🎯
Focusing
View GitHub Profile
@stnc
stnc / calculator.go
Last active July 6, 2023 03:46
golang first init interface and struct https://go.dev/play/p/5Grp31thhPr
//https://go.dev/play/p/5Grp31thhPr
package main
import "fmt"
type Start struct {
Number1 float64
Number2 float64
Text string
RequestHandler RequestHandler
@stnc
stnc / three_dot.go
Last active April 16, 2025 19:33
How to use Ellipsis (…) in Golang? - using a variadic function
package main
import (
"fmt"
)
// using a variadic function
func find(num int, nums ...int) {
fmt.Printf("type of nums is %T\n", nums)
found := false
@stnc
stnc / embed_map_fo_structure.go
Created July 2, 2023 09:15
Embed map in JSON output for struct
type Response struct {
Text string `json:"text,omitempty"`
SessionAttributes map[string]any `json:"sessionAttributes,omitempty"`
}
func main() {
var renderA Response
renderA.Text = "dsds"
renderA.SessionAttributes = make(map[string]interface{}) //https://dev.to/rytsh/embed-map-in-json-output-5dnj
renderA.SessionAttributes["read"] = true
@stnc
stnc / pointer_structure_with_embed.go
Last active April 14, 2025 07:18
A field declared with a type but no explicit field name is an anonymous field, also called an
//https://www.appsloveworld.com/go/12/embedding-when-to-use-pointer
//https://go.dev/play/p/IeUvieCOjs4
//https://go.dev/play/p/IeUvieCOjs4 You can use one or the other: for struct type, the spec mentions:
//A field declared with a type but no explicit field name is an anonymous field, also called an
//embedded field or an embedding of the type in the struct.
//An embedded type must be specified as a type name T or as a pointer to a
//non-interface type name *T, and T itself may not be a pointer type
package main
@stnc
stnc / wordpress hestiacp and vestacp permission.sh
Last active July 3, 2023 04:34
wordpress hestiacp and vestacp permission
find /home/admin/web/mysite.com/public_html/ -type f -exec chmod 664 {} \;
find /home/admin/web/mysite.com/public_html/ -type f -exec chmod 755 {} \;
chgrp -R admin /home/admin/web/mysite.com/public_html/
chown -R admin:admin /home/admin/web
@stnc
stnc / visa.py
Created March 9, 2022 07:11 — forked from yaojialyu/visa.py
ais usvisa reschedule
# -*- coding: utf8 -*-
import time
import json
import random
import platform
from datetime import datetime
import requests
from selenium import webdriver
@stnc
stnc / vesta.sh
Last active February 10, 2022 10:33
#!/bin/bash
# Vesta installation wrapper
# http://vestacp.com
#
# Currently Supported Operating Systems:
#
# RHEL 5, 6, 7
# CentOS 5, 6, 7
# Debian 7, 8
@stnc
stnc / HandleBar_mini.html
Last active April 14, 2025 06:59
HandleBar.js example demo page https://stnc.github.io/handleBar/
<div id="singleItems" class="d-lfex justify-content-center flex-column">
<script id="singleItemsTpl" type="text/x-handlebars-template">
<div class="name_container">
<div class="name-">{{data.first_name}} {{data.last_name}} </div>
</div>
<div class="address"><strong>Mail:</strong> {{data.email}} </div>
web site
<hr>
<div class="address">{{support.url}} </div>
@stnc
stnc / time.go
Last active October 7, 2020 22:15
timer go
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"runtime"
@stnc
stnc / golang_reduce_map.go
Created October 2, 2020 12:08 — forked from wuriyanto48/golang_reduce_map.go
How to Join Map In Golang (Map Union)
package main
import (
"fmt"
)
type Item struct{
Id int
Name string
Qty int