add sample apis
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
// Datadog is cloud Monitoring as a Service, where you can
|
||||||
|
// see metrics from all of your apps, tools & services in
|
||||||
|
// one place with Datadog's cloud monitoring as a service
|
||||||
|
// solution.
|
||||||
|
//
|
||||||
|
// This example streams the events sent to the api.
|
||||||
|
//
|
||||||
|
// Please see these for more information:
|
||||||
|
//
|
||||||
|
// http://docs.datadoghq.com/api/
|
||||||
|
// https://github.com/brettlangdon/node-dogapi for more details
|
||||||
|
|
||||||
|
var dogapi = require('dogapi');
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
api_key: '<YOUR API KEY>',
|
||||||
|
app_key: '<YOUR APP KEY>',
|
||||||
|
};
|
||||||
|
|
||||||
|
var api = new dogapi(options);
|
||||||
|
|
||||||
|
var end = parseInt(new Date().getTime() / 1000);
|
||||||
|
var start = end - 86400;
|
||||||
|
|
||||||
|
api.stream(start, end, function(error, result, status_code){
|
||||||
|
if(error){
|
||||||
|
console.log('Error: ', error);
|
||||||
|
console.log('Status Code: ', status_code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
result['events'].forEach(function(event){
|
||||||
|
console.log(event['id'] + ': ' + event['title']);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Github is online project hosting using Git. Includes
|
||||||
|
# source-code browser, in-line editing, wikis, and ticketing.
|
||||||
|
#
|
||||||
|
# This example uses their ruby sdk to authenticate a user
|
||||||
|
# and make requests on their behalf.
|
||||||
|
#
|
||||||
|
# Please see these for more information:
|
||||||
|
#
|
||||||
|
# https://developer.github.com/v3/
|
||||||
|
# https://github.com/octokit/octokit.rb
|
||||||
|
|
||||||
|
require 'octokit'
|
||||||
|
require 'pry'
|
||||||
|
|
||||||
|
Octokit.configure do |c|
|
||||||
|
c.login = '<YOUR USERNAME>'
|
||||||
|
c.password = '<YOUR PASSWORD>'
|
||||||
|
end
|
||||||
|
|
||||||
|
user = Octokit.user
|
||||||
|
puts user
|
||||||
|
|
||||||
|
repo = Octokit.repo 'koding/global.hackathon'
|
||||||
|
puts repo
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Imgur is used to share photos with social networks and
|
||||||
|
# on-line communities.
|
||||||
|
#
|
||||||
|
# This example uses python sdk to make an anonymous request
|
||||||
|
# to get the links of latest photos in the gallery.
|
||||||
|
#
|
||||||
|
# Please see these for more information:
|
||||||
|
#
|
||||||
|
# https://api.imgur.com
|
||||||
|
# https://github.com/Imgur/imgurpython
|
||||||
|
|
||||||
|
from imgurpython import ImgurClient
|
||||||
|
|
||||||
|
client_id = '<YOUR CLIENT ID>'
|
||||||
|
client_secret = '<YOUR CLIENT SECRET>'
|
||||||
|
|
||||||
|
client = ImgurClient(client_id, client_secret)
|
||||||
|
|
||||||
|
# Example request
|
||||||
|
items = client.gallery()
|
||||||
|
for item in items:
|
||||||
|
print(item.link)
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// PubNub is a Data Stream Network that enables developers to
|
||||||
|
// rapidly build realtime apps that scale globally, without
|
||||||
|
// worrying about infrastructure!
|
||||||
|
//
|
||||||
|
// This example publishes a event to a channel and then subscribes
|
||||||
|
// to receive that event.
|
||||||
|
//
|
||||||
|
// Please see these for more information:
|
||||||
|
//
|
||||||
|
// http://godoc.org/github.com/pubnub/go/messaging
|
||||||
|
// http://www.pubnub.com/developers/demos
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/pubnub/go/messaging"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PublishKey = "<YOUR KEY>"
|
||||||
|
SubscribeKey = "<YOUR KEY>"
|
||||||
|
SecretKey = "<YOUR KEY>"
|
||||||
|
KodingChannel = "koding"
|
||||||
|
TimeToken = "1000"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ()
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var pub = messaging.NewPubnub(PublishKey, SubscribeKey, SecretKey, "", false, "")
|
||||||
|
|
||||||
|
var errorChannel = make(chan []byte, 1)
|
||||||
|
var successChannel = make(chan []byte, 1)
|
||||||
|
var messageChannel = make(chan []byte, 1)
|
||||||
|
|
||||||
|
pub.Subscribe(KodingChannel, TimeToken, messageChannel, false, errorChannel)
|
||||||
|
pub.Publish(KodingChannel, "Hello koders!", errorChannel, successChannel)
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case err := <-errorChannel:
|
||||||
|
fmt.Printf("Got error :%s\n", err)
|
||||||
|
case result := <-successChannel:
|
||||||
|
fmt.Printf("Success :%s\n", result)
|
||||||
|
case result := <-messageChannel:
|
||||||
|
fmt.Printf("Got message :%s\n", result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Exit")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user