Jack N @ GitHub

Full stack AI Engineer, focus on: React, Next.js, node.js and .Net

1. 需求

一个angular web站点,通过一个iframe嵌套在另一个web站点中。点击一个按钮,希望能够在一个新的页面(Tab)中打开另外一个页面。

2. 方案

主要困难在于处理2个站点的地址不同的问题。既可以通过 html 设置href实现,又可以直接使用js代码实现。

Code:

1
2
3
4

<a [href]="url" target="_blank">1. open New Tab - based on a.href </a>

<button (click)="openNewTab()" >2. open New Tab - by pure js/ts</button>
1
2
3
4
5
6
7
8
9
10
// 1. open New Tab - based on a.href
url = "";
ngOnInit() {
this.url = window.location.origin + "/help.html";
}

// 2. open New Tab - by pure js/ts
openNewTab() {
window.open(window.location.origin + "/help.html", "_blank");
}

3. 总结

主要困难在于处理2个站点的地址不同的问题(window.location.origin),和是否嵌套在其他站点(iframe)没有关系。

Error on renaming database in SQL Server, when rename the database:

1
ALTER DATABASE MY_DB MODIFY NAME = [MY_DB_bak]

But it shows an error when executing:

1
The database could not be exclusively locked to perform the operation.

The solution is setting the database to single user mode.

1
2
3
4
use master
ALTER DATABASE MY_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE MY_DB MODIFY NAME = [MY_DB_bak]
ALTER DATABASE MY_DB_bak SET MULTI_USER

Why Hexo

I’m a fan of Node.js, and github, and I want to choose a tool written in node.js to help me write blogs.
And it is Hexo! It is a fast, simple & powerful blog framework, powered by Node.js.

Features of Hexo

  • Blazing fast generating
  • Support for GitHub Flavored Markdown and most Octopress plugins
  • One-command deploy to GitHub Pages, Heroku, etc.
  • Powerful plugin system

Several Node.js Static Site Generators

I like Node.js, so I give you several choose beside the Hexo!

Metalsmith

Metalsmith immediately caught my attention not only thanks to its beautiful and minimal design, but also because of the following tagline: An extremely simple, pluggable static site generator. The first blurb goes on to explain that all of the logic in Metalsmith is handled by plugins. You simply chain them together. This makes Metalsmith the most versatile of all the systems presented here.

Wintersmith

Wintersmith claims to be a flexible, minimalistic, multi-platform static site generator built on top of Node.js. Certainly, minimalistic is the key word! Wintersmith isn’t suited for beginners, but it’s perfectly fine for intermediate or advanced developers looking to get up and running with little fuss. Wintersmith’s approach isn’t the only thing that’s minimal. It was coded in CoffeeScript and ships with Jade and Markdown ready to go.

Assemble

Assemble is a powerful tool that integrates Grunt and Yeoman into its workflow. Like Punch and DocPad discussed later in this article, Assemble tries to get designers and developers on the same page. For example, Assemble comes pre-packaged with Handlebars, one of the most widely used and beginner-friendly templating systems available.

0%