Skip to content

Instantly share code, notes, and snippets.

View Mononofu's full-sized avatar

Julian Schrittwieser Mononofu

View GitHub Profile
import socket
def clean_cards(line):
return line.split(":")[-1].strip().split(" ")
def decide(player_worth):
if player_worth < 18:
s.send("H\n")
/* in SessionImpl */
void SessionImpl::sendMessage(ByteSeq message, string chatID) {
auto server = getServerForChan(chatID);
/* user is the user this session belongs to */
server->sendMessage(user, message, chatID);
}
/* in our InterServerImpl */
void InterServerImpl::sendMessage(User sender, ByteSeq message, string chatID) {
#!/usr/bin/env python
'''
SecEnv InetSec
DH key exchange and encryption
Curtesy of your friendly neighbourhood WDE assitant.
Just remember: We Don't Exist!
'''
import java.awt.*; //Graphics2D, LinearGradientPaint, Point, Window, Window.Type;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import java.io.IOException;
/**
string ChatManager::newChat(){
Chat c;
c.name = "Chat"+(i++);
chats[c.name] = c;
return c.name;
}
@Mononofu
Mononofu / client.cpp
Created April 15, 2013 08:00
Networked multi-user chat with auto-reconnect.
#include "zmq.hpp"
#include <string>
#include <iostream>
#include <pthread.h>
using namespace std;
void *msg_routine(void *arg) {
zmq::socket_t *message_source = (zmq::socket_t *) arg;
@Mononofu
Mononofu / 1_usage.cpp
Last active March 24, 2017 01:35
Auto reloader for .qml files. If you change one of your .qml files, the View will automagically refresh to reflect the change. Note: Right now, the watch is not recursive, so only changes in top level files will cause a refresh. For a usage sample, check below.
int main() {
QApplication a(argc, argv);
QMainWindow *window = new QMainWindow();
QDeclarativeView *view = new QDeclarativeView(window);
FileWatcher watcher;
// assuming all .qml files are in ./ui
watcher.addWatch(view, "./ui/ui.qml");
watcher.start("./ui");
cmake_minimum_required(VERSION 2.6)
project(task1)
set(CMAKE_CXX_FLAGS "-g -Wall")
add_executable(sdc_client sdc_client.cpp)
target_link_libraries(sdc_client boost_program_options)
@Mononofu
Mononofu / merge.py
Created February 25, 2013 14:04
Merge two sorted arrays with no extra space. However, this runs in O(n^2) time.
#!/usr/bin/python
import random
try:
from termcolor import colored
except ImportError:
def colored(s, color):
return s
ERROR = 0
@Mononofu
Mononofu / build.sbt
Created February 21, 2013 09:21
Fails to compile with: /home/mononofu/tmp/minimal/minimal.scala:7: erroneous or inaccessible type [error] def plus(x: Measure[T],y: Measure[T]): Measure[T] = x + y
scalaVersion in ThisBuild := "2.10.0"
scalacOptions in ThisBuild += "-language:experimental.macros"
libraryDependencies in ThisBuild ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.10.0"
)