Skip to content

Instantly share code, notes, and snippets.

View kuanyui's full-sized avatar
❄️
なんでそんなに慣れてんだよ!

クエン酸 kuanyui

❄️
なんでそんなに慣れてんだよ!
View GitHub Profile
@kuanyui
kuanyui / benchmark_sqlite_insert.js
Last active December 13, 2017 05:47
Compare the efficiency when DATETIME (actually stored as TEXT in SQLite3) is replaced by INTEGER (Unix Epoch in milliseconds)
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('benchmark_tmp.db');
var dateFormat = require('dateformat');
const ROWS = 100000
db.serialize(function() {
let begin
db.serialize(function() {
db.run("CREATE TABLE date_time (ctime DATETIME)")
(defun sort-ip (ip-list)
(sort ip-list #'>ip))
(defun >ip (a b)
(if (and (null a) (null b))
nil
(let ((x (car a))
(y (car b)))
(cond ((> x y) t)
((< x y) nil)
@kuanyui
kuanyui / freeze-emacs.scss
Last active March 29, 2017 05:47
This SCSS file may stuck your Emacs significantly (at least tested on Emacs 25.1 installed via Brew, statrtup with -Q option). Move cursor to EOL of `$colors:` , press Enter then type some characters. Use `pkill -SIGUSR2 Emacs` to interrupt it forcely. It seems that jit-lock.el is the murdurer.
// === colors ====
$colors:
"base_grey" #e8e8e8,
"base_white" #fff,
"base_black" #333,
"switch1_color" #e6943b,
"swtich2_color" #56b538,
"wireless_color" #4baae2,
"router_color" #969696,
"ite_color" #756bb1,
(defun mmm-mode-restart! ()
(interactive)
(widen)
(let ((ext (file-name-extension (buffer-name))))
(cond ((string= ext "jade")
(jade-mode))
((string= ext "vue")
(html-mode))
(t nil))

在QML中,我常常寫類似這樣的東西:

Item {
    id: settings
    property alias snapshot: snapshot
    Item {
        id: snapshot
        property string saveDirectory: "~/hello/world/"
  }
}
@kuanyui
kuanyui / README.md
Last active October 11, 2016 07:16
我還是搞不懂 QML 的 Component 在幹嘛

這個範例中使用 Loader { sourceComponent: block } 來載入名為 block 的 component,會導致 ColumnLayout 無法在 blockvisible 狀態改變時自動調整大小。

然而,如果把 block 獨立出成單一檔案 Block.qml ,然後直接在 ColumnLayout 中使用 Block {} 來載入 component,就沒有上述問題,Layout能夠自動根據 Blockvisible 來自動調整大小。

@kuanyui
kuanyui / mousePositionInVideoOutput.qml
Last active August 9, 2024 08:28
QtAV中的VideoOutput2在不同螢幕解析度下的滑鼠座標 (QtMultimedia內建的VideoOutput也許也適用,但我他媽的一個影片也沒播成功過所以無法測試)
Item {
id: videoArea
anchors.top: parent.top
width: parent.width
height: parent.height - panelRectangle.height
VideoOutput2 {
id: videoOutput
anchors.fill: parent
source: player
}
Canvas {
id: canvasTest
property int ratio: Screen.devicePixelRatio
width: 100 //* ratio
height: 100 //* ratio
//scale: 1/ratio
Path {
id: myPath1
startX: 0; startY: 50
@kuanyui
kuanyui / gist:4ea9a95618175b067c0cc43b479a58f7
Created August 2, 2016 05:56
replace-tab-in-jade-file-to-spaces
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import os, subprocess, re
import fileinput
def replaceTabInFile(filePath):
print("Processing file {} ...".format(filePath))
with fileinput.FileInput(filePath, inplace=True) as f:
for line in f:
@kuanyui
kuanyui / hexo-help.el
Created February 26, 2016 15:55
如何開個temp buffer在目前window下方顯示你要顯示的鬼東西
(setq hexo-help-buffer "*hexo-help*")
(defun hexo-command-open-fixed-help-window ()
(interactive)
(select-window (split-window-below -6))
(if (not (get-buffer hexo-help-buffer))
(temp-buffer-window-setup hexo-help-buffer))
(switch-to-buffer hexo-help-buffer)
(let ((inhibit-read-only t))
(insert (hexo-get-help-string)))