Skip to content

Instantly share code, notes, and snippets.

@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 / 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-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 / example.cpp
Created April 9, 2016 08:44 — forked from taxilian/example.cpp
partial example of global keyboard event handler
void *EventLoop(void *args)
{
int state;
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &state);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &state);
// In one thread run the event loop to get hotkey presses
EventHotKeyID gMyHotKeyID1, gMyHotKeyID2;
EventTypeSpec eventType;
@Noitidart
Noitidart / _ff-addon-snippet-AccessBootstrapScope.js
Last active August 17, 2016 22:27 — forked from yajd/_ff-addon-snippet-AccessBootstrapScope.js
_ff-addon-snippet-AccessBootstrapScope - example of how to access addon module scope of bootstrapped addon
var getScope = function(aAddonId) { var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm'); return XPIScope.XPIProvider.activeAddons.get(aAddonId).bootstrapScope; }; a = getScope('MouseControl@jetpack');
@Noitidart
Noitidart / AXWindow.swift
Created September 29, 2016 15:41 — forked from tylerlong/AXWindow.swift
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 / ba-issemver.js
Created October 12, 2016 22:07 — forked from cowboy/ba-issemver.js
isSemVer - semantic version comparison for JavaScript
/*!
* isSemVer - v0.1 - 9/05/2010
* http://benalman.com/
* http://semver.org/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
@Noitidart
Noitidart / x11-keylogger.c
Last active December 18, 2016 19:21
XLib keylogger
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <string.h>
#include <unistd.h> // for usleep() only
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
@Noitidart
Noitidart / base-neg-2.js
Created July 4, 2017 00:14 — forked from adamloving/base-neg-2.js
Toptal Codility Problem: Convert to-and-from base -2
'use strict';
function toDecimal(A) {
var sum = 0;
for (var i = 0; i < A.length; i++) {
sum += A[i] * Math.pow(-2, i);
}
return sum;
}