-
Devtools Guide. note: soon to be replaced by MDN docs when they're updated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Running this scratchpad in chrome mode will open a devtools window that's debugging | |
* the devtools window that's debugging the currently selected tab. | |
*/ | |
let {devtools} = Components.utils.import("resource:///modules/devtools/gDevTools.jsm", {}); | |
let tabTarget = devtools.TargetFactory.forTab(gBrowser.selectedTab); | |
let toolbox = gDevTools.getToolbox(tabTarget); | |
let win = toolbox._host.frame.contentWindow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Running this scratchpad in chrome mode will open a devtools window that's debugging | |
* the current browser window | |
*/ | |
let {devtools} = Components.utils.import("resource:///modules/devtools/gDevTools.jsm", {}); | |
let win = Services.wm.getMostRecentWindow("navigator:browser"); | |
let target = devtools.TargetFactory.forWindow(win); | |
let toolbox = gDevTools.showToolbox(target, "styleeditor", "window"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Running the following code in a Scratchpad running in the 'browser' context | |
* will add a `deviceorientation` command to the Firefox command line. | |
*/ | |
Components.utils.import("resource:///modules/devtools/gcli.jsm"); | |
gcli.addCommand({ | |
name: 'deviceorientation', | |
description: 'Fire a deviceorientation event', | |
params: [{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Run this in a Firefox "Scratchpad" (Tools > Web Developer > Scratchpad) | |
* With Cmd-R to simulate an orientation event in the current page | |
*/ | |
function simulateOrientation(alpha, beta, gamma) { | |
var event = document.createEvent("DeviceOrientationEvent"); | |
event.initDeviceOrientationEvent('deviceorientation', | |
true, true, alpha, beta, gamma, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This node.js script checks the Olympics website for any new Women's | |
* Gymnastics tickets. Every five minutes it fetches the available tickets | |
* page for the event, and uses the cheerio (https://npmjs.org/package/cheerio) | |
* module to parse the page and look for the UI element that indicates there | |
* are tickets. | |
* | |
* If there are any tickets it plays a song using node's built in `exec()` | |
* function to call OS X's command line utility to play a sound file. It also | |
* uses the growl module (https://npmjs.org/package/growl) to post a growl | |
* notification. |
Repos from the first Hack And Tell - Silicon Valley 2011-05-23
- Scottbot - TWSS IRC bot
- Brain - JS Machine Learning
- Emscripten - LLVM->JavaScript
- Dom3d - 3D in CSS
- Spritificator - HTML5 Sprite Creator
- Beamjs - V8<->Erlang
Go to Sublime Text 2 > Preferences > Key Bindings - User
and add this JSON to the file:
[
{ "keys": ["super+shift+o"],
"command": "insert_snippet",
"args": {
"contents": "dump(${1:} + \"\\n\");${0}"
},
"description": "insert a dump() call at the cursor, tab once to jump past"
harthur/brain - neural networks karpathy/covnetjs - convolutional neural networks naturalnode/natural - bayesian classifier - NLP peterbraden/node-opencv - computer vision karpathy/svmjs - support vector machines karpathy/forestjs - random forests harthur/clusterfck - clustering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRenderedFontFamily(fontFamily) { | |
var canvas = document.createElement("canvas"); | |
var context = canvas.getContext("2d"); | |
let families = fontFamily.split(/\s*,\s*/); | |
for each (let family in families) { | |
if (family == 'inherit') { | |
return family; | |
} |