Skip to content

Instantly share code, notes, and snippets.

View jackreichert's full-sized avatar

Jack Reichert jackreichert

View GitHub Profile
@jackreichert
jackreichert / document.xml
Last active May 25, 2022 15:18
Convert Docx XML to HTML
<?xml version="1.0" encoding="UTF-8"?>
<w:document xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
@jackreichert
jackreichert / inputtitle_submit.js
Last active September 26, 2020 15:03
Example showing how to use AJAX in WordPress
(function ($) {
$(document).ready(function () {
$('#next').click(function () {
$.post(
PT_Ajax.ajaxurl,
{
// wp ajax action
action: 'ajax-inputtitleSubmit',
// vars
@jackreichert
jackreichert / getKeyVals
Last active March 19, 2020 07:12
This is a swift extension for NSURL so you can parse the query string and get back a dictionary of the variables.
extension NSURL {
func getKeyVals() -> Dictionary<String, String>? {
var results = [String:String]()
var keyValues = self.query?.componentsSeparatedByString("&")
if keyValues?.count > 0 {
for pair in keyValues! {
let kv = pair.componentsSeparatedByString("=")
if kv.count > 1 {
results.updateValue(kv[1], forKey: kv[0])
}

Keybase proof

I hereby claim:

  • I am jackreichert on github.
  • I am jrbv (https://keybase.io/jrbv) on keybase.
  • I have a public key ASBnI2KlsGXVi_SlY1nrsj11Gcywpy2u9PuOd3UiVDVcWAo

To claim this, I am signing this object:

@jackreichert
jackreichert / gist-shortcode.php
Last active September 27, 2017 15:44
WordPress Gist ShortCode
// github gist Shortcode Usage: [gist un="" id=""]
function gist_shortcode( $atts ) {
extract(shortcode_atts(array(
'un' => '',
'id' => ''
), $atts));
return '<script src="https://gist.github.com/' . $username . '/' . $id.'.js"></script>';
}
add_shortcode('gist', 'gist_shortcode');
@jackreichert
jackreichert / google-maps-react
Created August 6, 2017 18:00
gist for issue submission
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {Map, Marker, GoogleApiWrapper} from 'google-maps-react';
class EventMap extends Component {
constructor() {
super();
this.styles = [
{
featureType: "all",
@jackreichert
jackreichert / Keychain.swift
Last active January 11, 2017 02:43 — forked from s-aska/Keychain.swift
Swift Keychain class ( supported Xcode Version 7.0 beta 4 (7A165t) )
import UIKit
import Security
class Keychain {
class func save(key: String, data: NSData) -> Bool {
let query = [
kSecClass as String : kSecClassGenericPassword as String,
kSecAttrAccount as String : key,
kSecValueData as String : data ]
config.trigger.before :halt do
info "Dumping the database before shutting down..."
run_remote "bash /vagrant/assets/exportdb.sh"
run_remote "bash /vagrant/assets/gz-wpcontent.sh"
end
@jackreichert
jackreichert / web-fonts.php
Last active October 6, 2016 11:15
Enqueuing Fonts in WordPress
<?php // add the following into your theme's functions.php
function theme_fonts() {
// typekit
wp_enqueue_script( 'theme_typekit', '//use.typekit.net/xxxxxxx.js');
// fonts.com
wp_enqueue_script( 'theme_fontsdotcom', '//fast.fonts.net/jsapi/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js');
// google fonts - Josefin (a favorite)
@jackreichert
jackreichert / add_class_to_menu_items
Created July 25, 2013 23:53
This is how you add a class to menu items in WordPress. Change the "theme_location" to == "primary" to any menu name you like. Or remove the condition to have it applied everywhere.
add_filter( 'wp_nav_menu_objects', 'add_menu_class', 10, 2 );
function add_menu_class( $sorted_menu_items, $args ) {
if ($args->theme_location == "primary")
foreach ($sorted_menu_items as $i => $menu )
$sorted_menu_items[$i]->classes[] = 'color-'.strtolower(str_replace(' ', '-', $menu->post_title));
return $sorted_menu_items;
}