This file contains 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 functools import lru_cache, wraps | |
from datetime import datetime | |
def lru_cache_by_minute(size): | |
""" Decorator that caches the result of `f` during the current minute """ | |
def real_decorator(f): | |
# create a cached function that wraps f but adds a minute argument | |
# the size is the number of entries in the cache |
This file contains 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 builtins | |
from inspect import getmembers, isfunction | |
from pymonad import curry | |
old_imp = builtins.__import__ | |
def currify(mod): | |
for name, val in getmembers(mod): |
This file contains 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 datetime import datetime | |
from time import sleep | |
def trange(start=None, end=None, interval=1): | |
now = datetime.now().timestamp() | |
if start is None: | |
start = now | |
else: | |
start = start.timestamp() |
This file contains 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
function function_params(func) { | |
if (typeof(func) == "function") { | |
let source_code = func.toString() | |
let regex_paren = new RegExp("\\((.*)\\)") | |
let args_str = regex_paren.exec(source_code) | |
return args_str[1].split(",").map((x) => x.trim()) | |
} | |
} | |
Function.prototype.applyObj = function (obj) { |
This file contains 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
--- sends a message on several channels at once --- | |
--- channels can be either a name or a number --- | |
/script m,cs="what you want to send",{"1","world","LookingForGroup"}; | |
/script for _,c in ipairs(cs) do i,n=GetChannelName(c);SendChatMessage(m,"CHANNEL",nil,i);end | |
--- toggles join/leave a channel --- | |
/script c="channel_name";i,n=GetChannelName(c);if i==0 then JoinChannelByName(c);ChatFrame_AddChannel(ChatFrame1,c);else LeaveChannelByName(c);end | |
--- swaps weapons with first 2 slots of last bag, works with 2H,1H+shield, not tested with 2 weapons --- |