Skip to content

Instantly share code, notes, and snippets.

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

クエン酸 kuanyui

❄️
なんでそんなに慣れてんだよ!
View GitHub Profile
var path = require('path')
var child_process = require('child_process')
const rootDir = path.join(__dirname, '../.')
child_process.exec(
`grep -RIPzo --no-filename --include=\\*.proto "(?s)\\n rpc (Get|Set|Run).*?(get|post|put|delete):\\N+" "${rootDir}"`,
{ maxBuffer: 1024 * 500 * 1024 },
function (error, stdout, stderr) {
@kuanyui
kuanyui / mediaserver.js
Last active April 26, 2020 16:01
Weekend bed potato generator. Lie on bed with tablet all the day.
var http = require('http')
var path = require('path')
var contentDisposition = require('content-disposition')
var finalhandler = require('finalhandler')
var serveStatic = require('serve-static')
var serveIndex = require('serve-index')
const ROOT = path.join(process.env.HOME, '###TO/YOUR/VIDEO/DIRECTORY/')
console.log(ROOT)
@kuanyui
kuanyui / README.md
Last active April 9, 2020 08:09
[AngularJS] Remove the directive of lower priority? (e.g. ng-disabled)

https://stackoverflow.com/questions/61101750/angularjs-remove-the-directive-of-lower-priority

Train of Thought

  1. Remove ng-disabled before it compiled
  2. Watch disabled attribute of the DOM

    Sounds stupid. And performance?

  3. Use CSS + class to fade the <button>

    -No. pointer-events cannot avoid <button> from triggered with [TAB] key.

  4. Write a new directive to replace ng-disabled (priority: 100) . ex: my-disabled (priority: 101)
@kuanyui
kuanyui / bench-array-map-object-int-key.js
Last active February 5, 2020 03:56
[JavaScript] Benchmark Accessing Performance among Array, Object, Map. (Run in browser or node)
const OBJ = {};
const ARR = [];
const MAP = new Map();
const KEYS = [];
LENGTH = 100000;
for (let i=0; i<LENGTH; i++) {
const key = i; // Use int as key
const val = { name: 'foo', id: Math.random(), count: 0 };
KEYS.push(key);
OBJ[key] = val;
@kuanyui
kuanyui / Array.js
Last active January 31, 2020 10:40
[JavaScript] Benchmark the Accessing Performance amoung Array, Object, Map (via USELESS http://jsben.ch/index )
for (const i of RAND_I) {
dummy(ARR[i]);
}
@kuanyui
kuanyui / userscript-pixi-api-doc-title.js
Last active January 29, 2020 08:50
User script to make the title of API documents of Pixi.js comprehensible
// ==UserScript==
// @name Pixi API Page Title
// @version 1
// @grant none
// @match http://pixijs.download/release/docs/*
// @match https://pixijs.download/release/docs/*
// @run-at document-end
// ==/UserScript==
//"http://pixijs.download/release/docs/PIXI.BaseTexture.html#.from"
@kuanyui
kuanyui / rpi-qt5-cc.md
Created May 15, 2018 04:15 — forked from uranusjr/rpi-qt5-cc.md
在 Ubuntu 16.04 為 Raspbian Jessie 交叉編譯 Qt 5.6 桌面版

在 Ubuntu 16.04 為 Raspbian Jessie 交叉編譯 Qt 5.6 桌面版

筆記

Qt 在 Raspberry Pi 上可以跑兩種版本:

  • 桌面版。你平常在 Linux 發行版裡看到的會是這個,包含 Raspbian 在內。通常基於 X11,就是個普通的 GUI 框架。
  • 嵌入版。這個版本不需要鐘面系統,通常是直接走 framebuffer 直接把東西畫到螢幕上,適合一些嵌入式設備的應用。

這個教學會編譯桌面版,因為我對這個版本比較熟。我上次試的時候 OpenGL 在 embedded 版還有些問題,不過 Qt 在那之後有很多更新,狀況應該會好很多。Qt 官方 wiki 也有個相關的教學:

放在function中的話:

MyObj a;            // 1. 宣告a並立刻呼叫他的default ctor(initialization)
MyObj b {123}       // 2. 宣告a並立刻呼叫他對應type的ctor(initialization)
MyObj *b;           // 3. 宣告一個可以指向MyObj 的instance的指標

如果拿MyObj當作另一個class的member variable:

class Foo {
public:
@kuanyui
kuanyui / wtf.sh
Created January 3, 2018 09:07
一旦L14的exit 1存在,什麼東西都印不出來.....
#!/bin/env bash
set -e
CURRENT=$(git describe --tags --abbrev=0)
uncommitted_non_dist_files=$(git status --porcelain | grep -v '^ . dist/')
if [[ ! -z $uncommitted_non_dist_files ]]; then
echo $(tput setaf 1)$(tput bold)"Found some uncommitted files:"$(tput sgr0)
echo $uncommitted_non_dist_files | while read -r file; do
@kuanyui
kuanyui / vvv
Last active April 12, 2018 14:40
ssh -v -i ~/.ssh/company [email protected]
OpenSSH_7.5p1, OpenSSL 1.0.2m 2 Nov 2017
debug1: Reading configuration data /home/ono/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: identity file /home/ono/.ssh/company type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ono/.ssh/company-cert type -1