Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Huy Tr. huytd

💭
I may be slow to respond.
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 org-journal-list.el
(defun read-journal (path)
(with-temp-buffer
(insert-file-contents (concat "~/notes/journal/" path))
(split-string (buffer-string) "\n" t)))
(defun read-first-three-lines (list)
(cond ((>= (length list) 4) (subseq list 1 3))
((>= (length list) 1) (nthcdr 1 list))
(t list)))
View firebug-lite-1.2.js
var firebug = {
version:[1.231,20100118],
el:{},
env:{
"css":"http://getfirebug.com/releases/lite/1.2/firebug-lite.css",
"debug":true,
"detectFirebug":true,
"dIndex":"console",
"height":295,
"hideDOMFunctions":false,
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('./research.org', '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('./research.org', '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
huytd / karabiner.json
Last active Mar 29, 2019
Custom modificator for Karabiner
View karabiner.json
{
"description":"Ctrl + G as Escape except Emacs",
"manipulators":[
{
"from":{
"key_code":"g",
"modifiers":{
"mandatory":[
"control"
]
@huytd
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
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}
View customize.material-dark-theme.md

;; Automatically generated
(custom-set-variables
 ;; 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)
You can’t perform that action at this time.