Skip to content

Instantly share code, notes, and snippets.

View MOOOWOOO's full-sized avatar

Jux Liu MOOOWOOO

  • Chongqing, China
View GitHub Profile
@MOOOWOOO
MOOOWOOO / saveGPTtoMD
Created April 12, 2023 04:10
save chatGPT conversion to a markdown file
javascript: (function () { function h(html) { return html.replace(/<p>/g, '\n\n').replace(/<\/p>/g, '').replace(/<b>/g, '**').replace(/<\/b>/g, '**').replace(/<i>/g, '_').replace(/<\/i>/g, '_').replace(/<code[^>]*>/g, (match) => { const lm = match.match(/class="[^"]*language-([^"]*)"/); return lm ? '\n```' + lm[1] + '\n' : '```'; }).replace(/<\/code[^>]*>/g, '```').replace(/<[^>]*>/g, '').replace(/Copy code/g, '').replace(/This content may violate our content policy. If you believe this to be in error, please submit your feedback — your input will aid our research in this area./g, '').trim(); } (() => { const e = document.querySelectorAll(".text-base"); let t = ""; for (const s of e) s.querySelector(".whitespace-pre-wrap") && (t += `**${s.querySelector('img') ? 'You' : 'ChatGPT'}**: ${h(s.querySelector(".whitespace-pre-wrap").innerHTML)}\n\n`); const now = new Date(); const formattedTime = now.getFullYear().toString() + (now.getMonth() + 1).toString().padStart(2, '0') + now.getDate().toString().padStart(2, '0
@MOOOWOOO
MOOOWOOO / extract_domain_name.py
Created April 7, 2023 11:09
extract domain name from an URL likely string
import re
def extract_domain_name(url):
"""
Given a URL string, returns the domain name without the TLD (top-level domain),
or an empty string if the input is invalid.
"""
if not isinstance(url, str):
return ""
url = url.strip().lower()
@MOOOWOOO
MOOOWOOO / block_stupid_makeding
Created November 29, 2022 02:17
block_stupid_makeding.txt
127.0.0.1 xmindchina.net
127.0.0.1 www.xmindchina.net
127.0.0.1 www.ntfsformac.cc
127.0.0.1 www.makeding.com
127.0.0.1 makeding.com
127.0.0.1 vm.makeding.com
127.0.0.1 www.bingdianhuanyuan.cn
127.0.0.1 xia.bingdianhuanyuan.cn
127.0.0.1 bingdianhuanyuan.cn
127.0.0.1 huishenghuiying.com.cn
@MOOOWOOO
MOOOWOOO / search_subslice.go
Created June 27, 2022 02:47
search subslice in slice
package main
// search all sub slices
func SearchSubSlice(mainSlice, subSlice []byte) []int {
var result []int
result = nil
// 主切片为空,直接返回 nil
// if main slice is nil or empty, just return nil
if mainSlice == nil {
@MOOOWOOO
MOOOWOOO / create_specified_size_file_by_random_content.py
Last active June 6, 2022 02:56
create specified size file by random content
# coding: utf-8
__author__ = 'Jux.Liu'
import os
from subprocess import Popen
from time import sleep
cmd_new_file_multiline = 'base64 /dev/urandom 2>>/dev/null | head -c {filesize} > ./{size}{unit}_{file_no} && echo "" >> ./{size}{unit}_{file_no}'
cmd_new_file_one_line = 'tr -dc A-Za-z0-9 </dev/urandom 2>>/dev/null | head -c {filesize} > ./{size}{unit} && echo "" >> ./{size}{unit}'
cmd_one_file_multiline = 'base64 /dev/urandom 2>>/dev/null | head -c {filesize} >> ./{size}{unit}_{file_no} && echo "" >> ./{size}{unit}_{file_no}'
@MOOOWOOO
MOOOWOOO / get_char_without_enter.py
Created December 6, 2021 02:58
get_char_without_enter
# coding: utf-8
__author__ = 'Jux.Liu'
import termios
import sys, tty
def getch():
def _getch():
fd = sys.stdin.fileno()
@MOOOWOOO
MOOOWOOO / remove_copy_listener.js
Created November 23, 2021 01:43
remove_copy_listener
javascript:getEventListeners(document).copy.forEach(({listener}) => document.removeEventListener('copy', listener))
@MOOOWOOO
MOOOWOOO / pick_from_json.py
Last active November 19, 2021 10:32
pick data from complex json by key path string
# coding: utf-8
__author__ = 'Jux.Liu'
def pick_from_json(json_obj, key_path, key_sep='.', list_index_start='$_', list_index_end='_$'):
if key_sep in list_index_start or key_path in list_index_end:
raise Exception('pick another key sep')
key_list = key_path.split(key_sep)
sub_obj = json_obj
for t in range(130000, 140000, 100):
if int(str(t)[2]) > 5:
break
for i in range(t, t+100, 3):
if int(str(i)[-2]) > 5:
break
print('elif {} < int_time <= {}:'.format(i, i + 3))
print("\tres = {} if align == 'floor' else {}".format(i, i + 3))
@MOOOWOOO
MOOOWOOO / argparse.py
Last active May 21, 2018 11:26
argparse
#!/usr/bin python
# coding: utf-8
import sys
from argparse import ArgumentParser
from os.path import exists
def main(*args):
start = args[0].start