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 <stdint.h> | |
#include <stdlib.h> | |
uint32_t tiny_rand(void) | |
{ | |
uint32_t t = _seed; | |
t ^= t >> 10; | |
t ^= t << 9; | |
t ^= t >> 25; |
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
WITH RECURSIVE t(x) AS (SELECT 0 UNION ALL SELECT x + 1 FROM t LIMIT 8 * 16) | |
SELECT group_concat(substr('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | |
abs(random()%(62))+1,1), '') | |
AS PASSWORD FROM t GROUP BY x % 16; |
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
#ifndef __VECTOR | |
#define __VECTOR(SZ) __attribute__ ((vector_size (SZ))) | |
#endif | |
typedef uint8_t u16x4_t __VECTOR(4); | |
typedef uint16_t u16x2_t __VECTOR(4); | |
typedef uint8_t u8x8_t __VECTOR(8); | |
typedef uint16_t u16x4_t __VECTOR(8); | |
typedef uint32_t u32x2_t __VECTOR(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
// (T)ype, (V)ariable, (S)ection, (F)ile. | |
#define INCBIN(T,V,S,F) \ | |
asm \ | |
( \ | |
".globl " #V "\n" \ | |
".section \"" S "\",\"a\"\n" \ | |
".balign 4\n" #V ":\n" \ | |
".incbin \"" F "\"\n" \ | |
); extern T V[] |
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
#ifndef _MISC_MACROS_H_ | |
#define _MISC_MACROS_H_ | |
#define _SET_BIT(V,B) (V) |= (1 << (B)) | |
#define _CLR_BIT(V,B) (V) &= ~(1 << (B)) | |
#define _INV_BIT(V,B) (V) ^= (1 << (B)) | |
#define NIBBLE_PAIR(LN,HN) (((LN) << 0) | ((HN) << 4)) | |
#define PRINT_TYPE_SZ(T) printf("sizeof(%s)=%u\n", #T, sizeof(T)) |
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
#ifndef SDCC_ZX_H | |
#define SDCC_ZX_H | |
#include <stdint.h> | |
// ### __z88dk_fastcall call convention in SDCC ### | |
// 32 bit: input - DEHL, output - DEHL. | |
// 16 bit: input - HL, output - HL. | |
// 8 bit: input - L, output - L. |
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
The trick is to read the declaration backwards (right-to-left): | |
const int a = 1; // read as "a is an integer which is constant" | |
int const a = 1; // read as "a is a constant integer" | |
Both are the same thing. Therefore: | |
a = 2; // Can't do because a is constant | |
The reading backwards trick especially comes in handy when you're dealing with more complex declarations such as: | |
const char *s; // read as "s is a pointer to a char that is constant" |
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
#define REV8(V) ((((V) & 0x01) << 7) | \ | |
(((V) & 0x02) << 5) | \ | |
(((V) & 0x04) << 3) | \ | |
(((V) & 0x08) << 1) | \ | |
(((V) & 0x10) >> 1) | \ | |
(((V) & 0x20) >> 3) | \ | |
(((V) & 0x40) >> 5) | \ | |
(((V) & 0x80) >> 7)) |
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 <conio.h> | |
void plot(int x, int y, int c) | |
{ | |
gotoxy(x+1,y+1); | |
putchar(c); | |
putchar(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
using System; | |
using System.Text; | |
namespace System.IO | |
{ | |
internal class ReadLinesIterator : Iterator<string> | |
{ | |
private readonly string _path; | |
private readonly Encoding _encoding; |