Skip to content

Instantly share code, notes, and snippets.

@djkskqyr3
djkskqyr3 / mediastream-I420A-to-I420-converter.js
Created November 23, 2021 02:10 — forked from saravanannkl/mediastream-I420A-to-I420-converter.js
Media stream video frame I420A to I420 converter
// Based on https://web.dev/mediastreamtrack-insertable-media-processing/
// Uses Webcodecs API, which is supported only in Chrome as of November 2021
function convertI420AFrameToI420Frame(frame) {
const { width, height } = frame.codedRect;
// Y, U, V, Alpha values are stored sequentially. Take only YUV values
const buffer = new Uint8Array(width * height * 3);
frame.copyTo(buffer, { rect: frame.codedRect });
const init = {
timestamp: 0,
@preziotte
preziotte / index.html
Last active August 29, 2015 14:04
Five Rotating Icosahedrons
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background-color: #36393B;
}
svg {
position: absolute;
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@mikeal
mikeal / gist:6084298
Last active December 20, 2015 06:18
Been rather busy....

Because I've been so busy lately I haven't really had a chance to talk about anything I've built or been using, but i've been publishing so many new modules it's worth going back over.

Real quick, Getable is a mobile/desktop ordering and fullfillment application for commercial construction. Think mobile amazon/ebay for large construction jobsites.

First off, everything is realtime, using engine.io with everything but long polling turned off. We tried leaving websockets on but there were some nasty bits that made the connection die and not come back on iPhone which we just couldn't debug in time so we turned it off.

Engine.io is a great module as it just provides a simple duplex stream-like (more on this later) interface that upgrades itself when available. This meant that in order to get some use out of it I had to write a few modules.

eiojson sends JSON messages rather than strings bidirectiona

@sindresorhus
sindresorhus / ios-clear-btn.css
Created January 22, 2013 13:54
Recreation of the native iOS textfield clear button in a data uri. *Should be identical, but is not the original*
.clear-btn {
width: 19px;
height: 19px;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAMAAACf4xmcAAAAMFBMVEWysrKysrKysrKysrKysrKysrKysrKysrKysrKysrL////39/fh4eG9vb23t7eysrKQDTJbAAAACnRSTlMBKlNxqbO70e7739UFWQAAAMFJREFUeNqNlMsOxSAIREs1AbVe/v9v78JMSn0kMytJTzqIwPWRpKxWimlOcp2U1IM07SHzSbaCor6RTta3+VZ2f6jiB5WboSIncNzKkB+yP0gHlRD/cJjCURdYPrX1F+qtPrCNP+u1Dg5UrYhSzKyBA9VCdhJtwOEICTzjx0jBNfvCLZRnpBa5SCE584WLFEpSfMOBggqJkabkFciCkOUlH4t7erKRuLYkm5wbGXIAuXHmlgO3asjFxa9BfqmSK/oPfl489V95hyMAAAAASUVORK5CYII=');
background-size: 100%;
cursor: pointer;
}
@justinperkins
justinperkins / jquery-auth-token.js
Created October 26, 2012 17:48
Put auth-token on all jQuery Ajax Requests
$(function(){
var tokenValue = $("meta[name='csrf-token']").attr('content');
$.ajaxSetup({
headers: {'X-CSRF-Token': tokenValue}
});
})