Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / index.php
Last active August 29, 2015 14:02
WordPress Disconnected from Themes
<?php
/**
* Model for interfacing with a Wordpress backend
*
* @author Alex Crooks, Si digital http://sidigital.co
**/
// Just replace your WordPress index.php content with this code to test.
define('APP_PATH', dirname( __FILE__ ));
@josephspurrier
josephspurrier / disable_wordpress_editor_cleanup.php
Last active August 29, 2015 14:04
Disable the WordPress Editor Cleanup
/**
* Disable the Visual and Text Editor p and br tag modifications when saving
*
* When you call the editor, it will automatically add a filter depending
* on which editor you have open:
* * Text Editor: add_filter('the_editor_content', 'wp_htmledit_pre');
* * Visual Editor: add_filter('the_editor_content', 'wp_richedit_pre');
*
* The only way to stop this is to remove the filter because it's applied.
* The next call after is do_action( 'media_buttons', $editor_id );
@josephspurrier
josephspurrier / centerbackground.htm
Last active August 29, 2015 14:04
Center a Background Image on a Webpage
<!DOCTYPE html>
<html lang="en" style="overflow: auto; height: 100%;">
<body style="background: #222222; margin: 0; height: 100%;">
<div style="overflow: hidden; height: 100%;">
<img id="background-image" src="https://www.gstatic.com/chat/hangouts/bg/a432eb7bf6eef1cccf7946ca20e5c2c0-NeilKremer.jpg">
</div>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
@josephspurrier
josephspurrier / array_vs_slice.go
Created December 22, 2014 16:12
Golang - Differences between Array and Slice
package main
import (
"fmt"
"reflect"
"strings"
)
func main() {
// Arrays, slices (and strings)
@josephspurrier
josephspurrier / aescmd.go
Created December 23, 2014 07:11
Golang - Encrypt, Decrypt, File Read, File Write, Readline
package main
import (
"bufio"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"io/ioutil"
@josephspurrier
josephspurrier / drop_encrypt.go
Last active March 24, 2020 17:48
Golang - Drag and Drop AES Encryption and Decryption
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"io/ioutil"
"os"
@josephspurrier
josephspurrier / values_pointers.go
Last active April 25, 2024 06:24
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@josephspurrier
josephspurrier / structs_interface.go
Last active March 21, 2024 08:11
Golang - Understand Structs and Interfaces
// Also available at: https://play.golang.org/p/yTTpB5gB6C
package main
import (
"fmt"
)
// *****************************************************************************
// Example 1 - Struct vs Struct with Embedded Type
@josephspurrier
josephspurrier / spinner.go
Last active November 19, 2017 17:38
Golang - Spinner
package main
import (
"fmt"
"time"
)
func main() {
// Make a channel for the spinner
@josephspurrier
josephspurrier / bitmask.go
Last active March 13, 2021 04:44
Golang - Determine if bitmask is set
/*
fmt.Println(Bitmask(0x6).IsSet(0x2))
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListDescriptions(charValues))
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListValues(charValues))
*/
type Bitmask uint16
// BitValue is a value and a description
type BitValue struct {