Skip to content

Instantly share code, notes, and snippets.

yaowenqiang / Regex to search only in NCLOCs
Created February 16, 2023 03:10 — forked from trebron21/Regex to search only in NCLOCs
Regex to search only between uncommented lines (NCLOC - Non-Comment Lines Of Code)
View Regex to search only in NCLOCs
Search only between uncommented lines (NCLOC - Non-Comment Lines Of Code):
First solution matches "keyWord" which is not commented with single line comment //
^*(?<!\/\/.*)keyWord // this uses negative lookbehind
or another solution without lookbehind for regex engines, that does not support it:
yaowenqiang / sniff.txt
Created January 12, 2023 09:51 — forked from manifestinteractive/sniff.txt
A friendly formatter for curl requests to help with debugging.
View sniff.txt
============= HOST: ==========\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
======= CONNECTION: ==========\n
yaowenqiang / Quirks of
Created November 21, 2022 10:30 — forked from fay59/Quirks of
Quirks of C
View Quirks of

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope []

struct foo {
   struct bar {
 int x;
yaowenqiang / tmux split-window
Created October 11, 2022 08:42 — forked from sdondley/tmux split-window
Super Guide to the split-window tmux Subcommand (and Beyond)
View tmux split-window

Super Guide to the split-window tmux Subcommand (and Beyond)

Guide overview

tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced power features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the

yaowenqiang /
Created July 15, 2022 08:08 — forked from ian-whitestone/
Best practices for presto sql

Presto Specific

  • Don’t SELECT *, Specify explicit column names (columnar store)
  • Avoid large JOINs (filter each table first)
    • In PRESTO tables are joined in the order they are listed!!
    • Join small tables earlier in the plan and leave larger fact tables to the end
    • Avoid cross joins or 1 to many joins as these can degrade performance
  • Order by and group by take time
    • only use order by in subqueries if it is really necessary
  • When using GROUP BY, order the columns by the highest cardinality (that is, most number of unique values) to the lowest.
yaowenqiang / gist:5c3a47171224b852dc5cc0110d2d5bda
Created June 28, 2022 11:49 — forked from ipedrazas/gist:2c93f6e74737d1f8a791
List Docker Container Names and IPs
View gist:5c3a47171224b852dc5cc0110d2d5bda
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
yaowenqiang / mysqld_exporter.service
Created May 23, 2022 12:03 — forked from lepiaf/mysqld_exporter.service
Prometheus - mysql_exporter systemd
View mysqld_exporter.service
# /etc/systemd/system/mysql_exporter.service
Description=Mysql Exporter
yaowenqiang / install-tmux
Created May 17, 2022 11:08 — forked from cdkamat/install-tmux
Install tmux 2.3 on rhel/centos 6
View install-tmux
# Install tmux on Centos release 6.5
# install deps
yum install gcc kernel-devel make ncurses-devel
curl -OL
tar -xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local