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
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);
<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 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);
@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
@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 / 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:
<script type="text/javascript">
// This is to deal with IE and style leakages
// see: http://stackoverflow.com/a/10557782/22466
(function () {
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
var completed = false;
style.type = 'text/css';
@brianly
brianly / update.cs
Last active August 29, 2015 14:05
Update a user profile in Yammer with a PUT request. Could be improved by using the newer HttpClient library.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@brianly
brianly / setauthtoken.html
Last active August 29, 2015 14:26
Use setAuthToken to store an OAuth token in a cookie. Long-lived OAuth tokens should be generated through the server-side flow and the token variable should be set from server-side code.
<!DOCTYPE html>
<html>
<head>
<title>setAuthToken() example</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" data-app-id="VlXilc0P6NemTfCzxTKChg" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function () {