Skip to content

Instantly share code, notes, and snippets.

View edm00se's full-sized avatar

Eric McCormick edm00se

View GitHub Profile
@edm00se
edm00se / gistFormatter.css
Created September 19, 2013 16:18
Some quick and dirty formatting for embedded gists, if you don't want them to take full height and 100% width by default. Just add to your CSS file.
.gist, .file-data {
width: 80% !important;
height: 300px !important;
}
@edm00se
edm00se / app.js
Last active December 24, 2015 15:09
NodeJS simple web app/server environment (using express, express's compress and prerender-node packages) set to serve out static content in root directory. For when you need a simple web server without the bloat.
//set up the app
var express = require('express');
var app = express();
//enables express-toobusy, which keeps it from melting under HIGH pressure
//app.use(require('express-toobusy')());
//enables compress and prerender-node
//app.use(express.compress());
//app.use(require('prerender-node'));
@edm00se
edm00se / IEfix-beforeRenderResponse.jss
Last active September 5, 2017 13:11
Place in the beforeRenderResponse event of an XPage to force IE versions <= 9 to use Edge (and disable Compatibility View Mode) and force newer versions than 9 to act like IE 9 (and disable Compatibility View Mode).By my experience, this enforces as much compatibility as possible for XPages with Domino 8.5.3 (my servers are on UP1, not that that…
// forces IE9 and below to not use compatibility mode, and forces any registered as IE >=10 to act like 9
if(context.getUserAgent().isIE()&&context.getUserAgent().getBrowserVersionNumber()<10) {
var exCon = facesContext.getExternalContext();
var response = exCon.getResponse();
response.setHeader("X-UA-Compatible", "IE=Edge");
}else if(context.getUserAgent().isIE()&&context.getUserAgent().getBrowserVersionNumber()>9 || (context.getUserAgent().getUserAgent().indexOf('Trident/7') > -1 && context.getUserAgent().getUserAgent().indexOf('rv:11')){
var exCon = facesContext.getExternalContext();
var response = exCon.getResponse();
response.setHeader("X-UA-Compatible", "IE=9");
}
@edm00se
edm00se / Utils.jss
Last active October 27, 2017 15:37
IBM/Lotus Domino SSJS for returning results as a Vector. Handy when expecting multiple values from a document field, when single (string object) is potentially returned.
/**
* @author Eric McCormick
* src: https://edm00se.io/xpages/consistent-multivalue-formatting/
* @param java.util.Object to examine
* @return java.util.Vector of values from originating Object
**/
var util = {
asVec: function(obj){
switch(typeof obj){
case "java.util.Vector": //it's already a Vector, just return it
@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
@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 / 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 / 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 / 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 / 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: