Skip to content

Instantly share code, notes, and snippets.

View sagar290's full-sized avatar
🏠
Working from home

Sagar sagar290

🏠
Working from home
View GitHub Profile
fields := reflect.VisibleFields(reflect.TypeOf(struct{ employeeDetails }{}))
for _, field := range fields {
fmt.Printf("Key: %s\tType: %s\n", field.Name, field.Type)
}
package structs
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
type PaymentBody struct {
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"github.com/gocolly/colly"
)
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"lib": ["dom", "es2017", "esnext.asyncIterable"],
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": true,
"noImplicitAny": true,
package main
import "fmt"
// AlphabteSize is the number of posible characters in tries
const AlphabteSize = 26
// Node represents the each node in the tries
type Node struct {
children [AlphabteSize]*Node
package main
import "fmt"
const ArraySize = 7
// has table hold the array
type HashTable struct {
array [ArraySize]*Bucket
}
@sagar290
sagar290 / wc_order_status_changes.php
Created July 3, 2021 16:37 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@sagar290
sagar290 / Makefile
Created May 28, 2021 08:43 — forked from PhirePhly/Makefile
A crazy simple SMTP server, for educational purposes only.
default:
cc ccsmtp.c -o ccsmtpd -lpthread
@sagar290
sagar290 / s3_policy.json
Created April 24, 2021 05:25
for public policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],