Skip to content

Instantly share code, notes, and snippets.

@cardinalblue
cardinalblue / gist:1318922
Created October 27, 2011 06:36
logout and authroization
//============================
// mixi setup
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_mixi = [[Mixi sharedMixi] setupWithType:kMixiApiTypeSelectorGraphApi
clientId:@"87b9651a2291e4853ac0"
secret:@"98866989c89c42e47d7d38394637faa84341ebb4"
appId:@"piccollage"];
[_mixi restore];
[_mixi reportOncePerDay];
@cardinalblue
cardinalblue / gist:1316720
Created October 26, 2011 15:38
code for handling mixi authetication
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
NSLog(@"handleOpenURL %@", [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding]);
NSError *error = nil;
if ([[url scheme] isEqualToString:@"mixiapp-piccollage"]) {
NSString *apiType = [[Mixi sharedMixi] application:application openURL:url sourceApplication:sourceApplication annotation:annotation error:&error];
if (error) {
}
@cardinalblue
cardinalblue / envolve.php
Created July 8, 2011 23:34
envolve example for PHP
<?php
/**
* Envolve API Client Library
*
* @version 0.1
*/
/**
* This method creates the full HTML that should be included in a page for an anonymous user.
class GeckoboardController < ActionController::Base
def newrelic
@newrelic_data = newrelic_data
render_board
end
private
def render_board
render :layout => false, :content_type => 'application/xml'
@cardinalblue
cardinalblue / newrelic.erb
Created April 7, 2011 17:46
custom widget for geckoboard
<?xml version="1.0" encoding="UTF-8"?>
<% epm = @newrelic_data["Errors"][0..-5].to_i %>
<% rpm = @newrelic_data["Throughput"][0..-5].to_i %>
<% response_time = @newrelic_data["Response Time"][0..-4].to_i %>
<% db = @newrelic_data["DB"][0..-2].to_f %>
<% cpu = @newrelic_data["CPU"][0..-2].to_f %>
<% db_time = db.to_f/100*response_time.to_f %>
<% cpu_time = cpu.to_f/100*response_time.to_f %>
<% other_time = response_time.to_f - db_time - cpu_time %>
@cardinalblue
cardinalblue / newrelic_data.rb
Created April 7, 2011 17:24
an example of using rest_graph to query New Relic
# returns like this:
# {"Apdex"=>"0.85 [0.5]", "Error Rate"=>"0.33%",
# "Throughput"=>"202 rpm", "CPU"=>"11%", "Response Time"=>"330 ms",
# "Errors"=>"0.67 epm", "Memory"=>"135 MB", "DB"=>"4.3%"}
def newrelic_data
key = Variant.current.newrelic_api_key
url = Variant.current.newrelic_data_url
return {} unless url # not using newrelic