Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
say hi

brad oyler bradoyler

👋
say hi
View GitHub Profile
@bradoyler
bradoyler / CreateCheckout.cs
Created Aug 13, 2012
example for creating a wepay checkout using the WePay SDK (C#)
View CreateCheckout.cs
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 Oct 9, 2012
SQL script for Column counts
View Column_Counts.sql
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 Oct 9, 2012
Getting all your SVN log via SharpSVN
View SharpSVN.getRecords.cs
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 Oct 9, 2012
An event tracking ActionFilter for your MVC app using Cloudmine
View UserTrackingMVC.cs
[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 Oct 9, 2012
Powershell function to extract stuff from Sharepoint
View GetFromSharepoint.ps1
# 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 Oct 9, 2012
Locate a user (ASP.Net) using ipinfodb.com
View GeoLocateVisitor.cs
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 Oct 9, 2012
Upload a file to S3 (asp.net)
View UploadtoAwsS3.cs
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 Oct 24, 2012
Get ALL docs from any collection in RavenDB
View GetAllFromRavenDB.cs
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 Nov 2, 2012
A DataContext wrapper for LINQ to SQL model.
View DataContextWrapper.cs
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 Nov 3, 2012
user-authenticated event tracking with jQuery in a Razor View
View UserTracking.js
$(function () {
$('a').mousedown(function () {
_gaq.push(['_trackEvent', 'userClick', $(this).attr('href'), '@User.Identity.Name']);
});
});