Skip to content

Instantly share code, notes, and snippets.

@Cologler
Cologler / gist-raw-newest-button.user.js
Last active September 13, 2021 02:19
add 'Raw (Newest)' button to gist.
// ==UserScript==
// @name gist: Raw (Newest) button
// @namespace https://github.com/cologler/
// @version 0.2.0
// @description add 'Raw (Newest)' button to gist.
// @author Cologler
// @match https://gist.github.com/*/*
// @connect gist.githubusercontent.com
// @noframes
// @license MIT
@Cologler
Cologler / open-image-in-subview.user.js
Last active July 6, 2018 06:11
open image in a subview without redirect
// ==UserScript==
// @name open image in subview
// @namespace https://github.com/Cologler/
// @version 0.1
// @description open image in a subview without redirect.
// @author Cologler ([email protected])
// @noframes
// @license MIT
// @grant GM_addStyle
// @grant GM_getResourceText
@Cologler
Cologler / code_timer.py
Last active May 12, 2019 12:30
code timer for python, base on timeit
import time
import contextlib
import gc
@contextlib.contextmanager
def disable_gc():
if gc.isenabled():
gc.disable()
yield
gc.enable()
param(
[Parameter(Position=0, mandatory=$true)]
[string] $Command,
[Parameter(Position=1, Mandatory=$false, ValueFromRemainingArguments=$true)]
[string[]] $CommandArgs
)
$PM_BASE_DIR = "$env:UserProfile\.pm"
@Cologler
Cologler / bak.ps1
Last active February 21, 2020 15:13
a script that create a *.bak file for target file
param(
[Parameter(Position=0, mandatory=$true)]
[string] $Path
)
function RenameBak {
param (
[string] $Path
)
@Cologler
Cologler / debug-route.js
Last active February 21, 2020 10:15
a script to debug rsshub route without run koa http server.
/*
* to use this script,
* 1. save debug-route.js to rsshub root dir.
* 2. try: node debug-route.js "/chrome/webstore/extensions/SOME_ID"
*/
const moduleAlias = require('module-alias');
moduleAlias.addAlias('@', () => __dirname + '/lib');
const util = require('util');
# git for fork.
param (
[string] $RepoUrl,
[string] $Dest
)
function Help {
Write-Host 'Git command for clone repo which not belong to you.'
Write-Host ' -> create dir with name ' -NoNewline
Write-Host '$host#$user#$repo' -ForegroundColor Green
@Cologler
Cologler / get-global.js
Created July 5, 2020 05:54
get global object on node/browser
function getGlobal() {
if (typeof globalThis !== 'undefined') {
return globalThis;
} else if (typeof window !== 'undefined') {
return window; // browser
} else if (typeof global != 'undefined') {
return global; // node
} else {
throw Error('unknown');
}
# base-on https://zhuanlan.zhihu.com/p/104046487
# clean patchs
Get-ChildItem -Path TCLS/patchs | Remove-Item
# clean Cross
Get-ChildItem -Path Cross | Where-Object -Property Name -NE -Value 'Apps' | Remove-Item –Recurse -Force
Get-ChildItem -Path Cross/Apps | Where-Object -Property Name -NE -Value 'Apps' | Remove-Item –Recurse -Force
# mark readonly.
@Cologler
Cologler / tinydb_atomic_storage.py
Last active August 9, 2020 13:17
extensions for python tinydb #tinydb
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020~2999 - Cologler <[email protected]>
# ----------
# tinydb storage with atomic write.
# ----------
import os
import json
from contextlib import suppress