Skip to content

Instantly share code, notes, and snippets.

@liudongmiao
liudongmiao / highlight.js
Last active December 7, 2018 11:43
highlight word
function highlightWord(root, word, className) {
// base on https://stackoverflow.com/a/10730063
// word is lower-case
var walker, textNodes = [];
walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
acceptNode: function (node) {
if (node.nodeType === Node.TEXT_NODE && node.textContent.toLowerCase().indexOf(word) >= 0) {
return NodeFilter.FILTER_ACCEPT;
} else {
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
/**
* Created by thom on 2018/9/23.
*/
public class BitmapUtils {
@liudongmiao
liudongmiao / SimpleApkV2.java
Last active March 19, 2020 17:43
SimpleApkV2
// package me.piebridge;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@liudongmiao
liudongmiao / rijndael.py
Created September 6, 2016 01:39 — forked from jeetsukumaran/rijndael.py
Pure-Python implementation of Rijndael (AES) cipher.
#############################################################################
# Original code ported from the Java reference code by Bram Cohen, April 2001,
# with the following statement:
#
# this code is public domain, unless someone makes
# an intellectual property claim against the reference
# code, in which case it can be made public domain by
# deleting all the comments and renaming all the variables
#
class Rijndael(object):
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class MinDepth {
private static void mindepth(int[] array, int index, int depth, HashMap<Integer, int[]> maps) {
List<Integer> added = new ArrayList<Integer>();
for (int i = 0; i < index; ++i) {
@liudongmiao
liudongmiao / fix_gcc_4.6.patch
Last active December 22, 2015 01:49
loadslic patch for grub4dos
--- configure.ac~ 2009-01-16 22:58:48.000000000 +0800
+++ configure.ac 2013-08-27 20:33:41.000000000 +0800
@@ -115,6 +115,22 @@ if test "x$ac_cv_prog_gcc" = xyes; then
if test "x$no_stack_protector_flag" = xyes; then
STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector"
fi
+ # GCC >= 3.3 supports -fno-reorder-functions; this defends us against
+ # unlikely-to-be-executed functions being linked before _start with GCC
+ # >= 4.6.
+ AC_CACHE_CHECK([whether gcc has -fno-reorder-functions],