Skip to content

Instantly share code, notes, and snippets.

View gist:6b1bcaf7724dfc2a54f3
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active Feb 1, 2023
Using multiple github accounts with ssh keys
View using-multiple-github-accounts-with-ssh-keys.md

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@shijij
shijij / VerifyCsrfToken.php
Created Jul 25, 2019
Laravel skip/except CSRF verification by domain name (useful for multiple subdomains)
View VerifyCsrfToken.php
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
@luncliff
luncliff / cmake-tutorial.md
Last active Feb 1, 2023
CMake 할때 쪼오오금 도움이 되는 문서
View cmake-tutorial.md

CMake를 왜 쓰는거죠?
좋은 툴은 Visual Studio 뿐입니다. 그 이외에는 전부 사도(邪道)입니다 사도! - 작성자

주의

  • 이 문서는 CMake를 주관적으로 서술합니다
  • 이 문서를 통해 CMake를 시작하기엔 적합하지 않습니다
    https://cgold.readthedocs.io/en/latest/ 3.1 챕터까지 따라해본 이후 기본사항들을 속성으로 익히는 것을 돕기위한 보조자료로써 작성되었습니다
@WebDevSimplified
WebDevSimplified / bootstrap-breakpoint.css
Last active Feb 1, 2023
This stylesheet adds text describing the current Bootstrap Breakpoint in the top right corner of the screen.
View bootstrap-breakpoint.css
body {
margin-top: 40px; /* This margin just makes the text easier to read. You can remove it if you want since it can mess with your other styles. */
}
body::before {
content: "XS";
color: red;
font-size: 2rem;
font-weight: bold;
position: fixed;
@ianlcassidy
ianlcassidy / create_features_container.py
Last active Feb 1, 2023
A function to automatically convert a dataframe to a Pydantic features container
View create_features_container.py
import typing as T
import pandas as pd
import numpy as np
def create_features_container_from_dataframe(
df: pd.DataFrame,
class_name: str = "Features",
) -> str:
@trickpattyFH20
trickpattyFH20 / examples.md
Created Feb 1, 2023 — forked from ef4/examples.md
Webpack 5 Node Polyfills Upgrade Cheatsheet
View examples.md

Webpack 5 Node Polyfills Upgrade Cheatsheet

Webpack 4 automatically polyfilled many Node APIs in the browser. This was not a great system, because it could lead to surprisingly giant libraries getting pulled into your app by accident, and it gave you no control over the exact versions of the polyfills you were using.

So Webpack 5 removed this functionality. That means you need to make changes if you were relying on those polyfills. This is a quick reference for how to replace the most common patterns.

List of polyfill packages that were used in webpack 4

For each automatically-polyfilled node package name on the left, this shows the name of the NPM package that was used to polyfill it on the right. Under webpack 5 you can manually install these packages and use them via resolve.fallback.

@MCKLtech
MCKLtech / woocommerce-add-fee-to-order.php
Created Mar 7, 2019
HOWTO: Adding A Discount or Fee to a WooCommerce Order Programmatically
View woocommerce-add-fee-to-order.php
<?php
/*
* The following code assumes you have an WC Order object already. We'll be adding a discount to an order.
* This code cannot be added directly anywhere, it is merely an explanation of how this can be done.
* We will add a discount to the order using Fees
*/
/* Assume order is set up already */
@shuamilabs
shuamilabs / Laravel Application (<laravel 9.19)
Last active Feb 1, 2023
How to create a simple laravel application (using bootstrap 5)
View Laravel Application (<laravel 9.19)
- Install Apache / Nginx
- Install PHP
- Install Composer
- on Windows, download the installer and install (https://getcomposer.org/download/)
- on macOS, you can install using brew
- on macOS, make sure to place Composer's system-wide vendor bin directory in your $PATH
$ echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.zshrc
@yqlbu
yqlbu / qnap_emby_nvidia.md
Last active Feb 1, 2023
Some hacks around using NVIDIA GPU for Emby Container with QNAP
View qnap_emby_nvidia.md

Hacks

Some hacks around using NVIDIA GPU for Emby Container with QNAP

Make sure you have NVIDIA driver installed already

Check NVIDIA Driver Path

find /share/ -name "NVIDIA_GPU_DRV"