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
@khanhhua
khanhhua / string-conversions.hs
Created July 13, 2022 22:30 — forked from dino-/string-conversions.hs
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).
0x10b37928f27551716b1fb255edc8a6bc14e697cd
0xa04b419eb4d25ad4d0c2659614e06e76d029a08b
0xf849fff77852fe0aa6ef0db7412da61fb9aa8974
%% Open a new table setting Name as primary key in tuples of {user, Name, Age}
{ok, Tab} = dets:open_file('demo.dat', [{type,set}, {keypos,2}]).
%% Inspect table info
dets:info(Tab).
dets:info(Tab, size).
%% Insert user Tom with ages 30 and 40
ok = dets:insert(Tab, {user, "Tom", 30}).
false = dets:insert_new(Tab, {user, "Tom", 40}).
@khanhhua
khanhhua / ReduxMicroBoilerplate.js
Created February 18, 2016 12:15 — forked from gaearon/ReduxMicroBoilerplate.js
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
// ------------
@khanhhua
khanhhua / gist:5c9cac99e3a084de3e30
Last active August 29, 2015 14:26
How to install GNU gettext on MAC OSX
  1. Wget ftp://ftp.gnu.org/pub/gnu/gettext/gettext...t-0.12.1.tar.gz
  2. Untar file as tar -zxvf gettext-0.12.1.tar.gz
  3. cd to the directory containing the package's source code and type ./configure to configure the package for your system. If you're using csh on an old version of System V, you might need to type sh ./configure instead to prevent csh from trying to execute configure itself.

Running configure takes awhile. While running, it prints some messages telling which features it is checking for.

  1. Type make to compile the package.
  2. Optionally, type make check to run any self-tests that come with the package.
  3. Type make install to install the programs and any data files and documentation.
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
<h3>Task for the workplace</h3>
<p>
<label>Task:</label>
<input ng-model={{item.task}} />
</p>
<p>
<label>Due:</label>
<input ng-model={{item.due}} />
</p>