Skip to content

Instantly share code, notes, and snippets.

View edm00se's full-sized avatar

Eric McCormick edm00se

View GitHub Profile
@edm00se
edm00se / nanorc.sh
Created January 19, 2019 03:12
nano syntax highlighting (macOS)
# install
brew install nano
# configure
echo 'include "/usr/local/Cellar/nano/3.2/share/nano/*.nanorc"' > ~/.nanorc
# restart your shell
@edm00se
edm00se / _darkMinima.scss
Created May 8, 2018 17:20
a Dark Minima "theme" on the cheap
$brand-color: #d07922;
$background-color: #222426; /* a dark, off-black for the bg */
$text-color: #e6e6e6; /* an off-white for the text */
$grey-color-light: #565656; /* for the border-top separators */
$grey-color-dark: #adadad; /* such as the site title in the header, visited */
@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 / 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 / vanillaXhrGet.js
Last active June 15, 2017 19:43
Vanilla JS function to perform a GET XMLHttpRequest against a passed URL and execute the callback function with the returned results. On error, puts an error message to the console and returns null to the callback.
/*
* Note: these days you should probably just use fetch:
* https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
*
* A convenience function, to handle the vanilla js xhr
* request.
*
* @param {string} url - the URI against which to make the request
* @param callback - the callback function, which returns an obj,
* with two params, err (which is null of not error), and
@edm00se
edm00se / About.md
Last active May 31, 2017 03:11
An open letter to CBS & Paramount, regarding the release of their fan film guidelines.

An Open Letter to CBS & Paramount

CBS & Paramount recently released and announced the new guidelines for fan films (productions). That they are fairly limited in scope for those who seek to create as part of their passion is pretty obvious. I seek anyone who is so empassioned to provide the well reasoned and respectful feedback that Star Trek deserves.

In Short

To reach for the stars, we need to reach a little higher.

@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 / ReadMe.md
Last active February 7, 2016 18:26
Sample utility library

Utility Library Example

Adding a utility library is a great and convenient way to provide convenince functions for use at a global or near-global level.

Adding

Hooking a utility SSJS library works about the same as any Code > Script Library asset in XPages. You can add it via a Theme, my personal recommendation as it makes keeping things tidy quite easy, or by adding it as an xp:resource (resources at the root XPage or Custom Control via the pretty pane). The down side of relying on adding it to a Custom Control is that it will only be available in an SSJS code block if the Custom Control in question has been loaded as part of the user's component tree (the built page); this also leads to potential duplication if the developer starts loading it on lots of Custom Controls.

Via Theme

@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 / 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;
}