Skip to content

Instantly share code, notes, and snippets.

View jeriley's full-sized avatar

Jesse jeriley

View GitHub Profile
@jeriley
jeriley / V1Api.cls
Last active August 29, 2015 14:00
Example of Apex code for sending a Story to VersionOne
public class V1Api {
private V1BasicConnector;
public V1Api(){
V1BasicConnector = new V1BasicConnector('https://www99.host.com/myInstance', 'admin', 'admin');
}
public void CreateStory(V1Story story)
{
Dom.Document doc = new Dom.Document();
@jeriley
jeriley / FullMultiMock.cls
Last active August 29, 2015 14:02
Salesforce Apex http callout test helper and example
public class FullMultiMock implements HttpCalloutMock {
private integer urlCount { get; set; }
private List<MockCallout> mockCallouts {get; set;}
public FullMultiMock(List<MockCallout> callouts){
system.debug('callouts : ' + callouts);
mockCallouts = callouts;
urlCount = 0;
}
@jeriley
jeriley / book.js
Last active August 29, 2015 14:07
example plugins for the leapmotion, also note you'll need underscorejs
Leap.plugin('book', function(options) {
options || (options = {});
options.frameDuration || (options.frameDuration = 20);
var toDegrees = 180/Math.PI;
var sendEvent = _.debounce(function(eventName, controller){
console.log(eventName);
$.jGrowl(eventName);
controller.emit(eventName);
@jeriley
jeriley / Update Story Example.ps1
Last active August 29, 2015 14:12
V1Api example : powershell
$username = "admin"
$password = "admin"
$instance = "http://localhost/VersionOne.Web/"
$base64ed = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($($username + ":" + $password)))
$storyId = "S-01001"
$story = GetStoryByID $storyId
UpdateAsset $story "<Asset><Attribute name='Description' act='set'>Descript Insert!</Attribute></Asset>"
#disabled because this will update a pile of stories -- be careful!
@jeriley
jeriley / java-ish.xsl
Created January 7, 2015 19:49
V1 Meta to java classes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE stylesheet
[
<!ENTITY mdash "&#8212;">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
@jeriley
jeriley / DbContextMockExtension.cs
Created March 23, 2015 02:18
DbContext Mocking example
namespace Moq.Context {
public static class DbContextMockExtension
{
public static Mock<AHContext> SetupPartOfTheContextWith<T>(this Mock<AHContext> mockContext, List<T> listOfT, Expression<Func<AHContext, DbSet<T>>> setupReturn) where T : BaseEntity
{
var queryable = listOfT.AsQueryable();
var mockSet = new Mock<DbSet<T>>();
@jeriley
jeriley / spark.bat
Created February 2, 2016 20:12
setting up Spark shortcut / reminders (windows)
@echo do you have winutils or hadoop_home?
mkdir C:\tmp\hive
%HADOOP_HOME%\bin\winutils chmod 777 /tmp/hive
@echo does your path have a thing for spark?
cd C:\
spark-shell
function buildIt($){
this.postIt = function(itemToChange){
$.post('giggle', function(data){
itemToChange.item = data.item;
});
}
};
@jeriley
jeriley / Checksum.cs
Created February 28, 2017 16:56
Salesforce ID checksum in C#
public class Checksum
{
private Dictionary<string, char> _lookup = new Dictionary<string, char>();
private char[] _checksumChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".ToCharArray();
public Checksum()
{
for (var i = 0; i < 32; i++)
{
var bit = Convert.ToString(i, 2).PadLeft(5, '0');
@jeriley
jeriley / SalesforceChecksum.ts
Created February 20, 2018 04:50
Salesforce ID checksum ... now in typescript!
export class SalesforceChecksum
{
private lookup = {};
private checksumChars = Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345");
constructor()
{
for (var i = 0; i < 32; i++)
{
let value = (i >>> 0).toString(2);