Skip to content

Instantly share code, notes, and snippets.

View anoopt's full-sized avatar

Anoop T anoopt

View GitHub Profile
@icebeam7
icebeam7 / run.csx
Created November 15, 2018 13:39
HTTP Azure Function Code which selects N random comments on a Facebook post
#r "Newtonsoft.Json"
using System.Net;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public class FacebookPost
{
@zplume
zplume / Log.ts
Last active December 12, 2017 13:55
export default class Log {
private prefix: string;
private logSource: object;
private parseArgument(arg: any): string {
return typeof(arg) === "string" ? arg : JSON.stringify(arg);
}
private getMethodName(callingFunction: Function): string {
const methodNames = Object.getOwnPropertyNames(Object.getPrototypeOf(this.logSource));
@zplume
zplume / GetUsers.js
Last active August 24, 2017 09:22
Quick script to get SharePoint user properties (LoginName, Title, Email) for multiple users, via the Chrome console, using async/await, Promise.all, fetch, computed properties and rest parameters.
(async function() {
let userIds = [239, 405];
// computed property name: [prop]:
// rest parameters: ...props
// stolen from: https://stackoverflow.com/a/25554551
function pick(o, ...props) {
return Object.assign({}, ...props.map(prop => ({[prop]: o[prop]})));
}
@msmfsd
msmfsd / es7-async-await.js
Last active February 4, 2024 17:38
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved