Skip to content

Instantly share code, notes, and snippets.

View brianly's full-sized avatar
🦙
Don't get much time to hack right now due to 👶

Brian Lyttle brianly

🦙
Don't get much time to hack right now due to 👶
View GitHub Profile
@brianly
brianly / example.py
Created March 4, 2013 06:21
An example showing how to use an Access Token to return messages with YamPy
# -*- coding: utf-8 -*-
ACCESS_TOKEN = ''
import json
import yampy
def pprint(raw_json):
print json.dumps(raw_json, sort_keys=True,
indent=2, separators=(',', ': '))
@brianly
brianly / gist:5644600
Created May 24, 2013 16:14
A collection of OK and bad regexs for email validation.
^(.+)@(.+)$
/.\@.*\../
/\A[^@]+@([^@\.]+\.)+[^@\.]+\z/
/^(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})$/i
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
@brianly
brianly / YammerClient.cs
Last active March 23, 2017 20:43
Example OAuth client for Yammer using DotNetOpenAuth. You'll need to generate some model classes with http://json2csharp.com after poking around with the API endpoints. These are needed to handle the JSON returned when the OAuth dance is finished, and when user properties are requested.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using DotNetOpenAuth.AspNet.Clients;
using DotNetOpenAuth.Messaging;
using Newtonsoft.Json;
using YammerAuthentication.Yammer.Models.User;
@brianly
brianly / put.rb
Created June 3, 2013 15:06
Code interpreted in my head for executing a PUT request to a Yammer user profile.
require 'net/http'
port = 443
host = "www.yammer.com"
path = "/api/v1/users/[:id].json"
req = Net::HTTP::Put.new(path, initheader = { 'Authorization' => 'Bearer YOUR_ACCESS_TOKEN'})
req.body = "work_telephone=01189998819991197253&work_extension=12345"
response = Net::HTTP.new(host, port).start {|http| http.request(req) }
puts response.code
@brianly
brianly / gist:5797841
Created June 17, 2013 15:34
Pings and traceroutes from Northern Ireland.
vagrant :: (master*) » ping www.yammer.com ~/vm/vagrant 127 ↵
PING www.yammer.com (204.152.18.206): 56 data bytes
64 bytes from 204.152.18.206: icmp_seq=0 ttl=240 time=191.176 ms
64 bytes from 204.152.18.206: icmp_seq=1 ttl=240 time=191.060 ms
64 bytes from 204.152.18.206: icmp_seq=2 ttl=240 time=194.129 ms
64 bytes from 204.152.18.206: icmp_seq=3 ttl=240 time=201.785 ms
64 bytes from 204.152.18.206: icmp_seq=4 ttl=240 time=264.036 ms
64 bytes from 204.152.18.206: icmp_seq=5 ttl=240 time=216.519 ms
64 bytes from 204.152.18.206: icmp_seq=6 ttl=240 time=308.934 ms
64 bytes from 204.152.18.206: icmp_seq=7 ttl=240 time=339.555 ms
def exchange_check(exchange_user_email, exchange_password, yammer_user_email,ooo_message)
user_is_busy = false
user_is_ooo = false
user_is_ooo_startdate = DateTime.now.strftime("%D") # Date only
user_is_ooo_lastdate = DateTime.now.strftime("%D") # Date only
require 'net/http'
url = URI.parse('http://bl-hackday.cloudapp.net/hackday/calendar')
@brianly
brianly / like.html
Created July 18, 2013 14:52
WHY NO WORK??
<!doctype html>
<html>
<head>
</head>
<body>
<script data-app-id="hyB2pTvrL36Y50py8EWj6A" src="https://assets.yammer.com/platform/yam.js"></script>
<script>
yam.connect.actionButton({
container: "#embedded-like",
network: "provinggroundtestnetwork312.com",
@brianly
brianly / gist:6031434
Created July 18, 2013 17:54
How many things are wrong with this?
<!doctype html>
<html>
<head>
<script data-app-id="YOUR APP ID" src="https://assets.yammer.com/platform/yam.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<script>
$(function() {
$('head').append('<meta property="og:title" content="Site Title" /> ');
@brianly
brianly / gist:6034957
Created July 19, 2013 03:42
What's wrong with this?
{
"activity": {
"actor": {
"name": "Jim Martin",
"email": "jim@seyammer.com"
},
"action": "yammermvc:publish",
"object": {
"url": "https://dox.com/file/abc123.pdf",
"description": "A set of charts showing the ROI of deploying Yammer over time.",
POST https://www.yammer.com/api/v1/activity.json HTTP/1.1
Authorization: Bearer REMOVED
Content-Type: text/plain; charset=utf-8
Host: www.yammer.com
Content-Length: 494
Expect: 100-continue
Connection: Keep-Alive
{"activity":{"actor":{"name":"Jim Martin","email":"jim@seyammer.com"},"action":"yammermvc:publish","object":{"url":"https://dox.com/file/abc123.pdf","description":"A set of charts showing the ROI of deploying Yammer over time.","video":{"width":1,"height":1},"type":"yammermvc:photo","title":"Yammer ROI.pdf","image":"https://dox.com/file/abc123.pdf"},"private":"false","message":"This is the updated version for the conference.","users":[{"name":"Brian Davis","email":"bdavis@seyammer.com"}]}}