Skip to content

Instantly share code, notes, and snippets.

View hncuong's full-sized avatar

Nhat-Cuong Ha (Clark) hncuong

  • Technical University of Munich
  • Munich, Germany
View GitHub Profile
### Recursive
with recursive r (i) as (
select 1 -- non-recursive term
union all
select i * 2 from r where i < 50) -- recursive term
select * from r;
with recursive r (i) as (
select 3-- non-recursive term
union all
@hncuong
hncuong / monitor_notebooks.py
Created January 28, 2021 08:52 — forked from 2torus/monitor_notebooks.py
Get operating system information about jupyter notebooks from https://stackoverflow.com/a/44936664/996379
"""
Prints notebook's pid, memory and gpu memory utilization
The code is from https://stackoverflow.com/a/44936664/996379
Also gpu code is from https://gist.github.com/takuseno/2958caf1cb5e74314a9b5971999182b2
Usage:
python monitor_notebooks.py $notebook_token
if token is not supplied, it will prompt you for a token.
"""
import os
import os.path
@hncuong
hncuong / remove_accents.py
Created July 8, 2019 04:56 — forked from cinoss/remove_accents.py
Remove Vietnamese Accents - Xoá dấu tiếng việt in Python
s1 = u'ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝàáâãèéêìíòóôõùúýĂăĐđĨĩŨũƠơƯưẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹ'
s0 = u'AAAAEEEIIOOOOUUYaaaaeeeiioooouuyAaDdIiUuOoUuAaAaAaAaAaAaAaAaAaAaAaAaEeEeEeEeEeEeEeEeIiIiOoOoOoOoOoOoOoOoOoOoOoOoUuUuUuUuUuUuUuYyYyYyYy'
def remove_accents(input_str):
s = ''
print input_str.encode('utf-8')
for c in input_str:
if c in s1:
s += s0[s1.index(c)]
else:
s += c
package com.zmining.processor.relation.community;
import com.vng.dataplatform.sdk.hdbc.HDFSConnection;
import com.vng.dataplatform.sdk.sparkjob.SparkJobAbst;
import com.vng.dataplatform.sdk.sparkjob.SparkjobResult;
import com.zmining.common.graph.community.clique.KCliqueCommunityFinder;
import com.zmining.service.JavaFriendService;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
@hncuong
hncuong / no_accent_vietnamese.py
Created January 16, 2019 07:07 — forked from thuandt/no_accent_vietnamese.py
Chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Chương trình chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
Chỉnh sửa từ mã nguồn của anh NamNT
http://www.vithon.org/2009/06/14/x%E1%BB%AD-ly-ti%E1%BA%BFng-vi%E1%BB%87t-trong-python
"""
import re
INTAB = "ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđẠẢÃÀÁÂẬẦẤẨẪĂẮẰẶẲẴÓÒỌÕỎÔỘỔỖỒỐƠỜỚỢỞỠÉÈẺẸẼÊẾỀỆỂỄÚÙỤỦŨƯỰỮỬỪỨÍÌỊỈĨÝỲỶỴỸĐ"
@hncuong
hncuong / ngrams.py
Created December 5, 2017 03:25 — forked from benhoyt/ngrams.py
Print most frequent N-grams in given file
"""Print most frequent N-grams in given file.
Usage: python ngrams.py filename
Problem description: Build a tool which receives a corpus of text,
analyses it and reports the top 10 most frequent bigrams, trigrams,
four-grams (i.e. most frequently occurring two, three and four word
consecutive combinations).
NOTES
/*
* Copyright (C) VNG Corp - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by Chien Nguyen Dang<dangchienhsgs@gmail.com>, September 2016
*/
package com.zalo.crawler.db.elastic;
import com.zalo.data.utils.LogCenter;
@hncuong
hncuong / hkrelax.py
Created September 12, 2017 09:00 — forked from dgleich/hkrelax.py
"""
hkrelax.py
A demonstration of a relaxation method for computing a heat-kernel based
community that implements the algorith from "Heat-kernel based community
detection" by Kloster & Gleich.
Written by Kyle Kloster and David F. Gleich
"""
@hncuong
hncuong / bobp-python.md
Created August 16, 2017 07:29 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@hncuong
hncuong / lol.c
Last active November 23, 2016 06:36
#st