Skip to content

Instantly share code, notes, and snippets.

View mattapayne's full-sized avatar

Matt Payne mattapayne

View GitHub Profile
1. private List parseComplaints(String results)
2. {
3. List complaints = new ArrayList();
4. try
5. {
6. JSONArray objects = new JSONArray(results);
7. for(int i=0; i<objects.length(); i++)
8. {
9. JSONObject o = (JSONObject)objects.get(i);
10. Complaint c = new Complaint();
#This is a Gist. This is also how you embed the Gist
<script src="http://gist.github.com/98216.js"></script>
def create_bar_chart(opts, data)
g = Gruff::Bar.new(opts[:size])
g.title = opts[:title]
g.minimum_value = opts[:minimum]
g.maximum_value = opts[:maximum]
g.labels = data.map { |e| e.category }
g.data(opts[:legend], data.map { |e| e.count } )
g.x_axis_label = opts[:x_axis_label]
g.y_axis_label = opts[:y_axis_label]
return g.to_blob
1. private String get(String url, Map params)
2. {
3. String result = null;
4. try
5. {
6. String queryString = getEncodedQueryString(params);
7. String fullUrl = url + "?" + queryString;
8. DefaultHttpClient client = new DefaultHttpClient();
9. HttpGet method = new HttpGet(new URI(fullUrl));
10. HttpResponse response = client.execute(method);
#For Rails:
#in an initializer
JamBase4R.configure do |c|
c.api_key = "your JamBase API key" #this is mandatory
c.logger = RAILS_DEFAULT_LOGGER #or any class that implements the same interface (optional)
end
#For Sinatra
#within the main application file
configure do
#Using JamBase4R in Rails is simple. Just include it in the controller you want to use
class MyJamBaseController < ApplicationController
include JamBase4R
def search
@results = API.search(params[:search])
#You could also NOT include JamBase4R and just call it like so:
# @results = JamBase4R::API.search(params[:search])
end
using System;
using System.Collections.Generic;
using Jambase4Net;
public class App
{
public static void Main(String[] args)
{
//You can use the default configuration, which reads from app.config or web.config
//To do this, just start using the API object
@mattapayne
mattapayne / SingleClick
Created August 13, 2009 17:42
Shows how to disable a button on submit in ASP.NET while maintaining validation checks and form submission
public static class HtmlHelper
{
private const string DISABLED_BUTTON_CSS_CLASS = "disabled_button";
public static void SingleClick(Page page, Button btn)
{
string scriptKey = String.Format("click_once_button_{0}", btn.ValidationGroup);
if (!page.ClientScript.IsClientScriptBlockRegistered(scriptKey))
{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
{% if is_home %}
{{ site.author }}
{% elif is_post %}
{{ post.title }}
{% elif is_link %}
@mattapayne
mattapayne / thinkific_enrollment_webhooks.txt
Created February 1, 2019 00:24
Thinkific Enrollment Webhook Payloads
General webhook docs:
[Help article](https://help.thinkific.com/support/solutions/articles/228892-webhooks) and
[API Docs](https://platform.thinkific.com/documentation/api/webhooks)
Enrollment Created:
{
"id":"20190131191810790022472",
"resource":"enrollment",