This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void __debug(const char* fname, const char* format, ...) | |
{ | |
fprintf(stderr, "DEBUG: %s", fname); | |
va_list args; | |
va_start (args, format); | |
vfprintf (stderr, format, args); | |
va_end (args); | |
} | |
#define debug(format, ...) __debug(__func__, format, __VA_ARGS__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ascii whitespace: | |
* U+0009 | |
* U+000A | |
* U+000C | |
* U+000D | |
* U+0020 | |
*/ | |
/* | |
* code point, four-to-six hex chars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/stat.h> | |
/* | |
* memory allocation sub routine that DOES NOT fail | |
*/ | |
void* tryAllocate() | |
{ | |
void* buffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2015 Ryan McCullagh <me@ryanmccullagh.com> | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = "Sending: 6011 1234 4321 1234:12/2016:543.21:John Doe | |
Received: Mon Apr 27 18:07:22 CDT 2015: Discover: 6011 1234 4321 1234 is valid: authorization code: 472080 for $543.21"; | |
$a = preg_split("/\n/", $str); | |
array_shift($a); | |
$c = preg_match_all('/authorization\scode:\s[0-9]+/', $a[0], $matches); | |
$d = preg_split('/\n/', $matches[0][0]); | |
$e = explode(" ", $d[0]); | |
var_dump($e[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isWebScaleCapable() { | |
return true; | |
} | |
if(isWebScaleCapable()) { | |
INIT_WEB_SCALE(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void read_file(void) | |
{ | |
FILE* fp = fopen("a.dat", "rb"); | |
size_t bread = 0; | |
int data; | |
if(fp == NULL) { | |
fprintf(stderr, "Read error\n"); | |
exit(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
int main() | |
{ | |
int r[10]; | |
for(size_t i = 0; i < 10; i++) { | |
r[i] = i + 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stdio.h> | |
bool is_power_of_two(size_t); | |
int my_pop_count(size_t); | |
int main() | |
{ | |
size_t n = 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* return the Hamming Weight | |
*/ | |
int my_pop_count(size_t x) | |
{ | |
unsigned setBits = 0; | |
do { | |
int rem = x % 2; | |
if(rem == 1) { | |
setBits++; |