Skip to content

Instantly share code, notes, and snippets.

@mdadams
mdadams / access_to_private_members_1.cpp
Created February 2, 2017 01:40
An example of private member access without friendship in C++
// This example is a variation on the code posted by Dave Abrahams at:
// https://gist.github.com/1528856.
#include <iostream>
template <typename Tag>
typename Tag::type saved_private_v;
template <typename Tag, typename Tag::type x>
bool save_private_v = (saved_private_v<Tag> = x);
@zecode
zecode / README.txt
Last active December 15, 2015 20:19
'Do Not Commit' subversion pre-commit hook.
'Do Not Commit' subversion pre-commit hook.
Concept. Sometimes to accelerate development I change production code from "const int CooldownMls = 5000;" to "const int CooldownMls = 0; // dnc"
Another example can be hardcoding db url to localhost like: $conn = createConn('127.1'); // dnc
Notice 'dnc' tag. It prevents the file from accidental commit. My svn repo rejects text files with such tag inside.
Installation.
1. Copy files to $REPOS/hooks
3. Then chmod +x both.
@adamgit
adamgit / .gitignore
Last active April 8, 2024 12:58
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@dabrahams
dabrahams / private_access.cpp
Created December 28, 2011 17:50
Accessing Private Data
#include <iostream>
// This is a rewrite and analysis of the technique in this article:
// http://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.html
// ------- Framework -------
// The little library required to work this magic
// Generate a static data member of type Tag::type in which to store
// the address of a private member. It is crucial that Tag does not