A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| ### 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 |
| """ | |
| 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 |
| 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; |
| #!/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 = "ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđẠẢÃÀÁÂẬẦẤẨẪĂẮẰẶẲẴÓÒỌÕỎÔỘỔỖỒỐƠỜỚỢỞỠÉÈẺẸẼÊẾỀỆỂỄÚÙỤỦŨƯỰỮỬỪỨÍÌỊỈĨÝỲỶỴỸĐ" |
| """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; |
| """ | |
| 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 | |
| """ |
| #st |