Skip to content

Instantly share code, notes, and snippets.

View bradoyler's full-sized avatar
👋
say hi

brad oyler bradoyler

👋
say hi
View GitHub Profile
@bradoyler
bradoyler / CreateCheckout.cs
Created August 13, 2012 20:40
example for creating a wepay checkout using the WePay SDK (C#)
public CheckoutCreateResponse Create(CheckoutCreateRequest req)
{
CheckoutCreateResponse response;
try
{
response = new WePayClient().Invoke<CheckoutCreateRequest, CheckoutCreateResponse>(req, req.actionUrl,req.accessToken);
}
catch (WePayException ex)
{
response = new CheckoutCreateResponse { checkout_id = 0, checkout_uri =req.redirect_uri+"?error="+ex.error, Error =ex };
@bradoyler
bradoyler / Column_Counts.sql
Created October 9, 2012 18:01
SQL script for Column counts
DROP TABLE #Fields
CREATE TABLE #Fields(ColumnID int ,Field varchar(150) NOT NULL ,Records bigint NULL)
DECLARE @count INT
DECLARE @colCount INT
DECLARE @Column VARCHAR(150)
DECLARE @Table VarChar(150)
DECLARE @RecordCount BIGINT
DECLARE @Sql VarChar(8000)
@bradoyler
bradoyler / SharpSVN.getRecords.cs
Created October 9, 2012 18:04
Getting all your SVN log via SharpSVN
Collection<SvnLogEventArgs> list;
using(SvnClient client = new SvnClient())
{
//client.Authentication.DefaultCredentials = new NetworkCredential("user", "pass");
Uri svnrepo = new Uri("svn://servername/reponame/");
SvnInfoEventArgs info;
client.GetInfo(svnrepo, out info);
long lastRev = info.Revision;
@bradoyler
bradoyler / UserTrackingMVC.cs
Created October 9, 2012 18:10
An event tracking ActionFilter for your MVC app using Cloudmine
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class UserTrackingAttribute : ActionFilterAttribute
{
public static readonly string appId = "your CloudMine app Id";
public static readonly string appSecret = "your CloudMine app Secret";
class PageRequest
{
public int PageId { get; set; }
public Double Created { get; set; }
public string Url { get; set; }
@bradoyler
bradoyler / GetFromSharepoint.ps1
Created October 9, 2012 18:14
Powershell function to extract stuff from Sharepoint
# below are some SP scripts that do some basic tricks
function GetDocInfo
{
#//this checks existence of a file in a specified SPList
Param ( [parameter(Mandatory=$true)][string]$LibName,
[parameter(Mandatory=$true)][string]$DocName
)
$web = Get-SPWeb http://yourSPserver
$docLibrary = $web.Lists[$LibName]
$folder = $docLibrary.RootFolder
@bradoyler
bradoyler / GeoLocateVisitor.cs
Created October 9, 2012 18:16
Locate a user (ASP.Net) using ipinfodb.com
string ip = Request.ServerVariables["X-Forwarded-For"]
public class LocationInfo
{
public string Country { get; set; }
public string RegionName { get; set; }
public string City { get; set; }
public string ZipCode { get; set; }
public float Latitude { get; set; }
public float Longitude { get; set; }
@bradoyler
bradoyler / UploadtoAwsS3.cs
Created October 9, 2012 18:18
Upload a file to S3 (asp.net)
HttpPostedFileBase file = Request.Files[0];
if (file.ContentLength > 0) // accept the file
{
string accessKey = "XXXXXXXXXXX";
string secretKey = "122334XXXXXXXXXX";
AmazonS3 client;
using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey))
{
PutObjectRequest request = new PutObjectRequest();
@bradoyler
bradoyler / GetAllFromRavenDB.cs
Created October 24, 2012 16:05
Get ALL docs from any collection in RavenDB
using Raven.Client;
public class RavenSearch
{
private IEnumerable<T> GetAllResults<T>(IDocumentSession session) where T : class
{
session.Advanced.MaxNumberOfRequestsPerSession = 1000;
int skip = 0;
var results = new List<T>();
var query = session.Query<T>();
@bradoyler
bradoyler / DataContextWrapper.cs
Created November 2, 2012 13:01
A DataContext wrapper for LINQ to SQL model.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Common;
using System.Data.Linq;
namespace MyApp.Models.DataContextWrapper
{
public interface IDataContextWrapper
@bradoyler
bradoyler / UserTracking.js
Created November 3, 2012 13:30
user-authenticated event tracking with jQuery in a Razor View
$(function () {
$('a').mousedown(function () {
_gaq.push(['_trackEvent', 'userClick', $(this).attr('href'), '@User.Identity.Name']);
});
});