Skip to content

Instantly share code, notes, and snippets.

View stnc's full-sized avatar
🎯
Focusing

TUNÇ Selman stnc

🎯
Focusing
View GitHub Profile
@stnc
stnc / pointer_structure_with_embed.go
Last active July 6, 2023 03:50
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 nam…
//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 / 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 / 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 / three_dot.go
Created July 2, 2023 22:47
How to use Ellipsis (…) in Golang?
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 / 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 / validator.php
Last active October 15, 2021 15:32
php turkey phone number validator (regex)
<?php
function turkcell_validator($str)
{
$regex = '/^(\+?12)?(9053\d{1}|7[1-9]\d{1})\d{7}$/';
preg_match_all($regex, $str, $matches, PREG_SET_ORDER, 0);
@stnc
stnc / HandleBar_mini.html
Last active March 7, 2021 18:12
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"