Skip to content

Instantly share code, notes, and snippets.

View tlongren's full-sized avatar
🎯
Focusing

Tyler Longren tlongren

🎯
Focusing
View GitHub Profile
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("STRIPE_API_KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
@tlongren
tlongren / gist:5597049
Last active December 17, 2015 10:48 — forked from vshvedov/gist:1370650
Sublime Text 2 on Debian from PPA
wget http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt
sudo mv add-apt-repository.sh.txt /usr/sbin/add-apt-repository
sudo chmod o+x /usr/sbin/add-apt-repository
sudo chown root:root /usr/sbin/add-apt-repository
sudo add-apt-repository ppa:webupd8team/sublime-text-2
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
<?php
define('PAPERTRAIL_PORT','123456');
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, 'logs.papertrailapp.com', PAPERTRAIL_PORT);
}
socket_close($sock);
}
<?php
/**
* Plugin Name: Email Confirmation
* Description: Send an email to the user with confirmation code and store form data in database until user confirms.
* Author: Cedric Ruiz
*/
class EmailConfirmation
{
const PREFIX = 'email-confirmation-';
@tlongren
tlongren / mysql-health.sh
Last active August 29, 2015 14:19 — forked from alexalouit/mysql-health.sh
Check And Repair All MySQL Databases on Debian And Ubuntu Linux
#!/bin/sh
#
# cron ex: 0 0 1 * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /home/tyler/mysql-health.sh >> /home/tyler/mysql-health.log
mysqlcheck --defaults-file=/etc/mysql/debian.cnf --auto-repair --optimize --all-databases
@tlongren
tlongren / soliloquy-reload-page-on-navigation-click.php
Last active August 29, 2015 14:19 — forked from n7studios/soliloquy-reload-page-on-navigation-click.php
Soliloquy - Reload Page on Navigation Click and Go to Slider Container
<?php
/**
* Plugin Name: Soliloquy - Reload Page on Navigation Click and Scroll to Slider Container
* Plugin URI: https://longren.io/soliloquy-reload-page-on-navigation-click-and-scroll-to-slider-container
* Version: 1.0
* Author: Tyler Longren
* Author URI: https://longren.io/
* Description: Reloads the entire Page when the next or previous arrows are clicked, or the pager navigation is used. The correct slide is injected into the URL and scrolls to the slider container.
*
* Based on the original plugin from Tim Carr (http://www.n7studios.co.uk). This simply takes the user to the slider after the page reload, good for sliders at the end of posts/pages.
@tlongren
tlongren / pug-bomb.php
Created February 2, 2016 04:38 — forked from retgef/pug-bomb.php
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
@tlongren
tlongren / insert-posts.php
Created September 22, 2016 08:50
WordPress: Insert a post into WordPress from an external script
<?php
// Load WordPress
require_once 'path/to/www/wp-load.php';
require_once ABSPATH . '/wp-admin/includes/taxonomy.php';
// Set the timezone so times are calculated correctly
date_default_timezone_set('Europe/London');
// Create post
@tlongren
tlongren / dashboard.yml
Last active February 13, 2018 17:24 — forked from kantord/dashboard.yml
dashboard "Food":
- h1 text: Food
- h2 text: By caloric content
- 3 columns:
- rows:
- h3 text: Bananas
- pie chart: {
"columns": [
["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1]
]