Skip to content

Instantly share code, notes, and snippets.

View jbubriski's full-sized avatar

John Bubriski jbubriski

View GitHub Profile
@jbubriski
jbubriski / robot.js
Created December 1, 2012 13:25
Skippy
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.turn(20);
@jbubriski
jbubriski / RegularExpressionMultiMatchAttribute.cs
Created December 3, 2012 21:30
RegularExpressionMultiMatchAttribute that allows multiple matches for data annotations (ex. w/ ASP.NET MVC)
public class RegularExpressionMultiMatchAttribute : RegularExpressionAttribute
{
public RegularExpressionMultiMatchAttribute(string pattern)
: base(pattern)
{
}
public override bool IsValid(object value)
{
@jbubriski
jbubriski / touch-button.js
Created December 9, 2012 16:09 — forked from phoboslab/touch-button.js
Touch Button Plugin for Impact
ig.module(
'plugins.touch-button'
)
.requires(
'impact.system',
'impact.input',
'impact.image'
)
.defines(function(){
<?
/**
Written by James Laughlin
http://developer.pardot.com/discussions/questions/55-php-login-example
There seems to be little on this forum that is language specific, so If you are using Drupal or Wordpress, you'll need to build interfaces to Pardot in PHP at some point. Here's a function you can use to retrieve your Pardot credentials in one array object so that you can make your API calls.
**/
// the pardot API key is only good for an hour
// so it's best to get it before every API call
function get_pardot_credentials(){
@jbubriski
jbubriski / drupal-pardot-webform-theme-rendering.php
Last active December 11, 2015 20:39
Theming an admin form for the webforms module.
function theme_pardot_webform_components_form($form) {
$form = $form['form'];
$rows = array();
$output = '';
$header = array(t('Name'), t('Type'), t('Pardot key'));
foreach (element_children($form['components']) as $k) {
$row = array();
@jbubriski
jbubriski / ReadExcel.cs
Last active December 14, 2015 23:19
Reading an excel using the Microsoft.ACE.OLEDB driver.
var fileName = "file.xlsx";
var connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", fileName);
var query = "select * from [{0}$]";
using (var dataAdapter = new OleDbDataAdapter(string.Format(query, "worksheet name"), connectionString))
{
var dataSet = new DataSet();
dataAdapter.Fill(dataSet);
var myTable = dataSet.Tables[0];
@jbubriski
jbubriski / CustomAuthorize.cs
Last active December 16, 2015 12:39
Custom Authorization in ASP.NET MVC through a custom Authorization attribute.
public class CustomAuthorizeAttribute : System.Web.Mvc.AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext)
{
// Clear Cookies
// Put your code here
base.HandleUnauthorizedRequest(filterContext);
}
}
@jbubriski
jbubriski / gist:5645243
Created May 24, 2013 17:47
SQL Command to Typed List
var sqlReader = sqlCommand.ExecuteReader();
var products = new List<Product>();
while(sqlReader.Read())
{
var product = new Product
{
ID = int.Parse(sqlReader["ID"].ToString()),
Name = sqlReader[1].ToString()
public List<ContactUsBizFormData> GetContactUsData()
{
using (SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString))
{
var sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlconn;
sqlconn.Open();
var sqlReader = sqlCommand.ExecuteReader();
@jbubriski
jbubriski / CsvWriter.cs
Created May 24, 2013 20:09
A CSV Writer that can be used to write directly to a response stream in ASP.NET
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace DataUtils
{
/// <summary>
/// Derived from Richard Carr's (Black Wasp) CsvWriter class at http://blackwasp.co.uk/WriteCsv.aspx