Skip to content

Instantly share code, notes, and snippets.

@hiiwave
hiiwave / delete_google_json.py
Created March 23, 2022 12:51
Delete json files generated by google drive after batch download
from pathlib import Path
from tqdm.auto import tqdm
import json
def delete_google_drive_json_recursively(drive_path):
drive_path = Path(drive_path)
for f in (pbar := tqdm(drive_path.glob("**/*.json"))):
try:
data = json.loads(f.read_bytes())
@hiiwave
hiiwave / D.py
Created March 22, 2020 07:45
Kickstart 2020 Round A
# Trie-based solution
# https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc7/00000000001d3ff3
# Seems to be feasible solution with good efficicency, though unfortunately got WA in larger test
from sys import stdin, stdout
class TrieNode(object):
def __init__(self, char: str):
@hiiwave
hiiwave / srt2txt.py
Created August 8, 2018 02:52 — forked from mgaitan/srt2txt.py
Convert subtitles to plain text
#!/usr/bin/env python
import sys
import re
import textwrap
def str2txt(srt):
lines = re.sub(r'^$\n|^[0-9].*\n|^\n','', srt, flags=re.MULTILINE | re.UNICODE)
print(textwrap.fill(lines, 70))
if __name__ == '__main__':
@hiiwave
hiiwave / newton.c
Last active July 24, 2018 02:15
Find root by Newton method
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef double (*func)(double);
double f(double x) {
return x * x - 2.0 * x - 5.0;
}
double fd(double x) {
@hiiwave
hiiwave / c_cpp_properties.json
Created June 29, 2018 06:11
vscode cpp configuration
{
"configurations": [
{
"name": "Win32",
"intelliSenseMode": "clang-x64",
"includePath": [
"${workspaceRoot}",
".",
"C:/Users/001151/Documents/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
"C:/Users/001151/Documents/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
@hiiwave
hiiwave / 1_complete.in
Created May 19, 2018 17:52
CodeJam 2018 Round 2 Problem 1 Test set 1 by exhaustion
174
2
0 2
2
1 1
2
2 0
3
0 0 3
3
@hiiwave
hiiwave / phantomjs_loadpage.js
Created March 23, 2018 09:19
Sample code of using phantomjs-node to scrape a web page fully loaded
var phantom = require('phantom');
var fs = require('fs');
let pageScraper = (function () {
'use strict';
let module = {
content: null,
onResourceRequested: function (requestData, request) {
// run in phantomjs runtime: https://github.com/amir20/phantomjs-node#pageon
@hiiwave
hiiwave / tos_unpackpatches.md
Last active February 18, 2018 16:43
Batch unpack patches of Tree of Savior

Batch unpack patches of Tree of Savior

  1. Download and unzip IPFUnpacker
  2. Make a copy of patch directory into the folder of IPFUnpacker
  3. Open cmd.exe, cd to the folder of IPFUnpacker.
  4. Batch decrypt all patch/*.ipf by command for /R %x in (patch\*.ipf) do ipf_unpack.exe %x decrypt
  5. Batch extract all lua and xml files by command for /R %x in (patch\*.ipf) do ipf_unpack.exe %x extract lua xml
  6. Now extract folder contains the latest updated lua scripts.
@hiiwave
hiiwave / ocmock-cheatsheet.m
Created December 18, 2017 09:07 — forked from kharmabum/ocmock-cheatsheet.m
OCMock cheatsheet
/*----------------------------------------------------*/
#pragma mark - XCTAsserts
/*----------------------------------------------------*/
XCTAssert(expression, format...);
XCTAssertTrue(expression, format...);
XCTAssertFalse(expression, format...);
XCTAssertEqual(expression1, expression2, format...);
XCTAssertNotEqual(expression1, expression2, format...);
XCTAssertNil(expression, format...);
0,0
1,1
2,2
3,3
4,4
5,5
6,6
7,7
8,8
9,9