Skip to content

Instantly share code, notes, and snippets.

View tilersmyth's full-sized avatar

Tyler Smith tilersmyth

View GitHub Profile
@tilersmyth
tilersmyth / raspi_os_flash.sh
Created December 11, 2020 14:45
Bash script for flashing Raspberry Pi OS onto SD card
#! /bin/bash
set_disk_speedbump () {
local sd_disk_path=${1}
local sd_disk_id=${2}
if (( $sd_disk_id < 2 )); then
read -p "Are you sure ${sd_disk_path}${sd_disk_id} is the SD Card? (y/n) " disk_verify
if [[ "${disk_verify}" == 'y' ]]; then
@tilersmyth
tilersmyth / arrayValidation.js
Created September 25, 2018 01:24
handle array validation based on specifications from another array
const userFields = [
{ key: "name", value: "tyler" },
{ key: "location", value: "boston" },
{ key: "phone", value: "555-555-5555" },
{ key: "email", value: "tyler@test.com" },
{ key: "color", value: "red" },
{ key: "sport", value: "golf" }
];
const primaryFields = [
function current_product($product_type){
global $post;
$price_meta = get_post_meta($post->ID, 'peruse-article-price');
$price = isset($price_meta[0]) ? $price_meta[0] : '.25';
return [
'id' => $post->ID,
function get_peruse_token(){
return peruse_user_token();
}
wp_enqueue_script( 'peruse-local', get_template_directory_uri() . '/js/peruse.js', array('jquery'));
wp_localize_script('peruse-local', 'peruse',
array(
'token' => get_peruse_token(),
'url' => 'app.goperuse.com/',
'user' => peruse_current_user(),
function peruse_pay_btn($postId, $default) {
$price_meta = get_post_meta($postId, 'peruse-article-price', true);
$price = $price_meta ? $price_meta : $default;
$output = '<div class="peruse_pay_container">';
$output .= '<button id="peruse_pay_submit">Continue for $' . $price . '</button>';
$output .= '<div id="peruse_confirm_product"></div>';
$output .= '</div>';
function standard_integration( $content ) {
if ( is_single() && 'post' == get_post_type() ) {
global $post;
if(!peruse_post_auth($post->ID, 'Article', null)){
$content_noAuth = has_excerpt($post->ID) ? get_the_excerpt($post->ID) : '';
$content_noAuth .= peruse_pay_btn($post->ID, '.25');
@tilersmyth
tilersmyth / sample_get.php
Last active May 31, 2017 17:10
Peruse get request example
function get($route) {
if(isset($_SESSION['peruse_access_token'])){
$request = $provider->getAuthenticatedRequest(
'GET',
'https://app.goperuse.com/api/graph/v1/' . $route,
$_SESSION['peruse_access_token']
);
$response = $provider->getHttpClient()->send($request);
var product = {
title: 'Post Title',
type: 'Article',
id: '100',
product_url: 'http://www.example.com/post-slug',
description: '',
regular_price: .15
}
var msg_array = {
<?php
session_start();
define('CLIENT_ID', XXXXXXX);
define('CLIENT_SECRET', XXXXXXXXXXXXXXXXXXXXXXX);
define('REDIRECT_URI', rtrim(site_url(), '/') . '/');
if (CLIENT_ID && CLIENT_SECRET){
$this->provider = new \League\OAuth2\Client\Provider\GenericProvider([