Skip to content

Instantly share code, notes, and snippets.

View retorillo's full-sized avatar

Retorillo retorillo

View GitHub Profile
@retorillo
retorillo / ctags-windows-include.md
Created February 28, 2018 09:55
%INCLUDE%フォルダ上のヘッダファイルに対してtagsを生成する(Windows/ctags)

%INCLUDE%フォルダ上のヘッダファイルに対してtagsを生成する(Windows/ctags)

目的

ctagsコマンドで%INCLUDE%フォルダ上のヘッダーの定義情報をファイル(デフォルト名 tags)に格納しVimなどからリファレンスとして活用できるようにします。

要件

  • Visual Studio 2017 CommunityなどでC++開発環境がインストールされていること
  • Universal CTAGSctagsおよびreadtagsコマンドのPATHが通ってること

windbg, windbgx quick reference

Windbgx does not support UTF-16 with nobomb

In vim, change fileformat by using :set fenc=utf-16 | set bomb.

must read

Writing C++ Unit Test From Scratch (without Visual Studio IDE) for VS2015

This post provides super-simplified examples that describes how to write C++ unit test without any Visual Studio IDE assistant and template. (Tested on Visual Studio 2015 Community edition)

In fact unit test can be accomplished by only using cl and vstest.console commands. To use these, start with VS Tools Command Prompt, or load vcvarsall on vanilla-cmd.exe to configure. (manual enviromental configuration is too complex and not recommended)

GNUPLOT References

  • power is ** (not ^)
  • show variables
  • e = 2.7182818284 naiper's constant is not defined by default
  • unset key
  • set size ratio -1
  • set autoscale
  • set margin and set bmargin
  • set xrange[0:1] and set xrange[0:1]
@retorillo
retorillo / cpp_pointer_increment.cpp
Created July 25, 2018 06:05
C++ Pointer Increment Demo
#include <vector>
int main() {
struct t{ int i1; int i2; };
std::vector<t> v;
v.push_back(t {1, 2});
v.push_back(t {3, 4});
v.push_back(t {5, 6});
for(int l = v.size(), c = 0; c < l; c++)
printf("%d, ", (v.data() + c)->i2);
}
@retorillo
retorillo / fast_vec_gen.cpp
Last active July 27, 2018 15:18
Fast vector generation (>= C++11)
#include <string>
#include <vector>
void main() {
std::string foo = "baz";
std::vector<char> bar;
printf("%d\n", bar.capacity());
bar.resize(foo.size());
// CAUTION: vector::reserve affects only "capacity", so does not change its "size",
// will causes empty-like behavior if using for(:) loop, vector::resize is adequate.

Install Latest GCC on Ubuntu

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-8 g++-8
sudo update-alternatives --install \
 /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 \
 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

Various way to achieve output from other executable

stdin w/ terminal script

#include <stdio.h>

int main() {
  char buffer[256];
  while (fgets(buffer, sizeof(buffer), stdin))
@retorillo
retorillo / blender_dupl_background_images.py
Last active August 7, 2018 14:21
[Blender] Duplicate background images from first one
# Duplicate background images from first one
# Paste to Blender Python Console, and press ENTER twice
# Authored by Retorillo
# CC0 License, No Rights Reserved
# <START>
for a in bpy.data.screens['Default'].areas:
if a.spaces[0].type != 'VIEW_3D':
continue
bkg = a.spaces[0].background_images
if len(bkg) == 0: