Skip to content

Instantly share code, notes, and snippets.

@sn-donbenjamin
sn-donbenjamin / README.md
Created August 5, 2020 14:37 — forked from magnetikonline/README.md
Python 2 json.dump() file-like object class for tab indenting of output file.

Python 2 json.dump() file-like object class for tab indenting of output file

Using json.dump() with Python 2, indent argument is limited to number of spaces only - no ability for tabs use.

Class JSONTabIndentFileWriter provides a file-like object which will rewrite json.dump() output indending from spaces to tabs.

@sn-donbenjamin
sn-donbenjamin / web-servers.md
Created April 15, 2020 01:19 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@sn-donbenjamin
sn-donbenjamin / JSUtil2.js
Created March 12, 2020 22:55 — forked from abhididdigi/JSUtil2.js
This is the entire JSUtil2 script. Creating a gist, to show it on Service Now diary.com
/*
* JSUtil already has some utility functions, Some more utility functions.
* Written by [email protected]
* Re-written for Service Now from underscore.js: http://underscorejs.org/
*
*/
var JSUtil2 = Class.create();

GlideRecord & GlideAggregate Cheat Sheet ❗

GlideRecord(String tableName) ❗

var gr = new GlideRecord('incident'); // use the incident table
gr.query(); // fetch data from the database
while (gr.next()) { // advance
    gs.info(gr.short_description);
}
@sn-donbenjamin
sn-donbenjamin / debugging_cheatsheet.md
Created October 22, 2019 17:56 — forked from iamwill/debugging_cheatsheet.md
Debugging on the Glide Platform

Debugging tips and tricks

Platform Troubleshooting

Console output too chatty?
Set com.glide.util.Log.developer_filter = true to cut down on non-interactive console log entries such as scheduled workers. (Don't forget to remove it when you're done!)

Utility urls

Note: Fast! These don't need a database.

ServiceNow UI Developer cheat sheet


Utility URLs

URL Purpose
/stats.do Quick stats
/cache.do Clear your instance cache
@sn-donbenjamin
sn-donbenjamin / JSONtoGlide.js
Created October 16, 2019 14:14 — forked from jmbauguess/JSONtoGlide.js
Converts a GlideRecord object into JSON, or converts JSON into a GlideRecord. See http://sensibleservicenow.com/?p=49
/**
* @description Converts between JSON Objects and GlideRecords
* @namespace
* @type {Class}
*/
var JSONtoGlide = Class.create();
JSONtoGlide.prototype = {
/**
* @description Converts an object into a new GlideRecord
* @param {Object} json A json object
@sn-donbenjamin
sn-donbenjamin / immutable-libraries.md
Created April 19, 2019 18:17 — forked from jlongster/immutable-libraries.md
List of immutable libraries

A lot of people mentioned other immutable JS libraries after reading my post. I thought it would be good to make a list of available ones.

There are two types of immutable libraries: simple helpers for copying JavaScript objects, and actual persistent data structure implementations. My post generally analyzed the tradeoffs between both kinds of libraries and everything applies to the below libraries in either category.

Libraries are sorted by github popularity.

Persistent Data Structures w/structural sharing

@sn-donbenjamin
sn-donbenjamin / removeKeys.js
Created April 19, 2019 16:01 — forked from aurbano/removeKeys.js
Remove a property from a nested object, recursively
/**
* Remove all specified keys from an object, no matter how deep they are.
* The removal is done in place, so run it on a copy if you don't want to modify the original object.
* This function has no limit so circular objects will probably crash the browser
*
* @param obj The object from where you want to remove the keys
* @param keys An array of property names (strings) to remove
*/
function removeKeys(obj, keys){
var index;