Skip to content

Instantly share code, notes, and snippets.

View retorillo's full-sized avatar

Retorillo retorillo

View GitHub Profile

LaTeX memo

Math

  • Vector \overrightarrow{a} (wider) vs \vec{a} (shorter)
  • Matrix and Determinant \begin{pmatrix} ... \end{pmatrix} (parentheses) or begin{vmatrix} ... \end{vmatrix} (simple vertical bar). Each of elements are separated by ampersand &, each of rows are separated by //
  • Cofactor \widetilde{A} (wider) vs \tilde{A} (shorter)
  • Minor determinant \overline{A} (wider) vs \bar{A} (shorter)
  • other symbols: amssymb

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]

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

@retorillo
retorillo / latex2png_win.md
Last active February 22, 2024 10:51
LaTeX to PNG on Windows

LaTeX to PNG on Windows

Prerequisite

  • Windows System (Tested on Windows 10)
  • pdflatex TexLive (/w standalone package)
  • magick Image Magick
    • choco install imagemagick
  • gswin32c Ghost Script (x86)
@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))
REM This snippet sort *.ts files in numerical order. Up to 9999. (1.ts - 9999.ts)
@echo off
setlocal enabledelayedexpansion
(
for /f %%f in ('dir /b *.ts') do (
set num=%%~nf
set elif=1
if !elif! equ 1 if !num! lss 10 set "num=000!num!" && set elif=0
if !elif! equ 1 if !num! lss 100 set "num=00!num!" && set elif=0
if !elif! equ 1 if !num! lss 1000 set "num=0!num!" && set elif=0