Skip to content

Instantly share code, notes, and snippets.

View springuper's full-sized avatar
👻
Happy Hacking

chun shang springuper

👻
Happy Hacking
View GitHub Profile
renderModel(model: IRenderMime.IMimeModel): Promise<void> {
// Retrieve Data Explorer persistent data and metadata
const data = model.data[this._mimeType] as JSONObject;
const metadata = (model.metadata.dataExplorer || {}) as JSONObject;
// Capture Data Explorer metadata changes and save them to notebook file in order to restore
const onMetadataChange = (data: object) => {
model.setData({ metadata: { ...model.metadata, dataExplorer: data } });
const notebookPanel = findNotebookPanel(this);
if (notebookPanel) notebookPanel.context.save();
@springuper
springuper / gist:c3b625e40707d969d43b
Last active September 9, 2015 07:23 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@springuper
springuper / microbinding
Created June 18, 2014 13:06
Micro Two-way Data Binding
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div data-component="input">
YUI.add('spring', function (Y) {
// do sth
}, '1.0.0', {
requires: ['yui', 'node-base']
});
@springuper
springuper / quicksort.js
Created December 1, 2012 13:41
quick sort
function swap(items, firstIndex, secondIndex){
var temp = items[firstIndex];
items[firstIndex] = items[secondIndex];
items[secondIndex] = temp;
}
function partition(items, left, right) {
var index = Math.floor((right + left) / 2),
pivot = items[index],
i = left,
/* Use this to cause a function to fire no more than once every 'ms' milliseconds.
For example, an expensive mousemove handler:
$('body').mouseover(ratelimit(function(ev) {
// ...
}, 250));
*/
function ratelimit(fn, ms) {
var last = (new Date()).getTime();