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
$feedUrl = "http://channel9.msdn.com/Events/TechEd/Europe/2014/RSS/mp4high" | |
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath | |
$rss = (new-object net.webclient) | |
$a = ([xml]$rss.downloadstring($feedUrl)) | |
$a.rss.channel.item | foreach{ | |
$url = New-Object System.Uri($_.enclosure.url) | |
$file = $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-") + "-" + $_.creator + ".mp4" | |
if (!(test-path $file)) | |
{ | |
$file |
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
private List<DiscoursSearchResult> SearchForum(string term) | |
{ | |
List<DiscoursSearchResult> results = new List<DiscoursSearchResult>(); | |
if (string.IsNullOrEmpty(term)) | |
return results; | |
string url = ConfigurationManager.AppSettings["DiscourseUrl"] + "/search.json?include_blurbs=true&type_filter=topic&api_key=" + ConfigurationManager.AppSettings["DiscourseAPIKey"] + "&api_username=" + ConfigurationManager.AppSettings["DiscourseUrl"] + "&term=" + term; | |
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); | |
req.Method = WebRequestMethods.Http.Get; | |
req.Accept = "application/json"; |
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
private bool setGroupAccess(string username, string groupName) | |
{ | |
string url = "/groups/{group_name}.json?api_key={api_key}&api_username={api_username}"; | |
var client = new RestClient(ConfigurationManager.AppSettings["DiscourseUrl"]); | |
var request = new RestRequest(url, Method.GET); | |
request.AddUrlSegment("group_name", groupName); | |
request.AddUrlSegment("api_key", ConfigurationManager.AppSettings["DiscourseAPIKey"]); | |
request.AddUrlSegment("api_username", ConfigurationManager.AppSettings["DiscourseAPIUsername"]); | |
request.RootElement = "basic_group"; | |
IRestResponse<DiscourseGroup> groupInfoResponse = client.Execute<DiscourseGroup>(request); |
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
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath | |
$rss = (new-object net.webclient) | |
$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/Build/2014/RSS/mp4high")) | |
$a.rss.channel.item | foreach{ | |
$url = New-Object System.Uri($_.enclosure.url) | |
$file = $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-") + "-" + $_.creator + ".mp4" | |
if (!(test-path $file)) | |
{ | |
$file | |
$wc = (New-Object System.Net.WebClient) |
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 ActionResult DiscourseLogin() | |
{ | |
if (string.IsNullOrEmpty(Request.QueryString["sso"]) || string.IsNullOrEmpty(Request.QueryString["sig"])) | |
return Content("Invalid"); | |
string ssoSecret = "YOUR SSO SECRET"; //must match sso_secret in discourse settings | |
string sso = Request.QueryString["sso"]; | |
string sig = Request.QueryString["sig"]; |
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 void BulkInsert<T>(string connection, string tableName, IList<T> list, string[] propsToSkip) | |
{ | |
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock)) | |
{ | |
bulkCopy.BatchSize = list.Count; | |
bulkCopy.DestinationTableName = tableName; | |
var table = new DataTable(); | |
var props = TypeDescriptor.GetProperties(typeof(T)) | |
//Dirty hack to make sure we only have system data types |