Skip to content

Instantly share code, notes, and snippets.

View longlho's full-sized avatar

Long Ho longlho

View GitHub Profile
@longlho
longlho / dethi.md
Last active December 8, 2019 06:15
dethi

Giới thiệu

Do vị trí địa lý của Qatar và khí hậu sa mạc, khiến nó không có tiếp cận trực tiếp với nước khử muối hoặc hệ thống sông có thể thu hoạch, nước biển là nguồn nước quan trọng nhất đối với người dân Qatar, chiếm khoảng một nửa lượng nước sử dụng.

Với tính bền vững của nước luôn được đặt lên hàng đầu, Qatar ngày nay chủ yếu dựa vào công nghệ khử mặn nhiệt thông thường sản xuất số lượng lớn nước khử muối hàng năm. Ba nhà máy khử mặn chính của Qatar là:

  • Ras Abu Fontas B-1
  • Ras Laffan-A
  • Ras Laffan-B

Chất lượng nước rõ ràng có tầm quan trọng đối với con người cũng như động vật. Một yếu tố ảnh hưởng đến chất lượng nước là hàm lượng muối. Một số điều tra cho thấy rằng nước mặn có thể dẫn đến giảm sản xuất sữa từ lạc đà. Mặt khác, các nghiên cứu khác cho thấy hàm lượng muối trong nước dường như không có tác dụng.

@longlho
longlho / transformer-p10.ts
Created August 20, 2019 03:02
transformer-p10.ts
import * as png from 'foo.png'
function render () {
return <img src={png} />
}
// Transform to
const hoisted_img = <img src="data:base64..." />
@longlho
longlho / transformer-p9.ts
Created August 20, 2019 02:52
transformer-p9.ts
function foo () {
return <img src="image.jpeg" />
}
// Into
const hoisted_element_1 = <img src="image.jpeg" />
function foo () {
return hoisted_element_1
@longlho
longlho / transformer-p8.ts
Created August 20, 2019 02:46
transformer-p8.ts
// Compiles to
const foo = {
id: '1h7a',
defaultMessage: 'asd'
}
// Also generate strings.json
{
'1h7a': {
description: 'foo',
defaultMessage: 'asd'
@longlho
longlho / transformer-p7.ts
Created August 20, 2019 02:44
transformer-p7.ts
import {_} from 'ts-transform-react-intl'
const foo = _({
description: 'foo',
defaultMessage: 'asd'
})
@longlho
longlho / transformer-p6.ts
Created August 20, 2019 02:38
transformer-p6.ts
if (newNode) {
// Link external CSS file in source map
const externalCssSource = ts.createSourceMapSource(
cssPath,
readFileSync(cssPath, "utf-8")
);
ts.setSourceMapRange(newNode, {
source: externalCssSource,
pos: node.pos,
end: node.end
@longlho
longlho / transformer-p5.ts
Last active August 20, 2019 02:38
transformer-p5.ts
if (ts.isImportDeclaration(node)) {
// Handle `import foo.css`
if (CSS_EXTENSION_REGEX.test(node.moduleSpecifier.getText())) {
cssPath = resolveCssPath(
node.moduleSpecifier.getText(),
sf,
tsImportResolver
);
newNode = importVisitor(cssPath, node);
@longlho
longlho / transformer-p4.ts
Created March 31, 2019 19:56
transformer-p4
const visitor: ts.Visitor = (node: ts.Node): ts.Node => {
if (ts.isImportDeclaration(node) && node.moduleSpecifier) {
const newNode = ts.getMutableClone(node) // Clone the node
const oldPathWithQuotes = node.moduleSpecifier.getText(sf)
const newPath = rewritePath(oldPathWithQuotes.slice(1, oldPathWithQuotes.length - 2))
newNode.moduleSpecifier = ts.createStringLiteral(newPath)
ts.setSourceMapRange(newNode, ts.getSourceMapRange(node))
return newNode
}
return ts.visitEachChild(node, visitor)
@longlho
longlho / transformer-p3.ts
Last active March 31, 2019 19:53
transformer-p3
const visitor: ts.Visitor = (node: ts.Node): ts.Node => {
if (ts.isImportDeclaration(node) && node.moduleSpecifier) {
const newNode = ts.getMutableClone(node) // Clone the node
const oldPathWithQuotes = node.moduleSpecifier.getText(sf)
const newPath = rewritePath(oldPathWithQuotes.slice(1, oldPathWithQuotes.length - 2))
newNode.moduleSpecifier = ts.createStringLiteral(newPath)
}
return ts.visitEachChild(node, visitor)
}
@longlho
longlho / transformer-p2.ts
Created March 31, 2019 19:49
transformer-p2
const visitor: ts.Visitor = (node: ts.Node): ts.Node => {
if (ts.isImportDeclaration(node) && node.moduleSpecifier) {
const newNode = ts.getMutableClone(node) // Clone the node
}
return ts.visitEachChild(node, visitor)
}