Skip to content

Instantly share code, notes, and snippets.

// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@sherief
sherief / gob.h
Created June 7, 2016 10:39 — forked from pervognsen/gob.h
gob.h
#pragma once
#include <stdint.h>
#pragma pack(push, 8)
#if __cplusplus >= 201103L || (__cplusplus && _MSC_VER >= 1900)
#define GOB_DISALLOW_COPYING(type) type(const type&) = delete;
#else
#define GOB_DISALLOW_COPYING(type)
@sherief
sherief / custom_iterator.cpp
Created January 18, 2018 13:42 — forked from jeetsukumaran/custom_iterator.cpp
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>
@sherief
sherief / gist:b1c47f2a7a015b622c3f15f8f85ac737
Created February 20, 2018 04:45 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@sherief
sherief / gist:616f43f97ce1c267cc0e77fafb1c792c
Created January 11, 2022 09:00 — forked from reidransom/gist:6033227
Configure Zeroconf on FreeBSD

Configure Zeroconf on FreeBSD

Install avahi-app and nss_mdns. Note: avahi-app is chosen over avahi because avahi depends on X11.

$ cd /usr/ports/net/avahi-app
$ sudo make config-recursive
$ sudo make install clean
$ cd /usr/ports/dns/nss_mdns
$ sudo make config-recursive

$ sudo make install clean

@sherief
sherief / Metacommands.txt
Created February 27, 2023 04:23 — forked from K0bin/Metacommands.txt
Nvidia D3D12 Metacommands
ID: 00007FFC8D287130
NAME: Conv (Convolution)
CREATION
NAME: InputResource
Type: GPU DESCRIPTOR HANDLE CBV SRV UAV
Input/Output:
STRUCTOFFSET: 0
NAME: FilterResource
// float->half variants.
// by Fabian "ryg" Giesen.
//
// I hereby place this code in the public domain, as per the terms of the
// CC0 license:
//
// https://creativecommons.org/publicdomain/zero/1.0/
//
// float_to_half_full: This is basically the ISPC stdlib code, except
// I preserve the sign of NaNs (any good reason not to?)
@sherief
sherief / SetMonitorPower.c
Created August 4, 2023 17:26 — forked from 3735943886/SetMonitorPower.c
Turn On / Off display monitor
/* dependencies */
#pragma comment(lib, "dxva2")
#pragma comment(lib, "user32")
#include <lowlevelmonitorconfigurationapi.h>
typedef struct _MONITORPOWERPARAM
{
LPCWSTR szPhysicalMonitorDescription;
BOOL bPowerOn;
} MONITOR_POWER_PARAM, *PMONITOR_POWER_PARAM;
using System.Windows.Automation;
// WINDOWS CREDENTIAL UI AUTOMATION by 3735943886
/*
Credential Dialog Xaml Host
- TextBlock / WindowLogo / 
- TextBlock / / Windows 보안
- Button / CloseButton / 닫기
- ScrollViewer / /
@sherief
sherief / SetDeviceState.c
Created August 4, 2023 17:27 — forked from 3735943886/SetDeviceState.c
Disable or Enable Device with Hardware ID
/* for Devpkey */
#define INITGUID
/* dependencies */
#pragma comment (lib, "SetupAPI")
#include <windows.h>
#include <SetupAPI.h>
#include <Devpkey.h>
VOID SetDeviceState(LPCWSTR lpszHardwareId, DWORD dwState)