Posts

Showing posts from July, 2018

Fix up: Can't Load URL: The domain of this URL isn't included in the app's domains.

Image
Issue Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. Scenario create a facebook app to get an appid use that appid in website to initialized the facebook javascript SDK use FB.ui to share content to facebook full source codes <!-- init facebook js sdk via your appid --> <script> window.fbAsyncInit = function() { FB.init({ appId : 'yourappid', autoLogAppEvents : true, xfbml : true, version : 'v3.1' }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "https://connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'

connect shadowsocks server on ubuntu via ss-local

#Server config [Set up your own shadowsocks server](https://errong.win/2018/06/05/setup-shadowsocks-on-ubuntu-16-04/) or found/buy one. You should have a shadowsocks server with below informations: * server ip * server port * password * method #install ~~~ sudo apt-get install software-properties-common -y sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y sudo apt-get update sudo apt install shadowsocks-libev ~~~ #configure match to the server's info. ~~~ sudo vim /etc/shadowsocks-libev/config.json {     "server":"xx.xx.xx.xx", // server IP     "server_port":8911,     "local_port":1008, // local port     "password":"jesuslove",     "timeout":60,     "method":"chacha20-ietf-poly1305" } ~~~ #run ss-local ```sudo ss-local -c  /etc/shadowsocks-libev/config.json``` #export socks proxy system wide ~~~ export http_proxy=socks5://127.0.0.1:1008 export https_proxy=socks5://127.0.0.1:1008 ~~~ #u

c++: Max Heap Template

https://en.wikipedia.org/wiki/Min-max_heap My simple implementation of max heap. Change the compare from > to < in below codes, you will get a min heap. template<typename T> class MaxHeap { public: MaxHeap() { size_ = 0; capacity_ = 2; heap_ = new T[capacity_]; } MaxHeap(int capacity) { if (capacity >= 2) { heap_ = new T[capacity]; capacity_ = capacity; size_ = 0; } else { size_ = 0; capacity_ = 2; heap_ = new T[capacity_]; } } ~MaxHeap() { if (heap_) delete[] heap_; } public: int size() { return size_; } void insert(const T& t) { if ((size_+1) >= capacity_) { capacity_ *= 2; T* tmp = new T[capacity_]; for (int i = 0; i <= size_; i++) tmp[i] = heap_[i]; delete[] heap_; heap_ = tmp; } size_++; heap_[size_] = t; int i = size_; int tmp = heap_[i]; while (i > 1 && tmp > heap_[i / 2]) { heap_[i] = heap_[i / 2]; heap_[i / 2] = tmp; tmp = heap_[i / 2]; i /= 2;