Skip to content

Instantly share code, notes, and snippets.

Don Cross cosinekitty

Block or report user

Report or block cosinekitty

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View quadinterp.py
#!/usr/bin/env python3
#
# quadinterp.py - by Don Cross - https://github.com/cosinekitty
#
# Sample code for finding approximate roots of
# an expensive function f(t) using quadratic interpolation.
# This source code is public domain. Use at your own risk.
#
import math
@cosinekitty
cosinekitty / quine.c
Created Nov 7, 2019
The working quine.
View quine.c
#include <stdio.h>
int main()
{
int i, k;
char s[] = {35,105,110,99,108,117,100,101,32,60,115,116,100,105,111,46,104,62,10,105,110,116,32,109,97,105,110,40,41,10,123,10,32,32,32,32,105,110,116,32,105,44,32,107,59,10,32,32,32,32,99,104,97,114,32,115,91,93,32,61,32,1,59,10,32,32,32,32,102,111,114,40,105,61,48,59,115,91,105,93,33,61,49,59,43,43,105,41,112,114,105,110,116,102,40,34,37,99,34,44,115,91,105,93,41,59,10,32,32,32,32,102,111,114,40,107,61,48,59,115,91,107,93,59,43,43,107,41,112,114,105,110,116,102,40,34,37,99,37,100,34,44,32,107,32,63,32,39,44,39,32,58,32,39,123,39,44,32,115,91,107,93,41,59,10,32,32,32,32,112,114,105,110,116,102,40,34,44,48,125,34,41,59,10,32,32,32,32,102,111,114,40,43,43,105,59,115,91,105,93,59,43,43,105,41,112,114,105,110,116,102,40,34,37,99,34,44,115,91,105,93,41,59,10,32,32,32,32,114,101,116,117,114,110,32,48,59,10,125,10,0};
for(i=0;s[i]!=1;++i)printf("%c",s[i]);
for(k=0;s[k];++k)printf("%c%d", k ? ',' : '{', s[k]);
printf(",0}");
for(++i;s[i];++i)printf("%
@cosinekitty
cosinekitty / factory.py
Created Nov 7, 2019
Program to translate raw quine template into working quine source code.
View factory.py
#!/usr/bin/env python3
with open('raw.c', 'rt') as infile:
raw = infile.read()
data = [('1' if c=='$' else str(ord(c))) for c in raw]
delim = raw.index('$')
quine = raw[:delim] + '{' + ','.join(data) + ',0}' + raw[delim+1:]
with open('quine.c', 'wt') as outfile:
@cosinekitty
cosinekitty / raw.c
Created Nov 7, 2019
A template for the quine
View raw.c
#include <stdio.h>
int main()
{
int i, k;
char s[] = $;
for(i=0;s[i]!=1;++i)printf("%c",s[i]);
for(k=0;s[k];++k)printf("%c%d", k ? ',' : '{', s[k]);
printf(",0}");
for(++i;s[i];++i)printf("%c",s[i]);
return 0;
@cosinekitty
cosinekitty / almost_quine_2.c
Created Nov 7, 2019
Trying to printf a printf, but still not a quine yet.
View almost_quine_2.c
#include <stdio.h>
int main()
{
printf("#include <stdio.h>\n");
printf("int main()\n");
printf("{\n");
printf(" printf(\"#include <stdio.h>\\n\");\n");
printf(" return 0;\n");
printf("}\n");
return 0;
View almost_quine.c
#include <stdio.h>
int main()
{
printf("#include <stdio.h>\n");
printf("int main()\n");
printf("{\n");
printf(" return 0;\n");
printf("}\n");
return 0;
}
@cosinekitty
cosinekitty / circle.py
Created Oct 16, 2019
Calculate 360 points equally spaced around a unit circle.
View circle.py
#!/usr/bin/env python3
import math
angle = math.radians(1)
a = math.cos(angle)
b = math.sin(angle)
x = 1.0
y = 0.0
for n in range(361):
print('{:3d} {:11.8f} {:11.8f}'.format(n, x, y))
You can’t perform that action at this time.