how to open download window using vimperator in firefox - firefox

How to open download window using vimperator in firefox. Is there any key map to view current downloads?

you can use the command :downloads

There is a command :downloads, but it is not working right now. This bug will be fixed in the next version of Vimperator (current version is 3.8.1).
In the meantime you can add the following to your .vimperatorrc (which, basically, does exactly the same as the patch applied to the official Vimperator tree)):
js <<EOF
commands._exCommands = commands._exCommands.filter(function (cmd) !cmd.hasName("downloads"));
commands.add(["downl[oads]", "dl"],
"Show progress of current downloads (fixed)",
function () {
liberator.open("chrome://browser/content/downloads/contentAreaDownloadsView.xul",
{ from: "downloads"});
},
{ argCount: "0" },
true);
EOF
(don't forget to restart Firefox or source ~/.vimperatorrc)

Related

How to run `go fmt` on save, in Visual Studio Code?

How to make Visual Studio Code (or Go Programming Language Extension) to run go fmt (or other tools/commands) on save? Even auto save?
Update:
It is working now perfectly inside VSCode, at this time; just need to add some config files inside .vscode directory (I use these).
Update 2019:
This question is old. The VSCode Go extension has all you need to develop in Go, now.
Last Update 2019
BTW It worth mentioning that right above the package declaration inside your test files appears a run package tests. If you click it, you can see your code coverage of your code. The covered and not-covered parts are highlighted in different colors.
Update 2020
And now, the Go Extension for VSCode, is under the supervision of Go Team! 🎉
Now, the feature has been implemented, you can enable format on save:
Open Settings (Ctrl + ,)
Search for editor.formatOnSave and set it to true
Your Go code will be formatted automatically on Ctrl + s
Its not possible at the moment but its being worked on https://github.com/Microsoft/vscode-go/issues/14
I'm not familiar with 'go fmt' specifically, but you can create a simple vscode extension to handle on save event and execute any arbitrary command passing the file path as an argument.
Here's a sample that just calls echo $filepath:
import * as vscode from 'vscode';
import {exec} from 'child_process';
export function activate(context: vscode.ExtensionContext) {
vscode.window.showInformationMessage('Run command on save enabled.');
var cmd = vscode.commands.registerCommand('extension.executeOnSave', () => {
var onSave = vscode.workspace.onDidSaveTextDocument((e: vscode.TextDocument) => {
// execute some child process on save
var child = exec('echo ' + e.fileName);
child.stdout.on('data', (data) => {
vscode.window.showInformationMessage(data);
});
});
context.subscriptions.push(onSave);
});
context.subscriptions.push(cmd);
}
And the package file:
{
"name": "Custom onSave",
"description": "Execute commands on save.",
"version": "0.0.1",
"publisher": "Emeraldwalk",
"engines": {
"vscode": "^0.10.1"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.executeOnSave"
],
"main": "./out/src/extension",
"contributes": {
"commands": [{
"command": "extension.executeOnSave",
"title": "Execute on Save"
}]
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
},
"devDependencies": {
"typescript": "^1.6.2",
"vscode": "0.10.x"
}
}
The extension is enabled via cmd+shift+p then typing "Execute on Save", but it could be reconfigured to start via another command including "*" which would cause it to load any time VSCode loads.
Once the extension is enabled, the event handler will fire whenever a file is saved (NOTE: this doesn't appear to work when file is first created or on Save as...)
This is just a minor modification of a yo code scaffolded extension as outlined here: https://code.visualstudio.com/docs/extensions/example-hello-world
Update
Here's a Visual Studio Code extension I wrote for running commands on file save. https://marketplace.visualstudio.com/items/emeraldwalk.RunOnSave.
I was using CTRL+S for saving the file manually (this is habitual for me). However, I had a different binding in VS Code that would start with CTRL+S (e.g. swagger extension has a chord where pressing CTRL+S CTRL+W would generate the swagger annotation). This resulted in VS Code waiting for me to press the second chord (CTRL+W) and as such it ignored the save part altogether. I reconfigured all the keybinding chords which had CTRL+S as the first chord to a different combination. After this, pressing CTRL+S formatted my file with gofmt properly.

Cannot open File protocol links in Resource protocol page in Firefox 41

I've made a local file (log.html) in Firefox profile and tried to open it in an add-on page (add-on folder/data/log.html and it's shown as Resource protocol in URL bar).
self.port && self.port.on('add-log-path', function(payLoad) {
addLogPath(payLoad);
});
function addLogPath(url) {
// url == "file:///Users/usr/Library/Application Support/Firefox/Profiles/05rhodfg.cfxo/log.html"
$('#logpath').attr('href', url);
}
I've also tried changing that to JS method window.open
function addLogPath(url) {
$('#logpath').on("click", function() {
window.open(url);
});
}
But the error is
JavaScript error: , line 0: Error: Access to
'file:///Users/usr/Library/Application%20Support/Firefox/Profiles/05rhodfg.cfxo/log.html'
from script denied
BTW, before Firefox version 41, it has no problem doing this.
Can you suggest other workaround to solve this? Thank you!
edit:
added add-on example to reproduce the problem
download and run the following statement in Terminal:
$ cd fileProtocolExample && cfx run
Do self.data.url('filename_here') to get that path to your file.
It will look something like resource://your-extension-id/data/filename_here, then this should load fine. That resource:// in front is important, make sure you get and use that URL.
The file:// won't work, because your addon is packed in a zip. Its not extracted into the system. How did it work in Firefox 41? Was your addon unpacked at that time? This is an Addon-SDK addon right?

PHPUnit + Selenium: How to set Firefox about:config options?

When running Selenium tests remotely with PHPUnit and Firefox, onChange events are not fired as they are when a user is operating the browser.
The solution to this seems to be to set the focusmanager.testmode option to true in Firefox's preferences (i.e. about:config), as suggested in a Selenium bug report.
However all the examples are using Selenium directly, while I am using PHPUnit which has its own API hiding the Selenium internals. I can't figure out how to set this Firefox option using PHPUnit, so I'm hoping someone else can tell me how this can be done!
(No, I can't go into about:config and set it myself manually because the tests create a new clean browser profile each time the tests are run, so any manual config changes are lost.)
Thanks to the Selenium developers I have a solution!
Short version
Put this in your test so that it gets called in the setUp() function:
// Firefox mini-profile that sets focusmanager.testmode=true in about:config
define('FIREFOX_PROFILE',
'UEsDBAoAAAAAADqAxkSBK46tKgAAACoAAAAIABwAcHJlZnMuanNVVAkAA1BZkVM6WZFTdXgLAAEE
6AMAAARkAAAAdXNlcl9wcmVmKCJmb2N1c21hbmFnZXIudGVzdG1vZGUiLCB0cnVlKTsKUEsBAh4D
CgAAAAAAOoDGRIErjq0qAAAAKgAAAAgAGAAAAAAAAQAAAKSBAAAAAHByZWZzLmpzVVQFAANQWZFT
dXgLAAEE6AMAAARkAAAAUEsFBgAAAAABAAEATgAAAGwAAAAAAA==');
protected function setUp()
{
$this->setDesiredCapabilities(Array('firefox_profile' => FIREFOX_PROFILE));
}
This sets focusmanager.testmode to true.
Long version
You need to create your own mini Firefox profile with the preferences you want set, and pass it along at the start of your tests. Here's how to do it:
Create a new folder and put the files you want in the Firefox profile in there. This can be anything (bookmarks, extensions, a copy of your own profile, etc.) but all we need here is a file called prefs.js which stores our about:config settings.
Create prefs.js in this folder with the following content:
user_pref("focusmanager.testmode", true);
Zip up the folder (prefs.js should be in the root of the archive), and base64 encode it.
If you're using Linux, you can do it all like this:
mkdir firefox-profile
cd firefox-profile
echo 'user_pref("focusmanager.testmode", true);' >> prefs.js
zip -r ../firefox-profile.zip *
base64 < ../firefox-profile.zip
Then take the base64 value and set it as the "firefox_profile" capability as per the short version above.

Xcode command line tool - how to run in terminal?

When you create a Command Line Tool project in Xcode you get this, in main.m:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
#autoreleasepool {
// insert code here...
NSLog(#"Hello, World!");
}
return 0;
}
I can run this from Xcode. But I want to compile it so that I can run it from Terminal. What are the steps?
Assuming your executable is named "my_program", and it's in the "/foo/bar/Debug" directory:
cd /foo/bar
./my_program
If you aren't sure how to find the program file itself, you can right-click it (i.e.: the "product") and "Show in Finder" as shown in this screenshot:
You can have the terminal launch everytime you run the application through editing the scheme. I believe this became available from Xcode 8.0.
Access Edit Scheme
Switch Console from Use Xcode to Use Terminal
In Xcode 9 you can try the following (works for me in June 2018):
instead of 'edit scheme' click 'new scheme', give it a name and save
now choose that new scheme you've just created and click 'edit
scheme'
go to the 'Info' tab and in a menu 'Executable' choose
'Other...'
in file window go to search input field and type
'terminal' and click on its icon when you find it. Now you should see 'Terminal.app' in 'Executable' field
go to the 'Arguments' tab, click on + and copy and paste this line there: ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}
click 'close' and run your program with your new scheme selected
Normally Xcode will open terminal for you. If not, you may also turn off any debug related fields in the 'Info' tab. Hope this helps!
Full tutorial here:
https://www.raywenderlich.com/163134/command-line-programs-macos-tutorial-2

Using venkman in my xul application

I've tried to follow these steps to get venkman in my xul application:
Get Venkman from addons.mozilla.org To download the package, right-click the install link and save the package locally. (got the newest version).
Create a directory /distribution/bundles/venkman. Unzip the package into that directory.
Add <script src="chrome://venkman/content/venkman-overlay.js" /> to one of your XUL windows.
Add UI to open Venkman to your window (it could be a menu item or a toolbar button). Make it call start_venkman() when activated.
Not sure where to create the distribution directory, I've tried in the same directory as my application.ini in chrome and in chrome/content but when I try to include the script as in step 3 I get:
No chrome package registered for chrome://venkman/content/venkman-overlay.js
And step 4 gives me:
Error: ReferenceError: start_venkman is not defined
I start my application using the following command:
firefox.exe --app application.ini -jsconsole
Changed the BuildID in my application.ini a couple of times but that didn't change anything.
Created the directory: C:\Program Files (x86)\Mozilla Firefox\distribution\bundles and copied the venkman directory in there.
In my xul window I added:
<script src="test.js" />
<button label="Press Me"
oncommand="start_venkman();"/>
The content of test.js is:
function toOpenWindowByType(inType, uri) {
var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
window.open(uri, "_blank", winopts);
}
When I click the button the Venkman window opens.

Resources