Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Huy Tr. huytd

Block or report user

Report or block huytd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View firebug-lite-1.2.js
var firebug = {
View markdown-combine-parser.ts
interface Token {
success: boolean;
value?: string;
rest?: string;
data?: string;
interface ParserFn {
(input?: string): Token;
View combine-parser-org-mode.ts
import * as fs from 'fs';
import { parse } from 'querystring';
const data = fs.readFileSync('./', 'utf-8');
interface Token {
success: boolean;
value?: string;
rest?: string;
data?: string;
View naive-org-mode-parser.ts
import * as fs from 'fs';
const data = fs.readFileSync('./', 'utf-8');
enum NodeType { HeaderType, TextType };
type NodeLevel = number | null;
type NodeValue = string | null;
interface Node {
nodeType: NodeType;
View stock-on-the-news.ts
import axios from 'axios';
import * as Parser from 'rss-parser';
import * as cheerio from 'cheerio';
const rss = new Parser();
interface Article {
title: string;
url: string;
huytd / karabiner.json
Last active Mar 29, 2019
Custom modificator for Karabiner
View karabiner.json
"description":"Ctrl + G as Escape except Emacs",
huytd / error-input.hs
Created Aug 14, 2018
Error handling and IO in Haskell
View error-input.hs
import Control.Exception
getWord :: IO String
getWord =
putStrLn "Enter something:" >>
getLine >>= \name ->
case name of
"bad" -> ioError $ userError "bad word detected"
_ -> return name
huytd / parser-combinator-with-error-handling.ts
Last active Jul 20, 2018
Hex color parsing using parser combinator
View parser-combinator-with-error-handling.ts
const match_char = (c: string) => (input: string) => {
if (input[0] === c) {
return {success: true, value: input[0], rest: input.slice(1), error: null}
return {success: false, value: null, rest: input, error: new Error("Expected " + c + " but found " + input[0] + "\nRemaining: " + input )}
const any_char = (input: string) => {
if (typeof input[0] === 'string') {
return {success: true, value: input[0], rest: input.slice(1), error: null}

;; Automatically generated
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(anzu-cons-mode-line-p nil)
View slack-chat-saving.html
<meta charset=utf-8><style>.c-virtual_list__item{border:none;padding:5px}.c-message__sender_link{text-decoration:none;color:#000;font-weight:700;display:block;margin-bottom:5px}.c-message{display:flex;flex-direction:row;font-family:sans-serif;font-size:14px}.c-message .c-message__content{flex:1}.c-message.c-message--adjacent{padding-left:50px}.c-message .c-message__gutter{flex-basis:50px}.c-message.c-message--adjacent .c-message__gutter{display:none}.c-avatar__image{width:32px;height:32px}.c-message_list__day_divider,.c-message_list__day_divider__label{display:none}.emoji-sizer{text-indent:-99999px;width:22px;height:22px;display:inline-block;background-size:contain;background-repeat:none}.c-custom_status,.c-file__actions,.c-message__comment,.c-message__file_meta,.c-timestamp{display:none}.c-message__image_container img{width:100%;height:100%;border:1px solid #ccc}</style><div class=c-virtual_list__item role=listitem style=top:1365.1px><div class="c-message c-message--light c-message--adjacent"role=presentatio
You can’t perform that action at this time.