Skip to content

Instantly share code, notes, and snippets.

View ba0f3's full-sized avatar
🇻🇳
#VietnamLeavesNoOneBehind

Huy Doan ba0f3

🇻🇳
#VietnamLeavesNoOneBehind
View GitHub Profile
@ba0f3
ba0f3 / enterprise_token.rb
Created April 17, 2024 02:51 — forked from markasoftware/enterprise_token.rb
OpenProject Enterprise mode for free
############ REPLACE app/models/enterprise_token.rb in the source code with this file! ################
############ also be sure to RESTART OpenProject after replacing the file. ################
############ it doesn't show that enterprise mode is enabled in the settings, but all ################
############ enterprise mode features, such as KanBan boards, are enabled. ################
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
@ba0f3
ba0f3 / filetime.nim
Created February 26, 2021 17:54
Get FILETIME and convert posix time to windows FILENAME
const EPOCH_DIFF = 11644473600'i64
type FILETIME = object
dwLowDateTime: uint32
dwHighDateTime: uint32
proc toFileTime(tv: Timeval): FILETIME =
var mtime = EPOCH_DIFF + tv.tv_sec.int64
mtime = mtime + tv.tv_usec * 10;
mtime = mtime * 10_000_000
@ba0f3
ba0f3 / gist:f01f6c559ed952411c2eb2366a1350e3
Last active July 13, 2021 05:54 — forked from freyes/gist:dfc3f5232526a62bbc09adc816e0477d
bluetoothd: a2dp-sink profile connect failed for AA:BB:CC:DD:EE:00: Protocol not available
Source: https://g751jy.wordpress.com/about/parrot-zik-bluetooth-headset/
https://bbs.archlinux.org/viewtopic.php?id=194006
Cached: http://webcache.googleusercontent.com/search?q=cache:4stTobIXSD0J:https://g751jy.wordpress.com/about/parrot-zik-bluetooth-headset/+&cd=3&hl=en&ct=clnk&gl=us
Bug and possible solution: actually I found a bug in that make the headset unusable, it seems that the pulse audio module: module-bluetooth-discover works only if started after the X11 session is up. So I have a workaround.
Edit the file:
/etc/pulse/default.pa
@ba0f3
ba0f3 / mm.nim
Created July 18, 2020 11:29
MemoryModule wrapper for Nim
{.compile: "MemoryModule.c".}
type
HMEMORYMODULE* = pointer
HMEMORYRSRC* = pointer
HCUSTOMMODULE* = pointer
{.push: cdecl, importc, discardable.}
proc MemoryLoadLibrary*(loc: pointer, size: int): HMEMORYMODULE
@ba0f3
ba0f3 / mongo_bpipe.sh
Last active June 23, 2022 11:36
backup mongodb using BareOS' bpipe plugin
#!/bin/sh
# Save this file on the on FD
# /usr/lib/bareos/plugins/mongo_bpipe.sh
#DBNAMES=""
#DBUSERNAME=""
#DBPASSWORD=""
#DBAUTHDB=""
@ba0f3
ba0f3 / gist:8709b57e85c75103759f698d8471a1e3
Created April 11, 2020 05:20 — forked from sielay/gist:0aa4077829f35f5e0310f9e0cc9fdc71
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
frontend www-http
bind :80
bind *:443 ssl crt /etc/haproxy/certs no-sslv3
capture request header X-Forwarded-For len 50
acl is_cf req.hdr(cf-connecting-ip) -m found
http-request set-header X-Client-IP %[src] if !is_cf
http-request set-header X-Client-IP %[hdr(cf-connecting-ip)] if is_cf
@ba0f3
ba0f3 / compile-glibc-214.sh
Created March 19, 2020 09:28
Compile GlibC 2.14 on Centos 6, copied from https://unix.stackexchange.com/a/299665
#!/bin/bash
mkdir ~/glibc_install; cd ~/glibc_install
wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
tar zxvf glibc-2.14.tar.gz
cd glibc-2.14
@ba0f3
ba0f3 / default.nim
Last active February 25, 2020 15:14
assign default values for object's members
import macros
template value(x: untyped) {.pragma.}
proc init[T](t: typedesc[T]): T =
for k, v in result.fieldPairs:
if v.hasCustomPragma(value):
v = v.getCustomPragmaVal(value)
type
MyObj = object
@ba0f3
ba0f3 / 1111.sh
Last active February 15, 2020 14:48
Cloudflare Warp+ 1.1.1.1 data boost script, only curl required
#!/bin/bash
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required"; exit 1; }
if [ "$1" == "" ]; then
echo "Usage: ${0} <warp+ id>"
exit 1
fi
RUNNING=true
BOOSTED=0
import prompt, unicode, terminal
proc autoComplete(line: seq[Rune], cursorpos: int): seq[string] {.gcsafe.} =
if line.len == 0:
return @[]
if $line == "hi":
result = @["Hello", "Xin chao", "Bonjour"]
else: