Skip to content

Instantly share code, notes, and snippets.

// 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;
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