Skip to content

Instantly share code, notes, and snippets.

Keep working...

Wasin Thonkaew haxpor

Keep working...
Block or report user

Report or block haxpor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
haxpor / aligned_allocator.cpp
Created Sep 27, 2019 — forked from donny-dont/aligned_allocator.cpp
An aligned allocator for placing SIMD types in std::vector
View aligned_allocator.cpp
#ifdef _WIN32
#include <malloc.h>
#include <cstdint>
#include <vector>
#include <iostream>
* Allocator for aligned data.
haxpor / gen100.cpp
Last active Sep 16, 2019
Simple program to generate N random numbers into standard output. You can pipe output from program into file manually. Example: echo 50 | ./a.out > random.txt
View gen100.cpp
* Input: n - number of random numbers to generate
* Output: n random numbers printed onto standard output separated by a space.
#include <iostream>
#include <cstdlib>
#include <ctime>
int main()
haxpor / genprogress.cpp
Created Sep 14, 2019
Generation of progress for UVa problem set. Use input.txt as input executing genprogress.cpp program. You can pipe the output to an actual .md file later.
View genprogress.cpp
* Generation of UVa's progress in markdown file.
* Input:
* A problem set number separated by a new line, each set will contains 100 problems with number running
* from it to a hundred. Terminate with 0 at the last line.
* 1
* 19
* 201
haxpor / stl_vector.h
Created Sep 2, 2019
"std::vector" won't use your class's move unless it's marked noexcept.
View stl_vector.h
#if __cplusplus >= 201103L
// Constant-time move assignment when source object's memory can be
// moved, either because the source's allocator will move too
// or because the allocators are equal.
_M_move_assign(vector&& __x, std::true_type) noexcept
vector __tmp(get_allocator());
haxpor / gist:a3ed3172ffc780b0c923091726d0eb94
Last active Sep 2, 2019
non-member function overloading an operator. Example defined in ostream to work with primitive normal types, which be idea to expand for user-defined object to output it into output stream. Excerpted from ostream header. See
View gist:a3ed3172ffc780b0c923091726d0eb94
* @brief String inserters
* @param __out An output stream.
* @param __s A character string.
* @return out
* @pre @p __s must be a non-NULL pointer
* Behaves like one of the formatted arithmetic inserters described in
* std::basic_ostream. After constructing a sentry object with good
haxpor / StructPb.cpp
Created Aug 24, 2019
Demonstrate hiding structure layout to public but still allow access.
View StructPb.cpp
#include <iostream>
#include <string>
struct PublicData
int a;
float b;
// private data
// this is a technique to hide the struct information thus users won't be able to know its layout
haxpor / Dialog.cpp
Created Aug 21, 2019
Boiler-plate code for QDialog, QMainWindow, and QWidget. Based on Qt 5.13.
View Dialog.cpp
#include "Dialog.h"
#include "ui_Dialog.h"
Dialog::Dialog(QWidget *parent) :
ui(new Ui::Dialog)
haxpor / SimpleDownloaders_future.cpp
Last active Aug 15, 2019
C++ studying of parallel + multithreading (c++11) following with some differences. Compile with "g++ -std=c++11 SimpleDownloader.cpp -lpthread -lcurl"
View SimpleDownloaders_future.cpp
/** Downloader app following but
* use libcurl (C API) with some adjusted API usage.
* Compile with
* g++ -std=c++11 -DNO_PROXY SimpleDownloader.cpp -lpthread -lcurl
* */
#include <iostream>
#include <fstream>
#include <string>
haxpor /
Created Aug 15, 2019
Example of writing extension with c++ for python with cpython.

How to build

  • python3 build
  • From current directory, cd build/lib.linux-x86_64-3.6 (tested on Ubuntu 18.04 with python 3.6.7).
  • python3 to enter interactive mode
  • import spam
  • spam.system('ls -la') then it should print the current directory listing as output
haxpor / dep.txt
Created Jul 27, 2019
Note on package requirement automatically installed by script of ue 4.18
View dep.txt
install -y libmono-system-data-datasetextensions4.0-cil
libmono-csharp4.0c-cil libmono-microsoft-csharp4.0-cil mono-dmcs mono-mcs
You can’t perform that action at this time.