Skip to content

Instantly share code, notes, and snippets.

@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;
@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 = {
@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."

@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
/**
* @constructs Printer
*/
function Printer(){};
Printer.prototype = {};
/**
* Returns if printer is local or network
* @returns {boolean}
*/
Printer.prototype.isLocal = function(){return true;};
@abe33
abe33 / init.coffee
Last active May 1, 2018 21:44
Scrolling Atom editors without moving the cursor
atom.commands.add 'atom-text-editor',
'editor:scroll-down': ->
editor = atom.workspace.getActiveTextEditor()
editorElement = atom.views.getView(editor)
newScrollTop = editorElement.getScrollTop() + editorElement.getHeight()
editorElement.setScrollTop(newScrollTop)
'editor:scroll-up': ->
editor = atom.workspace.getActiveTextEditor()
editorElement = atom.views.getView(editor)
@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
@nahanil
nahanil / layout.ejs
Last active September 8, 2019 19:37
Sails page title
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= typeof data !== 'undefined' && data.title ? data.title + ' | ' : (typeof title == 'undefined' ? '' : title + " | " )%><%= sails.config.appName %> | Chinese - English Dictionary &amp; Mandarin Learning Resources</title>
...
@nahanil
nahanil / nginx-app-basic.com
Last active November 15, 2019 18:54
nginx thing
server {
listen 80;
server_name myapp.com;
location / {
# Pass off API and socket requests to the app server
proxy_pass http://127.0.0.1:1337;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@Noitidart
Noitidart / stackoverflow-query-search-comments.txt
Last active May 20, 2020 01:17
Search for comments by tag of post
// https://data.stackexchange.com/stackoverflow/query/1027054/search-posts-by-userid-comment-text?CommentText=ios&TagName=react-native
SELECT Posts.Id AS [Post Link], Comments.Text, Comments.CreationDate
FROM Comments
LEFT JOIN Posts ON Posts.Id = Comments.PostId
WHERE UPPER(Comments.Text) LIKE UPPER('%##CommentText##%')
AND Comments.UserId = '1828637'
AND Posts.Tags LIKE '%<##TagName##>%'
ORDER BY Comments.CreationDate DESC