Skip to content

Instantly share code, notes, and snippets.

@vietjtnguyen
vietjtnguyen / Makefile
Last active January 13, 2021 19:01
Throw/assert method as customization point?
.PHONY: all
all: foo_with_assert foo_with_throw
foo_with_assert: assert.hpp foo.hpp foo.cpp main.cpp
g++ -std=c++11 -o foo_with_assert main.cpp foo.cpp -g -O0
foo_with_throw: assert.hpp foo.hpp foo.cpp main.cpp
g++ -std=c++11 -o foo_with_throw main.cpp foo.cpp -g -O0 -
DMY_LIB_THROW_INSTEAD_OF_ASSERT
// https://www.youtube.com/watch?v=2gjroKLyWKE
#include <utility>
struct S
{
// trailing & means only applies to lvalues on left side
S& operator=(const S& s) & = default;
S& operator=(S& s) & = default;
S& operator=(S&& s) & = default; // move from
@vietjtnguyen
vietjtnguyen / Makefile
Created January 30, 2018 17:27
Non-polymorphic destructor leak
check: main
valgrind --tool=memcheck --leak-check=yes ./main
main: main.cpp
g++ main.cpp -o main -std=c++11

Keybase proof

I hereby claim:

  • I am vietjtnguyen on github.
  • I am vietjtnguyen (https://keybase.io/vietjtnguyen) on keybase.
  • I have a public key ASBBdlSqxnnLk7twRHCM2rHhu1idwfIQVwaFyxN40iFwugo

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vietjtnguyen
vietjtnguyen / pycalc.py
Created November 12, 2013 09:07
Python script to do in place calculations while in vim. Inspired by https://github.com/arecarn/crunch.
#!/usr/bin/python
#import numpy as np
#import pandas as pd
#import scipy as sp
#import scipy.ndimage as nd
#import scipy.signal as sg
#import itertools, pickle, random, os
from math import *
import sys
for line in sys.stdin.readlines():
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.