Skip to content

Instantly share code, notes, and snippets.

View eahrold's full-sized avatar

Eldon Ahrold eahrold

View GitHub Profile
@eahrold
eahrold / HttpSessionResolver
Created May 9, 2022 01:56
A micronaut HttpSessionResolver
package com.example;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.context.ServerRequestContext;
import io.micronaut.session.Session;
import io.micronaut.session.SessionStore;
import io.micronaut.session.http.SessionForRequest;
import jakarta.inject.Singleton;
import java.util.Optional;
@eahrold
eahrold / chunkablePromises.js
Last active March 30, 2020 19:28
Chunkable Promises
const _ = require('lodash')
/**
* Async Waiting utility
* @param {Number} wait Number of MS to wait
* @return {Promise} A promise to await
*/
const waiter = async function(wait = 0) {
return new Promise((resolve) => {
if (wait <= 0) {
@eahrold
eahrold / ProcessPipe.swift
Last active October 24, 2020 17:12
pipe Process (NSTask) in swift
//
// ProcessPipe.swift
//
// Created by Eldon on 8/10/18.
// Copyright © 2018 Big Club Digital. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIO
[2016-02-16 15:43:05] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Illuminate\Routing\Middleware\ThrottleRequests::addHeaders() must be an instance of Illuminate\Http\Response, instance of Illuminate\Http\JsonResponse given, called in /home/vagrant/Code/MyCatsProject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php on line 52 in /home/vagrant/Code/MyCatsProject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:94
Stack trace:
#0 /home/vagrant/Code/MyCatsProject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(52): Illuminate\Routing\Middleware\ThrottleRequests->addHeaders(Object(Illuminate\Http\JsonResponse), '60', 59)
#1 [internal function]: Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), '60', '1')
#2 /home/vagrant/Code/MyCatsProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_
@eahrold
eahrold / OSXMounter.py
Last active November 21, 2020 16:11 — forked from pudquick/mount_shares.py
Programmatically mount shares in OS X via python without the need for AppleScript
import os
import objc, CoreFoundation
from ctypes import c_void_p, pointer, cast
# The only reason I'm doing this the XML way is because I don't have a better way (yet)
# for correcting a function signature -after- it's already been imported.
# The problem is the last argument is a pointer to a CFArrayRef, which works out to a
# pointer to a pointer to a CFArray. pyobjc doesn't handle that much abstraction, so I created
# a custom opaque type 'CFArrayRefRef' and manually handle the conversion to/from pointer.
@eahrold
eahrold / NSTextField+controlTextDidPause.h
Last active August 29, 2015 14:21
Monitor NSTextFiled for a pause during user input.
//
// NSTextField+controlTextDidPause.h
//
// Created by Eldon Ahrold on 5/23/15.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@eahrold
eahrold / afp_mount_test.py
Last active August 29, 2015 14:16
Mount an AFP Share (JSSImporter test...)
#!/usr/bin/env python
import urllib
import subprocess, os
''' Set these '''
user = "your_username"
password = "your_password"
server = "your.server.com"
@eahrold
eahrold / simple-mount.m
Created February 12, 2015 15:16
Most basic cocoa based network mount. Set to NOT prompt for user interaction.
#import <NetFS/NetFS.h>
///....////
- (void)mount:(NSURL *)networkShare user:(NSString *)user password:(NSString *)password
{
NSURL *mountPath = [NSURL URLWithString:@"/Volumes/"];
dispatch_queue_t myQueue = dispatch_get_main_queue();
AsyncRequestID requestID = NULL;
@eahrold
eahrold / jds_post_test.py
Last active August 29, 2015 14:11
Test POST to your JDS
#/usr/bin/python
''' if you don't have the requests module installed you'll need to do that
with either pip or easy_install'''
import os,requests
''' Setup server and auth data. This is the name of your JSS,
NOT the webdav share of the JDS. The JSS actually distributes the
data you upload to it across the JDS shares.
'''
@eahrold
eahrold / version.string.regex
Last active August 29, 2015 14:11
Version String Detection Regex
(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?(?:(?:-(alpha\d*|beta\d*|rc\d*))?)
Will detect these formats
1.21.23
1.21.23-rc
1.21.23-rc1
2.21.23-alpha
1.211.233-beta12
3.12