This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<TResult> Map<in TSource, TResult>(IEnumerable<TSource> sources, Func<TSource, TResult> mapper) | |
{ | |
foreach (var source in sources) | |
{ | |
yield return mapper(source); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class TicTacToe: | |
def __init__(self, playerX, playerO): | |
self.board = [' ']*9 | |
self.playerX, self.playerO = playerX, playerO | |
self.playerX_turn = random.choice([True, False]) | |
def play_game(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import os.path | |
import sys | |
from gensim.corpora import WikiCorpus | |
if __name__ == '__main__': | |
program = os.path.basename(sys.argv[0]) | |
logger = logging.getLogger(program) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
import os.path | |
import sys | |
import multiprocessing | |
from gensim.corpora import WikiCorpus | |
from gensim.models import Word2Vec | |
from gensim.models.word2vec import LineSentence | |
if __name__ == '__main__': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# อ่านบทความได้ที่ https://python3.wannaphong.com/2017/02/wordnet-ภาษาไทยกับ-python.html | |
from __future__ import print_function | |
import sqlite3 | |
from collections import namedtuple | |
conn = sqlite3.connect('tha-wn.db') | |
Word = namedtuple('Word', 'synsetid li') | |
Synset = namedtuple('Synset', 'synset li') | |
def getWords(wordid): | |
words = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Functions for converting dates to/from JD and MJD. Assumes dates are historical | |
dates, including the transition from the Julian calendar to the Gregorian | |
calendar in 1582. No support for proleptic Gregorian/Julian calendars. | |
:Author: Matt Davis | |
:Website: http://github.com/jiffyclub | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Example of `builder' design pattern | |
# Copyright (C) 2011 Radek Pazdera | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" lang="th" xml:lang="th"><head><title>Scala</title><meta name="keywords" content=" reddit, reddit.com, vote, comment, submit " /><meta name="description" content="reddit: the front page of the internet" /><meta name="referrer" content="always"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link type="application/opensearchdescription+xml" rel="search" href="/static/opensearch.xml"/><link rel="canonical" href="https://www.reddit.com/r/Python/" /><meta name="viewport" content="width=1024"><link rel="dns-prefetch" href="//out.reddit.com"><link rel="preconnect" href="//out.reddit.com"><link rel='icon' href="//www.redditstatic.com/icon.png" sizes="256x256" type="image/png" /><link rel='shortcut icon' href="//www.redditstatic.com/favicon.ico" type="image/x-icon" /><link rel='apple-touch-icon-precomposed' href="//www.redditstatic.com/icon-touch.png" /><link rel="alternate" type="application/atom+xml" title="RSS" href="https://www.reddit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ทำนายจำนวนประชากรของไทยด้วย Scikit-learn ใน Python | |
# เขียนโดย นาย วรรณพงษ์ ภัททิยไพบูลย์ | |
# https://python3.wannaphong.com | |
# อ่านได้ที่ https://python3.wannaphong.com/2017/05/thailand-population-scikit-learn-python.html | |
# 14 พ.ค. 2560 | |
''' | |
สร้าง dataset ข้อมูลประชากร | |
''' | |
thai = [20986780, | |
21550597, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
time = pd.date_range('1951', periods=67, freq='A') # สร้างช่วงเวลา โดยจะเรียงจาก ปี 1951 ไล่ต่อมา 67 ปี A คือ ปี | |
listtime=time.tolist() | |
plt.plot(listtime,thai) | |
plt.show() # แสดงข้อมูลประชากรจากอดีต | |
data=pd.DataFrame({'date':time.values,'value':thai}) | |
data['date_ordinal'] = data['date'].apply(lambda x: x.toordinal()) # แปลงวันเดือนปีไปเป็น proleptic Gregorian ordinal |