Skip to content

Instantly share code, notes, and snippets.

@kindlychung
kindlychung / Dockerfile
Created January 21, 2024 12:30 — forked from ciiiii/Dockerfile
Postgresql for Chinese Full-Text Search.中文全文搜索
# If you don‘t want to build it youself, you can try `docker pull killercai/postgres`.
FROM healthcheck/postgres:latest
# China debian mirror
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean && apt-get update
RUN apt-get install -y wget git build-essential libpq-dev python-dev postgresql-server-dev-all
# SCWS (Simple Chinese Word Segmentation library)
RUN cd /tmp && wget -q -O - http://www.xunsearch.com/scws/down/scws-1.2.1.tar.bz2 | tar xjf - && cd scws-1.2.1 && ./configure && make install
# zhpaser (postgres plugin)
/// disable-pageview-api.js
// Based on: https://addons.mozilla.org/firefox/addon/disable-page-visibility/
// License: http://www.opensource.org/licenses/bsd-license.php
(function(){
// visibilitychange events are captured and stopped
document.addEventListener("visibilitychange", function(e) {
e.stopImmediatePropagation();
}, true);
// document.visibilityState always returns false
Object.defineProperty(Document.prototype, "hidden", {
@kindlychung
kindlychung / ! Mongo+TLS on Docker.md
Created August 30, 2023 21:18 — forked from nielsmaerten/! Mongo+TLS on Docker.md
MongoDB + MongoExpress over TLS on Docker

Secure MongoDB on Docker (incl MongoExpress, Let's Encrypt)

This gist contains files and instructions to setup MongoDB on a simple docker host.
Connections to Mongo are secured using TLS, and the certificate is signed using Let's Encrypt.
MongoExpress is included as well, but should only be used over an SSH tunnel.

  1. Update .env

  2. Make sure docker-compose is available

Required on GCP Cloud Optimized OS

# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
{
"title": "Change caps_lock to esc repeated 3 times",
"rules": [
{
"description": "Change caps_lock to esc repeated 3 times",
"manipulators": [
{
"type": "basic",
"from": <%= from("caps_lock", [], ["any"]) %>,
"to": <%= to([["escape", "escape", "escape"]]) %>,
import 'dart:ui';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@kindlychung
kindlychung / tokio.rs
Created January 12, 2020 17:23 — forked from lolgesten/tokio.rs
futures::io::AsyncRead/AsyncWrite conversion to tokio::io::AsyncRead/AsyncWrite
use futures_io::{AsyncRead, AsyncWrite};
use std::fmt;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::AsyncRead as TokioAsyncRead;
use tokio::io::AsyncWrite as TokioAsyncWrite;
pub trait Stream: AsyncRead + AsyncWrite + Unpin + Send + 'static {}
@kindlychung
kindlychung / ld.gold.sh
Last active June 5, 2019 22:48 — forked from daniel-j-h/ld.gold.sh
default to ld.gold on Ubuntu'ish
sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20
sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10
sudo update-alternatives --config ld
ld --version
GNU gold
export CPP=cpp-5 gcc-5 g++-5
env CXXFLAGS='-march=native -flto -fuse-linker-plugin' cmake .. -DCMAKE_BUILD_TYPE=Release
In file included from src/io/./iter_batchloader.h:16:0,
from src/io/io.cc:7:
src/io/././inst_vector.h:157:46: error: expected class-name before ‘{’ token
class TBlobContainer : public mshadow::TBlob {
^
src/io/././inst_vector.h:166:30: error: ‘TShape’ in namespace ‘mshadow’ does not name a type
void resize(const mshadow::TShape &shape, int type_flag) {
^
src/io/././inst_vector.h: In constructor ‘mxnet::io::TBlobContainer::TBlobContainer()’:
src/io/././inst_vector.h:160:21: error: expected class-name before ‘(’ token
extern crate quick_xml;
use quick_xml::reader::Reader;
use quick_xml::events::Event;
fn main() {
let xml = r#"<tag1 att1 = "test">
text_from_tag1
<tag2><!--Test comment-->text1_from_tag2</tag2>
<tag2>