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 / mymessages.py
Last active August 29, 2015 14:01
Iterate over the /api/v1/messages/sent.json endpoint and just return those for your user. Takes your user ID as input (can be automated.)
import sys
import time
import yampy
import webbrowser
def get_input(prompt):
if sys.hexversion > 0x03000000:
return input(prompt)
else:
@brianly
brianly / users.py
Created May 13, 2014 02:18
Updated create() and update() to take department_name as parameters.
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
@brianly
brianly / gist:9858361
Created March 29, 2014 17:17
Weird extensions from the '90s.
HTML Components
http://msdn.microsoft.com/en-us/library/ms532146.aspx
http://www.w3.org/TR/NOTE-HTMLComponents
Element behaviors
http://msdn.microsoft.com/en-us/library/ms531426(v=vs.85).aspx
Introduction to DHTML Behaviors
http://msdn.microsoft.com/en-us/library/ms531079(v=vs.85).aspx
public class PostFile
{
public T Post<T>(string path, string text, List<Attachment> attachments)
{
using (var restClient = new RestClient())
using (var content = new MultipartFormDataContent())
{
// Message part
var messageContent = new StringContent(text);
<script type="text/javascript"
data-app-id="SPECIFY APP CLIENT ID HERE"
src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>
<script>
yam.getLoginStatus({ token: 'SPECIFY A TOKEN ASSOCIATED WITH APP CLIENT ID' },
function (response) {
if (response.authResponse) {
alert("logged in");
console.dir(response);
}
public T Post<T>(string path, IEnumerable<KeyValuePair<string, string>> parameters, FilePayload payload)
{
using (var restClient = new RestClient())
{
using (var content = new MultipartFormDataContent())
{
content.Add(new FormUrlEncodedContent(parameters));
var streamContent = new StreamContent(new MemoryStream(payload.ContentBytes));
content.Add(streamContent, "attachment1", payload.FileName);
@brianly
brianly / export.cmd
Created November 1, 2013 01:09
A version of the data export script that doesn't do certificate checking.
@ECHO OFF
IF [%1]==[] (
IF [%2]==[] (
ECHO "Usage: export.cmd <OAuth Access Token> <Directory>"
EXIT /B
)
)
:: Your Yammer OAuth 2 Access Token. This must be a token for a verified admin account.
@brianly
brianly / yammerwords.py
Created October 9, 2013 03:43
Some sort of word count script I wrote to process a Yammer data export.
import sys
import csv
import argparse
import re
import nltk
from operator import itemgetter
from string import punctuation
def replace_topic(matched_topic):
POST https://www.yammer.com/api/v1/activity.json HTTP/1.1
Authorization: Bearer REMOVED
Content-Type: application/json; charset=utf-8
Host: www.yammer.com
Content-Length: 392
Expect: 100-continue
Connection: Keep-Alive
{"activity":{"actor":{"name":"Brian Lyttle","email":"blyttle@seyammer.com"},"action":"yammermvc:publish","object":{"url":"https://bing.com/?233334","description":"This is a cool image","video":{"width":1,"height":1},"type":"yammermvc:photo","title":"Cool image","image":"http://news.bbcimg.co.uk/media/images/68853000/jpg/_68853657_ac86edof.jpg"},"private":"false","message":"","users":null}}
@brianly
brianly / activity-stream-http.txt
Last active December 24, 2015 12:39
Example post showing a story being posted to the Activity Stream.
POST https://www.yammer.com/api/v1/activity.json HTTP/1.1
Authorization: Bearer REMOVED_TOKEN
Content-Type: application/json; charset=utf-8
Host: www.yammer.com
Content-Length: 405
Expect: 100-continue
{
"activity": {
"actor": {