Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Payne mattapayne

View GitHub Profile
View jambase4net.cs
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
View jambase4r_use.rb
#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
View jambase4r_config.rb
#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
View gist_example.html
#This is a Gist. This is also how you embed the Gist
<script src="http://gist.github.com/98216.js"></script>
View redefensio.rb
#To announce an article:
RDefensio::API.announce_article({
"article-author" => "Me",
"article-author-email" => "my@email.com",
"article-title" => @post.title,
"article-content" => @post.body,
"permalink" => @post.slug
}
#To audit a comment:
View rdefensio_config.rb
configure do
RDefensio::API.configure do |conf|
conf.api_key = App::Config.defensio_api_key
conf.owner_url = App::Config.defensio_owner_url
end
end
View barchart.rb
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
View json_array.java
JSONArray objects = new JSONArray(response);
View java_get.java
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);
View complaints.java
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();
You can’t perform that action at this time.