Skip to content

Instantly share code, notes, and snippets.

View wannaphong's full-sized avatar

Wannaphong Phatthiyaphaibun wannaphong

View GitHub Profile
@stewartpark
stewartpark / xor.py
Created October 12, 2015 08:17
Simple XOR learning with keras
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))
@filipkral
filipkral / python-cheat-sheet-basic.py
Last active March 12, 2023 12:30
Basic Python Cheat Sheet
#!/usr/bin/env python
"""Basic Python Cheat Sheet by Filip Kral on 2015/02/16"""
"""
Python is a cross-platform, interpreted, object-oriented programming language.
That means you can run it on Linux, Windows, Mac, and other platforms,
you don't need to compile your code to execute it because it is compiled on
the fly, and you can use classes and objects.
@avinassh
avinassh / container.xml
Created October 27, 2015 05:38 — forked from anqxyr/archived
Create EPUB files with Python
<?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>
@jiffyclub
jiffyclub / jdutil.py
Created October 18, 2011 02:03
Functions for converting dates to/from JD and MJD
"""
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
"""
@bgreenlee
bgreenlee / autocorrrect.py
Created October 28, 2011 00:01
Simple ngram autocorrect #python #algorithms
import os.path
import collections
from operator import itemgetter
WORDFILE = '/usr/share/dict/words'
class Autocorrect(object):
"""
Very simplistic implementation of autocorrect using ngrams.
"""
@fheisler
fheisler / q.py
Created March 31, 2015 23:02
Q-learning Tic-tac-toe
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):
@dpk
dpk / gist:8325992
Last active February 27, 2024 05:08
PyICU cheat sheet

PyICU cheat sheet

Because you can't get the docs.

Transliteration

Create a transliterator:

greek2latin = icu.Transliterator.createInstance('Greek-Latin')
@HughP
HughP / UAX_29.py
Created March 30, 2015 06:10
PyICU
# We start by loading up PyICU.
import PyICU as icu
# Let's create a test text. Notice it contains some punctuation.
test = u"This is (\"a\") test!"
# We create a wordbreak iterator. All break iterators in ICU are really RuleBasedBreakIterators, and we need to tell it which locale to take the word break rules from. Most locales have the same rules for UAX#29 so we will use English.
wb = icu.BreakIterator.createWordInstance(icu.Locale.getEnglish())
# An iterator is just that. It contains state and then we iterate over it. The state in this case is the text we want to break. So we set that.
@alexanderbazo
alexanderbazo / build.yml
Created December 6, 2019 16:07
Github Actions: Build and Release Android-APK
name: Minimal Android CI Workflow
on:
push:
branches:
- master
tags:
- 'v*'
jobs:
@pdl
pdl / pl2py.pl
Created October 23, 2012 14:28
Convert perl scripts to python with the awesome power of regular expressions.
#!perl -w
=head1 NAME
pl2py.pl
=head1 DESCRIPTION
Attempts to convert perl scripts to python with the awesome power of regular expressions.