Skip to content

Instantly share code, notes, and snippets.

View mhulse's full-sized avatar
👋
👁 ❤️ open source software …

Michael Hulse mhulse

👋
👁 ❤️ open source software …
  • Instructure Inc.
  • Eugene, Oregon
View GitHub Profile
@mhulse
mhulse / fromhex.bash
Last active October 27, 2024 03:40
Bash function to convert hex to 256 terminal color.
# fromhex A52A2A
# fromhex "#A52A2A"
# BLUE_VIOLET=$(fromhex "#8A2BE2")
# http://unix.stackexchange.com/a/269085/67282
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
r=$(printf '0x%0.2s' "$hex")
@mhulse
mhulse / README.md
Last active September 16, 2024 23:06
Clipboard code prepend script

Clipboard code prepend script

This is a simple Zsh script designed to help developers who want to use AI services (like ChatGPT) to convert their code into multiple programming languages. The script’s goal is to streamline the process of adding a structured prompt to the clipboard for easier AI interaction.

Features

  • Automatically adds a customizable conversion prompt to existing code in the clipboard
  • Supports multiple programming languages (e.g., Ruby, TypeScript, JavaScript, Java, Python)
  • Uses pbpaste and pbcopy for clipboard management
  • Designed for macOS, with an option for cross-platform extension
@mhulse
mhulse / README.md
Last active April 19, 2024 08:52
Notable BETA channel installation instructions and global settings

macOS installation

  1. Visit the Notable “Insiders” GitHub repo
  2. Download the Notable-<latest-version>-mac.zip build from the releases page (e.g. Notable-1.9.0-beta.9-mac.zip)
  3. Double-click to open the zip, and then drag the app to your Applications directory (I think you can double click on the app, and macOS will ask if you want to move it)
  4. Open Notable ( + SPACE and type Notable)

To view/edit your settings, type COMMAND + ,.

Use SHIFT + COMMAND + P to open your command palette.

@mhulse
mhulse / SelectActiveLayers.jsx
Last active December 10, 2023 00:50
Adobe Illustrator script to select highlighted layers. Written by @Qwertyfly and only slightly modified by me. Original code and discussion can found here: https://forums.adobe.com/message/8328893
#target illustrator
function make() {
var name = 'temp'; // Action name.
var set = 'temp'; // Set name.
var level = app.userInteractionLevel;
var action;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
@mhulse
mhulse / Setting up Google Cloud Storage with CORS for Web Fonts.md
Last active August 5, 2023 19:17
Setting up CORS on Google Cloud Storage: An unofficial quick start guide to serving web fonts from Google's cloud. (I'm sure a lot of this info could be improved... Please leave comments if you have tips/improvements.)

Login:

Google Cloud Storage

You'll want to login using an official Google account (i.e. if this is for your company, use the comapany Gmail account vs. a personal one.)

When logging in, you might be prompted to verify the account; if so, enter your cell number to get a verification e-mail or phone call.

Once verified, you'll have to agree to the terms of service; do that, and click continue.

@mhulse
mhulse / ssh tunneling.md
Last active July 26, 2023 15:22
SSH Tunneling: Map port from remote machine to your local machine so you can work from the remote DB (example using Django DB settings)...

SSH Tunneling

  1. In your local_settings.py file:

    DATABASES = {
    	'default': {
    		'ENGINE': 'django.db.backends.postgresql_psycopg2',
    		'NAME': 'django_%s' % (PROJECT_NAME,),
    

'USER': xxxx,

@mhulse
mhulse / no-x.js
Last active July 22, 2023 09:08
[no-js] [no-touch] JavaScript utilities to put in <head> of HTML templates that will add `js` or `touch` classes for use in CSS and/or JS.
<!doctype html>
<html class="no-touch no-js">
<head>
<script> /* PUT `no-x.js` here, as early as possible, before any other CSS or JS calls ... */ </script>
</head>
...
@mhulse
mhulse / DetectDrag.as
Last active March 13, 2023 11:53
AS3: Drag object and detect what’s under the mouse during move.
package {
import flash.display.*;
import flash.events.*;
public class Main extends MovieClip {
// Constructor:
public function Main() {
@mhulse
mhulse / models.py
Created June 17, 2011 17:42
Django basic/simple category/sub-category model.
# ...
class Category(Base):
slug = models.SlugField(_(u'slug'), max_length=100, unique=True)
title = models.CharField(_(u'title'), max_length=250)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
class Meta:
verbose_name_plural = 'Categories'
<?php
/**
* Get a list of the most recently updated blogs.
*
* A copy of WP's `get_last_updated()`, exept I've added ability to filter
* and removed the need to pass so many args.
*
* @todo Move `$ignore` values to more global location?
*