This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Created on 2011-10-09 | |
Modified Python Recipe: http://code.activestate.com/recipes/522995/ | |
@author: mavc | |
''' | |
from heapq import heapify, heappop, heappush | |
__all__ = ['PriorityDict'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Boyer-Moore exact string search, implemented from the description | |
given in: | |
http://www.inf.fh-flensburg.de/lang/algorithmen/pattern/bmen.htm | |
''' | |
def _bad_character_shift(pat): | |
''' Calculates the bad character shift as the distance of the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Sample JSON decoder for demonstrating how to use pyparsing. | |
""" | |
import pyparsing as pp | |
# JSON types are number, string, boolean, object, array, and null. | |
# A boolean is either the literal 'true' or the literal 'false'. Set a | |
# parsing action that just replaces it with the Python equivalent. | |
boolean = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from ply import lex, yacc | |
from ply.lex import TOKEN | |
import pyparsing as pp | |
# First, let's define a pyparsing parser for JSON. | |
class JSONPyParsing(object): | |
# pylint: disable-msg=W0104,E0213 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.List; | |
public class SlowSort { | |
public static <T extends Comparable<? super T>> void slowSort(T[] array) { | |
slowSort(array, 0, array.length); | |
} | |
public static <T> void slowSort(T[] array, Comparator<? super T> comparator) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Kasi-Time Select | |
// @namespace github.com/mavc | |
// @include http://www.kasi-time.com/* | |
// @version 1.0 | |
// @grant unsafeWindow | |
// ==/UserScript== | |
(function() { | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Thread.And.Find.Out | |
// @namespace mavc | |
// @description Add < Prev and Next > Navigation for RAFO threads. | |
// @match http://*.readandfindout.com/* | |
// @version 1.0.0 | |
// ==/UserScript== | |
function getNext(t) { | |
// get first child, next sibling, or getNext() of parent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name twimg-icon | |
// @namespace github.com/mavc | |
// @description Download source images on Twitter. | |
// @include https://twitter.com/* | |
// @exclude https://twitter.com/i/* | |
// @version 1.1.1 | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import os | |
from os import path | |
from PIL import Image | |
import shutil | |
from sys import argv | |
EXTENSIONS = ('.jpg', '.png') | |
WALLPAPER_RATIO_MIN = 1.25 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
executeInBackground(async () => { | |
const tabs = await browser.tabs.query({currentWindow: true}); | |
const activeTab = tabs.find((t) => t.active); | |
if (activeTab.index > 0) { | |
// Set the current tab to the tab on the left. | |
let nextTab = tabs.find((t) => t.index == activeTab.index - 1); | |
await browser.tabs.update(nextTab.id, {active: true}); | |
} | |
// Close the current tab. | |
await browser.tabs.remove(activeTab.id); |
OlderNewer