Skip to content

Instantly share code, notes, and snippets.

View sim642's full-sized avatar

Simmo Saan sim642

View GitHub Profile
#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);
#include <iostream>
#include <algorithm>
#include <ctime>
#include <boost/regex.hpp>
using namespace std;
int main()
{
srand(time(0));
@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;
@sim642
sim642 / delegate.hpp
Last active July 22, 2020 17:27
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 / 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 / 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();
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 / kang.cpp
Created November 24, 2013 11:13
EIO lahtine võistlus 2013
#include <fstream>
using namespace std;
int main()
{
ifstream fin("kangsis.txt");
ofstream fout("kangval.txt");
int L, N;
@sim642
sim642 / main.cpp
Last active January 10, 2024 19:12
Multidimensional std::vector creation wrapper
#include <iostream>
#include "multivector.hpp"
using namespace std;
int main()
{
auto v = make_multivector(3, 2, 1, 5, 0.5);
for (auto x : v)
@sim642
sim642 / utf8.cpp
Last active August 29, 2015 14:09
SFML utf8
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <SFML/System/String.hpp>
#include <SFML/System/Utf.hpp>
using namespace std;
sf::String fromUtf8(const string &in)