Skip to content

Instantly share code, notes, and snippets.

View kishalmi's full-sized avatar
🤘
ready to rock

LMG kishalmi

🤘
ready to rock
View GitHub Profile
@kishalmi
kishalmi / main.js
Last active August 29, 2015 13:55
spawn a webworker without the need for a seperate file, including requirejs functionality
/*
assuming a rather standard requirejs script tag referring to main(.js)
<script type="text/javascript" data-main="main" src="js/require.min.js"></script>
*/
var w = newRequireWorker({
shim: { three: { exports: 'THREE' } },
baseUrl: 'js',
paths: { three: 'three.min' }
},
@kishalmi
kishalmi / gist:665fe7a8953a5b91cc3a
Created April 30, 2014 14:59
reverse (copy of) webaudio buffer
request.onload = function () {
context.decodeAudioData(request.response, function (buf) {
// store as forward buffer
buffer = buf;
// create a reversed copy
bufferReversed = context.createBuffer(buf.numberOfChannels, buf.length, buf.sampleRate);
for (var i = 0; i < buf.numberOfChannels; i++)
bufferReversed.getChannelData(i).set(
Array.prototype.reverse.call(new Float32Array(buf.getChannelData(i)))
);
@kishalmi
kishalmi / gist:db5060b30de5fa9cbae0
Created May 21, 2014 14:19
trapping TAB key in ember component input-helper
<script type="text/x-handlebars" id="components/chat-input">
{{input id="tiChatInput" action="chatInputEnter"}}
</script>
MyApp.ChatInputComponent = Ember.Component.extend({
didInsertElement: function () {
var self = this,
ctx = this.$('input').keydown(function (event) {
if (event.which === 9) {
// [TAB]