Skip to content

Instantly share code, notes, and snippets.

@lukewagner
lukewagner / ArrayBuffer.transfer
Created November 13, 2014 23:38
ArrayBuffer.transfer strawman
Proposal
--------
The proposal is to add a static ArrayBuffer.transfer(oldBuffer [, newByteLength]). This
method returns a new ArrayBuffer whose contents are taken from oldBuffer.[[ArrayBufferData]]
and then either truncated or zero-extended to be newByteLength. This operation leaves
oldBuffer in a detached state. If newByteLength is undefined, oldBuffer.byteLength is
used.
var buf1 = new ArrayBuffer(40);
var x11 = require('x11');
var PNG = require('png-js');
var bl = require('bl');
require('child_process').exec('locate png | grep 48').stdout.pipe(bl(function(err, files) {
var pngNames = files.toString().split('\n');
var pngIndex = 0;
x11.createClient(function(err, display) {
@kewisch
kewisch / TracedRequest.js
Created October 2, 2014 14:20
Monitor all http(s) network requests using the Mozilla Platform
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var allRequests = [];
/**
* Add the following function as a request observer:
* Services.obs.addObserver(httpObserver, "http-on-examine-response", false);
*

Alright then, lets start with copy array a into b, by reusing and modifying memset.

function memcpy(dst, src, size) {
  for (var i = 0; i < size; ++i) {
    dst[i] = src[i];
  }
} 

Now, thats nice, but does not actually make sure that the arrays have the same CType, better add a check for that.

@joyrexus
joyrexus / README.md
Created March 28, 2014 16:59
Nested grouping of arrays

nest.js

A multi-level groupBy for arrays inspired by D3's nest operator.

Nesting allows elements in an array to be grouped into a hierarchical tree structure; think of it like the GROUP BY operator in SQL, except you can have multiple levels of grouping, and the resulting output is a tree rather than a flat table. The levels in the tree are specified by key functions.

See this fiddle for live demo.

@gitaarik
gitaarik / git_submodules.md
Last active March 25, 2024 12:47
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@piroor
piroor / crash-with-crashreport.js
Last active December 31, 2015 14:49
Crash firefox by js-ctypes (run in the scratch pad or the browser console)
(function(){
Components.utils.import('resource://gre/modules/ctypes.jsm');
var library = ctypes.open(ctypes.libraryName('nss3'));
var PR_Free = library.declare(
'PR_Free',
ctypes.default_abi,
ctypes.void_t,
ctypes.voidptr_t
);
var ptr = new ctypes.voidptr_t(0123);
@antichris
antichris / about.md
Created October 21, 2013 14:55
Fork your own Gist

Fork your own Gist

This is a bookmarklet that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well).


@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;