Skip to content

Instantly share code, notes, and snippets.

@matthewmorrone
matthewmorrone / window.clipboard.js
Created January 16, 2015 20:26
clipboard nonsense
//$(document).bind({ cut: function () {}, copy: function () {}, paste: function () {} });
window.logCut = function () {
$(document).on("cut", function (e) {
var selectedText = (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);
if (!selectedText || selectedText == "") {
if (document.activeElement.selectionStart) {
selectedText = document.activeElement.value.substring(document.activeElement.selectionStart.document.activeElement.selectionEnd);
}
}
@matthewmorrone
matthewmorrone / commander.js
Created September 7, 2016 17:13
for keyboard shortcuts in chrome extensions (allows more than 4)
function getTab(sender, count) {
chrome.tabs.query({
windowId: sender.tab.windowId
}, function (tabs) {
var newTabId = tabs[(((count + sender.tab.index) % tabs.length) + tabs.length) % tabs.length].id;
return chrome.tabs.update(newTabId, {
active: true
});
BM25.stopwods = ['a', 'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'amoungst', 'amount', 'an', 'and', 'another', 'any', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere', 'are', 'around', 'as', 'at', 'back', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom', 'but', 'by', 'call', 'can', 'cannot', 'cant', 'co', 'computer', 'con', 'could', 'couldnt', 'cry', 'de', 'describe', 'detail', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight', 'either', 'eleven', 'else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fifteen', 'fify', 'fill', 'find', 'fire', 'first', 'five', 'for', 'former', 'formerly', 'forty', 'found', 'four', 'from', 'front', 'full', 'further', 'get', 'g
"use strict"
/*
const fs = require('fs')
const https = require("https")
const url = require("url")
const path = require('path')
const args = process.argv.slice(2)
*/
@matthewmorrone
matthewmorrone / mouse-wheel-events.js
Last active May 25, 2021 12:58
specific mouse wheel up and down events
window.addEventListener('wheel', function(e){
wDelta = e.wheelDelta < 0
? this.dispatchEvent(new Event('wheeldown'))
: this.dispatchEvent(new Event('wheelup'))
})
$(function() {
$(window).on("wheeldown", function(e) {
console.log(e)
// window.scrollBy(0, window.innerHeight)
(function (a) {
a.fn.replaceTag = function (f) {
var g = [], h = this.length;
while (h--) {
var k = document.createElement(f), b = this[h], d = b.attributes;
for (var c = d.length - 1; c >= 0; c--) {
var j = d[c];
k.setAttribute(j.name, j.value)
}
k.innerHTML = b.innerHTML;
@matthewmorrone
matthewmorrone / sudoku.css
Last active January 28, 2021 18:18
run as a console snippet. now with plain and hidden pairs, triplets, all the way up through 8
.su-candidate-button {
-webkit-transition: opacity 1;
-moz-transition: opacity 1;
-o-transition: opacity 1;
transition: opacity 1;
-webkit-transition-delay: 0;
-moz-transition-delay: 0;
-o-transition-delay: 0;
transition-delay: 0;
opacity: 0;
@matthewmorrone
matthewmorrone / undoRedoHelper.java
Last active December 22, 2020 20:08
batch for grouping similar changes in undo/redo
https://stackoverflow.com/questions/14777593/android-textwatcher-saving-batches-of-similar-changes-for-undo-redo
public class UndoRedoHelper {
private static final String TAG = UndoRedoHelper.class.getCanonicalName();
private boolean mIsUndoOrRedo = false;
private EditHistory mEditHistory;
private EditTextChangeListener mChangeListener;
<html>
<body>
<p>If the language you speak is not on the list, you can include it in the URL</p>
<select><script>
var option = decodeURIComponent(document.location.hash.substring(1));
document.write("<OPTION value=1>English</OPTION>");
document.write("<OPTION value=2>French</OPTION>");
document.write("<OPTION value=3>"+option+"</OPTION>");
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:keyHeight="7%p"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- <Row></Row> -->
<Row android:keyWidth="9.09%p">
<Key android:codes="-25" android:keyIcon="@drawable/ic_double_pointer_left" />
<Key android:codes="-26" android:keyIcon="@drawable/ic_double_pointer_right" />
<Key android:codes="-108" android:keyIcon="@drawable/ic_arrow_left" android:isRepeatable="true" />