Skip to content

Instantly share code, notes, and snippets.

@Kxrr
Kxrr / solution.py
Created February 26, 2021 02:23
Shamis's solution
# https://stackoverflow.com/a/66368555/5512649
from typing import List
# problem description
class Object(object):
def __init__(self, integers):
self.integers = integers
@Kxrr
Kxrr / grok_caddy_log.txt
Last active May 7, 2022 10:24
Grok Pattern for Caddy Log
%{IP:remote} - %{USER:user} \[%{HTTPDATE:time}\] \"%{WORD:method} %{URIPATHPARAM:uripath} %{WORD:proto}\/%{NUMBER:proto_ver}\" %{NUMBER:status_code} %{NUMBER:body_length}
@Kxrr
Kxrr / puppeteer_response_buffer_issue.js
Created September 15, 2017 05:11
Puppeteer's response.buffer() issue
const http = require('http');
const puppeteer = require('puppeteer');
const ORIGINAL_DATA = Buffer.from(JSON.stringify({'msg': '测试'}));
function serve() {
http.createServer(function (req, res) {
// The correct header should be 'application/json; charset=utf-8'
// but I change it to 'text/plain' to REPRODUCE THE BUG
@Kxrr
Kxrr / webdev_jianguoyun.py
Last active January 18, 2022 08:40
Webdev example for Jianguoyun
# -*- coding: utf-8 -*-
"""
* 关于坚果云的 Webdav 的配置可以参看: https://griddiary.uservoice.com/knowledgebase/articles/478287-%E5%9D%9A%E6%9E%9C%E4%BA%91-webdav-%E8%AE%BE%E7%BD%AE%E6%95%99%E7%A8%8B
* 使用前请先安装 `easywebdav` : ``pip install easywebdav``
坚果云 Webdav
============
假设有下面的坚果云目录结构
@Kxrr
Kxrr / img2ascii.py
Last active November 7, 2016 11:56
Image to Ascii
# -*- coding: utf-8 -*-
from PIL import Image
CHARS = list("""MNHQ$OC?7>!:-;. """)
CHARS_N = len(CHARS)
WIDTH = 40
HEIGHT = 40
def rgb2char(r, g, b, alpha=256):
@Kxrr
Kxrr / splinter_proxy_example.py
Created September 19, 2016 06:54
Proxy example for splinter(0.7.4) on python2.7
# -*- coding: utf-8 -*-
"""
ProxyBrowser for splinter(0.7.4) on python2.7
Working on Chrome and Phantomjs
"""
from functools import partial
from selenium import webdriver
from splinter import Browser
@Kxrr
Kxrr / private.xml
Created May 26, 2016 06:25 — forked from wangtai/private.xml
Karabiner Mapping Control + HJKL on Arrow keys. Mapping Control + D/U on Page Down/Up. Control + Delete_Left on Delete_Right
<?xml version="1.0"?>
<!--
List of KeyCode
https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/KeyCode.data
List of ModifierCode
https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/ModifierFlag.data
List of ConsumerKeyCode
https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/ConsumerKeyCode.data
List of PointingButton
https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/PointingButton.data