Skip to content

Instantly share code, notes, and snippets.

@broken-e
broken-e / SPDistinctFieldValues.js
Created February 1, 2018 23:54
Retrieves a set of distinct values for the given field
var siteUrl = '<your site url>';
var listTitle = '<your list title>';
var fieldName = '<field internal name>';
var groupLimit = 30; // max unique fields returned
var ctx = new SP.ClientContext(siteUrl);
var list = ctx.get_web().get_lists().getByTitle(listTitle);
var camlString = '<View><Query>'
+ '<GroupBy Collapse="TRUE" GroupLimit="' + groupLimit + '">'
@broken-e
broken-e / SPListViewFieldsByJSOM.js
Created January 26, 2018 00:14
SharePoint List Fields By View Using JSOM
var siteUrl = '<your site url>';
var listTitle = '<your list title>';
var viewTitle = '<your view title>';
var clientContext = new SP.ClientContext(siteUrl);
var list = clientContext.get_web().get_lists().getByTitle(listTitle);
var view = list.get_views().getByTitle(viewTitle);
var viewFields = view.get_viewFields();
clientContext.load(viewFields);
@broken-e
broken-e / appear-chars.js
Last active October 9, 2015 21:42
Make text appear one character at a time.
/** make text appear in the innerHTML of the element, one character at a time per timeBetween */
function appearChars(str, elem, timeBetween) {
var index = -1;
(function go() {
if (++index < str.length) {
p.innerHTML = p.innerHTML + str.charAt(index);
setTimeout(go, timeBetween);
}
})();
}
@broken-e
broken-e / AppController.php
Last active August 29, 2015 14:10
debug your cakephp routing
<?php
// AppController.php
/** store a history of every route you hit, including every redirect */
public function beforeFilter() {
$routes = CakeSession::read('routes');
$routes[] = $this->request->here;
if (count($routes) > 5) { // limit history to 5
array_shift($routes);
}
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.utils.Array;
/** class for showing a toast message with queueing if one is already showing. Uses two Tables and a Label */