Skip to content

Instantly share code, notes, and snippets.

View PumpkinSeed's full-sized avatar
🍞
Brot

Ferenc Fabian PumpkinSeed

🍞
Brot
View GitHub Profile

Keybase proof

I hereby claim:

  • I am pumpkinseed on github.
  • I am pumpkinseed (https://keybase.io/pumpkinseed) on keybase.
  • I have a public key ASDETIsqylA0ZhLdIsu3jkz2su4a9MPqtuVDqPrOIrlwQAo

To claim this, I am signing this object:

@PumpkinSeed
PumpkinSeed / data_structure.go
Created October 10, 2019 14:36
Example data structure for blog post
type webshop struct {
Token string `json:"token"`
...
PaymentTransactionID string `json:"payment_transaction_id"`
Product *product `json:"product" cb_referenced:"product"`
Store *store `json:"store,omitempty" cb_referenced:"store"`
}
type product struct {
ID string `json:"id"`
package htmltopdf
import (
"bytes"
"io/ioutil"
// import the main library what we use
"github.com/SebastiaanKlippert/go-wkhtmltopdf"
)
package main
import (
"encoding/json"
"fmt"
"reflect"
)
var test = `{
"title":"%s",
@PumpkinSeed
PumpkinSeed / sql.go
Last active June 11, 2023 12:56
Extension for sql package
func structScan(rows *sql.Rows, model interface{}) error {
v := reflect.ValueOf(model)
if v.Kind() != reflect.Ptr {
return errors.New("must pass a pointer, not a value, to StructScan destination") // @todo add new error message
}
v = reflect.Indirect(v)
t := v.Type()
cols, _ := rows.Columns()
func Contains(s, value interface{}) bool {
v := reflect.ValueOf(s)
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
typeOfField := field.Type()
switch typeOfField {
case stringType:
if containsString(field.String(), value) {
return true
}
@PumpkinSeed
PumpkinSeed / file.go
Created July 26, 2017 20:40
File output handler for heurelog
package output
import (
"fmt"
"io/ioutil"
"github.com/PumpkinSeed/heurelog/config"
)
type File struct {
@PumpkinSeed
PumpkinSeed / nsq.go
Last active July 26, 2017 16:49
NSQ input handler for heurelog
package input
import (
"sync"
"fmt"
"github.com/PumpkinSeed/heurelog/config"
"github.com/PumpkinSeed/heurelog/handlers/output"
"github.com/Sirupsen/logrus"
@PumpkinSeed
PumpkinSeed / memory.go
Created July 21, 2017 11:23
Visual example how golang GC and memory usage working.
package main
import (
"log"
"runtime"
"time"
)
var counter int