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 / 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 / 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 / FS_Allocation.md
Last active December 12, 2018 12:08
Something about operating system.

FS Allocation Methods

Purpose:

  • allocate disk blocks for files, utilize space effectively

3 common way: contiguous, linked, indexed.

@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 / memo.md
Last active November 18, 2018 17:16
Memo, everything.

Memo

cross compile failed: conflicting CPU arch

Cannot compile the stm32f407-discovery demo program on linux toochain?
All you need to do is just update libnewlib
bbcmicrobit/micropython#514 (comment)

wget to http web server require username & password

wget http://course.cse.ust.hk/comp3511/project/project2/os2018fall_nachos_proj2.tar.gz --http-user=username --http-password=pa$$w0rd