Skip to content

Instantly share code, notes, and snippets.

View eurica's full-sized avatar

David Hayes eurica

View GitHub Profile
@eurica
eurica / app.js
Last active April 18, 2024 02:03
Quick one off to compare LLMs handling tweets
// WARNING: this code is 80% machine generated with Github Copilot
// I've fixed the bugs I've found, but only refactoring in the rare cases I literally can't follow the code.
// This is a bad codebase.
require("dotenv").config();
const { HeliconeProxyOpenAI} = require("@helicone/helicone");
const { Anthropic } = require('@anthropic-ai/sdk');
const OpenAI = HeliconeProxyOpenAI;
const fs = require("fs");
@eurica
eurica / autobackup.bat
Created February 3, 2011 06:10
My automated backup script
@rem Simple recursive backup script dave@euri.ca 2011
@echo off
rem I strongly recommend backing up to a different drive or machine
set sourcedir=c:\projects
set destdir=g:\autobackups\projects
for /f "tokens=1-3 delims=/ " %%g in ('date /t') do (
set mm=%%g
set dd=%%h
@eurica
eurica / PagerDutyWebhookToEmail.php
Last active November 22, 2019 02:12
Simple example of using PagerDuty webhooks and PHP to forward all incident state changes to an email address.
Sample PHP code to accept PagerDuty webhooks and send out notifications by email on state changes.
For more information, see http://developer.pagerduty.com/documentation/rest/webhooks
This example threads emails based on "$status: $description on $service" so each update to each incident would start a new thread.
This code is unsupported by PagerDuty.
<?php
$emailAddress = "CHANGEME@example.com";
require 'pp'
require 'httparty'
class PagerDuty
include HTTParty
format :json
def initialize(subdomain, api_token)
@options = {
:headers => {
"Authorization" => "Token token=#{api_token}",
@eurica
eurica / twilio-numbers.rb
Created December 20, 2013 20:55
Ruby script to check numbers against the Twilio Price list.
require 'csv'
#Parse the CSV that Twilio provides https://www.twilio.com/resources/rates/international-rates.csv
numbers = []
CSV.foreach('international-rates.csv', :headers => true) do |row|
starts = row[2].split(",")
starts.each do |p|
numbers.push([p.strip, p.strip.length, row[1], row[0]])
end
end
@eurica
eurica / spark2pd.js
Created July 7, 2016 21:13
A custom event transformer to create incidents from Cisco Spark
function transform(PD) {
var webhook = PD.inputRequest.body
var message = webhook.text || "Error: Not a Spark chat message";
var room_link = ciscospark2web(b64decode(webhook.roomId)); // clean up the link
var normalized_event = {
incident_key: room_link, //So that all messages from a room de_dupee into the same incident
event_type: PD.Trigger,
description: message,
details: {
@eurica
eurica / README.md
Last active December 21, 2015 23:49 — forked from mbostock/.block
Fixed-X Force Directed Tree
@eurica
eurica / s3upload.sh
Created May 1, 2013 00:46
A bash script to upload files for static hosting on s3
# Bash script to upload files to static s3 hosting with s3cp
# dave@pagerduty.com April 30th, 2013
# Modified from https://github.com/roqs23/sync-svn-updates-to-s3/blob/master/svnupd2s3.sh
export COMMON_HEADER="--header \"x-amz-acl: public-read\" --header \"Vary: Accept-Encoding\" "
export HTML_HEADER="--header \"Cache-Control: max-age=604800,must-revalidate\" --header \"Content-Type: text/html\""
export CSS_HEADER="--header \"Cache-Control: max-age=604800,must-revalidate\" --header \"Content-Type: text/css\""
export JS_HEADER="--header \"Cache-Control: max-age=604800,must-revalidate\" --header \"Content-Type: application/javascript\""
export PNG_HEADER="--header \"Cache-Control: max-age=2592000,must-revalidate\" --header \"Content-Type: image/png\""
export GIF_HEADER="--header \"Cache-Control: max-age=2592000,must-revalidate\" --header \"Content-Type: image/gif\""
@eurica
eurica / otp.php
Created November 9, 2012 06:16
One time pad server code sample
<?
// One Time Pad from string demo.
// http://euri.ca/2012/11/encryption-that-calls-home-skyfall-movie-magic/
// Don't use this in production, obviously since you can brute force the seed.
// (Actually coming up with a server that generates OTPs in response to a seed is a decent problem)
$seed = "LOCALSECRET" + $_SERVER["QUERY_STRING"];
$hash = hash('sha256', $seed);
$dec = hexdec($hash);
mt_srand($dec);
@eurica
eurica / gist:825248
Created February 13, 2011 22:50
Automated backup script for Android smartphone
@echo off
set destdir=G:\autobackups
set devicefile=htc_desire
for %%d in (E F G H I J K L) do (
if exist %%d:\%devicefile% (
echo %%d is the %devicefile%
xcopy %%d:\ "%destdir%\%devicefile%" /V /E /D /C /I /Y > %destdir%\%devicefile%\lastbackup.txt
)
)