Skip to content

Instantly share code, notes, and snippets.

View tlongren's full-sized avatar
🎯
Focusing

Tyler Longren tlongren

🎯
Focusing
View GitHub Profile
@tlongren
tlongren / gist:5898315
Created July 1, 2013 04:17
Save TOP info for diagnosing high usage situations
top -b -i -n 20 >> topInfo.txt
@tlongren
tlongren / addService.js
Last active December 19, 2015 08:18
Stripe code with invalid token. Includes js, php, and the form used.
Stripe.setPublishableKey('pk_test_Wfzrj4uDDPOcv7XxVJKXRERS');
var stripeResponseHandler = function(status, response) {
if (response.error) {
// show the errors on the form
$("#stripe-errors").html(response.error.message);
} else {
var token = response['id'];
var form$ = $("#addservice-form");
form$.append("<input type='hidden' name='stripeToken' value='" + token + "' />");
}
@tlongren
tlongren / addService.php
Last active November 25, 2021 04:07
Stripe Setup as of July 12
<?php
require_once("/srv/www/vpsstat.us/public_html/includes/stripe-php/lib/Stripe.php");
Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxxx");
$token = ($_GET['stripeToken']) ?$_GET['stripeToken'] : $_POST['stripeToken'];
$customerDetails = get_customer_details($customer_id);
if (empty($customerDetails['stripe_id'])) {
$customer = Stripe_Customer::create(array(
"card" => $token,
"plan" => "standard",
"email" => $customerDetails['email']
@tlongren
tlongren / .htaccess
Created October 21, 2013 05:22
Wicd.net .htaccess Redirection
RewriteEngine on
RewriteCond %{REQUEST_URI} !https://launchpad.net/wicd$
RewriteRule $ https://launchpad.net/wicd [R=301,L]
@tlongren
tlongren / index.php
Created October 25, 2013 01:53
AltoRouter index.php
<?php
header("Content-Type: text/html");
require 'AltoRouter.php';
$router = new AltoRouter();
$router->setBasePath('');
/* Setup the URL routing. This is production ready. */
$router->map('GET','/', 'home.php', 'home');
$router->map('GET','/home/', 'home.php', 'home-specific');
$router->map('GET','/home', 'home.php', 'home-specific-noslash');
@tlongren
tlongren / index.php
Created December 12, 2013 19:47
Simple personal API with static array and PHP
<?php
header('Content-Type: application/json');
$dob = "8/17/1983";
$json = '{
"person": {
"age": {
"years": 23,
"months": 8,
"weeks": 2,
"days": 5,
<?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);
}
@tlongren
tlongren / .htaccess
Last active October 15, 2015 03:14
AltoRouter htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
@tlongren
tlongren / index.php
Last active August 29, 2015 13:56
AltoRouter index.php
<?php
header("Content-Type: text/html");
include dirname(__FILE__) . '/includes/AltoRouter.php';
$router = new AltoRouter();
$router->setBasePath('');
/* Setup the URL routing. This is production ready. */
// Main routes that non-customers see
$router->map('GET','/', 'home.php', 'home');
@tlongren
tlongren / charge.php
Created February 16, 2014 19:27
AltoRouter charge.php
<?php
$customer = new Customer();
$customer_id = $match['params']['customer_id'];
if ($customer->valid_customer($customer_id) && $customer->needs_paid($customer_id)) {
$customer->pay($customer_id);
}
?>