Skip to content

Instantly share code, notes, and snippets.

View edm00se's full-sized avatar

Eric McCormick edm00se

View GitHub Profile
@edm00se
edm00se / AltDataProvider.java
Last active August 29, 2015 14:05
Alternate JSON Java provider, implementing the com.ibm.commons.util.io.json package instead of Google GSON (as seen in my original Class).
package com.eric.test;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import lotus.domino.*;
import com.ibm.xsp.model.domino.DominoUtils;
@edm00se
edm00se / DataProvider.java
Last active August 29, 2015 14:05
XAgent Java FacesContext response JSON data class.
package com.eric.test;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import lotus.domino.*;
import com.ibm.xsp.model.domino.DominoUtils;
@edm00se
edm00se / CustAuthRestConsumer.java
Last active August 29, 2015 14:05
Extending the CustRestConsumer class, the get method is public for invocation but the build URL and credentialing methods are both private, so as to prevent exposing that information. This is covered in detail in my blog post: http://edm00se.github.io/DevBlog/xpages/server-rest-with-authentication/
package com.eric.restful;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedReader;
import org.apache.commons.codec.binary.Base64;
import com.google.gson.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
@edm00se
edm00se / CustRestConsumer.java
Last active February 9, 2016 12:35
My proof of concept that Java on the server, along with RESTful APIs, can be an impressive and easy way of managing business applications (this uses a standard Domino Java Code element with an XPage as the front-end). Package is defined with a single class and single (static) method, to return the data from a simple REST call, fully on the serve…
package com.eric.restful;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedReader;
import com.google.gson.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.MalformedURLException;
@edm00se
edm00se / coderay_domino_elements.md
Last active August 29, 2015 14:05
Redmine CodeRay Syntax Highlighting of Domino/XPages Eesign Elements

Updating Redmine CodeRay to Syntax Highlight (most) Domino/XPages Design Elements

Get into the correct file that pertains to file extensions and syntax highlighting definitions.

  • go to your Redmine directory (ex- /var/www/redmine)
  • enter your vendor library path for CodeRay (ex- vendor/bundle/ruby/1.9.1/gems/coderay-1.0.9/)
  • edit the file_type.rb file (which defines the language syntax associtiations, ex- lib/coderay/helpers/file_type.rb) with your preferred editor

Now that you're there, we need to associate the design elements accordingly. Scroll down to the section defining the array of TypeFromExt (or search, in nano CTRL+W, for something like xml), and add in the following:

@edm00se
edm00se / snippet_localAngularFallbackFromCDN.htm
Last active August 29, 2015 14:03
AngularJS local fallback for Google CDN.
<!-- attempt to load AngularJS from CDN -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<!-- if AngularJS fails to load fallback a local version -->
<script type="text/javascript">
if(!window.angular){
var ang = document.createElement('script');
//exlpicit path to server library copy
ang.src = "//server.com/libs/angularjs/1.2.19/angular.min.js";
// relative path
@edm00se
edm00se / iframeHeightResizing.htm
Last active August 29, 2015 14:03
iFrame resizing dynamically by the height of the content of the destination frame.
<!-- Include early for reference by the iframe itself -->
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
<!-- the onload triggers the resize against its own content -->
<iframe name="Stack" src="http://my.server.com/path/to/destination.html" frameborder="0" scrolling="no" id="iframe" onload='resizeIframe(this);' />
@edm00se
edm00se / BS3_consistentHeightClasses.css
Last active August 29, 2015 14:03
Consistent responsive row column height in Bootstrap 3.
/*
* Provides Bootstrap 3 compatible classes for making responsive rows and columns consistently formatted for height.
* src: http://www.minimit.com/articles/solutions-tutorials/bootstrap-3-responsive-columns-of-same-height
*/
/* columns of same height styles */
.row-same-height {
display: table;
width: 100%;
}
.col-xs-height {
@edm00se
edm00se / mobile date control snippets.xml
Last active August 29, 2015 13:57
This provides an XPages way of failing over on mobile devices to use the native / mobile browser's date/time controls with correct formatting to save back into a Notes Document as the correct Notes Item type.
<!--
mobileLib.isMobile() returns boolean of whether the current device's user agent string
matches a mobile browser (iPhone, iPad, iPod, Android, etc.)
modified version of src: http://openntf.org/XSnippets.nsf/snippet.xsp?id=read-user-agent
dateTimeLib.dateFormatMobile = (!mobileLib.isMobile()?"MM/dd/yy":"yyyy-MM-dd");
dateTimeLib.timeFormatMobile = (!mobileLib.isMobile()?"hh:mm a z":"hh:mm");
-->
@edm00se
edm00se / calPickerImprover.js
Last active August 29, 2015 13:57
Dojo implementation of the "improved user interaction with XPages date picker" script (jQuery) by Marky Roden (src: http://xomino.com/2012/03/14/improving-user-interaction-with-xpages-date-picker/). This uses pure Dojo (which can prevent the need to load another library, if you're already using Dojo). This is used and tested with Dojo v. 1.6.1. …
/*
* Dojo version of the improved behavior of the XPages calendar picker.
* Adapted from the jQuery version, originally by Marky Roden.
* credit: http://xomino.com/2012/03/14/improving-user-interaction-with-xpages-date-picker/
* Adapted by Eric McCormick, @edm00se, http://about.me/EricMcCormick
*/
dojo.addOnLoad(function(){
//id has _Container and is class of xspInputFieldDateTimePicker
var myAr = dojo.query("[id$=_Container].xspInputFieldDateTimePicker");
//iterate over each element to apply affect