Skip to content

Instantly share code, notes, and snippets.

View modosc's full-sized avatar

jonathan schatz modosc

View GitHub Profile
#!/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
@modosc
modosc / gist:cda31967282f78cfa361c95cac66f777
Created October 27, 2022 18:15
install gems from lockfile in github actions (workaround private gems / dependabot bugs)
#!/usr/bin/env ruby
require "bundler"
require "rubygems/commands/install_command"
# install a gem at the version specified in Gemfile.lock without using bundler.
# why? if you've got a private gem/repo in your Gemfile which requires a secret to install then 'bundle install' will fail on
# unsafe actions (eg, dependabot or any 3rd party opening a pr).
# this makes sense but it also breaks things like rubocop. to work around this you can use this script to programmatically
# install individual gems from your Gemfile with the correct version from Gemfile.lock.
@modosc
modosc / ios-custom-file-types.patch
Created October 29, 2021 19:17
patch for ios custom file types in juce
diff --git a/modules/juce_events/messages/juce_ApplicationBase.h b/modules/juce_events/messages/juce_ApplicationBase.h
index efb639d27..1086efeaa 100644
--- a/modules/juce_events/messages/juce_ApplicationBase.h
+++ b/modules/juce_events/messages/juce_ApplicationBase.h
@@ -205,6 +205,13 @@ public:
*/
virtual void memoryWarningReceived() { jassertfalse; }
+ /** Called by the operating system when a custim file type was opened. You are expected
+ * to return true of you handled the URL.
@modosc
modosc / ngrok.plist
Created December 5, 2018 18:07
plist to run ngrok in the background
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin</string>
</dict>
<key>KeepAlive</key>
@modosc
modosc / rollbar-wrapper.js
Created February 9, 2017 18:05
wrapper for node.js rollbar implementation that handles most of the client-side api.
// HACK HACK HACK
// rollbar's node api is totally different than the rollbar.js browser api.
// so we create a Proxy instance which intercepts calls to:
//
// 'debug', 'info', 'warn', 'warning', 'error', 'critical'
//
// and rewrites them to use the node api equivelant.
//
// this way we can do stuff like:
//
// fake localStorage - i use this with edux-persist when localStorage/localForage isn't available
export default class FakeLocalStorage {
constructor() {
this.storage = {}
}
setItem(key, value, callback) {
return new Promise((resolve, reject) => {
this.storage[key] = value
// eslint-disable-next-line no-console

Keybase proof

I hereby claim:

  • I am modosc on github.
  • I am modosc (https://keybase.io/modosc) on keybase.
  • I have a public key ASB5luMBRwDwZYI1YYBXD1H9wRXM2TLBxRoFl9fXDBBkCAo

To claim this, I am signing this object:

@modosc
modosc / class method wrapper
Created March 28, 2014 23:00
adding a wrapper around a class method from a superclass
# i didn't know that resque had hooks to do this already so i added it myself. of course the resque way is much cleaner
# this was fun to figure out
class ParentClass
@override = false
def self.singleton_method_added(name)
# metaprogram a wrapper around perform so that we transparently keep track
# of how many jobs are currently running
unless @override
if name == :perform
@override = true