Skip to content

Instantly share code, notes, and snippets.

View braz's full-sized avatar

Eoin Brazil braz

View GitHub Profile
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
BsonSerializer.RegisterSerializer(new DecimalSerializer(BsonType.Decimal128));
var settings = MongoClientSettings.FromConnectionString("");
var client = new MongoClient(settings);
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mdbu</groupId>
<artifactId>curriculum</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync -->
<dependency>
[program:code-server]
command = code-server workspace /app --user-data-dir /app/user-data --auth none --disable-telemetry
stdout_events_enabled = true
stderr_events_enabled = true
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
@braz
braz / gist:ef61902d12e75d8d5043e69020d2eb45
Created September 14, 2021 10:04
Cleanup local branches in Git no longer present remotely
$ ~/.gitconfig
[alias]
janitor = !"git remote prune origin ; git branch -vv | grep ' gone]' | awk '{print $1}' | xargs git branch -D"
Run using
$ git janitor
@braz
braz / requirements.txt
Created February 26, 2020 11:30
Gist for Python ML environment setup/configuration.
cycler==0.10.0
dnspython==1.16.0
flatten-json==0.1.7
joblib==0.14.1
kiwisolver==1.1.0
matplotlib==3.1.3
mlxtend==0.17.2
numpy==1.18.1
pandas==1.0.1
pprint==0.1
@braz
braz / SaveModelToGridFS.py
Created February 28, 2019 15:40
Simple example for saving the model to GridFS
import datetime
import gridfs
import pickle
import pymongo
from bson.binary import Binary
# Copy and paste the model here from https://gist.github.com/braz/8a65ffc359fd9f208c1e8ca64b7dfac3
model_name = str(type(model))
@braz
braz / plot_red_wine_quality_linear_regression.py
Last active February 27, 2019 16:47
Python plotting of "Vinho Verde" red wine dataset for linear regression
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
# URL for the Wine Quality Portuguese "Vinho Verde" red wine dataset (UCI Machine Learning Repository)
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv"
# download the file
try:
@braz
braz / tenfold_testtrain_data_example.py
Last active February 27, 2019 10:56
Example of kFold (10) for training and for test data
import numpy as np
from sklearn.model_selection import KFold
X = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
kf = KFold(n_splits=10)
for train, test in kf.split(X):
print("%s %s" % (train, test))
@braz
braz / plot_linearreg_iris_1.py
Created February 26, 2019 15:31
Linear regression plotting against Iris data
import urllib
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# URL for the Iris dataset (UCI Machine Learning Repository)
url = "http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
raw_data = urllib.urlopen(url)