Skip to content

Instantly share code, notes, and snippets.

: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 / command.go
Created Jun 14, 2020
Start (and kill) a command with arguments from go
View command.go
package main
import (
"log"
"os/exec"
"time"
)
func main() {
// Start a process:
@danesparza
danesparza / main.go
Created Oct 7, 2019
Send a Slack notification to a channel using an incoming webhook on an app
View main.go
package main
import (
"bytes"
"encoding/json"
"errors"
"log"
"net/http"
"time"
)
@danesparza
danesparza / main.go
Created May 22, 2019
Create a QR code
View main.go
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 Feb 27, 2019
Last 50 queries run on SQL server
View lastqueries.sql
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 Feb 4, 2019
Test of ical library
View main.go
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/danesparza/ical"
"github.com/teambition/rrule-go"
@danesparza
danesparza / main.go
Created Jan 14, 2019
Command execution (with pipes) in Go / golang
View main.go
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 Aug 30, 2018
Simple laydon test
View main.go
package main
import (
"log"
. "github.com/ory/ladon"
manager "github.com/ory/ladon/manager/memory"
)
func main() {
@danesparza
danesparza / main.go
Created Aug 6, 2018
sqlx and ql testing
View main.go
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/cznic/ql/driver"
"github.com/jmoiron/sqlx"
)
@danesparza
danesparza / tplinktest.go
Created Aug 4, 2018
TPLink smart plug energy meter working smoke test
View tplinktest.go
package main
import (
"fmt"
"log"
"github.com/danesparza/tplink"
)
func main() {
@danesparza
danesparza / activity_and_queryplan.sql
Last active Jun 22, 2018
Finding high CPU queries in SQL server
View activity_and_queryplan.sql
select getdate() 'colltime',
c.session_id,
s.login_name,
@@SERVERNAME 'sqlnwname',
db_name(m.dbid) 'dbname',
s.status,m.blocked,
s.program_name,
s.host_name,
t.last_wait_type,
t.wait_resource,
You can’t perform that action at this time.