Navigation Menu

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 / index.php
Last active December 17, 2015 04:59
Stripe PHP Implementation from http://www.longren.org/pay/
<?php
require 'stripe-php/lib/Stripe.php';
if ($_POST) {
Stripe::setApiKey("SECRET_API_KEY_HERE");
$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
@tlongren
tlongren / flush-iptables.sh
Last active December 18, 2015 00:49
iptables firewall for VPS on Debian Squeeze
#!/bin/sh
# This file will reset the firewall to allow everything.
#
# Set the default policy
#
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
#
@tlongren
tlongren / HEAD
Created June 10, 2013 17:36
FCC .git folder exposure
0000000000000000000000000000000000000000 94c673c713cd043bb8bf09961f079a5acd0e63b4 root <root@fcc-cms-test-1.domain.local> 1296617728 -0500
94c673c713cd043bb8bf09961f079a5acd0e63b4 7a90725d60bf2bc6e1c4239a441fc0f2f86de8c9 root <root@fcc-cms-test-1.domain.local> 1299516632 -0500 pull origin staging: Fast forward
7a90725d60bf2bc6e1c4239a441fc0f2f86de8c9 88f257ffd94f3ca1e9bd6874c436fd69b34c4394 root <root@fcc-cms-test-1.domain.local> 1299594428 -0500 pull origin staging: Fast forward
88f257ffd94f3ca1e9bd6874c436fd69b34c4394 a6896f37cf532f06c130c7b2cc8cb83cbb52004b root <root@fcc-cms-test-1.domain.local> 1300923087 -0400 pull origin staging: Fast forward
a6896f37cf532f06c130c7b2cc8cb83cbb52004b c605429aba8d28834869467cde53919598054613 root <root@fcc-cms-test-1.domain.local> 1300926414 -0400 pull origin staging: Fast forward
c605429aba8d28834869467cde53919598054613 a66e9e81c462f7ced571cd91bd43744d14451edc root <root@fcc-cms-test-1.domain.local> 1300976836 -0400 pull origin staging: Fast forward
a66e9e81c462f7ced
@tlongren
tlongren / checkAPI.php
Created June 19, 2013 18:18
Check if API url is online before proceeding with calls to said API
<?php
$checkapi = (@fsockopen("solus.fliphost.net", 443, $errno, $errstr, 0.4) ? "up" : "down");
echo $checkapi;
?>
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(),
@tlongren
tlongren / checkForString.php
Created June 27, 2013 16:03
My favorite method for checking for the existence of a string in a variable
<?php
$status = (strpos($_SERVER['REQUEST_URI'],'my-page') ? 'active' : 'notactive');
?>
@tlongren
tlongren / error_log
Created June 28, 2013 22:16
Stripe apache error_log
[Fri Jun 28 17:11:59 2013] [error] [client 173.245.55.171] PHP Fatal error: Uncaught exception 'Stripe_InvalidRequestError' with message 'You must supply a valid card' in /srv/www/mydomain.us/public_html/includes/stripe-php/lib/Stripe/ApiRequestor.php:86\nStack trace:\n#0 /srv/www/mydomain.us/public_html/includes/stripe-php/lib/Stripe/ApiRequestor.php(136): Stripe_ApiRequestor->handleApiError('{? "error": {?...', 400, Array)\n#1 /srv/www/mydomain.us/public_html/includes/stripe-php/lib/Stripe/ApiRequestor.php(74): Stripe_ApiRequestor->_interpretResponse('{? "error": {?...', 400)\n#2 /srv/www/mydomain.us/public_html/includes/stripe-php/lib/Stripe/ApiResource.php(76): Stripe_ApiRequestor->request('post', '/v1/customers', Array)\n#3 /srv/www/mydomain.us/public_html/includes/stripe-php/lib/Stripe/Customer.php(26): Stripe_ApiResource::_scopedCreate('Stripe_Customer', Array, NULL)\n#4 /srv/www/mydomain.us/public_html/addService.php(39): Stripe_Customer::create(Array)\n#5 {main}\n thrown in /srv/www/mydomain.us/p
@tlongren
tlongren / addOrder.js
Last active December 19, 2015 03:18
Add New Subscription. This is broken code, so please do not use it for a Stripe.com implementation. It's here for reference purposes only.
Stripe.setPublishableKey('pk_test_Wfzrj4uDDPOcv7XxVJKXRERS');
var stripeResponseHandler = function(status, response) {
if (response.error) {
// re-enable the submit button
$('.submit-button').removeAttr("disabled");
// show the errors on the form
$(".payment-errors").html(response.error.message);
} else {
var form$ = $("form#addservice-form");