Skip to content

Instantly share code, notes, and snippets.

David Pennington Xeoncross

View GitHub Profile
@Xeoncross
Xeoncross / simple_query.go
Created Apr 17, 2019
Simple helper function to reduce duplicated `rows.Scan()` code
View simple_query.go
package main
import (
"fmt"
"log"
"reflect"
"testing"
)
// What if you could provide the query, params, and the slice of objects to populate?
@Xeoncross
Xeoncross / dump.go
Created Apr 17, 2019 — forked from janhalfar/dump.go
golang reflection games
View dump.go
func dump(v reflect.Value, path string) {
switch v.Type().Kind() {
case reflect.Interface:
if v.Elem().Type().Kind() == reflect.Interface {
fmt.Println(path, ":", "merry xmas an interface")
} else {
dump(v.Elem(), path)
}
case reflect.Int, reflect.Int64, reflect.Float64:
fmt.Println(path, ":", "it is a number", v.String())
View hi_reddit.go
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}
@Xeoncross
Xeoncross / serve.go
Created Apr 14, 2019 — forked from paulmach/serve.go
Simple Static File Server in Go
View serve.go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@Xeoncross
Xeoncross / keybase.md
Created Apr 9, 2019
New Keybase Identity
View keybase.md

Keybase proof

I hereby claim:

  • I am xeoncross on github.
  • I am xeoncross (https://keybase.io/xeoncross) on keybase.
  • I have a public key ASDJo_-IuEPErcIf46_LTrZ3apNvcRQOPOjqEFnOdixU6wo

To claim this, I am signing this object:

@Xeoncross
Xeoncross / bar_chart.py
Created Apr 3, 2019
Simple python3 chart of list values - https://matplotlib.org
View bar_chart.py
import matplotlib.pyplot as plt
# Easy way to see a large list as a barchart for visual inspection of a numeric attribute like "size"
sizes = [1,2,3,4,5,6,4,3,2,1]
fig = plt.figure()
ax = plt.subplot(111)
ax.bar(range(len(sizes)), sizes)
plt.show()
@Xeoncross
Xeoncross / nil_chan.go
Created Apr 1, 2019
Example of setting a channel to nil from a receiver while still closing it from the caller.
View nil_chan.go
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan int)
@Xeoncross
Xeoncross / call_method_with_reflection.go
Created Mar 27, 2019 — forked from tkrajina/call_method_with_reflection.go
Golang, call method (and fill arguments) with reflection
View call_method_with_reflection.go
package main
import (
"fmt"
"reflect"
)
type Aaa struct {
a string
}
@Xeoncross
Xeoncross / spacy_to_question.py
Created Mar 19, 2019
Convert input sentences to questions using spaCy
View spacy_to_question.py
# https://stackoverflow.com/questions/55243829/easy-way-for-sentence-to-question-using-spacy-in-python
from textacy.spacier import utils
import spacy
nlp = spacy.load("en_core_web_sm")
inp = input() # The ingredients for an omelette are eggs, bacon, cheese, and onions, I do zip your code
doc = nlp(inp) # John will be finishing his homework We were taking classes for decades
string,label = [],""
for sentence in doc.sents:
root = sentence.root
View amazon_dynamodb.md

Amazon DynamoDB

Amazon DynamoDB supports several more advanced key/value operations:

  • Batch Operations
  • Atomic Counters
  • Conditional Writes
  • Time To Live
You can’t perform that action at this time.