Skip to content

Instantly share code, notes, and snippets.

View mpenick's full-sized avatar
🍵

Michael Penick mpenick

🍵
View GitHub Profile
@mpenick
mpenick / batch_perf.c
Created June 1, 2017 16:08
Performance test for batch regression
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
@mpenick
mpenick / alloc1.cpp
Created May 23, 2017 15:03
Overriding C++ Allocators
#include <new>
#include <iostream>
// Approach #1: Overload global operators
//
// Problem: Our allocator overrides/conflicts with the application's
// allocator when static linking.
void* operator new(size_t size) throw(std::bad_alloc) {
void* p = malloc(size);
@mpenick
mpenick / CMakeLists.txt
Last active August 23, 2018 07:07
PHP CLion CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(php_driver)
set(CMAKE_C_STANDARD 90)
include_directories(/usr/local/include)
include_directories(${CMAKE_SOURCE_DIR}/ext)
include_directories(${CMAKE_SOURCE_DIR}/ext/src/Cassandra)
include_directories(${CMAKE_SOURCE_DIR}/ext/utils)
include_directories(/usr/local/include/php/)
include_directories(/usr/local/include/php/main/)
include_directories(/usr/local/include/php/Zend/)
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
<?php
$cluster = Cassandra::cluster()
->build();
$session = $cluster->connect();
$session->execute("CREATE KEYSPACE IF NOT EXISTS test WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' }");
$session->execute(new Cassandra\SimpleStatement("CREATE TABLE IF NOT EXISTS test.test (key int PRIMARY KEY, value 'LexicalUUIDType')"));
$session->close();
<?php
$cluster = Cassandra::cluster()->build();
$connectionFuture = $cluster->connectAsync();
$session = $connectionFuture->get();
$schema = $session->schema();
foreach ($schema->keyspaces() as $keyspace) {
foreach ($keyspace->tables() as $table) {
foreach ($table->columns() as $column)
{ $column->type(); }
<?php
$cluster = Cassandra::cluster()->build();
$session = $cluster->connect();
$session->execute(new Cassandra\SimpleStatement(
"CREATE KEYSPACE IF NOT EXISTS simplex
WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' }"));
$session->execute(new Cassandra\SimpleStatement("USE simplex"));
#include <stdio.h>
#include <stdint.h>
void print(uint64_t value) {
printf("%llu\n", (unsigned long long)value);
}
int main() {
print(-1);
@mpenick
mpenick / mem_leak_prepared.c
Created January 25, 2017 01:20
CPP-363 - Reproduce memory leaks in schema metadata
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the