Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Noitidart / _ff-addon-snippet-jniScreenshot.js
Last active March 24, 2021 18:33
_ff-addon-snippet-jniScreenshot - Shows how to take a native screenshot and draw it to HTML5 canvas. [jni] [canvas] [jsctypes] [android]
// http://stackoverflow.com/questions/2661536/how-to-programatically-take-a-screenshot-on-android/16109978#16109978
// public Bitmap screenShot(View view) {
// Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
// view.getHeight(), Config.ARGB_8888);
// Canvas canvas = new Canvas(bitmap);
// view.draw(canvas);
// return bitmap;
// }

Getting Unix In New York (Date.now() as if "run in New York at a given time")

// get utc of Feb2 2021 10am in New York - moment.tz('America/New_York').month(1).date(2).hour(10).minute(0).second(0).valueOf()
// now with the return of the above is Date.now() as if i ran it in New York timezone on Feb2 2021 10am - so doing moment.utc(1612278000203).tz('America/New_York').format('llll') gives 'Tue, Feb 2, 2021 10:00 AM'
@Noitidart
Noitidart / _ff-addon-tutorial-jniAndroidToast.js
Last active November 19, 2020 13:55
_ff-addon-tutorial-jniAndroidToast - Using js-ctypes to use JNI to call functions from the Android API, this specific example does the same as the NativeWindow component, it creates a toast message as seen here: https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/NativeWindow/toast
var my_jenv = null;
try {
my_jenv = JNI.GetForThread();
// We declare the classes, methods, etc we will be using: this part is not seen in the native example
var SIG = {
CharSequence: 'Ljava/lang/CharSequence;',
Context: 'Landroid/content/Context;',
GeckoAppShell: 'Lorg.mozilla.gecko.GeckoAppShell;',
Toast: 'Landroid/widget/Toast;', // can use .'s or /'s so `android.widget.Toast` and `android/widget/Toast` both work // from docs page header http://developer.android.com/reference/android/widget/Toast.html#makeText%28android.content.Context,%20int,%20int%29
/////////
var chunk_cnt = 0;
var upload = function() {
// /{user-id}/feed?message={message}&access_token={access-token}
aReportProgress({
body_prefix: 'Chunk ' + (++chunk_cnt) + ' - ',
reason: formatStringFromName('uploading_init', 'app')
});
@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
const { routes } = require('../../../config/routes');
const pluralize = require('pluralize');
const { camelCase } = require('lodash');
/**
* implicitRoutes hook
*
*
* @description :: A hook definition. Extends Sails by adding shadow routes, implicit actions, and/or initialization logic.
* @docs :: https://sailsjs.com/docs/concepts/extending-sails/hooks
@Noitidart
Noitidart / _ff-addon-snippet-WinAPI_EnumHandles.js
Last active March 9, 2020 11:12
_ff-addon-snippet-WinAPI_EnumHandles - Enumerate handles WinAPI. (js-ctypes) (Windows)
Cu.import("resource://gre/modules/ctypes.jsm");
var lib_ntdll = ctypes.open("ntdll.dll");
var lib_kernel32 = ctypes.open("kernel32.dll");
var STATUS_BUFFER_TOO_SMALL = 0xC0000023>>0;
var STATUS_INFO_LENGTH_MISMATCH = 0xC0000004>>0;
var SystemHandleInformation = 16;
var UNICODE_STRING = new ctypes.StructType("UNICODE_STRING", [
{'Length': ctypes.unsigned_short}, //USHORT
@Noitidart
Noitidart / _ff-addon-snippet-WinAPI_EnumHandlesExAndReadFilePaths.js
Last active March 9, 2020 11:12
_ff-addon-snippet-WinAPI_EnumHandlesExAndReadFilePaths - Trying to read file paths of handles returned from a PID that is not equal to the PID of where the code is running from. (js-ctypes) (Windows)
Cu.import('resource://gre/modules/ctypes.jsm');
var lib = {
ntdll: ctypes.open('ntdll.dll'),
kernel32: ctypes.open('kernel32.dll'),
}
//HANDLE WINAPI GetCurrentProcess(void);
var GetCurrentProcess = lib.kernel32.declare("GetCurrentProcess", ctypes.winapi_abi, ctypes.voidptr_t);
//DWORD WINAPI GetCurrentProcessId(void);
@Noitidart
Noitidart / _ff-addon-snippet-WinAPI_NtDll.js
Last active March 9, 2020 11:12
_ff-addon-snippet-WinAPI_NtDll - Demonstrating some capabilities of ntdll. [jsctypes] [windows]
Cu.import("resource://gre/modules/ctypes.jsm");
var lib_ntdll = ctypes.open("ntdll.dll");
var lib_kernel32 = ctypes.open("kernel32.dll");
var _pPID = null;
var STATUS_BUFFER_TOO_SMALL = 0xC0000023>>0;
var STATUS_INFO_LENGTH_MISMATCH = 0xC0000004>>0;
var SystemProcessInformation = 5;
var SystemBasicInformation = 0;
var SystemProcessorPerformanceInformation = 8;
2020-02-22T05:47:29.811462184Z - GET /vod_installer/.env (4ms 404)
2020-02-22T05:47:30.201288566Z - GET /login/.env (2ms 404)
2020-02-22T05:47:30.590670434Z - GET /apps/.env (6ms 404)
2020-02-22T05:47:30.975336099Z - GET /docker/.env (2ms 404)
2020-02-22T05:47:31.356389783Z - GET /engine/.env (2ms 404)
2020-02-22T05:47:31.755648105Z - GET /.env (5ms 404)
2020-02-22T05:47:32.139752236Z - GET /inc/.env (3ms 404)
2020-02-22T05:47:32.523264401Z - GET /development/.env (2ms 404)
2020-02-22T05:47:32.905328696Z - GET /system/.env (2ms 404)
2020-02-22T05:47:33.288912713Z - GET /admin/.env (1ms 404)