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 multiplicate2($a, $b){ | |
printf("%16b x %b\n%16b\n", $a, $b, $a * $b); | |
} | |
function multiplicate($a, $b){ | |
printf("%1s %32d x %8d = %d\n", "", $a, $b, $a * $b); | |
printf("%1s %32b x %8b\n", "", $a, $b); |
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> | |
/* | |
* Base class. It defines int area() method. | |
* The class is abstract so we did not made constructor. | |
* Calling the area() method will probably core dump. | |
*/ |
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 | |
<? | |
error_reporting(E_ALL); | |
$a = 5 / 0; | |
var_dump($a); | |
<ctrl-d> |
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 <stdio.h> | |
#define MAX 2000000000 | |
//#define IMPL 0 | |
int do_loop(int max); | |
int main(){ | |
printf("%d\n", do_loop(MAX) ); |
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
var fs = require('fs'); | |
var Q = require("q"); | |
/* | |
Q.all( | |
[ | |
Q.ninvoke(fs, "readFile", "/etc/hosts", "utf8") | |
] | |
) | |
*/ |
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
gcc mmap_test.c -Wall | |
touch file.bin | |
./a.out | |
hexdump -C file.bin | |
./a.out Hello Sir | |
hexdump -C file.bin |
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> | |
size_t malloc_calc(size_t size){ | |
const size_t realloc_size = sizeof(void *) * 2; | |
const size_t realloc_add = sizeof(void *); | |
size_t newsize = size / realloc_size; | |
if (size % realloc_size) |
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 <malloc.h> | |
#include <stdio.h> | |
void test(size_t size){ | |
char *a = new char[size]; //malloc(size); | |
size_t usize = malloc_usable_size(a); | |
printf("%5zu %5zu %5zu\n", size, usize, usize - size); |
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 "string.h" | |
const char *String::__NULLSTR = ""; | |
// ============================== | |
String::String(const char *s){ | |
if (s == nullptr){ | |
_terminator = TERM_LOCAL; | |
_buff.local[0] = '\0'; // the NULL terminator. |
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 <queue> | |
#include <vector> | |
#include <iostream> | |
struct comparator{ | |
bool operator()(int a, int b) const{ | |
return a > b; | |
} | |
}; |
OlderNewer