Skip to content

Instantly share code, notes, and snippets.

View jeremysimmons's full-sized avatar

Jeremy Simmons jeremysimmons

View GitHub Profile
@jeremysimmons
jeremysimmons / admin_head_post_edit_check.php
Created September 18, 2023 20:50 — forked from petenelson/admin_head_post_edit_check.php
WordPress admin action hooks for listing/adding/editing posts or pages
/* actions fired when listing/adding/editing posts or pages */
/* admin_head-(hookname) */
add_action( 'admin_head-post.php', 'admin_head_post_editing' );
add_action( 'admin_head-post-new.php', 'admin_head_post_new' );
add_action( 'admin_head-edit.php', 'admin_head_post_listing' );
function admin_head_post_editing() {
echo 'you are editing a post';
}
@jeremysimmons
jeremysimmons / wc_get_first_parent.php
Created August 28, 2023 14:55
Get the first parent id of a simple product woocommerce
function wc_get_first_parent($prod_id) {
$group_args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => '_children',
'value' => 'i:' . $prod_id . ';',
'compare' => 'LIKE',
)
),
@jeremysimmons
jeremysimmons / IndexedEnumerable.cs
Created October 18, 2022 14:33
Enumerable With Metadata
public static class IndexedEnumerable
{
public static IndexedEnumerable<T> AsIndexedEnumerable<T>(this IEnumerable<T> source)
{
return Create(source);
}
public static IndexedEnumerable<T> Create<T>(IEnumerable<T> source)
{
return new IndexedEnumerable<T>(source);
@jeremysimmons
jeremysimmons / .bashrc
Created September 19, 2022 16:21
dotnet format with desktop notify script
fcs() {
OUTPUT=$(dotnet format)
if [ $? -eq 0 ]; then
powershell -file $HOME/Toast.ps1 "Dotnet Format", "Completed successfully"
else
powershell -file $HOME/Toast.ps1 "Dotnet Format", "Failed $OUTPUT"
fi
}
@jeremysimmons
jeremysimmons / .gitconfig
Last active June 21, 2023 15:24
gitconfig
[user]
email = jsimmons@jeremysimmons.net
name = jeremy simmons
[alias]
# Get the current branch name (not so useful in itself, but used in other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track the upstream branch
publish = "!git push -u origin $(git branch-name)"
# Delete the remote version of the current branch
@jeremysimmons
jeremysimmons / MultipartFormDataContentExample.cs
Created August 23, 2022 00:57
HttpClient MultipartFormDataContent
HttpClient httpClient = new HttpClient();
MultipartFormDataContent form = new MultipartFormDataContent();
form.Add(new StringContent(username), "username");
form.Add(new StringContent(useremail), "email");
form.Add(new StringContent(password), "password");
form.Add(new ByteArrayContent(file_bytes, 0, file_bytes.Length), "profile_pic", "hello1.jpg");
HttpResponseMessage response = await httpClient.PostAsync("PostUrl", form);
response.EnsureSuccessStatusCode();
@jeremysimmons
jeremysimmons / .envrc
Created June 7, 2022 13:10
direnv githooks
git config --local core.hooksPath $PWD/.githooks
### Keybase proof
I hereby claim:
* I am jeremysimmons on github.
* I am jeremysimmons (https://keybase.io/jeremysimmons) on keybase.
* I have a public key ASDIP-c5HuHQmDj7RHXsgbpuzy-rz3dvocAQAqQ7XYMK2Ao
To claim this, I am signing this object:
@jeremysimmons
jeremysimmons / .gitignore
Created October 9, 2021 17:34 — forked from salcode/.gitignore
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@jeremysimmons
jeremysimmons / checkpoint-dismiss.js
Created September 30, 2021 16:20
Automatically dismiss CheckPoint access warning pages
// ==UserScript==
// @name Dismiss Checkpoint Access Warning
// @namespace checkpoint
// @version 1
// @description automatically dismiss the checkpoint access pages so I don't have to.
// @author Jeremy Simmons
// @match *://10.2.1.4/*
// @grant none
// @run-at document-idle
// ==/UserScript==