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}'`
* How do I release this?
* I must be able to perform a 'rolling' release this in a live system w/o
causing a service interruption
* does it break backward compatability with existing users of the api/system/etc
* do we need to cut a new XSD? A new version (URI prefix) of our API?
* did we make updates to checkouts/SNAPSHOT deps? Do we need to cut new versions of project deps?
* how do I support existing users?
* in what order do the affected systems need to be released?
* are there system or service configuration changes that are required?
* What are the Security implications of my change?
@jptoto
jptoto / gist:7910411
Created December 11, 2013 13:27
log4net Debug
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\temp\log4net.txt" />
@jptoto
jptoto / gist:6225332
Created August 13, 2013 20:27
Swift PHP Mailer Example
<?php
require_once 'lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('staging-smtp.postmarkapp.com', 2525)
->setUsername('api_key')
->setPassword('api_key')
;
/*
@jptoto
jptoto / gist:5265126
Last active December 15, 2015 13:09
Postmark PHP Inbound Example
<?php
// Uses https://github.com/jjaffeux/postmark-inbound-php
require_once 'lib/Postmark/Autoloader.php';
\Postmark\Autoloader::register();
$inbound = new \Postmark\Inbound(file_get_contents('php://input'));
$filename = 'test.txt';
// ReSharper disable CheckNamespace
namespace RestSharp.Deserializers
// ReSharper restore CheckNamespace
{
public class DynamicJsonDeserializer : IDeserializer
{
public string RootElement { get; set; }
public string Namespace { get; set; }
public string DateFormat { get; set; }
@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 / webapi.cs
Created February 1, 2012 12:42
WebAPI Error Catch
[WebInvoke(UriTemplate = "", Method = "POST")]
public Email Post(Email email)
{
try
{
repository.Add(email);
foreach (var file in email.Attachments)
{
@jptoto
jptoto / gist:1054231
Created June 29, 2011 16:25
Tacking URL Function for SSRS
Function GetTrackingURL(ServiceProvider as String, TrackingNumber as String)
If ServiceProvider = "UPS" Then
Return string.format("http://wwwapps.ups.com/WebTracking/processInputRequest?InquiryNumber1={0}&sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&track.x=0&track.y=0",TrackingNumber)
Else
Return string.format("http://www.fedex.com/Tracking?tracknumbers={0}&action=track&language=english&state=0&cntry_code=us",TrackingNumber)
End If
End Function