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
# solver for https://hard.mathler.com | |
# copyright@gooooloo | |
import random | |
def answer_to_score(answer): | |
ret = 0 | |
for ch in answer: | |
ret <<= 2 | |
if ch == 'g': |
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
name: groupThenUnGroupSimple | |
description: 'Clicking the button, then ungroup the PT,' | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#setup").click(() => tryCatch(setup)); | |
async function setup() { | |
await Excel.run(async (context) => { |
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
name: groupThenUnGroup | |
description: 'Clicking the button, then ungroup the PT, check the content' | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#setup").click(() => tryCatch(setup)); | |
async function setup() { | |
await Excel.run(async (context) => { |
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
name: Create and modify (1) | |
description: Creates and modifies a PivotTable. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#setup").click(() => tryCatch(setup)); | |
async function setup() { | |
await Excel.run(async (context) => { |
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
#!/usr/bin/python3 | |
import sys | |
from PDFNetPython3 import * | |
def main(): | |
if len(sys.argv) < 3: | |
print("Usage: python3 pdf_to_txt.py path_to_pdf path_to_txt") | |
return |
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 sys | |
def ch2int(ch): | |
if '0' <= ch <= '9': | |
return ord(ch) - ord('0') | |
if 'a' <= ch <= 'f': | |
return ord(ch) - ord('a') + 10 | |
if 'A' <= ch <= 'F': | |
return ord(ch) - ord('A') + 10 |
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 re | |
import os | |
import sys | |
def vba_vso_name(text): | |
ans = text.replace(' ', '_').replace('.', '_') | |
assert re.compile(r'^\w*$').match(ans) | |
return ans | |
def generate_VBA(d_dir_dep): |
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
def simple_tklb(fn_get_list, fn_double_click_item): | |
from tkinter import Tk, Listbox | |
tk = Tk() | |
lb = Listbox(tk) | |
for idx, item in enumerate(fn_get_list()): | |
lb.insert(idx, item) | |
def onselect(event): |
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
#include <stdio.h> | |
#include <stdarg.h> | |
typedef void (*f_type)(int, ...); | |
void foo1(int n1) { printf("%d\n", n1); } | |
void foo2(int n1, int n2) { printf("%d %d\n", n1, n2); } | |
void foo3(int n1, int n2, int n3) { printf("%d %d %d\n", n1, n2, n3); } | |
void bar(f_type pf, ...) { | |
if ((void *)pf == (void *)foo1) { |
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
/** | |
* Here is an example of mem leak I met today. I didn't write the codes, I just help finding the memleak. | |
* Of course the real code is much more complicated, I simplify it here. | |
* | |
* To prove there is memleak, just compile and run: | |
* $ gcc a.cpp --std=c++11 -lstdc++ && ./a.out | |
* | |
* And you will see below: | |
* 4 bytes leaked. | |
* |
NewerOlder