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 / talkingskull.ino
Created October 13, 2020 19:02
Updated jawduino code to control a servo based on sound
#include <Servo.h> // Standard servo library
Servo myservo;
#define SERVO_PIN 9 // Set to the controller pin for the servo
int servo_pos = 0;
int val1; // Floating value 1
int val2; // Floating value 2
int val3; // Floating value 3
@danesparza
danesparza / gcal.html
Created November 20, 2015 07:24
Google client side calendar API
<html>
<head>
<script type="text/javascript">
/*
Sample code taken shamelessly (and modified)
from https://developers.google.com/google-apps/calendar/quickstart/js
*/
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
@danesparza
danesparza / gist:1093992
Created July 19, 2011 23:21
Javascript date range overlap
var e1start = e1.start.getTime();
var e1end = e1.end.getTime();
var e2start = e2.start.getTime();
var e2end = e2.end.getTime();
return (e1start > e2start && e1start < e2end || e2start > e1start && e2start < e1end);
@danesparza
danesparza / exec.go
Last active June 28, 2023 20:41
Go exec.Command example
package main
import (
"bytes"
"fmt"
"os/exec"
"strings"
)
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 / logging.go
Created September 17, 2022 23:40 — forked from asdine/logging.go
Send zerolog errors to Sentry
package logger
import (
"encoding/json"
"fmt"
"io"
"log"
"os"
"runtime"
"time"
@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 / client.html
Created February 16, 2022 14:11
Small golang / html Server Sent Events (SSE) proof of concept
<html>
<head>
<meta charset="UTF-8">
<title>Server-sent events demo</title>
</head>
<body>
<button>Close the connection</button>
<ul>
</ul>
@danesparza
danesparza / gist:973923
Created May 16, 2011 04:02
Gravatar in C# - creating the hash
using System.Security.Cryptography;
/// Hashes an email with MD5. Suitable for use with Gravatar profile
/// image urls
public static string HashEmailForGravatar(string email)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
@danesparza
danesparza / main.go
Created June 2, 2021 13:41
Motion detection using Raspberry Pi and a PIR
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/stianeikeland/go-rpio"
)