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 sample-news-data.js
const NEWS_DATA = {"links":[{"body":"","id":988,"source":"medium.com","time":1540522920,"title":"Ứng dụng CSS variables để xây dựng tính năng dark theme","url":"https://medium.com/p/2796644ea1f2"},{"body":"<p>Dark theme, dark mode hay night mode,&#8230; là một tính năng khá thú vị. Mình hay chuyển theme (trình duyệt, IDE) về chế độ này. Vì đơn giản là trông nó có vẻ chuyên nghiệp và mang màu sắc bí ẩn &#8211; kiểu hacker ấy. Mà nói vậy chứ, thực ra mình để vậy cho đỡ chói mắt thôi. Không phải làm màu đâu nhé! À, thế bạn biết cách xây dựng nhiều theme cho một trang web không? Mình thì không chắc đâu. Nhưng sau khi tìm hiểu về CSS variable xong, mình đã nảy ra một ý tưởng. [&#8230;]</p>\n<p>The post <a rel=\"nofollow\" href=\"https://completejavascript.com/tao-dark-theme-voi-css-variable/\">Tạo Dark Theme với CSS Variable</a> appeared first on <a rel=\"nofollow\" href=\"https://completejavascript.com\">Complete JavaScript</a>.</p>\n","id":987,"source":"completejavascript.com","time":1540420240,"title":"Tạo Dark
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}
You can’t perform that action at this time.