Skip to content

Instantly share code, notes, and snippets.

View jptoto's full-sized avatar
😃

JP Toto jptoto

😃
View GitHub Profile
@jptoto
jptoto / gist:3b2197dd652ef13bd7f3cab0f2152b19
Last active February 8, 2023 23:56
Catch camera event
#!/bin/bash
# Begin looking at the system log via the steam sub-command. Using a --predicate and filtering by the correct
# subsystem first improves CPU performance DRASTICALLY. Then just pull out the camera event
log stream --predicate 'subsystem == "com.apple.VDCAssistant" && eventMessage CONTAINS[c] "Post event kCameraStream"'| while read line; do
# If we catch a camera start event, turn the light on
if echo "$line" | grep -q "Post event kCameraStreamStart"; then
echo "Camera has been activated, turn on the light."
curl -s -o /dev/null http://192.168.1.198/gpio/1
@jptoto
jptoto / gist:0a4a755328eb57f074c0b0b72549054a
Created September 28, 2020 19:43
Restart MacOS Sound Server Core Audio
sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`
@jptoto
jptoto / example.cs
Created October 2, 2015 15:18
PM Async Example
// Send an email with the Postmark .NET library
// Learn more -> http://developer.postmarkapp.com/developer-official-libs.html#dot-net
// Install with NuGet
PM> Install-Package Postmark
// Import
using PostmarkDotNet;
// Example asynchronous request
@jptoto
jptoto / phpmailer.php
Created May 26, 2015 18:06
PHP Mailer Example
<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.postmarkapp.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
@jptoto
jptoto / Program.cs
Created April 23, 2015 16:15
Get Bounces Async
using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Channels;
using System.Threading.Tasks;
using System.Xml;
using PostmarkDotNet;
namespace ConsolePostmarkLibTester
{
class Program
@jptoto
jptoto / Program.cs
Created April 18, 2015 21:59
Sending a message with Postmark Async
using System.Threading.Tasks;
using PostmarkDotNet;
namespace ConsolePostmarkLibTester
{
class Program
{
static void Main(string[] args)
{
Task.Run(async () =>
foreach ($f in Get-ChildItem -Recurse -Path ".\" -Filter *.sln | sort-object)
{
nuget.exe restore $f.FullName -verbosity detailed
}
@jptoto
jptoto / Program.cs
Created February 2, 2015 14:08
log4net testing
class Program
{
private static readonly ILog _log = LogManager.GetLogger(typeof(Program));
static void Main(string[] args)
{
try
{
var z = decimal.Divide(10, 0);
}
catch (Exception ex)
@jptoto
jptoto / custom_exception.cs
Created January 27, 2015 21:16
Custom Exception w/ Log4net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using log4net;
namespace ConsoleApplication1
{
@jptoto
jptoto / gist:af50adc56e26c98be819
Created December 2, 2014 14:13
Send to Postmark w/ UTF8 Chars
import httplib
import json
postmark_token = 'API_TOKEN'
toRecip = u'''\u2122'''.encode('utf8')
url = '/email'
msg = {
'From': '"JP Toto" <jp@wildbit.com>',