Skip to content

Instantly share code, notes, and snippets.

View pmelanson's full-sized avatar
💭
😠 rancorous

Patrick Melanson pmelanson

💭
😠 rancorous
  • Seattle, WA
View GitHub Profile
@pmelanson
pmelanson / weapondata-exporter.py
Last active September 12, 2022 22:36
Scrapes zomboid weapon.txt scripts, outputting a csv with specified fields
import os
import csv
import re
item_block_begin_pattern = re.compile(r"\sitem\s(\S+)")
item_block_end_pattern = re.compile(r"}")
weapon_info_line = re.compile(r"=\s+(.+?)\s*,")
fieldnames = [
'DisplayName',
'Weight',

Keybase proof

I hereby claim:

  • I am pmelanson on github.
  • I am pj2melan (https://keybase.io/pj2melan) on keybase.
  • I have a public key ASDfyzQR6IrXGIa3zMbzjUF6dEpqj_wakIv6NvuxTiE4YAo

To claim this, I am signing this object:

@pmelanson
pmelanson / gauss.rb
Last active August 29, 2015 14:14 — forked from trishume/gauss.rb
# Step-By-Step Gaussian Elimination on Augmented Matrices
# By Tristan Hume
require "rational"
def reduce_down(mat)
# Use each row going down to cancel lower rows
# Each iteration of this loop is one step
rows = mat.length
(0..rows-2).each do |ri1|
@pmelanson
pmelanson / sin_simpson.py
Last active February 10, 2020 19:31
Simpson's rule applied to sin(x), and also hardcoded
#!/bin/python
# Approximates the definite integral of sin(x) using Simpson's rule.
from math import pi,sin,cos
def simpson_approximation(a, b, n):
"Approximates the definite integral of sin(x) from a to b with respect to x with 'n' iterations"
dx = (b-a)/n
#include <iostream>
#include <vector>
#include <boost/intrusive/list.hpp>
using namespace std;
class entity_c : public boost::intrusive::list_base_hook<> {
public:
const int isconst;
int notconst;
#include <iostream>
using namespace std;
class object_c {
public:
int x,
y;
object_c(int X, int Y) : x (X), y (Y){}
@pmelanson
pmelanson / bum.hpp
Created December 14, 2012 01:12
how you should structure your program and stuff you can structure the files something like summative.cbp src (short for source) main.cpp class.cpp include (headers) summative.hpp class.hpp
#ifndef CLASS_HPP
#define CLASS_HPP //in codeblocks you can just type "guard" then press ctrl-j
#include <whatever>
//if you need another class that you've made, declare it like this
class ineeddis;
class bum {
private:
@pmelanson
pmelanson / con.cpp
Created December 14, 2012 00:29
dis be consurctor
class_c::class_c (int foo, char bar) : a (foo), b (bar) {
cout << a << "==" << foo << endl;
cout << b << "==" << bar << endl;
}
@pmelanson
pmelanson / eigen profile.cpp
Created December 12, 2012 04:22
dot product profiling, see bottom of file for execution speeds
#include "include/eigen/dense"
int main() {
const unsigned max = 86800;
// long double v[max][2];
// long double d[2] = {3.14159e5, 82.31283e3};
Eigen::Matrix<long double, 2, 1> v[max];
Eigen::Matrix<long double, 2, 1> d;
d(0,0) = 3.14159e5;