Skip to content

Instantly share code, notes, and snippets.

View phillipsj's full-sized avatar

Jamie Phillips phillipsj

View GitHub Profile
@phillipsj
phillipsj / SODA-Php.php
Created May 31, 2012 13:47
Example of working with Socrata API using PHP
<?php
//Url for column metadata
$urlColumns = "http://data.austintexas.gov/api/views/ecmv-9xxi/columns.json";
$curlColumns = curl_init($urlColumns);
curl_setopt($curlColumns, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-App-Token: GQXtcmDiC3Qjcoys9iwCI8esO', 'Content-Type: application/json'));
$json_columns = curl_exec($curlColumns);
$status = curl_getinfo($curlColumns, CURLINFO_HTTP_CODE);
@phillipsj
phillipsj / SODA-Ruby.rb
Created May 31, 2012 13:48
Example of working with Socrata API using Ruby
require 'faraday_middleware'
require 'json'
connection = Faraday.new 'http://data.austintexas.gov' do |conn|
conn.request :json
conn.response :json, :content_type => /\bjson$/
conn.adapter Faraday.default_adapter
end
@phillipsj
phillipsj / gist:9367366
Created March 5, 2014 13:42
Repository pattern example for Postgres-py
from postgres.orm import Model
from postgres import Postgres
class Foo(Model):
typname = "foo"
class FooRepository(connection_string):
def __init__(self):
self.db = Postgres(connection_string)
self.db.register_model(Foo)
@phillipsj
phillipsj / gist:d28720411ee9320fdc2d
Created July 2, 2014 16:44
INotifyPropertyChane without WPF
public class Child
{
public string ParentPopertyName { get; set; }
}
public class Parent: INotifyPropertyChanged
{
public Parent()
{
this.PropertyChanged += Parent_PropertyChanged;
@phillipsj
phillipsj / gist:168f011bc6d6b5e0632f
Created February 27, 2015 02:17
DPMFromAuthorize
public ActionResult DPM()
{
String ApiLogin = "Your_login_id";
String TxnKey = "Your_transaction_key";
String checkoutform = DPMFormGenerator.OpenForm(ApiLogin, TxnKey, 2.25M,
"https://YOUR_RELAY_RESPONSE_URL", true);
// Add a credit card number input field
checkoutform = checkoutform + @"<p><div style='float:left;width:250px;'><label>Credit Card
@phillipsj
phillipsj / gist:541f16ab8cae65e07994
Created February 27, 2015 02:20
BeginDirectPostForm Helper
@using (Html.BeginDirectPostForm("ApiLogin", "TransactionKey", 2.25M, "https://YOUR_RELAY_RESPONSE_URL", true))
{
<p>
<div style='float: left; width: 250px;'>
<label> Credit Card Number </label>
<div id='CreditCardNumber'>
<input type='text' size='28' name='x_card_num'
value='4111111111111111' id='x_card_num' />
</div>
</div>
@phillipsj
phillipsj / gist:219e37df1cc1efef51ba
Created February 27, 2015 02:25
DirectPostForm Extension
public static class FormExtensions
{
private class DirectPostForm : IDisposable
{
private readonly HtmlHelper _helper;
public DirectPostForm(HtmlHelper helper, string apiLogin, string transactionKey, decimal amount,
string returnUrl, bool isTest)
{
_helper = helper;
@phillipsj
phillipsj / StringLayout.cs
Created September 11, 2015 02:57
Orchard Layout Example
layout =
"{\"elements\": [" +
"{" +
"\"typeName\": \"Orchard.Layouts.Elements.Html\"," +
"\"data\": \"Content=" + Encode(Text) + "\"" +
"}" +
"]}";
@phillipsj
phillipsj / JsonLayout.cs
Created September 11, 2015 03:06
Orchard Layout with JSON.NET
var layout = new JObject("elements",
new JArray(
new JObject(
new JProperty("typeName", "Orchard.Layouts.Elements.Html"),
new JProperty("data", string.Format("Content={0}", Encode(Text)))
)
)
);
@phillipsj
phillipsj / ExcludeExample.xml
Last active September 29, 2015 02:22
Exclude Folder VS Project
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ExcludeFoldersFromDeployment>node_modules</ExcludeFoldersFromDeployment>
</PropertyGroup>