Skip to content

Instantly share code, notes, and snippets.

View psorensen's full-sized avatar

Peter Sorensen psorensen

  • 10up
  • United States
View GitHub Profile
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
<style>.om-feed-container{width: 100%;max-width: 300px;background: #dfdfdf;font-family: arial;float: left;}.om-feed-header{background: #505050;color: white;padding: 10px;clear: both;}.om-feed-header img, .om-feed-header h4{float: left;}.clear:after{clear: both; content: ""; display: table;}ul#feed{width: 100%;display: block;padding-left: 0;padding: 10px;/*margin-left: 0;*/}ul#feed li{list-style: none;margin-bottom: 10px;}ul#feed li a{color: #3d8180;font-size: 12px;}.gist{max-width: 600px;float: left;margin-left: 50px;}</style> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript">google.load("feeds", "1"); function initialize(){var feed=new google.feeds.Feed("https://www.openminds.com/market/child-welfare/feed/"); feed.setNumEntries(6); feed.load(function(result){if (!result.error){var container=document.getElementById("feed"); for (var i=0; i < result.feed.entries.length; i++){var entry=result.feed.entries[i]; var li=document.createElement("li"); var a=doc
@psorensen
psorensen / om_feed
Last active August 29, 2015 14:16
OPEN MINDS Child Welfare Feed
<style>.om-feed-container{width:100%;max-width:300px;background:#dfdfdf;font-family:arial;float:left}.om-feed-header{background:#505050;color:#fff;padding:10px;clear:both}.om-feed-header h4,.om-feed-header img{float:left}.clear:after{clear:both;content:"";display:table}ul#feed{width:100%;display:block;padding-left:0;padding:10px;box-sizing:border-box}ul#feed li{list-style:none;margin-bottom:10px}ul#feed li a{color:#3d8180;font-size:12px}</style><script type="text/javascript" src="https://www.google.com/jsapi"></script><script type="text/javascript">function initialize(){var e=new google.feeds.Feed("https://www.openminds.com/market/child-welfare/feed/");e.setNumEntries(6),e.load(function(e){if(!e.error)for(var t=document.getElementById("feed"),n=0;n<e.feed.entries.length;n++){var d=e.feed.entries[n],i=document.createElement("li"),l=document.createElement("a"),a=document.createTextNode(d.title);l.appendChild(a),l.title=d.title,l.href=d.link,i.className="om-rss-entry",i.appendChild(l),t.appendChild(i)}})}google.
@psorensen
psorensen / convertformdatatoobject.js
Last active September 25, 2015 19:20
Convert form data to object
function get_form_data($form){
var search_form_data = $($form),
search_form_data_object = search_form_data.serializeArray(),
search_form_data_len = search_form_data_object.length;
// loop through object and asign key/value pairs
var returnObj = {};
for (var i = 0; i < search_form_data_len; i++) {
returnObj[search_form_data_object[i].name] = search_form_data_object[i].value;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello!</title>
<link rel="stylesheet" href="https://stackedit.io/res-min/themes/base.css" />
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body><div class="container"><h1 id="membership-transition-notes">Membership Transition Notes</h1>
@psorensen
psorensen / slimes.php
Created October 2, 2015 18:43
slimes app->request
object(Slim\Http\Request)[39]
protected 'env' =>
object(Slim\Environment)[36]
protected 'properties' =>
array (size=25)
'REQUEST_METHOD' => string 'POST' (length=4)
'REMOTE_ADDR' => string '::1' (length=3)
'SCRIPT_NAME' => string '/slimes' (length=7)
'PATH_INFO' => string '/contact' (length=8)
'QUERY_STRING' => string '' (length=0)
@psorensen
psorensen / user_exists_by_id.php
Created August 5, 2016 19:20
Wordpress: Find If User exists by ID
/**
* Determine if user exists by ID
* @param int $user_id User ID
* @return bool true if user exists
*/
public function user_id_exists( $user_id ){
global $wpdb;
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->users WHERE ID = %d", $user ) );
@psorensen
psorensen / wpMandrill-send-function.php
Created August 8, 2016 23:49
wpMandrill example send function
function SendTemplate() {
// Create a template called MyCoolTemplate and use this code:
$template_code = '
Hello *|FNAME|*,
<p>Your personal coupon code is: *|COUPON|*</p>
<p>Event Date: *|DATE|*</p>
<p>Address: *|ADDRESS|*</p>
@psorensen
psorensen / main.scss
Created January 10, 2017 00:08
Sage main.scss
@import "common/variables";
// Import npm dependencies
@import "~bootstrap/scss/bootstrap";
@import "~slick-carousel/slick/slick";
@import "~slick-carousel/slick/slick-theme";
@import "~font-awesome/scss/font-awesome";
@import "common/global";
@import "components/buttons";