Skip to content

Instantly share code, notes, and snippets.

@okumura
okumura / NULL definition on FreeBSD
Created March 10, 2011 12:33
NULL definition on FreeBSD
#ifndef NULL
#if !defined(__cplusplus)
#define NULL ((void *) 0)
#else
#if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
#define NULL __null
#else
#if defined(__LP64__)
#define NULL (0L)
#else
@okumura
okumura / NULL definition on Darwin
Created March 10, 2011 12:34
NULL definition on Darwin
#ifdef __cplusplus
#ifdef __GNUG__
#define __DARWIN_NULL __null
#else /* ! __GNUG__ */
#ifdef __LP64__
#define __DARWIN_NULL (0L)
#else /* !__LP64__ */
#define __DARWIN_NULL 0
#endif /* __LP64__ */
#endif /* __GNUG__ */
@okumura
okumura / NULL definition on Visual Studio 2005 stdio.h
Created March 10, 2011 12:40
NULL definition on Visual Studio 2005 stdio.h
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
@okumura
okumura / NULL definition on Windows SDK v7.1 windef.h
Created March 10, 2011 12:42
NULL definition on Windows SDK v7.1 windef.h
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
@okumura
okumura / git export
Created March 11, 2011 21:53
git export
git checkout-index -a -f --prefix=export/
@okumura
okumura / OpenSSL initialization
Created March 11, 2011 22:24
OpenSSL initialization
SSL_library_init();
SSL_load_error_strings();
RAND_poll();
while (RAND_status() == 0) {
unsigned short rand_ret = rand() % 65536;
RAND_seed(&rand_ret, sizeof(rand_ret));
}
@okumura
okumura / OpenSSL finalization
Created March 11, 2011 22:24
OpenSSL finalization
#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
#endif
CRYPTO_cleanup_all_ex_data();
ERR_free_strings();
ERR_remove_state(0);
EVP_cleanup();
@okumura
okumura / Create NSWindow Programatically
Created July 14, 2013 06:42
Create NSWindow Programatically
// init window.
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
// configure window.
[window setLevel:NSPopUpMenuWindowLevel];
[window setHasShadow:NO];
@okumura
okumura / Get Stack Trace to String by Java.
Created July 19, 2013 06:03
Get Stack Trace to String by Java.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
new Throwable().printStackTrace(pw);
String stackTraceString = sw.toString();
# .ssh/config
Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh_github/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes