Skip to content

Instantly share code, notes, and snippets.

View ejdanderson's full-sized avatar
🗿
mostly

Evan Anderson ejdanderson

🗿
mostly
View GitHub Profile
@ejdanderson
ejdanderson / sort_eig.m
Created September 19, 2021 22:29
Sort via descending order for eig in MATLAB (real values)
[V, D] = eig(A);
[nuDiag,order] = sort(diag(D),'descend');
D = diag(nuDiag);
V=V(:,order);
@ejdanderson
ejdanderson / update-url.js
Created June 6, 2017 22:22
Add/remove query parameters to the URL bar
updateParams : function() {
$('.class').on('change', function(e) {
e.preventDefault();
let url = window.location.pathname;
if ( $(this).prop('checked') ) {
let query_string = this.buildParamStr('param-name', 'param-value', true);
window.history.pushState('old-ai-state', '', url + query_string);
} else {
let query_string = this.buildParamStr('ai_fwp_filter', null, false);
window.history.pushState('old-ai-state', '', url + query_string);
@ejdanderson
ejdanderson / anno-custom-header-size.php
Last active August 29, 2015 14:09
Annotum Custom Header Size
<?php
// Add the following function to a child theme or plugin:
// Class exists check in case adding to a plugin and themes are swapped.
if ( class_exists ( 'Anno_Keeper' ) ) {
function anno_custom_header_size() {
Anno_Keeper::keep( 'header_image', new Anno_Header_Image( 'header', array ( 1265, 110 ) ) );
}
// Priority 10 to come in after the annotum's initial template initialization.
@ejdanderson
ejdanderson / igor-colors
Last active August 29, 2015 14:05
Milarite Color Swap
ModifyGraph rgb(Bran2_Arm_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Bran4N_Dist_T)=(26112,52224,0),rgb(Darapi_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Dusmatovite_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Eifelite_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Kl_chite_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Merrihueite_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Mila25_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Mila29a_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Mila29b_Dist_T)=(26112,52224,0);DelayUpdate
ModifyGraph rgb(Mila30_Dist_T)=(26112,52224,0),rgb(Mila31_Dist_T)=(26112,52224,0);DelayUpdate
@ejdanderson
ejdanderson / wp create term
Created August 26, 2014 15:55
Programatically create taxonomy terms
<?php
// Prevents duplicate term creation, useful when terms need to be programatically generated
function create_term( $slug, $name, $taxonomy ) {
$term_id = term_exists( $slug, $taxonomy );
if ( ! $term_id ) {
$term_data = wp_insert_term( $name, $taxonomy, array( 'slug' => $slug ) );
if ( $term_data && ! is_wp_error( $term_data ) ) {
$term_id = $term_data['term_id'];
}
}
@ejdanderson
ejdanderson / addToWaveRange
Last active January 3, 2016 20:29
IGOR Functions
// Add a value to a specific range of points of a wave
Function addToWaveRange(wname, startPoint, endPoint, addition)
wave wname
variable startPoint
variable endPoint
variable addition
variable ii
for ( ii=0; ii< (endPoint-startPoint); ii += 1 )
wname[startPoint + ii] += addition
@ejdanderson
ejdanderson / taxonomy-register.php
Last active December 21, 2015 09:28
Full list of taxonomy arguments and example of registering them
<?php
$taxonomies = array(
'taxonomy-slug' => array(
'labels' => array(
'name' => __('Genres', 'textdomain'),
'singular_name' => __('Genre', 'taxonomy singular name', 'textdomain'),
'menu_name' => __('Genre', 'textdomain'),
'all_items' => __('All Genres', 'textdomain'),
'edit_item' => __('Edit Genre', 'textdomain'),
'view_item' => __('View Genre', 'textdomain'),
@ejdanderson
ejdanderson / gist:3996147
Created November 1, 2012 20:09
WP Options Page Setup with button to run action
<?php
function create_menu() {
add_options_page(__('Plugin Settings', 'ejda'), __('Plugin Settings', 'ejda'), 'manage_options', 'ejda-slug', 'options_page_content');
}
add_action('admin_menu', 'create_menu');
function options_page_content() {
?>
<div class="wrap">
@ejdanderson
ejdanderson / bash prompt
Created June 23, 2012 03:08
Bash token prompt
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: inputs.sh file.txt"
else
codes=$(grep -o "###.*###" $1)
inputs=$(echo $codes | sed 's/#//g')
for x in $inputs; do
#Check if the variable is empty
@ejdanderson
ejdanderson / gist:2370749
Created April 12, 2012 20:27
String Evaluates to 0
<?php
$arr = array();
$arr['foo'] = 'bar';
// 'boo' evaluates to 0
echo $arr['foo']['boo']; // b
// This evaluates as true and echos
if (isset($arr['foo']['boo'])) {