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 / activity
Created August 13, 2013 19:41
Example JSON activity stream post to https://www.yammer.com/api/v1/activity.json.
{
"activity": {
"actor": {
"name": "Brian Lyttle",
"email": "[email protected]"
},
"action": "yammermvc:publish",
"object": {
"url": "http://localhost:33128/media/detail?id=33",
"description": "",
@brianly
brianly / activity-response
Created August 13, 2013 19:43
Example response returns "202 Accepted" and the JSON below.
{
"actor_id": 1491478840,
"object_id": 352364218665986,
"action_id": 837943
}
@brianly
brianly / gist:6236102
Last active December 21, 2015 02:38
Suspending a Yammer user with PowerShell.
function Invoke-HttpDelete([string]$target, [string]$token) {
try {
# Setup the request
$webRequest = [System.Net.WebRequest]::Create($target)
$webRequest.Method = "DELETE"
$webRequest.Headers.Add("Authorization", "Bearer $token");
# Execute the request
[System.Net.WebResponse]$resp = $webRequest.GetResponse();
$rs = $resp.GetResponseStream();
@brianly
brianly / gist:6242214
Last active December 21, 2015 03:29
PowerShell snippet showing how to delete a user in a Yammer network.
function Yammer-HttpDelete([string]$target,[string]$token) {
try {
# Setup the request
$webRequest = [System.Net.WebRequest]::Create($target)
$webRequest.Method = "DELETE"
$webRequest.Headers.Add("Authorization", "Bearer $token");
# Execute the request
[System.Net.WebResponse]$resp = $webRequest.GetResponse();
$rs = $resp.GetResponseStream();
@brianly
brianly / deploy.sh
Last active December 22, 2015 01:48
Some random configuration for an Ubuntu server instance that wants to popup a dialog a little too much.
#!/bin/bash
echo 'DEBIAN_FRONTEND="noninteractive"' >> /etc/profile
---
### CONFIGURE REPOSITORIES ###
- name: install python-software-properties
action: apt name='python-software-properties' state=installed
- name: "add nginx ppa if ubuntu 10.04 and up"
action: apt_repository repo=ppa:nginx/stable
only_if: "$is_ubuntu and $is_10_up"
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@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": {
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":"[email protected]"},"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 / 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):