Skip to content

Instantly share code, notes, and snippets.

View Denisss025's full-sized avatar
๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ
I'm watching you!

Denis Denisss025

๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ
I'm watching you!
  • GARANT
  • Moscow, Russian Federation
View GitHub Profile
@Denisss025
Denisss025 / delete_git_submodule.md
Created September 12, 2018 11:29 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@Denisss025
Denisss025 / README.md
Last active March 1, 2016 07:06
Declare a single function for several getter function name variations

Problem

Lets suppose, we want to create some function size(), which should take one argument and return some size.

It's easy, isn't it?

template <typename T>
/*
* Copyright (c) 2014, Denis Novikov <denisnovikov@garant.ru>
* All rights reserved.
*
* Created on: Oct 28, 2014
* Author: Denis Novikov <denisnovikov@garant.ru>
* License: LGPL v.3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
*/
#include <cassert>
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
@Denisss025
Denisss025 / min-max.md
Last active August 29, 2015 13:56
Finding of a minimum and maximum with variadic templates and C++11

Listing #1:

#include <algorithm>
#include <iostream>
#include <type_traits>
#include <initializer_list>

template <typename... Ts>
auto min(Ts... ts) -> typename std::common_type<Ts...>::type {
	return std::min({static_cast<typename std::common_type<Ts...>::type>(ts)...});
// Navigation
w // move to the end of a word
b // move to the beginning of a word
% // go to matching bracket
0 // go to beginning of line
$ // go to end of line
{ // move down by a block
} // move up by a block
gg // move to the top of the file
G // move to the bottom of the file