Skip to content

Instantly share code, notes, and snippets.

# y = theta_1 * x + theta_0
# Not actually required in the gradient descent calculation; just used to verify
# the sanity of the results :)
def compute_error_for_line_given_points(theta_0, theta_1, points):
totalError = 0
for i in range(0, len(points)):
x = points[i, 0]
y = points[i, 1]
totalError += (y - (theta_1 * x + theta_0)) ** 2
return totalError / (2 * float(len(points)))
<?php
// Setup Start object
require_once('./lib/Start.php');
Start::setApiKey("test_sec_k_e06df93760b388375e1f6");
// Get the customer ID (usually from your Database)
$customer_id = "cus_abc123def456ghi789";
// Charge the customer (can be done many times, over a period of time)
Start_Charge::create(array(
<?php
$token = $_POST['startToken']; // from Beautiful.js
require_once('./lib/Start.php');
Start::setApiKey("test_sec_k_e06df93760b388375e1f6");
Start_Customer::create(array(
"name" => "Abdullah Ahmed",
"email" => "abdullah@msn.com",
"card" => $token,
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/json"];
NSDictionary *params = @{@"amount":@"1000",
@"currency":@"aed",
@"email":@"ahmed@example.com",@"card[name]":@"Abdullah Ahmed",
@"card[number]":@"4242424242424242",
@"card[exp_month]":@"11",
@"card[exp_year]":@"2016",
@"card[cvc]":@"123",
@yazinsai
yazinsai / how-to-bill-a-token.php
Last active August 29, 2015 14:14
Bill a token -- John
# From https://whitepayments.com/docs/api/#create-a-new-charge
<?php
require_once('./lib/White.php');
White::setApiKey("test_sec_k_886a1e89b2c0abce479bf"); # Your secret API key
White_Charge::create(array(
"amount" => 1000, // 10.00
"currency" => "aed",
"card" => "tok_38951a48cd3859d2dcf62957e1c9", # The token from White.js
@yazinsai
yazinsai / index-without-token.php
Last active August 29, 2015 14:12
Create and charge a customer using pure PHP (for Alexey)
<?php
# Step 1: Create a customer from the card details
require_once("vendor/autoload.php");
White::setApiKey("test_sec_k_886a1e89b2c0abce479bf"); // Secret key
$customer = White_Customer::create(array(
'name' => "John Doe",
'description' => "Amember customer",
'email' => "john.doe@example.com",
'card' => array(