Skip to content

Instantly share code, notes, and snippets.

View Alexhuszagh's full-sized avatar

Alexander Huszagh Alexhuszagh

View GitHub Profile
@Alexhuszagh
Alexhuszagh / no_moderates.py
Created July 25, 2017 22:11
No GOP Moderates
from collections import namedtuple
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
import pandas as pd
import requests
Representative = namedtuple("Representative", "member party state trump_score trump_margin predicted_score trump_plus_minus")
@Alexhuszagh
Alexhuszagh / product.cpp
Created February 18, 2017 20:12
Cartesian Product Implementation in C++
// :copyright: (c) 2017 Alex Huszagh.
// :license: MIT.
/**
* Cartesian product algorithm.
*
* Lazily calculates the cartesian product from a container of containers,
* of either linear (array, vector, set, unordered_set) or associative
* (map, unordered_map, multimap, unordered_multimap) containers.
*
* The code can be used as follows:
@Alexhuszagh
Alexhuszagh / Test on all compilers
Created February 5, 2017 05:01
Sfinae detection for all compilers.
#include <utility>
class A
{
friend bool operator<(const A &lhs, const A &rhs)
{
return false;
}
@Alexhuszagh
Alexhuszagh / com.cpp
Last active June 26, 2022 01:21
Example Using COM IDispatch Interface
/** Example using the COM interface without AutoCOM. The entire
* file can be automated with AutoCOM in under 15-lines of code.
*
* #include "autocom.hpp"
* int main(int argc, char *argv[])
* {
* com::Bstr text;
* com::Dispatch dispatch("VBScript.RegExp");
* dispatch.put("Pattern", L"\\w+");
* for (auto match: dispatch.iter("Execute", L"A(b) c35 d_[x] yyy")) {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script will delete all of the tweets in the specified account.
You may need to hit the "more" button on the bottom of your twitter profile
page every now and then as the script runs, this is due to a bug in twitter.
You will need to get a consumer key and consumer secret token to use this
script, you can do so by registering a twitter application at https://dev.twitter.com/apps
@Alexhuszagh
Alexhuszagh / async.cpp
Last active December 10, 2016 06:31
Example using lattice with async
// :copyright: (c) 2016 The Regents of the University of California.
// :license: MIT, see LICENSE.md for more details.
/**
* \addtogroup Example
* \brief Simple asynchronous GET requests.
*/
#include "lattice.hpp"
#include <iostream>
@Alexhuszagh
Alexhuszagh / curl.c
Last active December 10, 2016 02:50
Lattice vs. cURL
#include <curl/curl.h>
#include <iostream>
int main(void)
{
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
@Alexhuszagh
Alexhuszagh / widestream.cpp
Created October 10, 2016 18:11
Filestream with support for Windows wide API file names.
/** \brief FStream-like handle for Wide API support.
*
* Although the C standard makes no guarantees a C FILE descriptor will
* be used internally, both GCC and Clang do so, with GCC providing
* an extension to create a basic_filebuf from an existing C FILE or
* POSIX file descriptor[1]. As basic_fstream is merely a wrapper around
* basic_iostream with a basic_filebuf, this provides a full API
* that should have native performance.
*
* By using a GNU extension to solve a GNU-specific problem, or std::fstream
@Alexhuszagh
Alexhuszagh / samsung_to_silence.py
Last active October 4, 2016 19:29
Samsung to Silence SMS
#!/usr/bin/env python
'''
samsung_to_silence.py
---------------------
Convert Samsung SMS plaintext backups (XML) to the silence format.
:warning: This has only been tested with the Samsung Galaxy S6, other
systems may differ.
@Alexhuszagh
Alexhuszagh / Encoding.md
Created September 15, 2016 05:42
Characterset-Conversion Stream Buffer Wrapper

Encoding

This file contains a stream-buffer wrapper automatically converting charactersets from a one encoding to a another. If the source and the destination encodings are the same, it calls memmove to move the bytes from the source to the destination.

Dependencies

Installation