Skip to content

Instantly share code, notes, and snippets.

View JossWhittle's full-sized avatar
😸

Joss Whittle JossWhittle

😸
View GitHub Profile
#include "FImage.hpp"
using namespace CR;
// Constructor
FImage::FImage() {};
FImage::FImage(int w, int h) {
Constructor(w, h);
};
module drawtext(text) {
//Characters
chars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}";
//Chracter table defining 5x7 characters
//Adapted from: http://www.geocities.com/dinceraydin/djlcdsim/chartable.js
char_table = [ [ 0, 0, 0, 0, 0, 0, 0],
[ 4, 0, 4, 4, 4, 4, 4],
[ 0, 0, 0, 0,10,10,10],
[10,10,31,10,31,10,10],
#include "DRand.hpp"
#define RAND48_SEED_0 (0x330e)
#define RAND48_SEED_1 (0xabcd)
#define RAND48_SEED_2 (0x1234)
#define RAND48_MULT_0 (0xe66d)
#define RAND48_MULT_1 (0xdeec)
#define RAND48_MULT_2 (0x0005)
#define RAND48_ADD (0x000b)
len = 30;
%GRID = int8(rand(len,len));
% Diehard
GRID = int8(zeros(len,len));
GRID(10,10:11) = 1;
GRID(11,11) = 1;
GRID(11,15:17) = 1;
GRID(9,16) = 1;
#include <cstdio>
// C-Quine
int main() {
char *s = "#include <cstdio>%c// C-Quine%cint main() {%c char *s = %c%s%c;%c printf(s, 0x0a, 0x0a, 0x0a, 0x22, s, 0x22, 0x0a, 0x0a, 0x0a);%c return 1;%c};";
printf(s, 0x0a, 0x0a, 0x0a, 0x22, s, 0x22, 0x0a, 0x0a, 0x0a);
return 1;
};
#include <cstdio>
#include <omp.h>
#include <cassert>
using namespace std;
constexpr int T_SIZE = 1e8;
// Bitwise operator based function to check multiple of 9
bool isMulOf9(int n) {
void glPrintString(void *font, const char *str) {
int len, i;
len = (int)strlen(str);
for (i = 0; i < len; i++) {
glutBitmapCharacter(font, str[i]);
}
}
void glPrintString(int x, int y, std::string str) {
struct Pixel {
Colour val;
real_t cnt;
// Stats on Luminance
real_t mean, var, skew, kurtosis, m2, m3, m4;
inline void add(const Colour &col) {
val = val + ((col - val) / ++cnt);
@JossWhittle
JossWhittle / DNListRenderer.java
Created July 6, 2012 18:23
Source Code for Course-Selector
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JList;
import javax.swing.JPanel;
@JossWhittle
JossWhittle / script_builder.php
Created July 7, 2012 23:51
A PHP function for simultaneously building 'flat' (hardcoded) RSS, Atom, and Sitemap XMLs...
<?php
// Called after an insertion or update to the `posts` table
// Returns void
function writeScripts() {
$atom_date = getDateRFC(getD()); // Current Date 3339 for Atom feed
$site_date = getDateSite(getD()); // Current Date YYYY-MM-DD for Sitemap
// Beginning of Atom.xml
$atom_str = '<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">