Skip to content

Instantly share code, notes, and snippets.

View tungd's full-sized avatar
🐳
Back to normal

Tung Dao tungd

🐳
Back to normal
View GitHub Profile
@tungd
tungd / tkgate_install.sh
Created October 20, 2011 16:10
Install TkGate 2.0 on Ubuntu
#!/bin/bash
sudo apt-get install build-essential autotools-dev tcl8.5-dev tk8.5-dev
cd $HOME
mkdir build && cd build
wget ftp://gadoid.ices.cmu.edu/pub/tkgate/pre-release/tkgate-2.0-b10.tar.gz
tar xvzf tkgate-2.0-b10.tar.gz
cd tkgate-2.0-b10/
./configure
make
# Only if you want to install
@tungd
tungd / highlight-format-string-spec.el
Last active May 17, 2022 04:15
WIP Highlight `printf` format string specifier token. Used some code from: http://www.emacswiki.org/emacs/AddKeywords#toc7
(defvar font-lock-format-specifier-face
'font-lock-format-specifier-face)
(defface font-lock-format-specifier-face
'((t (:inherit font-lock-preprocessor-face)))
"Font Lock mode face used to highlight format specifiers."
:group 'font-lock-faces)
(defun highlight-format-specifier ()
(font-lock-add-keywords
define PROXY_FN
export async function onRequest(context) {
const { request, params, env } = context;
const url = new URL(request.url);
url.host = env.API_HOST;
url.pathname = params.path.join('') === 'json' ? `/api/json` : params.path.join('/');
if (request.method === 'POST' && !request.headers.get('Content-Type')) {
const headers = Object.fromEntries(request.headers.entries())
return fetch(url, {
method: request.method,
/**
* react-catalyst.js
*
* LinkedState for Facebook's React UI Library. Add support for
* deep path state access.
*
* Author: Tung Dao <me@tungdao.com>
*
* Usage:
*
@tungd
tungd / vietnamese-telex_utf-8.vim
Created March 19, 2012 17:07
Vietnamese TELEX keymap for vim
" Vim Keymap file for vietnamese through the Telex method
" Maintainer: Tung Dao <tungd.dao@gmail.com>
" Last Change: 30 Aug 2011
scriptencoding utf-8
let b:keymap_name = "vietnamese"
loadkeymap
a a
@tungd
tungd / build.gradle.kts
Last active February 12, 2019 06:32
Configuration file for microservice using Gradle, Spring Boot, Spring Cloud, Spring Webflux, Srping Data JPA, OpenJPA (for entity class generation)
group = "com.tungdao.sample"
extra["spring.version"] = "5.1.3.RELEASE"
extra["spring.boot.version"] = "2.1.1.RELEASE"
extra["spring.cloud.version"] = "Greenwich.RC2"
plugins {
java
idea
id("org.springframework.boot") version "2.1.1.RELEASE"
@tungd
tungd / react-helper.js
Last active November 30, 2018 06:33
React Helper to initialize the component from HTML, similar to AngularJS.
/**
* react-helper.js
*
* Helper for Facebook's React UI Library. Add support for declare
* component on DOM (similar to AngularJS Directive).
*
* Usage:
* - Register a component:
* ReactHelper.register('MyComponent', MyComponent)
* - Declare the DOM node:
@tungd
tungd / index.js
Last active November 1, 2018 07:59
Sequelize insert demo
const Sequelize = require('sequelize')
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: 'db.sqlite3'
})
const Product = sequelize.define('product', {
name: Sequelize.STRING
})
@tungd
tungd / td_shortcode.php
Created July 2, 2014 13:38
Shortcode for Presestashop's CMS page.
<?php
if (!defined('_PS_VERSION_')) exit;
class TD_Shortcode extends Module {
protected static $initialized = false;
public function __construct() {
$this->name = 'td_shortcode';
$this->tab = 'front_office_feature';
@tungd
tungd / index.js
Last active October 11, 2018 10:43
const xlsx = require('xlsx')
const table = xlsx.readFile('sample.xlsx', { cellStyles: true })
const sheet = table.Sheets[table.SheetNames[0]];
console.log(sheet)
// sheet['C10'] = { t: 's', v: 'Test update value' }
const addCell = (sheet, cell, value) => {
sheet[cell] = Object.assign({}, sheet[cell], value)