Skip to content

Instantly share code, notes, and snippets.

@rdhyee
rdhyee / fargo_io_op_visitSubs_starter.js
Created January 3, 2014 20:09
An example invocation of op.visitSubs in Fargo Scripting (http://docs.fargo.io/fargoScripting) to run in the JavaScript console in context of a Fargo.io outline to understand how op.visitSubs works.
op.visitSubs ( //get bodytext
function (headline, levelnum) { // lineCallback
console.log("lineCB -> headline, levelnum: " + headline.getLineText () + ", " + levelnum);
},
function (levelnum) { // indentCallback
console.log("indentCB -> levelnum: " + levelnum);
},
function (levelnum) { // outdentCallback
console.log("outdentCB -> levelnum: " + levelnum);
}
@rdhyee
rdhyee / print_numbered_outline.js
Created January 4, 2014 03:41
I use this script to print out the textual content of a fargo.io subtree to the JavaScript Console, numbering each subitem. Example output: 1. A 1.1 A1 1.2 A2 2. B 3. C See http://outliner.smallpicture.com/fargoVerbs.js for more background.
(function(){
var t = Array();
t.push(0);
op.visitSubs (
function (headline, levelnum) {
t[t.length-1] += 1;
console.log(t.join(".") + ". " + headline.getLineText ());
},
function (levelnum) {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[[1, "China", 1385566537], [2, "India", 1252139596], [3, "United States", 320050716], [4, "Indonesia", 249865631], [5, "Brazil", 200361925], [6, "Pakistan", 182142594], [7, "Nigeria", 173615345], [8, "Bangladesh", 156594962], [9, "Russia", 142833689], [10, "Japan", 127143577], [11, "Mexico", 122332399], [12, "Philippines", 98393574], [13, "Ethiopia", 94100756], [14, "Vietnam", 91679733], [15, "Germany", 82726626], [16, "Egypt", 82056378], [17, "Iran", 77447168], [18, "Turkey", 74932641], [19, "Congo, Democratic Republic of the", 67513677], [20, "Thailand", 67010502], [21, "France", 64291280], [22, "United Kingdom", 63136265], [23, "Italy", 60990277], [24, "Myanmar", 53259018], [25, "South Africa", 52776130], [26, "Korea, South", 49262698], [27, "Tanzania", 49253126], [28, "Colombia", 48321405], [29, "Spain", 46926963], [30, "Ukraine", 45238805], [31, "Kenya", 44353691], [32, "Argentina", 41446246], [33, "Algeria", 39208194], [34, "Poland", 38216635], [35, "Sudan", 37964306], [36, "Uganda", 37578876], [37, "Ca
[[1, "China", 1349585838], [2, "India", 1220800359], [3, "European Union", 509365627], [4, "United States", 316438601], [5, "Indonesia", 251160124], [6, "Brazil", 201009622], [7, "Pakistan", 193238868], [8, "Nigeria", 174507539], [9, "Bangladesh", 163654860], [10, "Russia", 142500482], [11, "Japan", 127253075], [12, "Mexico", 118818228], [13, "Philippines", 105720644], [14, "Ethiopia", 93877025], [15, "Vietnam", 92477857], [16, "Egypt", 85294388], [17, "Germany", 81147265], [18, "Turkey", 80694485], [19, "Iran", 79853900], [20, "Congo, Democratic Republic of the", 75507308], [21, "Thailand", 67497151], [22, "France", 65951611], [23, "United Kingdom", 63395574], [24, "Italy", 61482297], [25, "Burma", 55167330], [26, "Korea, South", 48955203], [27, "South Africa", 48601098], [28, "Tanzania", 48261942], [29, "Spain", 47370542], [30, "Colombia", 45745783], [31, "Ukraine", 44573205], [32, "Kenya", 44037656], [33, "Argentina", 42610981], [34, "Poland", 38383809], [35, "Algeria", 38087812], [36, "Sudan", 34847910],
@rdhyee
rdhyee / vincent_examples.ipynb
Created January 27, 2014 20:14
IPython notebook to illustrate error I'm getting in trying to use vincent 0.4.3 + IPython 1.1 to display a map
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rdhyee
rdhyee / dimple_test.ipynb
Created March 12, 2014 04:45
Attempt to embed dimplejs into the IPython Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rdhyee
rdhyee / MutationObserver.js
Created March 12, 2014 14:33
code bit to observe changes in DOM. Based on http://stackoverflow.com/a/18970264
var whatToObserve = {childList: true, attributes: true, subtree: true, attributeOldValue: true, attributeFilter: ['class', 'style']};
var mutationObserver = new MutationObserver(function(mutationRecords) {
$.each(mutationRecords, function(index, mutationRecord) {
if (mutationRecord.type === 'childList') {
if (mutationRecord.addedNodes.length > 0) {
//DOM node added, do something
console.log("DOM node added");
}
else if (mutationRecord.removedNodes.length > 0) {
//DOM node removed, do something
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.