Skip to content

Instantly share code, notes, and snippets.

@star114
star114 / private_inherit.cpp
Last active July 10, 2018 06:15
[c++ private virtual function inheritance]
#include <iostream>
class Base {
public:
virtual ~Base() = default;
void test() { testInternal(); }
private:
virtual void testInternal()
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
@star114
star114 / removeDuplicates.cpp
Created June 25, 2018 05:30
[c++ remove duplicate entries] #c++
std::sort(data.begin(), data.end(), data_less());
data.erase(std::unique(data.begin(), data.end(), data_equal()), data.end());
@star114
star114 / removeNewLine.cpp
Created June 25, 2018 05:28
[c++ string remove new line characters] #c++
str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
@star114
star114 / find_problem.sh
Created May 28, 2018 09:33
[Listing installed casks fails with an error and it leads to bundle dump failure] homebrew cask bundle
# It’ll output all casks that no longer exist. One of those is causing your issue.
for cask in $(ls -1 "$(brew --prefix)/Caskroom"); do
if ! brew cask info "${cask}" &> /dev/null; then
echo "${cask}"
fi
done
@star114
star114 / remove.sh
Created May 7, 2018 13:38
[remove all subdirectories in bash] bash
find -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 rm -R
@star114
star114 / sap_sso_preference.sh
Created April 19, 2018 03:15
[Mac Google Chrome AutoSelectCertificateForUrls] mac
defaults write com.google.Chrome AutoSelectCertificateForUrls -array-add -string '{"pattern":"https://[*.]sap.corp/*","filter":{"ISSUER":{"CN":"SSO_CA"}}}'
defaults write com.google.Chrome AutoSelectCertificateForUrls -array-add -string '{"pattern":"https://[*.]sap.com/*","filter":{"ISSUER":{"CN":"SSO_CA"}}}'
@star114
star114 / httpserver.sh
Created April 4, 2018 15:07
[shell, python - simple http server] running simple http server using python3 #python #python3 #http #server
python3 -m http.server 8888
@star114
star114 / count.py
Created April 4, 2018 15:04
[python - count words in the file] simple function counting words in the file
def count(filename, w):
f = open(filename)
x = f.readlines()
y = [word for word in (' '.join(x)).split() if word == w]
return len(y)
@star114
star114 / thread.cpp
Created March 11, 2018 02:49
[c++ thread]
#include <functional>
#include <iostream>
#include <memory>
#include <stdlib.h>
#include <string>
#include <thread>
class Greeting {
std::string message;
@star114
star114 / type.cpp
Created March 11, 2018 01:46
[c++ default template parameter and type] std::enable_if usage
/*
* 1) 디폴트 템플릿 파라미터는 템플릿 펑션 시그니처에 안들어감(그래서 typename = std::enable_if_t(condition, type))의 condition만 다른 두 함수를 만들 수 없음
* 2) enable_if의 type이 int char등 넌 타입 템플릿에 올 수 있는 타입이여야 함.(더블 안됨) 그래야 typename int = 0형태인 넌 타입 템플릿 파라미터 형식으로 추론됨
* 올수 이는 녀석은 nullptr, integral lvalue reference, pointer, enum 이라고 함
*/
#include <iostream>
#include <string>
#include <type_traits>