Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
research!!!

Wannaphong Phatthiyaphaibun wannaphong

🔥
research!!!
View GitHub Profile
View epub-embed-fonts.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
from BeautifulSoup import BeautifulSoup, Tag # Better for HTML
from lxml import etree # Better for XML
@wannaphong
wannaphong / container.xml
Created Jan 8, 2017 — forked from avinassh/container.xml
Create EPUB files with Python
View container.xml
<?xml version='1.0' encoding='UTF-8'?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile media-type="application/oebps-package+xml" full-path="content.opf"/>
</rootfiles>
</container>
@wannaphong
wannaphong / xor.py
Created Jan 22, 2017 — forked from stewartpark/xor.py
Simple XOR learning with keras
View xor.py
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD
import numpy as np
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[1],[1],[0]])
model = Sequential()
model.add(Dense(8, input_dim=2))
@wannaphong
wannaphong / map.cs
Created Jan 22, 2017 — forked from huangcd/map.cs
a map function like python in C#
View map.cs
public static IEnumerable<TResult> Map<in TSource, TResult>(IEnumerable<TSource> sources, Func<TSource, TResult> mapper)
{
foreach (var source in sources)
{
yield return mapper(source);
}
}
@wannaphong
wannaphong / q.py
Created Jan 22, 2017 — forked from fheisler/q.py
Q-learning Tic-tac-toe
View q.py
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):
@wannaphong
wannaphong / jdutil.py
Created Feb 11, 2017 — forked from jiffyclub/jdutil.py
Functions for converting dates to/from JD and MJD
View jdutil.py
"""
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
"""
@wannaphong
wannaphong / builder.py
Created Mar 8, 2017 — forked from pazdera/builder.py
Example of `builder' design pattern in Python
View builder.py
#!/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.
@wannaphong
wannaphong / Tensorflow-GPU-ubuntu16.04.md
Last active Jun 13, 2017 — forked from unsalted/Tensorflow-GPU-ubuntu16.04.md
Ubuntu 16.04 - Tensorflow (GPU) setup
View Tensorflow-GPU-ubuntu16.04.md
@wannaphong
wannaphong / LK82.py
Last active Jun 29, 2017 — forked from korakot/LK82.py
Thai Soundex LK82, Udom83
View LK82.py
# ตาม guru.sanook.com/1520
import re
t1 = str.maketrans("กขฃคฅฆงจฉชฌซศษสญยฎดฏตณนฐฑฒถทธบปผพภฝฟมรลฬฤฦวหฮอ",
"กกกกกกงจชชชซซซซยยดดตตนนททททททบปพพพฟฟมรรรรรวหหอ")
t2 = str.maketrans(
"กขฃคฅฆงจฉชซฌฎฏฐฑฒดตถทธศษสญณนรลฬฤฦบปพฟภผฝมำยวไใหฮาๅึืเแโุูอ",
"1111112333333333333333333444444445555555667777889AAABCDEEF")
def LK82(s):
res = []
@wannaphong
wannaphong / ngrams.py
Last active Sep 8, 2017 — forked from benhoyt/ngrams.py
Print most frequent N-grams in given file
View ngrams.py
# -*- coding: utf-8 -*-
"""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).