Skip to content

Instantly share code, notes, and snippets.

-- Previous tables before this simply included members, events, projects and the auxiliaries.
-- I'm beginning to consider migrating this database from SQLite3 to MySQL 5.x
CREATE TABLE IF NOT EXISTS member_teams {
member_id INTEGER NOT NULL,
team_id INTEGER NOT NULL,
PRIMARY KEY (member_id, team_id),
FOREIGN KEY (member_id) REFERENCES members (member_id),
FOREIGN KEY (team_id) REFERENCES teams (team_id)
}
@Hydrotoast
Hydrotoast / AdversarialSearchAI.java
Last active December 10, 2015 15:18
An pseudocode AI demonstrating the Minimax algorithm. Note that the algorithm has two helper functions: min and max.
class AdversarialSearchAI {
private PieceType piece;
public AdversarialSearchAI(PieceType piece) {
this.piece = piece;
}
/**
* Returns the best move given the state of the game
*/
function GroupMining() {
this.member_ids = [];
this.semaphore = 0;
this.groupsCount = 1;
}
GroupMining.prototype = {
unlock: function() {
if (++(this.semaphore) === this.groupsCount) {
resultStr = this.member_ids.join(',');
function GroupInvitations() {
this.event_id = 517949684905901;
this.member_ids = [];
this.semaphore = 0;
}
GroupInvitations.prototype = {
unlock: function() {
if (++(this.semaphore) === 3) {
resultStr = this.member_ids.join(',');
#include <iostream>
#include "emmintrin.h"
using namespace std;
int main(int argc, char* argv[]) {
const LENGTH = 1 << 10;
const SSE_LENGTH = LENGTH >> 2;
// Set constant vectors
@Hydrotoast
Hydrotoast / ChristmasTree.py
Created December 14, 2012 04:22
Creates a simple christmas tree.
def CreateTree(half_width):
for i in range(half_width):
print(' ' * (half_width - i), '*' * (2 * i - 1))
for i in range(half_width >> 2):
print(' ' * (half_width - 1), '+')
# CreateTree(6)
# *
# ***
# *****
@Hydrotoast
Hydrotoast / gist:4257243
Created December 11, 2012 09:14
Linear Classification
LinearClassify(w, b, x):
""" Computes a class of a two-class classifier using an n - 1 dimensional hyperplane """
dot_product = sum(i * j for i, j in zip(w, x))
if dot_product > b:
return 1
else:
return 0
@Hydrotoast
Hydrotoast / Output
Created December 9, 2012 14:19
Simple C++ Unit Tester
Sorted List Tests Running
=========================
canAdd SUCCESS
canIterate SUCCESS
canClear SUCCESS
canPrintReverse SUCCESS
canPrintStrings SUCCESS
canCopy SUCCESS
canAssign SUCCESS
@Hydrotoast
Hydrotoast / gist:4243800
Created December 9, 2012 07:34
Anticipated Game Loop
CppCKPlayer player = new CppCKPlayer(dllNameStr, playerInt, BoardModel model);
while (!game.isEnd()) {
// Opponent makes a move
Cell cell;
cell.row = opponentMove.row;
cell.col = opponentMove.col;
Mark m = (opponentMove.mark == 'X') ? Mark.A : Mark.B;
player.updateBoard(cell, mark);
Cell c = player.getMove();
@Hydrotoast
Hydrotoast / gist:4188102
Created December 2, 2012 10:32
FriendZoneAlgorithm
def analyze(other, weights):
return reduce(lamda base, items: base + items[0] * items[1], zip(other, weights), 0)
def friend_zone(other):
friend_zone_dict[other] = True
def FriendZone():
while date_is_ongoing:
certainty_of_others_feelings_of_me = analyze(other)
if certainty_of_others_feelings_of_me >= threshold_of_romantic_felings: