This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Returns DataMemberAttribute names for a DataContract object | |
public static List<string> GetDataMemberAttributeNames(object obj) | |
{ | |
List<string> result = new List<string>(); | |
foreach (PropertyInfo p in obj.GetType().GetProperties()) | |
{ | |
foreach (System.Runtime.Serialization.DataMemberAttribute ca in p.GetCustomAttributes(false)) | |
{ | |
result.Add((string)ca.Name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static object TableBuilder(IEnumerable<object> obj) | |
{ | |
XElement result = new XElement("table"); | |
//add header row using property names | |
result.Add( new XElement("tr", | |
obj.FirstOrDefault().GetType().GetProperties().Select (property => new XElement("th",property.Name)))); | |
//add object values to table rows | |
foreach(object o in obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.toDataTable = function () { | |
var results = {}; | |
results.cols = Enumerable.From(this[0]).Select(function (p) { | |
return { id: p.Key, label: p.Key, type: "string" }; | |
}).ToArray(); | |
results.rows = Enumerable.From(this).Select(function (c) { | |
return { c: Enumerable.From(results.cols).Select(function (i) { | |
return { v: c[i.id] }; | |
}).ToArray() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//using office 14.0.0.0 | |
//using Microsoft.Office.Interop.Powerpoint | |
//http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint._application(v=office.14).aspx | |
public static Microsoft.Office.Interop.PowerPoint.Application ppt { get; set; } | |
void Main() | |
{ | |
ppt = new Microsoft.Office.Interop.PowerPoint.Application(); | |
MigratePPT(@"C:\Users\MyFiles"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
string path = Path.GetFullPath(@"C:\Users\Username"); | |
System.IO.DirectoryInfo di = new DirectoryInfo(path); | |
var query = di.GetFiles("*.*",SearchOption.TopDirectoryOnly).IncludeFileExtensions("*.asp").SearchFileContents("searchterm"); | |
query.Dump(); | |
} | |
public static class FileIOExtensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
System.Net.WebClient client = new System.Net.WebClient(); | |
JavaScriptSerializer js = new JavaScriptSerializer(); | |
var url = "https://api.github.com/repos/kbrammer/kevinbrammer.azurewebsites.net/contents"; | |
var results = client.DownloadString(url); | |
Content[] r = js.Deserialize<Content[]>(results); | |
r.Dump("Results"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' http://msdn.microsoft.com/en-us/library/office/gg278834(v=office.15).aspx | |
Sub ExportQueryObjs() | |
' File System Properties | |
Const ForReading = 1, ForWriting = 2, ForAppending = 3 | |
Dim fs, f | |
Set fs = CreateObject("Scripting.FileSystemObject") | |
' DAO / Query definition properties | |
' http://stackoverflow.com/questions/20252599/how-do-you-export-ms-access-query-objects-to-text-file | |
Dim def As DAO.QueryDef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require("https"); | |
// based on https://stackoverflow.com/questions/35182752/promises-with-http-get-node-js | |
module.exports = { | |
get(urlString, token = null) { | |
return new Promise((resolve, reject) => { | |
const url = new URL(urlString); | |
const requestOptions = { | |
method: "GET", | |
hostname: url.hostname, |