Skip to content

Instantly share code, notes, and snippets.

View andrewljohnson's full-sized avatar

Andrew L. Johnson andrewljohnson

View GitHub Profile
View parse_magiccon.py
from bs4 import BeautifulSoup
import pandas as pd
with open('magiccon.html', 'r', encoding='utf-8') as file:
html_data = file.read()
soup = BeautifulSoup(html_data, 'html.parser')
# Initialize lists to store data
data = {
'Title': [],
View finetg.py
from segments.huggingface import release2dataset
from segments import SegmentsClient
dataset_identifier = "andrewljohnson/magic_cards"
release_name = "v0.1"
api_key = "HIDDEN"
client = SegmentsClient(api_key) # this is different from blog, blog seemed outdated
release = client.get_release(dataset_identifier, release_name)
hf_dataset = release2dataset(release)
from segments.utils import get_semantic_bitmap
View groupdefenderscommentsanditerators.cpp
/*
Print out all ways for attackers to be blocked. blockAssignments maps ids of attackers to
vectors of defender ids for which blocks have already been chosen. defenders/defendersIterator specify
defenders that could block any of the attackers. This method iterates over all ways to choose blocks for
the remaining defenders.
example input: groupDefenders({0:[2 3] 1:[4 5]}, [6 7 8 9], 3)
output:
View groupdefenders.cpp
/*
This method prints all possible blocks, recursively.
For example, if you have blockers A & B, and attacker C, there are three posible blocks.
No blockers:
A:
B:
C blocks A:
View group_defenders.cpp
void groupDefenders(vector<vector<int>> attackers, vector<int> defenders, int i) {
int x = 0;
for (vector<int> attackerBucket:attackers) {
cout << x << ": ";
for (int defender:attackerBucket) {
cout << defender << " ";
}
cout << "\n";
x+= 1;
}
View alpha_magic.cpp
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Current Cards
// Mountain
// Future Cards
View alpha_magic_40_scratch.cpp
#include <iostream>
using namespace std;
// Current Cards
// Mountain
// Future Cards
// Forest
// Lightning Bolt, Giant Growth, Earthquake
View model.py
import datetime
import math
import numpy as np
import pandas as pd
import pickle
import time
from django.db.models.functions import Cast
from django.db.models import IntegerField
from real_estate.models import AnalysisRecord
View gist:dcc5b594b34c559f2b37bd3ccf50f6f9
root@8e3b54c9c353:/code# python manage.py shell < real_estate/scripts/generate_neural_net.py
fetching AnalysisRecords took 0.0015206336975097656
Fetched 47555 records for properties.
2183530944 - Hashing AnalysisRecords took 3.006469964981079
annotating years and months took 3.25303053855896
making value map took 36.68412470817566
Using 47550 properties for analysis.
4202095867 - data_hash
4036931971 - value_map_hash
making model took 0.8455119132995605
View gist:05503a0aede4a511c7259e42392229dd
root@8e3b54c9c353:/code# python manage.py shell < real_estate/scripts/generate_neural_net.py
fetching AnalysisRecords took 0.0015499591827392578
Fetched 15577 records for properties.
annotating years and months took 1.1473767757415771
making value map took 11.682528972625732
Using 15573 properties for analysis.
making model took 0.3301811218261719
Model: "model"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to