Skip to content

Instantly share code, notes, and snippets.

View sawaYch's full-sized avatar
🐧
Focusing

Sawa sawaYch

🐧
Focusing
View GitHub Profile
@sawaYch
sawaYch / Cpp.sublime-build
Last active February 7, 2018 12:15
c++ build system for windows 10 (MinGW) and execute on git-Bash.
{
"cmd": ["g++", "./*.cpp", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run(native)",
"cmd": ["git-bash", "-c", "./${file_base_name}.exe;echo -e '\\e[0;32m- press any key to continue -';read;"],
@sawaYch
sawaYch / msys2.reg
Last active October 13, 2018 02:06
MSYS2, gtkmm-3.0 config
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\open_msys2]
@="Open MSYS2 here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\open_msys2\command]
@="c:\\msys64\\usr\\bin\\mintty.exe /bin/sh -lc 'cd \"$(cygpath \"%V\")\"; exec bash'"
[HKEY_CLASSES_ROOT\Folder\shell\open_msys2]
@="Open MSYS2 here"
@sawaYch
sawaYch / res&ico.md
Last active October 14, 2018 21:42
How to create an exe ico res file (M$Win)

Create .ico

Make .rc file

...with the content like this:
A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "./hc05.ico"

Compile it

windres -i ./res.rc --input-format=rc -o icon.res -O coff

Link the .res file with your program

`

@sawaYch
sawaYch / cpp_boost_makefile.md
Last active October 26, 2018 17:51
C++ Boost & Mysys

Simple makefile for compiling cpp with Boost lib

Install Boost using Mysys2

# pacman -S mingw-w64-x86_64-boost

Just few line

all:./main.cpp
@sawaYch
sawaYch / Method1_for_cpp.md
Last active October 26, 2018 22:11
Is there any better way to keep api key private if you push code over here :/ ?

Method 1 (demo using C++) - Encapsulate your api key with class

Create a api key vault class

Like this :

#ifndef API_KEY_VAULT
#define API_KEY_VAULT

#include <string>
using namespace std;
@sawaYch
sawaYch / main.cpp
Created October 27, 2018 17:59
Fixer: currency rates api ; demo using C++ with Boost
#include <boost/asio.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/filesystem.hpp>
#include <iostream>
#include "apiKey.h"
using namespace boost::asio::ip;
using namespace boost::asio;
using namespace std;
using namespace boost::filesystem;
@sawaYch
sawaYch / init.js
Created October 28, 2018 13:25
ES6 module, import, export equivalent code to achieve browser compatible
// init function, just a test
function init() {
$(".accordion").on("click", ".accordion-header", function() {
$(this).toggleClass("active").next().slideToggle();
});
return true;
}
// run it when it;s ready
$(document).ready(init);
@sawaYch
sawaYch / modern_C++.md
Last active November 4, 2018 15:39
Something you need to care about in modern C++

Vector, Beware of erase()

If you are using this style and when you erase() items in vector, be careful dont perform ++iterator.
Since the pointer to the item that you erase(), it already release, so the pointer target will become unknown,
and causing undefined behaviour if the iteration keep going.
It is possible cause the vector iteration out-of-bound.

template <class T>
void Container<T>::removeValue(T *value, bool deletePointer)
{
	for (iterator i = values.begin(); i != values.end(); ) {
@sawaYch
sawaYch / magic.md
Last active November 7, 2018 15:33
To make WSL work with 32bit emulation

HOW TO MAKE WSL work with 32bit emulation

Based on some tinkering I was doing with qemu for some ARM dev, I think I may have found a technique to allow general 32-bit support in WSL. Hat-tip to @therealkenc for the concept 😁

Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)

Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt sudo apt update sudo apt install qemu-user-static

@sawaYch
sawaYch / junit_test.md
Last active November 10, 2018 23:46
Special way to test binding type (JavaFX and Junit)

Special way to test binding type (JavaFX and Junit)

Code of DataModel Class

The class data model is a binding type for javafx bar chart.

public static class DataModel {
    private final SimpleStringProperty title;
    private final SimpleStringProperty price;
    private final SimpleStringProperty url;
    private final SimpleStringProperty postedd;