Skip to content

Instantly share code, notes, and snippets.

View JAChapmanII's full-sized avatar

Jeff Chapman II JAChapmanII

View GitHub Profile
@JAChapmanII
JAChapmanII / universe.c
Created August 10, 2012 21:10
models of the universe
// an int completely represents the state of the universe, position of all particles, velocities, whatever is needed to perfectly recreate it exactly.
// strictly deterministic
int sd_step(int currentUniverse) {
return currentUniverse + 2; // magical constant
}
void sd_universe() {
int universe = 0;
while(true) {
#!/bin/bash
print=0
while read line; do
echo "CERR: $line" 1>&2
if [[ "$(echo $line | cut -d':' -f3)" == "opencyc_jac" ]]; then
echo "CERR: to cyc: $(echo "$line" | cut -d':' -f4-)" 1>&2
echo "$line" | cut -d':' -f4-
fi
done | ./run-cyc.sh | while read oline; do
@JAChapmanII
JAChapmanII / map_iterator.h
Created September 11, 2012 00:06
vmap from current c_map
#ifndef MAP_ITERATOR_H
#define MAP_ITERATOR_H
// Various locations an iterator can be at currently
typedef enum { IT_BEGIN, IT_END, IT_NODE, IT_INVALID } IteratorType;
#endif /* MAP_ITERATOR_H */
@JAChapmanII
JAChapmanII / pow!
Created September 16, 2012 00:17 — forked from anonymous/pow!
/* index of po2 works as follows:
po2[0] is base ^ 2^0
po2[1] is base ^ 2^1
po2[2] is base ^ 2^2
...
po[i] is base ^ 2^i
*/
int power(int base, int exp) {
int n = (exp+1)/2;
@JAChapmanII
JAChapmanII / decode.c
Created September 25, 2012 00:42
decode block code
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
int decodeString(char *str) {
int res = 0, p10 = 1;
for(ssize_t i = strlen(str) - 1; i >= 0; --i)
res += (str[i] - '0') * p10, p10 *= 10;
return res;
}
@JAChapmanII
JAChapmanII / integer.h
Created September 25, 2012 17:41
integer.h
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "gmp.h"
#define positive true
#define negative false
#define byte uint8_t
@JAChapmanII
JAChapmanII / read.c
Created September 25, 2012 21:30
read a file character by character
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char **argv) {
char *fileName = argv[1];
FILE *file = fopen(fileName, "r");
char c;
while(true) {
int ret = fscanf(file, "%c", &c);
if(ret == EOF || feof(file))
>>+++++++>>++>>++++>>+++++++>>+>>++++>>+>>+++>>+>>+++++>>+>>++>>+>>++++++>>++>>++++>>+++++++>>+>>+++++>>++>>+>>+>>++++>>+++++++>>+>>+++++>>+>>+>>+>>++++>>+++++++>>+>>+++++>>++++++++++++++>>+>>+>>++++>>+++++++>>+>>+++++>>++>>+>>+>>++++>>+++++++>>+>>+++++>>+++++++++++++++++++++++++++++>>+>>+>>++++>>+++++++>>+>>+++++>>++>>+>>+>>+++++>>+>>++++++>>+>>++>>+>>++++++>>+>>++>>+>>++++++>>+>>++>>+>>++++++>>+>>++>>+>>++++++>>+>>++>>+>>
@JAChapmanII
JAChapmanII / irc_log awful
Created November 30, 2012 23:33
irc_log awful
JOIN #uakroncs
:[email protected] JOIN :#uakroncs
:concrete.slashnet.org 332 jjjjjjjj #uakroncs :http://acm.cs.uakron.edu | ACM General Assembly Meetings Wednesday @ 4:15PM in CAS 254 | Accepting Donations for Child's Play 2012 : http://acm.cs.uakron.edu/childsplay
:concrete.slashnet.org 333 jjjjjjjj #uakroncs Nybbles 1353902680
:concrete.slashnet.org 353 jjjjjjjj = #uakroncs :jjjjjjjj DrChickenSalad42 apajx EArndt zb3 DrChickenSalad Pinky2 rublets Octet omalley phuzion sam @Nybbles +tm258 relrod ajanata @jac zok
:concrete.slashnet.org 366 jjjjjjjj #uakroncs :End of /NAMES list.
NAMES #uakroncs
:concrete.slashnet.org 353 jjjjjjjj = #uakroncs :jjjjjjjj DrChickenSalad42 apajx EArndt zb3 DrChickenSalad Pinky2 rublets Octet omalley phuzion sam @Nybbles +tm258 relrod ajanata @jac zok
:concrete.slashnet.org 366 jjjjjjjj #uakroncs :End of /NAMES list.
!push/azn/([b-df-hj-mp-tv-z])([^a-zA-Z]|$)/\1u\2/
!push/azn/([B-DF-HJ-MP-TV-Z])([^A-Za-z]|$)/\1U\2/
!push/desu/(\S+)/desu/
!push/cthulhu/[oe]/f'th/
!push/cthulhu/[ia]/gh/
!push/2012/.+/HERP DERP, END OF THE WORLD!
!push/2109/(\S+)/sustainable
!push/2ref/.*(\S+)$/STOUT SHAKO FOR TWO \U\1!
!push/amperdesert/./&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
!push/awyeah/(\S+)/*thrust*