Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Noitidart / _ff-addon-snippet-xhrPromise.js
Last active September 18, 2016 01:58
_ff-addon-snippet-xhrPromise - A function that does XHR wrapped up in a promise. MAINTHREAD USE ONLY. Cannot use from Workers.
// rev10 - https://gist.github.com/Noitidart/30e44f6d88423bf5096e
function xhrPromise(aUrlOrFileUri, aOptions={}) {
// does an async request
// aUrlOrFileUri is either a string of a FileURI such as `OS.Path.toFileURI(OS.Path.join(OS.Constants.Path.desktopDir, 'test.png'));` or a URL such as `http://github.com/wet-boew/wet-boew/archive/master.zip`
// :note: When using XMLHttpRequest to access a file:// URL the request.status is not properly set to 200 to indicate success. In such cases, request.readyState == 4, request.status == 0 and request.response will evaluate to true.
// Returns a promise
// resolves with xhr object
// rejects with object holding property "xhr" which holds the xhr object
var aOptionsDefaults = {
/**
* @constructs Printer
*/
function Printer(){};
Printer.prototype = {};
/**
* Returns if printer is local or network
* @returns {boolean}
*/
Printer.prototype.isLocal = function(){return true;};
@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@Happy-Ferret
Happy-Ferret / lib.hs
Last active November 8, 2016 16:17
Mixed assembly (C/Haskell)
{-# LANGUAGE ForeignFunctionInterface #-}
module Test where
import Foreign.C.Types
hsfun :: CInt -> IO CInt
hsfun x = do
putStrLn "Hello from haskell"
return (42 * x)
hsfoo :: CInt -> IO CInt
@carlin-q-scott
carlin-q-scott / keycodeCaptor.js
Last active June 28, 2016 06:47
Detect Media Key events on MacOSX
/*jshint moz: true, undef: true, unused: true */
/*global ctypes, require, console, exports */
let { Cu } = require('chrome');
let { setTimeout } = require('sdk/timers');
Cu.import('resource://gre/modules/ctypes.jsm');
var objc = ctypes.open(ctypes.libraryName('objc'));
var is64bit = ctypes.voidptr_t.size == 4 ? false : true;
@tylerlong
tylerlong / AXWindow.swift
Last active August 13, 2019 09:36
Make window frontmost (BUT not floating. I don't know how to make windows floating)
import Cocoa
class AXWindow {
let app: AXUIElement
let window: AXUIElement
init(app: AXUIElement, window: AXUIElement) {
self.app = app
self.window = window
@Noitidart
Noitidart / bugzilla-search.md
Last active October 20, 2016 17:58
how to search on bugzilla

Note: Bugzilla has a [somewhat esoteric][bugzilla-searchhelp] search syntax. To look for all open and closed WebExtension bugs that mentioned the history API, [try searching][bugzilla-searchhistory] for ALL Component:WebExtensions #history, which should turn up [Bug 1208334][]: "Implement history API for open extension API."

@brenopolanski
brenopolanski / npm-list-globally.md
Created November 1, 2016 19:34
Listing globally installed NPM packages and version
npm list -g --depth=0
@ssokolow
ssokolow / firefox_migration.rst
Last active February 26, 2024 04:35
Disaster Plans for Firefox XUL Sunset

Disaster Plans for Firefox XUL Sunset

Public URL

Github Gist

Status

Incomplete

Last Updated

2018-08-23 04:10 EDT

Threat Summary

@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 16, 2024 14:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {