Skip to content

Instantly share code, notes, and snippets.

@kswlee
kswlee / gist:3182851
Created July 26, 2012 15:51
jQuery.Callbacks
/*
* Create a callback list using the following parameters:
*
* flags: an optional list of space-separated flags that will change how
* the callback list behaves
*
* By default a callback list will act like an event callback list and can be
* "fired" multiple times.
*
* Possible flags:
@kswlee
kswlee / gist:3183078
Created July 26, 2012 16:30
Run tests that need a body at doc ready
// Run tests that need a body at doc ready
jQuery(function() {
var container, outer, inner, table, td, offsetSupport,
marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
paddingMarginBorderVisibility, paddingMarginBorder,
body = document.getElementsByTagName("body")[0];
if ( !body ) {
// Return for frameset docs that don't have a body
return;
function cksLongestPlateau(data) {
var length = 1;
for (var i = 1; i < data.length; ++i) {
if (data[i] == data[i - length])
++length;
}
return length;
}
mCodecInputBuffers = mCodec.getInputBuffers();
mCodecOutputBuffers = mCodec.getOutputBuffers();
mCodecInputBuffers = mCodec.getInputBuffers();
mCodecOutputBuffers = mCodec.getOutputBuffers();
MediaSource::ReadOptions options;
int64_t thumbNailTime;
if (trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)) {
options.setSeekTo(thumbNailTime);
} else {
thumbNailTime = -1;
}
public VideoFrameExtractor(Context context, String path, TextureView textureView) {
mVideoPath = path;
mTextureView = textureView;
textureView.setSurfaceTextureListener(this);
textureView.setTranslationX(-1920);
if (textureView.isAvailable()) {
initPlayer(textureView.getSurfaceTexture());
}
$.fn.lineHeight = function() {
if (this.length <= 0) return 0;
var clone = $(this[0]).clone().empty().appendTo($('body')).html('&nbsp;');
var baseheight = clone.height();
clone.html('&nbsp;<br>&nbsp;');
var lineheight = clone.height() - baseheight;
clone.remove();
return lineheight;
var rect = {
leftTop: {x: $this.offset().left + 2, y: $this.offset().top + lineHeight / 2},
bottomRight: {x: $this.offset().left + $this.width() - 2, y: $this.offset().top + limitHeight - lineHeight / 2}
};
var rangeStart = doc.caretRangeFromPoint(rect.leftTop.x, rect.leftTop.y);
var rangeEnd = doc.caretRangeFromPoint(rect.bottomRight.x, rect.bottomRight.y);
var range = doc.createRange();
range.setStart(rangeStart.startContainer, rangeStart.startOffset);
range.setEnd(rangeEnd.startContainer, rangeEnd.startOffset);
@kswlee
kswlee / index.html
Created June 26, 2013 07:41
A CodePen by Kenny Lee.
<br /><br />
<div id="absdiv1">
<br /><span class="bold">DIV #1</span>
<br />position: absolute;
</div>
<div id="flodiv1">
<br /><span class="bold">DIV #2</span>
<br />float: left;