Skip to content

Instantly share code, notes, and snippets.

View sawaYch's full-sized avatar
🐧
Focusing

Sawa sawaYch

🐧
Focusing
View GitHub Profile
@sawaYch
sawaYch / code-snippet.js
Created August 15, 2019 18:06
Firebase storage listAll() example.
// Load single image
// replace images/photo6244288433388366130.jpg with your image path
// You can find it on the firebase storage console
var imgRef = firebase.storage().ref().child('images/photo6244288433388366130.jpg');
imgRef.getDownloadURL().then(function(url){
var img = document.getElementById('img1');
img.src = url;
}).catch(function(error) {
@sawaYch
sawaYch / init.vim
Last active July 4, 2019 16:09
My Neovim config
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs' " enhance nerdtree's tabs
Plug 'ryanoasis/vim-devicons' " add beautiful icons besides files
@sawaYch
sawaYch / FIx.md
Created May 20, 2019 12:52
Arch - Plasma Desktop - Second Display Fix

Arch - Plasma Desktop - Second Display Fix

Temp fix on KDE Plasma Desktop for low resolution when external display connected.

➜ ~ xrandr Screen 0: minimum 8 x 8, current 2624 x 900, maximum 32767 x 32767 eDP1 connected primary 1600x900+0+0 (normal left inverted right x axis y axis) 280mm x 160mm 1920x1080 60.04 + 1400x1050 59.98
1600x900 60.00* 1280x1024 60.02

@sawaYch
sawaYch / IBM_Thinkpad_x60.md
Last active November 19, 2023 10:52
A upgrade log of IBM Thinkpad X60.

IBM Think-Pad X60 Upgrade Log

These day, I tried to upgrade second-hand X60 IBM Think-pad.

It is a really old model (Intel Core 2 Duo ), but still good to use.

It has facing several problems and I am trying to use minimum cost (maybe) to increase the user experience :P

@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;
@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 / .travis.yml
Last active May 10, 2023 16:46
Conditional Build in Travis-CI
matrix:
include:
# config for PHP, server side codebase
- language: php
php:
- 7.0
# deploy jobs here
install:
- cd backend_server && composer install
# unit test jobs here
@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
@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 / 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;