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 / go-ole.go
Last active April 20, 2017 14:53
Using OLE to provide windows authenticated http requests
package main
import (
"fmt"
ole "github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
)
func main() {
@danesparza
danesparza / hdc1008.py
Created April 11, 2017 00:06
Python code to read temperature and humidity from an HDC1008 sensor on a Raspberry Pi
#!/usr/bin/python
import struct, array, time, io, fcntl
I2C_SLAVE=0x0703
# find with sudo i2cdetect -y 1
HDC1008_ADDR = 0x40
bus=1
fr = io.open("/dev/i2c-"+str(bus), "rb", buffering=0)
@danesparza
danesparza / bitshift.go
Created April 7, 2017 21:39
Golang bitshift test
package main
import (
"log"
)
const (
configRST = (1 << 15)
configHeat = (1 << 13)
)
@danesparza
danesparza / GetErrorLoggingMetrics.sql
Created February 24, 2017 19:20
SQL server script to get the error count by hour for the logging database
select
'Year' = DATEPART(YEAR, log_date),
'Month' = DATEPART(MONTH, log_date),
'Day' = DATEPART(DAY, log_date),
'Hour' = DATEPART(HOUR, log_date),
'Entries' = count(*)
from
system_logging
where
log_level = 'Error'
@danesparza
danesparza / pseudorandom_uuid.go
Created October 27, 2016 18:09
A pseudorandom UUID implementation using Go's crypto/rand
package main
import (
"crypto/rand"
"fmt"
)
func main() {
b := make([]byte, 16)
@danesparza
danesparza / database_sizes_and_fileinfo.sql
Created July 25, 2016 15:27
SQL script to get database sizes, disk information, and database recovery modes
with fs
as
(
select database_id, type, size * 8.0 / 1024 size
from sys.master_files
)
select
name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB
@danesparza
danesparza / player
Created May 27, 2016 20:34 — forked from isaiah/player
An audio player in golang.
package main
import (
"bytes"
"code.google.com/p/portaudio-go/portaudio"
"encoding/binary"
"fmt"
"io"
"log"
"os"
@danesparza
danesparza / grep-non-bootstrap.sh
Created May 13, 2016 16:33
grep command to find aspx files not converted to bootstrap
grep --directories=recurse --files-without-match "class=\"row\"" --include "*.aspx"
@danesparza
danesparza / install.bat
Created May 3, 2016 16:54
NSSM based service installation/removal scripts
@echo off
set InstallFolder="d:\services\centralconfig"
nssm install centralconfig %InstallFolder%\centralconfig_windows_amd64.exe
nssm set centralconfig AppParameters serve
nssm set centralconfig Description CentralConfig REST config service
nssm set centralconfig Start SERVICE_AUTO_START
@danesparza
danesparza / NLogExtensions.cs
Created January 12, 2016 19:10
NLog extension to log objects associated with a requestId
public static class NLogExtensions
{
/// <summary>
/// Logs the item with an associated requestid
/// </summary>
/// <param name="logger">The logger to use</param>
/// <param name="level">The log level to use</param>
/// <param name="objectToLog">The object to serialize</param>
/// <param name="message">The message to associate with the serialized object</param>
/// <param name="requestId">The requestid to associate with this item</param>