Skip to content

Instantly share code, notes, and snippets.

Avatar

Thodoris Tsiridis 72lions

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am 72lions on github.
  • I am 72lions (https://keybase.io/72lions) on keybase.
  • I have a public key whose fingerprint is DFDF 68CA 58D4 3CEA 1DEF 8797 94D4 DF3C AB45 E082

To claim this, I am signing this object:

@72lions
72lions / replace.audiobuffer.from.audiosource.js
Created Jan 14, 2013
Replaces the AudioBuffer of an AudioSource
View replace.audiobuffer.from.audiosource.js
// Adding a bit of scheduling so that we won't have single digit milisecond overlaps.
// Thanks to Chris Wilson for his suggestion.
var scheduledTime = 0.015;
try {
_audioSource.stop(scheduledTime);
} catch (e) {}
_audioSource = _context.createBufferSource();
_audioSource.buffer = _audioBuffer;
@72lions
72lions / concat.array.buffers.js
Created Jan 14, 2013
Concatenates two ArrayBuffers
View concat.array.buffers.js
/**
* Creates a new Uint8Array based on two different ArrayBuffers
*
* @private
* @param {ArrayBuffers} buffer1 The first buffer.
* @param {ArrayBuffers} buffer2 The second buffer.
* @return {ArrayBuffers} The new ArrayBuffer created out of the two.
*/
var _appendBuffer = function(buffer1, buffer2) {
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
@72lions
72lions / create.audio.buffer.from.array.buffer.js
Created Jan 14, 2013
Creates an AudioBuffer from and ArrayBuffer
View create.audio.buffer.from.array.buffer.js
/**
* Is triggered when a chunk is loaded
*/
var _onChunkLoaded = function() {
// Concat two ArrayBuffers into a new one
_activeBuffer = _appendBuffer(_activeBuffer, _request.response);
// Use decodeAudioData for creating an AudioBuffer,
// so that we don't block the main thread.
@72lions
72lions / loading.binary.data.xmlhttprequest.js
Created Jan 14, 2013
Loading a binary data with the HXMLHttpRequest object
View loading.binary.data.xmlhttprequest.js
/**
* It is responsible for loading all the different chunks
*
* @private
* @type {XMLHttpRequest}
*/
var _request = new XMLHttpRequest();
// Set the responseType to arraybuffer
_request.responseType = 'arraybuffer';
@72lions
72lions / frameworkjs.retrieve.get.an.already.instantiated.model.js
Created Feb 29, 2012
FrameworkJS.retrieve - Get an already instantiated model
View frameworkjs.retrieve.get.an.already.instantiated.model.js
var alreadyInstantiatedGridModel = FrameworkJS.retrieve(
'gridModel',
'models.Grid');
@72lions
72lions / frameworkjs.retrieve.instantiate.a.model.js
Created Feb 29, 2012
FrameworkJS.retrieve - Instantiate a model
View frameworkjs.retrieve.instantiate.a.model.js
var instanceOfGridModel = FrameworkJS.retrieve(
'gridModel',
'models.Grid');
@72lions
72lions / Frameworkjs.extend.extending.a.model.js
Created Feb 29, 2012
FrameworkJS.extend - Extending a model
View Frameworkjs.extend.extending.a.model.js
FrameworkJS.extend(function() {
// Overwritting the properties
this.name = 'GridModel';
// Initial data
this._data = {title: "MyTitle", prop1: 'Property 1'};
}, FrameworkJS.Model, 'models.Grid');
@72lions
72lions / frameworkjs.retrieve.get.an.instance.of.a.view.js
Created Feb 29, 2012
FrameworkJS.retrieve - Get an instance of a view
View frameworkjs.retrieve.get.an.instance.of.a.view.js
var gridView = FrameworkJS.retrieve(
'SomeId',
'views.Grid');
@72lions
72lions / frameworkjs.retrieve.get.an.already.instantiated.view.js
Created Feb 29, 2012
FrameworkJS.retrieve - Retrieve an already instantiated view
View frameworkjs.retrieve.get.an.already.instantiated.view.js
var alreadyInstantiatedGridView = FrameworkJS.retrieve(
'SomeId',
'views.Grid');