Skip to content

Instantly share code, notes, and snippets.

View char101's full-sized avatar
💭
Welcome

Charles char101

💭
Welcome
View GitHub Profile
@char101
char101 / main.py
Created August 22, 2023 07:42
Python http server to browse zipped documentations
import email.utils
import mimetypes
import os
from contextlib import contextmanager
from http import HTTPStatus
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from io import StringIO
from zipfile import ZipFile
DOC_DIR = '/directory/containing/zip/files'
@char101
char101 / client.js
Created June 16, 2023 04:23
Simple javascript - python rpc via websocket
class RemoteService {
#id = 0;
#socket = null;
#queue = new Map();
constructor(wsUrl) {
this.#socket = new WebSocket(wsUrl);
this.#socket.addEventListener('error', error => console.log('socket error: ', error));
this.#socket.addEventListener('message', this._onMessage.bind(this));
return new Promise((resolve, reject) => {
@char101
char101 / RunWithShellToken.ahk
Created May 18, 2023 07:57
[AutoHotkey v2] RunWithShellToken
RunWithShellToken(cmd, args := '', workingDir := '') {
static token := 0
static startupInfo := 0
static processInfo := 0
if !startupInfo {
startupInfo := Buffer(7 * A_PtrSize + 9 * 4 + 2 * 2, 0)
NumPut('Int', startupInfo.Size, startupInfo) ; cb
NumPut('Int', 1, startupInfo, 4 + 3 * A_PtrSize + 4 * 7) ; dwFlags STARTF_USESHOWWINDOW
NumPut('UShort', 5, startupInfo, 4 + 3 * A_PtrSize + 5 * 7) ; wShowWindow SW_SHOW
@char101
char101 / windows.md
Last active May 6, 2023 12:21
Windows LTSB/LTSC VirtualBox Optimization

Steps

  1. Update
  2. Cleanup
  3. Optimize

Update

  1. Run Windows Update
  • Installng update requires 2 GB memory.
@char101
char101 / pastecolor.ahk
Last active May 13, 2022 16:56
[Autohotkey] Paste hex color into Windows color picker
HexToDec(h) {
SetFormat, integer, D
d := 0
d += "0x" h
return, d
}
PasteColor() {
c := Clipboard
If (RegExMatch(c, "^#[A-Za-z0-9]{6}$")) {
@char101
char101 / term.vim
Created October 3, 2021 06:20
[vim] switch to existing terminal window
func s:Term()
let terms = term_list()
if len(terms) > 0
let winid = win_findbuf(terms[0])
let winnr = win_id2tabwin(winid[0])
exe 'tabnext '.winnr[0]
exe winnr[1].'wincmd w'
else
tab term
endif
@char101
char101 / funcsummary.bat
Created April 29, 2021 10:52
Generating php functions prototype info (alternative to the old funcsummary.txt)
mkdir php-doc
pushd php-doc
git clone --depth=1 https://github.com/php/phd
mkdir phpdoc
pushd phpdoc
git clone --depth=1 https://github.com/php/doc-base
git clone --depth=1 https://github.com/php/doc-en en
php doc-base\configure.php --enable-chm
popd
@char101
char101 / hocr2djvused.py
Last active June 19, 2023 03:05
Converter from tesseract hocr to djvused commands (python 3, tested with tesseract 5.0.0 alpha)
import os
import re
import sys
from io import StringIO
from lxml import etree
SPECIAL_CHARACTERS = {
7: 'a', # BELL
8: 'b', # BS
@char101
char101 / PKGBUILD.patch
Last active September 6, 2017 05:08
neo4j-community 3.2.3
diff --git a/PKGBUILD b/PKGBUILD
index 8a964c7..2a2cdfc 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,6 +1,6 @@
# Maintainer: Marcel Campello Ferreira <marcel.campello.ferreira@gmail.com>
pkgname=neo4j-community
-pkgver=3.0.6
+pkgver=3.2.3
pkgrel=1
@char101
char101 / remove_post.js
Last active August 29, 2015 14:02
Purge post from nodebb redis db
"use strict";
global.env = process.env.NODE_ENV || 'production';
var nconf = require('nconf'),
async = require('async');
nconf.file({file: "config.json"})
var db = require('./src/database');