Skip to content

Instantly share code, notes, and snippets.

View cwfitzgerald's full-sized avatar
🚀
wgpu is dope, though I'm biased

Connor Fitzgerald cwfitzgerald

🚀
wgpu is dope, though I'm biased
View GitHub Profile
@cwfitzgerald
cwfitzgerald / Hangman.py
Last active July 14, 2023 16:33
Python based hangman. Made in Python 2.7.9 and tested on a Windows 7 machine. The word list at the bottom is the 10000 most common words in the English language (Original list was 1000, this is only 3 letters or above).
import random
import os
char_left = -1
def render(self, choosen):
os.system('cls' if os.name == 'nt' else 'clear')
## All credit for these little pictures is to reddit user Magical Pop. Kudos to him! (He made a good version of this too!)
import math,decimal, os, time, cProfile, multiprocessing
from decimal import Decimal as large
## Simple Libnitz forumla pi calculation SigFig=15
def additivecalc(nlim):
pi = float(0)
while n < xrange(nlim):
pi += float(((-1)**n)*4) / float(2*n + 1)
return pi
@cwfitzgerald
cwfitzgerald / Rule90OpenCLSerpinki.py
Last active September 13, 2015 21:54
OpenCL Implimentation of Rule90 making a Serpinki Triangle
# Call this with arguments of size, and the name of the png file of the result
# eg. python Rule90OpenCLSerpinki.py 1000 rule90serpinki.png
# Needs PyOpenCL, Numpy, and MatPlotLib
from time import time
timer = time()
import pyopencl as cl
from pyopencl import array
import numpy as np
from sys import argv
@cwfitzgerald
cwfitzgerald / ipsort.py
Created December 19, 2015 06:42
Daily Programmer #245 Hard - Python Solution
import numpy as np
import time
from collections import Counter
from numba import jit
def to_int(ip_str):
ip = map(int, ip_str.strip().split("."))
return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + (ip[3])
$ cmake -DCC=/mingw64/bin/gcc.exe -DCXX=/mingw64/bin/g++.exe ../llvm -G "MSYS Makefiles" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 6.1.0
-- The CXX compiler identification is GNU 6.1.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
Determining if the include file dlfcn.h exists failed with the following output:
Change Dir: C:/llvm/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/msys64/mingw64/bin/make.exe" "cmTC_da95a/fast"
C:/msys64/mingw64/bin/make.exe -f CMakeFiles/cmTC_da95a.dir/build.make CMakeFiles/cmTC_da95a.dir/build
make.exe[1]: Entering directory 'C:/llvm/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_da95a.dir/CheckIncludeFile.c.obj
./dataBlueprint.cpp: In constructor 'shaderUtils::dataBlueprint::dataBlueprint(std::vector<std::__cxx11::basic_string<char> >)':
./dataBlueprint.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < format.size(); ++i) {
~~^~~~~~~~~~~~~~~
./Drawable.cpp: In constructor 'Drawable::Drawable()':
./Drawable.cpp:10:26: warning: pure virtual 'virtual int& Drawable::getInstanceCount()' called from constructor
if (getInstanceCount() == 0) {
^
./Drawable.cpp:12:26: warning: pure virtual 'virtual int& Drawable::getInstanceCount()' called from constructor
getInstanceCount() += 1;
#include <tmmintrin.h>
#include <immintrin.h>
#include <smmintrin.h>
void Fpt3::FastNormalize() {
__m128 inputs = _mm_setr_ps(x, y, z, 0);
__m128 squared = _mm_mul_ps(inputs, inputs);
__m128 sum;
#ifdef __SSE3__
sum = _mm_hadd_ps(squared, squared);
class Fpt3Container {
private:
std::vector<float> x;
std::vector<float> y;
std::vector<float> z;
public:
Fpt3Container(std::vector<Fpt3>& val) {
x.reserve(val.size());
y.reserve(val.size());
@cwfitzgerald
cwfitzgerald / pow.hpp
Last active October 20, 2016 02:10
A power function using polynomials
#include <cinttypes>
#include <cmath>
#include <limits>
// Various magic numbers for functions
namespace magic_numbers {
// Coefficients for polynomial to approximate log(x)
constexpr static float logc0 = -2.4204054330123117482f;
constexpr static float logc1 = 5.8848619015611924602f;
constexpr static float logc2 = -7.4051206397067798695f;