Skip to content

Instantly share code, notes, and snippets.

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);
}
# 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
@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;
@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
{
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')
#!/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'
if date <= x.lastplay:
if verbose:
print 'Current date is not newer than logged!'
if force:
print 'Forcing anyway.'
else
print 'Skipping entry.'
if not force:
session.rollback()
continue
#!/bin/env python
import pyawk
pa = pyawk.Awk(fs='\w+')
def cpu_num(pa):
pa.global[numprocs] = int(pa.field[3])
def cpu_end(pa):
httpd -fstype=nfs,soft,tcp,vers=3,fsc,intr,nolock web-storage:/web/httpd
@jrmoserbaltimore
jrmoserbaltimore / python.md
Last active December 15, 2015 11:09
Fixing the python docs

Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of dotted module names saves the authors of multi-module packages like NumPy or the Python Imaging Library from having to worry about each other’s module names.

Suppose you want to design a collection of modules (a “package”) for the uniform handling of sound files and sound data. There are many different sound file formats (usually recognized by their extension, for example: .wav, .aiff, .au), so you may need to create and maintain a growing collection of modules for the conversion between the various file formats. There are also many different operations you might want to perform on sound data (such as mixing, adding echo, applying an equalizer function, creating an artificial stereo effect), so