Skip to content

Instantly share code, notes, and snippets.

View robertgreiner's full-sized avatar

Robert Greiner robertgreiner

View GitHub Profile
@robertgreiner
robertgreiner / SystemProcessesToXML.cs
Created December 15, 2011 16:01
Use LINQ to build an XML file containing system processes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Diagnostics;
namespace SystemProcessesToXML {
class Program {
static void Main(string[] args) {
@robertgreiner
robertgreiner / google-rss.js
Created December 28, 2011 22:43
A Google RSS feed example
<!-- ++Begin Dynamic Feed Wizard Generated Code++ -->
<!--
// Created with a Google AJAX Search and Feed Wizard
// http://code.google.com/apis/ajaxsearch/wizards.html
-->
<!--
// The Following div element will end up holding the actual feed control.
// You can place this anywhere on your page.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery Example</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.6.1.min.js">
</script>
<script type="text/javascript">
//$(document).ready() is cross-browser
public double SumSquaresUsingLinq()
{
return numberList.Sum(num => Math.Pow(num, 2));
}
@robertgreiner
robertgreiner / apply_migrations.ps1
Created May 10, 2012 17:50
Apply SQL Azure Migrations
Update-Database -StartUpProjectName "ToTheCloud.Infrastructure" -ConnectionString "Server=tcp:<server_name>.database.windows.net,1433;Database=<database_name>;User ID=<db_user_name>@<server_name>;Password=<password>;Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True;Max Pool Size=100;" -ConnectionProviderName "System.Data.SqlClient"
<script src="https://gist.github.com/<gist_id>.js"> </script>
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException: ID1038: The AudienceRestrictionCondition was not valid because the specified Audience is not present in AudienceUris.
Audience: 'http://localhost:54012'
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
@robertgreiner
robertgreiner / post.html
Created April 23, 2012 20:06
Creating a Gist that looks good on your blog and is compatible with Google Reader
<p>
<script src="https://gist.github.com/<gist_id>.js"> </script>
<noscript>
<pre>
//Your code here
//Be sure you escape your tags with &lt; and &gt; when displaying things like HTML.
</pre>
</noscript>
</p>
@robertgreiner
robertgreiner / reverse.go
Last active October 30, 2016 19:57
Take a shortened URL and expand it to its final address
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
resp, err := http.Get("http://bit.ly/2eXwN8A") //robertgreiner.com

If you take a flat map
And move wooden blocks upon it strategically,
The thing looks well, the blocks behave as they should.
The science of war is moving live men like blocks.
And getting the blocks into place at a fixed moment.
But it takes time to mold your men into blocks
And flat maps turn into country where creeks and gullies
Hamper your wooden squares. They stick in the brush,
They are tired and rest, they straggle after ripe blackberries,
And you cannot lift them up in your hand and move them.