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
test=> select count(*) from orders; | |
count | |
--------- | |
1003116 | |
(1 row) | |
test=> select count(distinct articleid) from orders; | |
count | |
-------- | |
999921 |
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
package permutation | |
// Based on https://stackoverflow.com/a/30230552/14660 by Paul Hankin | |
// perm := NewPermutation( slice ) | |
// for next := perm.Next(); next != nil; next = perm.Next() { | |
// ... | |
// } | |
// | |
// or |
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
for i, j := 0, len(r)-1; | |
i < len(r)/2; | |
i, j = i+1, j-1 | |
{ | |
r[i], r[j] = r[j], r[i] | |
} | |
for i, j := 0, len(r)-1; | |
i < len(r)/2; | |
i, j = i+1, j-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 <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
char * strcat_ex( const char *s, ... ) | |
{ | |
if ( s == NULL ) { | |
return NULL; | |
} |
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 <string.h> | |
#include <stdlib.h> | |
int read_line_fgetc(FILE *fp, char *line, int line_size){ | |
int c; | |
int i = 0; | |
while( (c = fgetc(fp)) > 0) { | |
if( (char)c == '\n' ) { | |
break; |
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
/* See http://www.pcg-random.org/using-pcg-c-basic.html */ | |
#include "pcg_basic.h" | |
#include <stdio.h> | |
void try_random(unsigned int seed, int initseq) { | |
pcg32_random_t rng; | |
pcg32_srandom_r(&rng, seed, initseq); | |
printf("Seed: %u\n", seed); | |
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
t = Process.clock_gettime(Process::CLOCK_MONOTONIC); | |
puts "%10.10f" % t.prev_float; # 391942.2739719209 | |
puts "%10.10f" % t; # 391942.2739719210 | |
puts "%10.10f" % t.next_float; # 391942.2739719211 | |
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> | |
typedef struct date_t { | |
int year; int month; int day; | |
} date_t; | |
#define EPOCH 1970 | |
void date_convert(date_t* date, unsigned int days) { | |
int year = EPOCH, mo = 0, day = 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 <time.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#ifdef __MACH__ | |
#include <mach/mach_time.h> | |
#define CLOCK_REALTIME 0 | |
#define CLOCK_MONOTONIC 0 | |
int clock_gettime(int clk_id, struct timespec *t){ | |
mach_timebase_info_data_t timebase; |
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
(?:(?:(?:https?)://(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]*)))?(?:/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;/?:@&=+$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)|(?:(?:file)://(?:(?:(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z]))|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+))|localhost)?)(?:/(?:(?:(?:(?:[-a-zA-Z0-9$_.+!*'(),:@&=]|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:/(?:(?:[-a-zA-Z0-9$_.+!*'(),:@&=]|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)))))|(?:(?:nntp)://(?:(?:(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9] |
NewerOlder