Skip to content

Instantly share code, notes, and snippets.

@brettz9
brettz9 / before.js
Created September 28, 2018 13:58 — forked from harto/before.js
Mocha before() & beforeEach() execution order with nested describe()
'use strict';
describe('mocha before hooks', function () {
before(() => console.log('*** top-level before()'));
beforeEach(() => console.log('*** top-level beforeEach()'));
describe('nesting', function () {
before(() => console.log('*** nested before()'));
beforeEach(() => console.log('*** nested beforeEach()'));
it('is a nested spec', () => true);
});
@brettz9
brettz9 / ctags definitions for Javascript
Last active October 26, 2015 23:04 — forked from tim-smart/ctags definitions for Javascript
CTags Definitions for Javascript
--langdef=JavaScript
--langmap=JavaScript:.js
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))[ \t]*([A-Za-z_$][A-Za-z0-9_$.]*)[ \t]*=[ \t]*\{/\5/,object/
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))[ \t]*([A-Za-z_$][A-Za-z0-9_$.]*)[ \t]*=[ \t]*(\[|(new[ \t]+)?Array\()/\5/,array/
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))[ \t]*([A-Za-z_$][A-Za-z0-9_$.]*)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))[ \t]*([A-Za-z_$][A-Za-z0-9_$.]*)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))[ \t]*([A-Za-z_$][A-Za-z0-9_$.]*)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))[ \t]*([A-Za-z_$][A-Za-z0-9_$.]*)[ \t]*=[ \t]*null/\5/,null/
--regex-JavaScript=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]*\.)+))
@brettz9
brettz9 / atom-events
Created October 25, 2015 00:17 — forked from ardcore/atom-events
atom.io events
application:open-your-keymap
application:open-your-stylesheet
autocomplete:attach
autoflow:reflow-paragraph
bookmarks:clear-bookmarks
bookmarks:jump-to-next-bookmark
bookmarks:jump-to-previous-bookmark
bookmarks:toggle-bookmark
bookmarks:view-all
check:correct-misspelling
var me = Services.wm.getMostRecentWindow(null);
Cu.import('resource://gre/modules/osfile.jsm');
var pathProfilesIni = OS.Path.join(OS.Constants.Path.userApplicationDataDir, 'profiles.ini');
me.alert(pathProfilesIni);
//apparently theres for profiles made in default prof dir:
//localDir = C:\Users\ali57233\AppData\Local\Mozilla\Firefox\Profiles\czbm1ps9.rnd1
//rootDir = C:\Users\ali57233\AppData\Roaming\Mozilla\Firefox\Profiles\czbm1ps9.rnd1
//for custom prof dir localDir and rootDir are same
@brettz9
brettz9 / chunkify.js
Created June 5, 2014 21:24 — forked from woollsta/chunkify.js
See https://gist.github.com/brettz9/0cfda9e04751090f4a7a for an example use on a particular Mediawiki installation (not abstracted to an extension, but could easily be so)
/**
* Chunkify
* Google Chrome Speech Synthesis Chunking Pattern
* Fixes inconsistencies with speaking long texts in speechUtterance objects
* Licensed under the MIT License
*
* Peter Woolley and Brett Zamir
*/
var speechUtteranceChunker = function (utt, settings, callback) {
// Based on work by John-David Dalton, Juriy Zaytsev, and Asen Bozhilov.
Object.forEach = (function () {
// Convenience aliases.
var toString = {}.toString, hasOwnProperty = {}.hasOwnProperty ||
// Simulate `Object#hasOwnProperty` in Safari 2.
function (property) {
// Save the original prototype chain.
var original = this.__proto__, result;
// Break the prototype chain.
this.__proto__ = null;
@brettz9
brettz9 / each.js
Created August 28, 2013 15:43 — forked from WebReflection/each.js
var each = function (Array) {"use strict";
/*! all you need to `each(obj, cb [,context])`
* @author WebReflection
* @license WTFPL - http://en.wikipedia.org/wiki/WTFPL
* @gist https://gist.github.com/2294934
*/
var
toString = {}.toString,
hasOwnProperty = {}.hasOwnProperty,
array = toString.call([]),
@brettz9
brettz9 / gist:5790179
Last active December 18, 2015 13:29 — forked from rrobe53/gist:976610
File extensions and content type
/*globals module */
// Adapted from https://gist.github.com/rrobe53/976610
module.exports = (function () {
'use strict';
var extensionTypeMap = {
"3gp": "video/3gpp",
"a": "application/octet-stream",
"ai": "application/postscript",
// Adds one JSONP global (for requireJS module, see JSONP.js)
var JSONP = (function (global) {
// (C) WebReflection Essential - Mit Style
// cleaned up by Brett Zamir for JSLint and avoiding additional globals and need for conventional [?&]callback= in URL)
'use strict';
var id = 0,
ns = 'JSONP',
prefix = '__JSONP__',
document = global.document,
documentElement = document.documentElement;
@brettz9
brettz9 / require.js
Created October 31, 2012 18:45 — forked from erikvold/require.js
Imports a commonjs style javascript file with loadSubScrpt for restartless Firefox add-ons.
/* Imports a commonjs style javascript file with loadSubScrpt
* By Erik Vold <erikvvold@gmail.com> http://erikvold.com/
*
* @param src (String)
* The url of a javascript file.
*/
(function(global) {
var modules = {};
global.require = function require(src) {
if (modules[src]) return modules[src];