Skip to content

Instantly share code, notes, and snippets.

View Bak-Jin-Hyeong's full-sized avatar

Bak, Jin Hyeong Bak-Jin-Hyeong

View GitHub Profile
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / AbseilInlinedVector.h
Last active September 4, 2018 00:02
#include <absl/container/inlined_vector.h> without defining _SCL_SECURE_NO_WARNINGS globally.
#ifndef ABSEILINLINEDVECTOR__H__
#define ABSEILINLINEDVECTOR__H__
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <initializer_list>
#ifndef APPEND_UNESCAPED_JSON_STRING__HPP__
#define APPEND_UNESCAPED_JSON_STRING__HPP__
//
// usage:
//
// const char json[] = u8"유티엪후-8! XYZ, \\uAC00, \\uD600\\uc5c9, QVW \\u0X 유티엪후-8!, 써로게이트 \\uD83D\\uDCA9 페어!";
// const auto json_length = strlen(json);
// std::string s;
// append_unescaped_json_string(json, json_length, [&s](auto c) {
#include "jsmn.h"
struct JSMN_Verify_Stack_Element
{
int offset;
int num_tokens;
};
int JSMN_Verify(const jsmntok_t* tokens, const JSMN_Verify_Stack_Element param)
{
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / abseil-cpp.natvis
Last active August 13, 2019 05:03
visual studio 2015 debug visualizer for google abseil-cpp
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="absl::lts_2019_08_08::InlinedVector&lt;*&gt;">
<DisplayString>{{ size={storage_.metadata_.value >> 1} }}</DisplayString>
<Expand>
<Item Name="[N]" ExcludeView="simple">sizeof(storage_.data_.inlined.inlined_data) / sizeof(storage_.data_.inlined.inlined_data[0])</Item>
<Item Name="[allocator]" ExcludeView="simple">storage_.metadata_</Item>
<Item Name="[capacity]" ExcludeView="simple" Condition="(storage_.metadata_.value &amp; 1) == 0">$T2</Item>
<Item Name="[capacity]" ExcludeView="simple" Condition="(storage_.metadata_.value &amp; 1) == 1">storage_.data_.allocated.allocated_capacity</Item>
<IndexListItems Condition="(storage_.metadata_.value &amp; 1) == 0">
function Get-AliasPattern($exe) {
$aliases = @($exe) + @(Get-Alias | Where-Object { $_.Definition -eq $exe } | Select-Object -Exp Name)
"($($aliases -join '|'))"
}
$options = @(
@(@('-A', '--after-context'), @('<NUM>')),
@(@('-B', '--before-context'), @('<NUM>')),
@(@('-S', '--case-sensitive'), @()),
@(@('', '--color'), @('never', 'auto', 'always', 'ansi')),
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / perfer_dGPU.cpp
Created June 29, 2017 07:26
enable NVidia Optimus & AMD PowerXpress
extern "C"
{
__declspec(dllexport) int NvOptimusEnablement = 1;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
param (
[Parameter(Mandatory=$true)][string]$Uri,
[string]$DownloadDir,
[string]$ExtractDir,
[string]$DownloadFilePath
)
$invocation_dir = Split-Path $MyInvocation.MyCommand.Path
$response = Invoke-WebRequest -Uri $Uri -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox
$response_path = $response.BaseResponse.ResponseUri.AbsolutePath.Split('/')
function Get-RegistryValue
{
param
(
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $Path,
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $Value
)
if (Test-Path $Path)
{
#ifndef ANONYMOUSPIPE__HPP__
#define ANONYMOUSPIPE__HPP__
#if !defined(_WINDOWS_) && !defined(__AFX_H__)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif
#include <cstdlib>
#include <cstdio>
#ifndef GETEXEMODULEPATH__HPP__
#define GETEXEMODULEPATH__HPP__
#if !defined(_WINDOWS_) && !defined(__AFX_H__)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif
#include <string>