Posts

Showing posts from June, 2018

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

setup https server via An ACME Shell script on nginx

I will give every detail steps when I setup https server for https://git.errong.win . You can refer as a guide. acme.sh acme.sh is probably the easiest & smartest shell script toautomatically issue & renew the free certificates from Let's Encrypt . Install the shell script via guide http server nginx conf First, let's setup a http server first via nginx. After you installed nginx, the simple way to setup a http server is to add a conf file under /etc/nginx/sites-enabled/ folder. cat /etc/nginx/sites-enabled/git.errong.com.conf server { listen 80; listen [::]:80; server_name git.errong.com; location / { root html; index index.html index.htm; } } Reload nginx via sudo nginx -s reload issue free certificates sudo acme.sh --issue --home /etc/letsencrypt --domain example.com --webroot /home/errong_leng/www/git --reloadcmd "nginx -s reload" --accountemail errong.leng@gmail.com [Wed Jun 13 01:51:07

Samba add user for share

add user sudo smbpasswd -a USER sudo smbpasswd -e USER set up share path /etc/samba/smb.conf [USER]  comment = USER home  path = /home/USER  writeable = yes  public=yes  browseable = yes  create mode = 776  force directory mode = 776 restart samba service sudo systemctl restart smbd.service sudo systemctl restart nmbd.service if still can't access, then check below config /etc/samba/smb.conf [global] hosts allow = #add your IP here restart samba service again, it should work now.

Fix issue : grunt init failed with error Couldn't find match for "

Issue PS D:\Ghost> grunt init Running "update_submodules:pinned" (update_submodules) task Running "subgrunt:init" (subgrunt) task yarn install v1.7.0 [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... warning Pattern ["glob@latest"] is trying to unpack in the same destination "C:\\Users\\lenger\\AppData\\Local\\Yarn\\Ca che\\v1\\npm-glob-7.1.2-c19c9df9a028702d678612384a6552404c636d15" as pattern ["glob@^7.0.5","glob@^7.0.5","glob@^7.1.0", "glob@^7.0.4","glob@^7.1.2","glob@^7.0.3","glob@^7.0.3","glob@^7.0.0","glob@7.1.2","glob@^7.0.3"]. This could result in non-deterministic behavior, skipping. error Couldn't find match for "8dc6b689903c9363ade94e2e4d21c94813bbbe98" in "refs/heads/master,refs/heads/node-4-compat, refs/tags/v0.0.1,refs/tags/v0.0.2,refs/tags/v0.0.3,refs/tags/v0.1.0,refs/ta

Transfer your ghost server between hosts

Assume you have a ghost server ran at a host machine. Oneday the host machine maybe out of space or you find a new cheap host, or you have a new host that have power memory and performance. Then you may need to transfer your ghost server to another new host. tar your ghost server to a *.tar.gz //blog is my ghost server root directory $cd www/blog $tar -zcvf blog.tar.gz blog copy the blog.tar.gz to the new host preinstall on new host nginx sudo apt-get install nginx node.js https://nodejs.org/en/download/ extract and add node bin path to env ghost npm i -g ghost-cli acme.sh https://github.com/Neilpang/acme.sh configure on new host tar cvf blog.tar.gz nginx conf sudo ln -sf blog/system/files/blog.conf /etc/nginx/sites-available/blog.conf sudo ln -sf /etc/nginx/sites-available/blog.conf /etc/nginx/sites-enabled/blog.conf start http server ghost start if you encounter systemd error, just follow the hint command(ghost linuxuser systemd) by ghost and run ghost

setup shadowsocks server on ubuntu 16.04

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 sudo vim /etc/shadowsocks-libev/config.json { "server":"10.128.0.2", "server_port":8911, "local_port":1008, "password":"jesusislove", "timeout":60, "method":"chacha20-ietf-poly1305" } start server sudo systemctl start shadowsocks-libev google compute engine If the server are running on a google compute engine, You need to setup a firewall rules for the server port(8911, written in config.json). shadowsocks Apply to all IP ranges: 0.0.0.0/0 tcp:8911, udp:8911 Allow client configuration iOS Android Shadowsocks for Android / iOS also accepts BASE64 encoded URI format configs: ss://BASE64-ENCODED-STRING-WITHOUT-PADDING#TAG Where the plain URI should be: ss://method:passwo

他的力量若不够

Image
利未记五7、11 7「他的力量若不够献一只羊羔,就要因所犯的罪,把两只斑鸠或是两只雏鸽带到耶和华面前为赎愆祭:一只作赎罪祭,一只作燔祭。 11「他的力量若不够献两只斑鸠或是两只雏鸽,就要因所犯的罪带供物来,就是细面伊法十分之一为赎罪祭;不可加上油,也不可加上乳香,因为是赎罪祭。 Photo by Brooke Lark / Unsplash

expressjs : implement http file download

Express helper, res.download Express has a helper for this: app.get('/xxx', function(req, res){  var file = __dirname + '/xxx';  res.download(file); // Set disposition and send it.  }); http file download header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition res.setHeader('Content-disposition', 'attachment; filename=xxx');

iptables, clean all rules

command sudo iptables -P INPUT ACCEPT sudo iptables -F list all rules sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy DROP) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination