Skip to content

Instantly share code, notes, and snippets.

@songpp
songpp / number-of-islands-ii.rs
Last active June 28, 2024 16:32
leetcode 305 number-of-islands-ii
//! leetcode 305 number-of-islands-ii
//! 给你一个大小为 m x n 的二进制网格 grid 。网格表示一张地图,其中,0 表示水,1 表示陆地。
//! 最初,grid 中的所有单元格都是水单元格(即,所有单元格都是 0)。
//! 可以通过执行 addLand 操作,将某个位置的水转换成陆地。给你一个数组 positions ,
//! 其中 positions[i] = [ri, ci] 是要执行第 i 次操作的位置 (ri, ci) 。
//!
//! 返回一个整数数组 answer ,其中 answer[i] 是将单元格 (ri, ci) 转换为陆地后,地图中岛屿的数量。
//! 岛屿 的定义是被「水」包围的「陆地」,通过水平方向或者垂直方向上相邻的陆地连接而成。
//! 你可以假设地图网格的四边均被无边无际的「水」所包围。
@songpp
songpp / regular_expression_engine_comparison.md
Created February 11, 2023 12:21 — forked from CMCDragonkai/regular_expression_engine_comparison.md
Regular Expression Engine Comparison Chart

Regular Expression Engine Comparison Chart

Many different applications claim to support regular expressions. But what does that even mean?

Well there are lots of different regular expression engines, and they all have different feature sets and different time-space efficiencies.

The information here is just copied from: http://regular-expressions.mobi/refflavors.html

@songpp
songpp / two_three_four_tree.rs
Created January 13, 2022 13:59
stupid half 2-3-4 tree
use std::cmp::max;
use std::collections::VecDeque;
use std::convert::TryInto;
use std::fmt::Debug;
use std::mem::MaybeUninit;
use std::ptr::slice_from_raw_parts;
use itertools::Itertools;
use itertools::MinMaxResult;
@songpp
songpp / pg_dump_reader.rs
Last active April 14, 2022 17:52
directory format toc.dat reader
//! this is a pg_dump archive (only 'directory' output) toc.dat reader.
use bytes::{buf::Buf, BytesMut};
use futures_util::stream::StreamExt;
use tokio_util::codec::*;
use nom::{IResult,
number::streaming as ns,
@songpp
songpp / doubly_linked_list.rs
Last active January 2, 2021 16:43
Doubly Linked List in purely safe rust
/// doubly linked list in purely safe rust
use std::rc::{Rc, Weak};
use std::cell::RefCell;
use std::fmt::Debug;
type Node<T> = RefCell<Option<T>>;
#[derive(Debug)]
pub struct ListNode<T> {
@songpp
songpp / gist:5d98773ddb002a216bdc7bf6d7fd2e76
Created July 12, 2020 16:30 — forked from patshaughnessy/gist:70519495343412504686
How to Debug Postgres using LLDB on a Mac
This note explains how to build Postgres from source and setup to debug it using LLDB on a Mac. I used this technique to research this article:
http://patshaughnessy.net/2014/10/13/following-a-select-statement-through-postgres-internals
1. Shut down existing postgres if necessary - you don’t want to mess up your existing DB or work :)
$ ps aux | grep postgres
pat 456 0.0 0.0 2503812 828 ?? Ss Sun10AM 0:11.59 postgres: stats collector process
pat 455 0.0 0.0 2649692 2536 ?? Ss Sun10AM 0:05.00 postgres: autovacuum launcher process
pat 454 0.0 0.0 2640476 304 ?? Ss Sun10AM 0:00.74 postgres: wal writer process
pat 453 0.0 0.0 2640476 336 ?? Ss Sun10AM 0:00.76 postgres: writer process
@songpp
songpp / .ghci
Last active March 21, 2020 13:32
dev .ghci
:set -XGADTs
:set -XOverloadedStrings
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Lazy.IO as LT
@songpp
songpp / vs-settings.json
Created March 19, 2020 17:53
vs-settings.json
#
@songpp
songpp / haskell.json
Last active February 24, 2020 05:43
vs haskell snipptes
{
// Place your snippets for haskell here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@songpp
songpp / gen-stores.sh
Created September 9, 2016 09:48
用于生成开发用的keystore和trust store以及对应的android端用的bks格式的trust store
#!/usr/bin/env bash
# 用于生成开发用的keystore和trust store以及对应的android端用的bks格式的trust store
# 需要 bcprov-ext-jdk15on-1.46.jar 与这个脚本在同一个目录
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd);
TARGET_DIR="${SCRIPT_DIR}/new_certs"
KEYSTORE="${TARGET_DIR}/keystore.jks"