Skip to content

Instantly share code, notes, and snippets.

Avatar

Tyler Longren tlongren

View GitHub Profile
View gist:5548728
<?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 Dec 17, 2015
Stripe PHP Implementation from http://www.longren.org/pay/
View index.php
<?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 Dec 17, 2015 — forked from vshvedov/gist:1370650
Sublime Text 2 on Debian from PPA
View gist:5597049
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 Dec 18, 2015
iptables firewall for VPS on Debian Squeeze
View flush-iptables.sh
#!/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 Jun 10, 2013
FCC .git folder exposure
View HEAD
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 Jun 19, 2013
Check if API url is online before proceeding with calls to said API
View checkAPI.php
<?php
$checkapi = (@fsockopen("solus.fliphost.net", 443, $errno, $errstr, 0.4) ? "up" : "down");
echo $checkapi;
?>
View ajax-form.js
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 Jun 27, 2013
My favorite method for checking for the existence of a string in a variable
View checkForString.php
<?php
$status = (strpos($_SERVER['REQUEST_URI'],'my-page') ? 'active' : 'notactive');
?>
@tlongren
tlongren / error_log
Created Jun 28, 2013
Stripe apache error_log
View 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 Dec 19, 2015
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.
View addOrder.js
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");