Skip to content

Instantly share code, notes, and snippets.

View sim642's full-sized avatar

Simmo Saan sim642

View GitHub Profile
from fractions import gcd
from random import randint
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)
@sim642
sim642 / simbot.js
Last active December 19, 2015 05:09
Source for simbot aka swagbot
var irc = require("irc");
var fs = require("fs");
var swag = {};
var cangive = {};
var cangive2 = {};
/*var regex = /^\s*([a-z_\-\[\]\\^{}|`][a-z0-9_\-\[\]\\^{}|`]*)[\s,:]*(\+\+|--)$/i*/
var regex = /^\s*([a-z_\-\[\]\\^{}|`][a-z0-9_\-\[\]\\^{}|`]*)[\s,:]*(\+\+)$/i
process.stdin.resume();
@sim642
sim642 / init.cpp
Last active December 13, 2015 20:48
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cctype>
using namespace std;
class Trie
{
@sim642
sim642 / delegate.hpp
Last active September 5, 2024 13:25
C++11 variadic template class for C# equivalent of delegates.
#ifndef DELEGATE_HPP_INCLUDED
#define DELEGATE_HPP_INCLUDED
#include <functional>
#include <vector>
// general case
template<typename R, typename... Args>
class delegate
{
@sim642
sim642 / gist:1213875
Created September 13, 2011 14:04
Input validation
#include <iostream>
#include <limits>
using namespace std;
template<typename T>
bool valid_input(istream &stream, T &value)
{
bool good = true;
#include <iostream>
#include <algorithm>
#include <ctime>
#include <boost/regex.hpp>
using namespace std;
int main()
{
srand(time(0));
#include "IpAddressControl.h"
#include <CommCtrl.h>
using namespace Goop;
IpAddressControl::IpAddressControl(Base *parent)
{
HINSTANCE instanceHandle = GetModuleHandle( NULL );
m_handle = (HWND)CreateWindowExW(0, WC_IPADDRESS, L"", WS_CHILD | WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, instanceHandle, 0);