Skip to content

Instantly share code, notes, and snippets.

(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 / 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>");
@matthewmorrone
matthewmorrone / lang.groovy
Created December 2, 2020 18:39
groovy language detection
// Language detection and translation thanks to the Google language APIs
// Script inspired by Glen Smith's article:
// http://blogs.bytecode.com.au/glen/2009/07/30/getting-groovy-with-google-language-translation-apis.html
def text = URLEncoder.encode("J'ai envie de manger des fraises", "UTF-8")
def detectUrl = "http://www.google.com/uds/GlangDetect?v=1.0&q=${text}".toURL()
def langGuessResponse = jsonToGroovyMap(detectUrl.text)
def lang = langGuessResponse.responseData.language
private int longClickDuration = 3000;
private boolean isLongPress = false;
numEquipeCheat.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
isLongPress = true;
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
EditText editText = new EditText(this) {
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
final InputConnection ic = super.onCreateInputConnection(editorInfo);
EditorInfoCompat.setContentMimeTypes(editorInfo,
new String [] {"image/png"});
final InputConnectionCompat.OnCommitContentListener callback =
new InputConnectionCompat.OnCommitContentListener() {
@Override
@matthewmorrone
matthewmorrone / setOnTouchListener.java
Created October 29, 2020 07:39
attempt to prevent outside touch from dismissing
wordbar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
System.out.println(view+" "+motionEvent);
if (motionEvent.getX() < 0 || motionEvent.getX() > popupWindow.getWidth()) return true;
if (motionEvent.getY() < 0 || motionEvent.getY() > popupWindow.getHeight()) return true;
return false;
public static void makeKeyboardTransparent(InputMethodService service) {
try {
View decorView = service.getWindow().getWindow().getDecorView();
final int viewId = fetchInternalRId("fullscreenArea");
View fullscreenArea = decorView.findViewById(viewId);
if (fullscreenArea != null) {
modifyView(fullscreenArea);
return;
}
} catch (Exception e) {
float x1, x2, y1, y2, dx, dy;
String direction;
boolean isDown = false;
Keyboard.Key activeKey;
public String getDirection(MotionEvent me) {
switch(me.getAction()) {
case MotionEvent.ACTION_DOWN: {
isDown = true;
package name.boyle.chris.sgtpuzzles;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;