Posts

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;

Ember.js : Custom "index" route's path and Custom "/" path's route

Image
"index" Route The index route, which will handle requests to the root URI (/) of our site. How to generate a new route called index: ember g route index The index route is special: it does NOT require an entry in the router's mapping. a Nested "index" Route An index nested route works similarly to the base index route. It is the default route that renders when no route is provided. Use 'rentals' as example, when we navigate to /rentals, Ember will attempt to load the rentals index route as a nested route. To create an index nested route, run the following command: ember g route rentals/index If you open up your Router (app/router.js) you may notice that the rentals line has changed. This extra function() {} is required because it needs a child route, the this.route('index', { path: '/'}); is implied. Router.map(function() { this.route('about'); this.route('contact'); this.route('rentals', functi

Set up gitweb server on nginx

Image
Precondition please setup your git server via git-http-backend on nginx. Setup gitweb conf sudo apt-get install gitweb /etc/gitweb.conf is Gitweb (Git web interface) configuration file The default project root is /usr/lib/git. Here, I changed to my own path. our $projectroot = "/home/errong_leng/www/git"; Change nginx conf cat /etc/nginx/sites-enabled/git.errong.win.conf server { listen 80; listen [::]:80; server_name git.errong.win; auth_basic "Restricted"; auth_basic_user_file /home/errong_leng/.gitpasswd; location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ { root /home/errong_leng/www/git; fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; fastcgi_param PATH_INFO $uri; fastcgi_param GIT_PROJECT_ROOT /home/errong_leng/www/git; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param REMOTE_USER $remote_user; in

Install Perl module on ubuntu

Install by cpan cpan -i foo Replace foo with the module name you want to install. Install from source Search the module on cpan.org Download the source. Let's use HTML::Entities for example. You will get your search url: http://search.cpan.org/~gaas/HTML-Parser-3.72/lib/HTML/Entities.pm The source url will be: http://www.cpan.org/authors/id/G/GA/GAAS/HTML-Parser-3.72.tar.gz Make and install perl module tar -xvf HTML-Parser-3.72.tar.gz cd HTML-Parser-3.72/ perl Makefile.PL make sudo make install

setup http/https git server on nginx via git-http-backend

Precondition sudo apt-get install nginx fcgiwrap git apache2-utils Set up https server First, please setup your https server by your self. You can refer to my guide git-http-backend git-http-backend is a Server side implementation of Git over HTTP. /usr/lib/git-core/git-http-backend Set Up Password Authentication file for your git server We can get a password with MD5-based password algorithm, Apache variant via openssl passwd command. You can add a username to the file using this command. We are using sammy as our username, but you can use whatever name you'd like: sudo sh -c "echo -n 'sammy:' >> .gitpasswd" Next, add an encrypted password entry for the username by typing: sudo sh -c "openssl passwd -apr1 >> .gitpasswd" You can repeat this process for additional usernames. You can see how the usernames and encrypted passwords are stored within the file by typing: cat .gitpasswd Output sammy:$apr1$wI1/T0nB$jEKuTJHkTOOWk