Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Noitidart / _ff-addon-snippet-WINAPI_FocusMostRecentWindowOfPID.js
Last active August 29, 2015 14:07 — forked from Noitidart/_ff-addon-snippet-FocusWindowHwndCTypes.js
_ff-addon-snippet-WINAPI_FocusMostRecentWindowOfPID - Windows. WinAPI. js-ctypes. Give pid and the most recent window will be focused. Even if it's minimized.
Cu.import('resource://gre/modules/ctypes.jsm');
var lib = {
user32: ctypes.open('user32.dll')
}
var NULL = ctypes.cast(ctypes.uint64_t(0x0), ctypes.voidptr_t);
/* http://msdn.microsoft.com/en-us/library/ms633514%28VS.85%29.aspx
* HWND WINAPI GetTopWindow(
* __in_opt_ HWND hWnd
@Noitidart
Noitidart / lock.c
Last active August 29, 2015 14:06 — forked from anonymous/gist:0ab40694144dfb612335
lock.c - Testing fcntl from c writen by nixeagle
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main() {
int fd;
struct flock lock, savelock;
printf("F_GETLK: %d\n", F_GETLK);
@Noitidart
Noitidart / _ff-addon-snippet-X11_FocusMostRecentWindowOfPid.js
Last active August 29, 2015 14:06 — forked from Noitidart/_ff-addon-snippet-X11_WindowsMatchingPid.js
_ff-addon-snippet-X11_FocusMostRecentWindowOfPid - Focuses the most recent window given a process id. (js-ctypes) (X11)
Cu.import('resource://gre/modules/ctypes.jsm');
function doit() {
try {
_x11 = ctypes.open('libX11.so.6');
} catch (e) {
try {
var libName = ctypes.libraryName('X11');
} catch (e) {
@Noitidart
Noitidart / _ff-addon-tutorial-JSCtypesMemmove.js
Last active August 29, 2015 14:03 — forked from nmaier/memmove.md
_ff-addon-tutorial-JSCtypesMemmove - How to use memmove from js-ctypes. Tutorial by @nmaier.
Cu.import('resource://gre/modules/ctypes.jsm');
/*
* Alright then, lets start with copy array `a` into `b`, by reusing and modifying `memset`.
* Note: memset refered to is found here: http://stackoverflow.com/questions/24466228/memset-has-no-dll-so-how-ctype-it
*/
function memcpy(dst, src, size) {
for (var i = 0; i < size; ++i) {
dst[i] = src[i];
}
@Noitidart
Noitidart / _ff-addon-template-BootstrapWatchHostEventListenerInjectFiles.xpi
Last active August 29, 2015 13:57 — forked from Noitidart/_ff-addon-template-BootstrapWatchHostEventListener.xpi
_ff-addon-template-BootstrapWatchHostEventListenerInjectFiles - Uses event listener (DOMContentLoaded) to watch page loads in all tabs and windows with gBrowser once it finds matching host it will inject files that are packaged with the addon.
@Noitidart
Noitidart / _ff-addon-template-BootstrapCustomEventListeners.xpi
Last active August 29, 2015 13:56 — forked from Noitidart/_ff-addon-template-BootstrapWatchHostEventListener.xpi
_ff-addon-template-BootstrapAddEventListenerCustomEvent.xpi - This shows how to listen to and respond to custom events dispatched by web pages.
@Noitidart
Noitidart / _ff-addon-template-BootstrapWatchHostEventListener.xpi
Last active August 29, 2015 13:56 — forked from Noitidart/_template-bootstrapSkeleton.xpi
_ff-addon-template-BootstrapWatchHostEventListener - Uses event listener (DOMContentLoaded) to watch page loads in all tabs and windows with gBrowser. When a page matching a certain host name is found it will inject into it. It also shows you how to attach event listeners to injected elements and elements that were already in the webpage.
@Noitidart
Noitidart / _template-ff-addon-BootstrapURLIconWidget.xpi
Last active December 15, 2017 07:55 — forked from Noitidart/bootstrap.js
_template-ff-addon-BootstrapURLIconWidget - This bootstrap addon shows how to add an icon to the URL bar and when clicked it opens a panel.