Skip to content

Instantly share code, notes, and snippets.

#!/bin/env python
# Loads the configuration
from ConfigParser import ConfigParser
class Configuration:
"""Convenience class to load our configuration file"""
__default_config_file = '/etc/wcm/wcm.ini'
class WCMFTPUser(Base):
"""WCM FTP Users table"""
__tablename__ = 'user'
username = Column(String(50), nullable=False, unique=True)
password = Column(String(255), nullable=False)
uid = Column(Integer, primary_key=True, nullable=False)
gid = Column(Integer, nullable=False)
homedir = Column(String(1024), nullable=False, default='/var/www/content')
shell = Column(String(255), nullable=False, default='/sbin/nologin')
@jrmoserbaltimore
jrmoserbaltimore / RoomObject.cs
Last active February 22, 2016 00:26
Horrendous code
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using BlackCore.GameWorld;
namespace BlackCore.GameWorld
{
@jrmoserbaltimore
jrmoserbaltimore / misread.cs
Created February 22, 2016 00:32
Ways to misread an if statement if you're blind and stupid
hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
hashOut.length = SSL_SHA1_DIGEST_LEN;
if ((err = SSLFreeBuffer(&hashCtx)) != 0)
goto fail;
if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
# Quick MariaDB container listening on localhost:3306
db:
image: mariadb:10.1
ports:
- localhost:3306:3306
volumes:
/opt/containers/mariadb/data/db:/var/lib/mysql
/opt/containers/mariadb/conf/mariadb/my.cnf:/etc/my.cnf:ro
restart: always
protected virtual void OrderVotes()
{
int priorValue = 0;
Votes.Sort();
/* One vote, always rank 1 */
if (Votes.Count >= 1 && Votes[0].Value != 1)
{
priorValue = Votes[0].Value;
Votes[0] = new Vote(Votes[0].Candidate, 1);
}
// Not valid
namespace Boilerplate
{
public boilerplate BCompareOperators<T>
{
bool operator >(T lhs, T rhs) => lhs.CompareTo(rhs) > 0;
bool operator <(T lhs, T rhs) => lhs.CompareTo(rhs) < 0;
bool operator >=(T lhs, T rhs) => lhs.CompareTo(rhs) >= 0;
bool operator <=(T lhs, T rhs) => lhs.CompareTo(rhs) <= 0;

Ordered preferences X≻A → if X is not a candidate, voter votes for A

14: Alex≻Bobbie≻Chris≻Dane  \
12: Bobbie≻Alex≻Chris≻Dane   | ← 51% majority, doesn't count.
25: Chris≻Bobbie≻Alex≻Dane  /
49: Dane≻Chris≻Bobbie≻Alex  ← Most votes, wins plurality

Instant runoff voting:

@jrmoserbaltimore
jrmoserbaltimore / arXiv-social-choice.md
Created May 31, 2021 18:01
Social choice theory papers on arXiv

These papers cover social choice, public choice, and voting theory. See the Handbook of Social Choice and Voting by Heckelman and Miller; or Collective Decisions and Voting by Nicolaus Tideman.

Voting rules and analysis

These are analyses of voting rules or other theoretical analysis independent of political conditions. This stretches as far as analyzing how and when voters behave strategically under particular systems, although that's more blurry.

@jrmoserbaltimore
jrmoserbaltimore / fm-step-by-step.md
Last active April 20, 2024 02:42
Step-by-step FM synthesis explanation

An attempt to explain step-by-step how FM synthesis calculation works.

OPL3

Using the OPL3 as an example, there are several components:

  • Vibrato feeds into the phase generator (PG) to modulate its frequency
  • Tremolo feeds into the envelope generator (EG) to modulate its amplitude
  • PG and EG feed into the operator
  • Operator outputs to the next operator