Skip to content

Instantly share code, notes, and snippets.

View danesparza's full-sized avatar
:octocat:
The best way to predict the future is to invent it - Alan Kay

Dan Esparza danesparza

:octocat:
The best way to predict the future is to invent it - Alan Kay
View GitHub Profile
@danesparza
danesparza / negroni-gorilla.go
Last active December 16, 2020 12:36
Negroni with Gorilla mux subrouter
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"log"
"net/http"
)
@danesparza
danesparza / command.go
Created June 14, 2020 18:33
Start (and kill) a command with arguments from go
package main
import (
"log"
"os/exec"
"time"
)
func main() {
// Start a process:
@danesparza
danesparza / main.go
Created October 7, 2019 12:48
Send a Slack notification to a channel using an incoming webhook on an app
package main
import (
"bytes"
"encoding/json"
"errors"
"log"
"net/http"
"time"
)
@danesparza
danesparza / main.go
Created May 22, 2019 18:37
Create a QR code
package main
import (
"log"
qrcode "github.com/skip2/go-qrcode"
)
func main() {
err := qrcode.WriteFile("https://www.danesparza.net", qrcode.Medium, 128, "qr.png")
@danesparza
danesparza / lastqueries.sql
Created February 27, 2019 19:18
Last 50 queries run on SQL server
SELECT TOP 50 * FROM(SELECT COALESCE(OBJECT_NAME(s2.objectid),'Ad-Hoc') AS ProcName,
execution_count,s2.objectid,
(SELECT TOP 1 SUBSTRING(s2.TEXT,statement_start_offset / 2+1 ,
( (CASE WHEN statement_end_offset = -1
THEN (LEN(CONVERT(NVARCHAR(MAX),s2.TEXT)) * 2)
ELSE statement_end_offset END)- statement_start_offset) / 2+1)) AS sql_statement,
last_execution_time
FROM sys.dm_exec_query_stats AS s1
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s2 ) x
WHERE sql_statement NOT like 'SELECT TOP 50 * FROM(SELECT %'
@danesparza
danesparza / main.go
Last active February 4, 2019 18:02
Test of ical library
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/danesparza/ical"
"github.com/teambition/rrule-go"
@danesparza
danesparza / main.go
Created January 14, 2019 21:26
Command execution (with pipes) in Go / golang
package main
import (
"log"
"os/exec"
)
func main() {
// First, query the OS to get a list of Wifi AP SSIDs
@danesparza
danesparza / main.go
Created August 30, 2018 18:09
Simple laydon test
package main
import (
"log"
. "github.com/ory/ladon"
manager "github.com/ory/ladon/manager/memory"
)
func main() {
@danesparza
danesparza / main.go
Created August 6, 2018 12:25
sqlx and ql testing
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/cznic/ql/driver"
"github.com/jmoiron/sqlx"
)
@danesparza
danesparza / tplinktest.go
Created August 4, 2018 17:28
TPLink smart plug energy meter working smoke test
package main
import (
"fmt"
"log"
"github.com/danesparza/tplink"
)
func main() {