Skip to content

Instantly share code, notes, and snippets.

@jefftrull
jefftrull / gist:4063200
Created November 13, 2012 01:06
Test case for deletion of unneeded (childless) parent objects
trigger UpdateRelatedObjects on Contact (after update) {
// this is meant for reproducing an issue where after the Household lookup on a Contact changes,
// empty Households are deleted, and then a Contact's workflow rule evaluation will fail due to
// the Household being deleted (despite the fact that it now points to a different Household)
// in this experiment TestRelatedObject takes the place of Household, as I have installed the NPSP
// in my dev org, and already had TestRelatedObject from a previous experiment
// follow code from NPSP (taken off Github):
list<id> blankHHDeletes = new list<id>();
List<id> oldHouseholds = new list<id>();
@jefftrull
jefftrull / gist:4247930
Created December 10, 2012 01:49
Reproducing Date serialization issue - controller
public with sharing class DateIssueRepro {
// controller for testing Date setting issue ( case 08471144 )
// 2012-12-09 Jeff Trull <jetrull@sbcglobal.net>
public String selectedSer { get; set; } // only needed to set default
public DateIssueRepro() {
// initialize serialization method
selectedSer = 'none';
}
@jefftrull
jefftrull / gist:4247933
Last active October 13, 2015 19:58
Reproducing Date serialization issue - VF page
<apex:page controller="DateIssueRepro">
<!-- Simple VF page to demonstrate issue with setting Date fields of SObjects via Remoting -->
<!-- This is case 08471144 -->
<!-- Author: Jeff Trull <jetrull@sbcglobal.net> 2012-12-09 -->
<apex:form >
<table>
<tr>
<th>Date source</th>
<th>New value</th>
</tr>
@jefftrull
jefftrull / crash.cpp
Created February 20, 2013 00:21
Test case for gcc 4.7.2 crash ("internal compiler error: in get_expr_operands, at tree-ssa-operands.c:1035")
// A test case for gcc 4.7.2 crash
// Author: Jeff Trull <jeff.trull@ciere.com>
#include <vector>
#include <algorithm>
template<class Base>
class MyClass : Base
{
public:
// An attempt to generically parse expressions like this:
// <token> <int> ;
// - <some-expr> ;
// - <some-expr> ;
// - <some-expr> ; <- exactly as many times as given by <int> above
// END <token>
// where <token> is a string, and <some-expr> is a rule with attribute A
// the synthesized attribute of the result should be a fusion sequence of A
// Furthermore the resulting grammar should check the number of <some-expr> and ensure it
// matches the supplied <int>, with (ideally) a suitable error message
@jefftrull
jefftrull / gist:5544308
Created May 8, 2013 22:56
Using semantic actions with synthesized attributes. Do the attributes only get matched with the part of the rule that lacks actions? Or the whole thing?
// a test case for combining semantic actions with synthesized attributes in the same rule
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
@jefftrull
jefftrull / gist:5971433
Created July 11, 2013 00:20
Test code for jqm-datepicker #282
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" />
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
<!-- Optional Mousewheel support: https://github.com/brandonaaron/jquery-mousewheel -->
@jefftrull
jefftrull / gist:8910059
Created February 10, 2014 03:50
queue<shared_ptr<SimpleStruct>> is not nothrow move constructible
#include <queue>
#include <memory>
struct Foo {
int i;
};
using namespace std;
static_assert(is_nothrow_move_constructible<shared_ptr<Foo>>::value,
"Shared pointer is not move constructible");
@jefftrull
jefftrull / gist:5625b77c0f86c439f29f
Created August 15, 2014 06:05
Replacement for harmonic_oscillator.cpp with Eigen Matrix as state type and necessary changes made
/*
Copyright 2010-2012 Karsten Ahnert
Copyright 2011-2013 Mario Mulansky
Copyright 2013 Pascal Germroth
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
@jefftrull
jefftrull / gist:6131ffeb35ef72ef348f
Last active August 29, 2015 14:06
void_t usage test case
#include <type_traits>
#include <iostream>
using namespace std;
template<class... > using void_t = void;
template< class, class = void >
struct has_type_member : false_type { };