This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import json | |
import sys | |
def configure_args(args): | |
parser = argparse.ArgumentParser( | |
usage="%(prog)s [--remove-pandas-kwargs | --add-pandas-kwargs] <filename>", | |
epilog="", | |
description="Updates Pywr model `pandas_kwargs` syntax. A new file containing updated syntax is created." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
#include <iomanip> | |
#include <numeric> | |
#include <cmath> | |
static const int PTERMS = 3; | |
/* Construct b vector of Ax=b */ | |
double *build_bproduct(const std::vector<double>& xs, const std::vector<double>& ys) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Second-degree polynomial fit of f(xseries) => yseries | |
by Choleskification and Ly=b, L^x=y | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
""" | |
# Test series: y=x^2 | |
xseries = [0, 0.5, 1.0, 1.5, 2.0, 2.5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function execPolyfill() { | |
(function(){ | |
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1. | |
/* | |
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | |
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | |
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def atan_ts(z): | |
""" ___ oo (-1)^2n+1 * x^(2n+1) | |
atan(z) = \ -------------------- | |
/__ n=0 2n+1 | |
""" | |
a = 0 | |
for n in range(17): | |
q = 2.0*n+1 | |
a += (-1)**n * z**q / q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Bitmap glyph-to-include codec | |
..####.. ..####.. | |
.#.##.#. .#.##.#. | |
##.##.## -d ##.##.## | |
######## => 60,90,219,255,129,66,60,0 ==> ######## | |
#......# #......# | |
.#....#. .#....#. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include "b64.h" | |
const char *const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
const char pad = '='; | |
char *b64_encode(const unsigned char *src, size_t src_len) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generates full set of planet names across all galaxies | |
in the Elite series of games. | |
Original name generation algorithm by David Braben and Ian Bell. | |
Leestian Evil Juice also to Christian Pinder and the Oolite crew. | |
Usage: | |
$ python ./elitenames.py <galaxy> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
class Parent(object): | |
def __init__(self): | |
self.children = [] | |
def addChild(self, child): | |
self.children.append(child) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Fixed out-of-scope SDL_Renderer*. Now compiles with | |
$CC sdl2_opengl.c -o sdl2_opengl -lSDL2 -lGL -lGLU | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> |