Skip to content

Instantly share code, notes, and snippets.

View khanhhua's full-sized avatar
🪜
Haskell

Hua Do Gia Khanh khanhhua

🪜
Haskell
View GitHub Profile
@shanerk
shanerk / package.xml
Last active May 2, 2023 12:20
Salesforce package.xml file to get all metadata from your org. Works great with vscode and cli.
<?xml version="1.0" encoding="UTF-8" ?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
@hungneox
hungneox / mekong.md
Created April 15, 2020 20:10
Mekong is dying

Trong hình là đoạn sông Mekong khổng lồ bị cạn trơ đáy chỉ còn một dòng nước nhỏ ở chính giữa ở gần làng Sangkhom (thuộc tỉnh Nong Khai, Thái Lan) vào tháng 1/2020. Đây là đoạn sông Mekong vừa thoát ra khỏi Lào, cũng như bắt nguồn từ con sông Lan Thương (Lancang), chảy từ các khối băng thuộc dãy Himalayas, cao nguyên Tây Tạng (tỉnh Thanh Hải) và Thanh Tạng (tỉnh Vân Nam, Trung Quốc).

Ảnh này là của New York Times, được đăng trong bài viết nói về dữ kiện vệ tinh của Mỹ cho thấy dù nước về trên cao nguyên Tây Tạng và đang làm mùa mưa/tuyết tan, nhưng có một khối lượng nước khổng lồ được giữ lại trong lãnh thổ Trung Quốc khiến phần sông Mekong từ Lào đến Thái Lan hoàn toàn khô cạn. Xem:

https://www.nytimes.com/2020/04/13/world/asia/china-mekong-drought.html

https://558353b6-da87-4596-a181-b1f20782dd18.filesusr.com/ugd/81dff2_68504848510349d6a827c6a433122275.pdf?index=true

https://www.reuters.com/article/us-mekong-river/chinese-dams-held-back-mekong-waters-during-drought-study-finds-idUSKCN21V0U7

export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=>
// arrays
e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])):
// components
e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=>
render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):(
// create notes
m=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props
@dino-
dino- / string-conversions.hs
Last active May 3, 2024 08:57
A handy illustration of converting between String, Text and ByteString in Haskell
#! /usr/bin/env stack
-- stack --resolver lts-18.8 script
{-# LANGUAGE OverloadedStrings #-}
{-
This is a handy illustration of converting between five of the commonly-used
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy
Text).
@tonymtz
tonymtz / default.conf
Created March 4, 2018 07:37
Nginx configuration for HTML5 routing
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
@cscalfani
cscalfani / CompositionWithMultipleParameters.md
Created December 5, 2017 22:29
Functional Composition with Multiple Parameters in Haskell

Functional Composition with Multiple Parameters in Haskell

In the past, I've written composition functions in both Elm and Haskell that take multiple parameters for the leftmost function, i.e. the function that gets applied first.

(All examples here are in Haskell)

Here was my Haskell implemenation (stolen from the web):

compose2 :: (c -&gt; d) -&gt; (a -&gt; b -&gt; c) -&gt; a -&gt; b -&gt; d
@rgl
rgl / wait_for_http_200.sh
Last active March 7, 2024 17:08
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@gaearon
gaearon / ReduxMicroBoilerplate.js
Last active March 26, 2020 00:35
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
@hungneox
hungneox / generator-and-generator-in-es6.md
Last active August 29, 2015 14:25
Generator in ES6 as solution to solve callback hell

1. What is Generator?

Generally, Generator is a object returned by a generator function that behaves like an Iterator. In Javascript, according to Mozilla:

The Generator object is returned by a generator function and it conforms to both the iterator and the Iterable protocol.

While a normal function will return a value using return keyword, Generator uses yield keyword to generate a rule to create values rather than the actual values. In other words, it is the lazily way to generate values.

The obvious benefit of Generator is improving the performance and help us to organize source code better. This is a new feature in ES6, but it has been implemented in other languages (e.g.Python, C# etc) for a long time.

2. Syntax

@staltz
staltz / introrx.md
Last active May 6, 2024 01:44
The introduction to Reactive Programming you've been missing