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
public class Base64 | |
{ | |
public static String encode(byte[] data) | |
{ | |
char[] tbl = { | |
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', | |
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', | |
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', | |
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' }; |
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
// this has hacky support for swedish characters in utf8. | |
// i do not recommend this solution for any serious purposes. :) | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <wchar.h> | |
// convert a twobyte utf8 character into a single integer | |
#define MB(str) (((str[0] & 0xFF) << 8) | (str[1] & 0xFF)) |
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> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef struct word_ { | |
char *str; | |
int c; | |
struct word_ *next; | |
} word; |
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
import java.io.*; | |
import java.util.*; | |
public class wordcount | |
{ | |
public static class Word implements Comparable<Word> | |
{ | |
String word; | |
int count; |
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> | |
#include <stdlib.h> | |
#define FormatID 'fmt ' /* chunkID for Format Chunk. NOTE: There is a space at the end of this ID. */ | |
struct GlobalFormat { | |
unsigned int id; | |
unsigned int size; | |
unsigned int type; | |
}; |
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> | |
#include <math.h> | |
/* | |
The algorithm is: | |
d_i = (c mod 10^(i+1)) / 10^i | |
S = sum_{i=0}^{floor(log_10(c))+1} d_i = sum_{i=0}^{floor(log_10(c))+1} (c mod 10^(i+1)) / 10^i | |
Where c is the number in question, d_i is the digit at position i counted from the least significant digit | |
and S is the sum of the digits in the number. |
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> | |
#include <stdlib.h> | |
int expand(char *target, int size, char *format, char **params, int count) | |
{ | |
int i, placeholders = 0; | |
for (i = 0; i < strlen(format); i++) { | |
if (format[i] == '?') { | |
placeholders++; | |
} |
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> | |
#include <stdlib.h> | |
#include <string.h> | |
int explode(char*** ret, char* instr, char* delim) | |
{ | |
char* str = strdup(instr); | |
char** arr = (char**)malloc(sizeof(char*) * (strlen(instr)+1)); | |
int count = 0; |
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> | |
#include <stdlib.h> | |
#include <math.h> | |
struct GlobalFormat { | |
unsigned int id; | |
unsigned int size; | |
unsigned int type; | |
}; |
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> | |
#include <stdlib.h> | |
int main(int argc, char** argv) | |
{ | |
if (argc != 2) { | |
printf("usage: genprimes num\n"); | |
return 0; | |
} |
OlderNewer