Skip to content

Instantly share code, notes, and snippets.

View zshannon's full-sized avatar

Zane Shannon zshannon

View GitHub Profile
@zshannon
zshannon / example.swift
Created August 12, 2024 23:59
AsyncSempaphore deadlock demo
import Semaphore
struct Example {
public func observe() async throws -> (AsyncThrowingStream<Int, Error>, AsyncSemaphore) {
let semaphore: AsyncSemaphore = .init(value: 0)
let stream: AsyncThrowingStream<Int, Error> = .init { continuation in
let forwardingTask = Task {
// simulate counter changing [0 -> 1]
continuation.yield(1)
try await Task.sleep(for: .milliseconds(50))
@zshannon
zshannon / LiquidBlobs.swift
Created February 14, 2024 23:32 — forked from stammy/LiquidBlobs.swift
Liquid Blob effect with SwiftUI
//
// ContentView.swift
// LiquidCircles
//
// Created by Paul Stamatiou on 10/10/22.
//
import SwiftUI
struct ContentView: View {
@zshannon
zshannon / olark.js
Created December 7, 2014 22:20
Turbolinks Compatible Olark Initiator
var initOlark = function(){
var c = {
loader: "static.olark.com/jsclient/loader0.js",
name: "olark",
methods: ["configure", "extend", "declare", "identify"]
};
var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";
var nt=function(){
f[z]=function(){
@zshannon
zshannon / 0-Angular Tips.md
Last active August 29, 2015 14:06
AngularJS Tips

Couple abstract ideas:

  • Angular apps are little separate kingdoms.
  • You can't get into them from outside, and it's really frowned upon to use jQuery within them to access the DOM.
  • Angular Controllers extend this concept. They can only control the DOM nodes at and below the node with ng-controller designated.

The loading order is somewhat important. I set it up like this: [jQuery, jQueryUI, Bootstrap, Underscore, Angular Library, any Angular Plugins, Angular Application init file, rest of angular files].

### Keybase proof
I hereby claim:
* I am zshannon on github.
* I am zcs (https://keybase.io/zcs) on keybase.
* I have a public key whose fingerprint is F35D 5E5F C30B 14FF 3630 0579 2A0D 9512 67DA 24F8
To claim this, I am signing this object:
@zshannon
zshannon / gist:7595974
Created November 22, 2013 07:00
Gitlab Mavericks Install: posix_spawn seg fault
$ sudo -u git -H bash -l -c 'bundle exec rake gitlab:setup RAILS_ENV=production'
Password:
/Users/git/gitlab/vendor/bundle/ruby/2.0.0/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle: [BUG] Segmentation fault
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
@zshannon
zshannon / README.md
Last active December 16, 2020 14:02
Bash script for MySQL Dumps GPG Public Key encrypted, then offloaded to S3.

mysql-backup.sh will dump all of your MySQL databases, encrypt them using a GPG public key, transfer them to a S3 bucket, then delete them.

Getting Started:

  1. Install s3cmd ($ apt-get install s3cmd)
  2. Generate a GPG key and upload it to a key server. Remember the $KEY_ID and $KEY_NAME. (Google this. It's straightforward.)
  3. Download the GPG key onto the MySQL host server. ($ gpg --keyserver subkeys.pgp.net --recv-key $KEY_ID)
  4. Create a new keyring for this key. ($ gpg --export $KEY_NAME | sudo tee /etc/backups/keyring.gpg > /dev/null)
  5. Put mysql-backup.sh somewhere, and CHMOD 755 it. (/etc/backups/mysql-backup.sh is cool.)
  6. Test it. ($ ./etc/backups/mysql-backup.sh)
  7. Check your S3 bucket for the backup file, download it and decrypt it using the private key you made in Step 2.