Skip to content

Instantly share code, notes, and snippets.

View makmac213's full-sized avatar

Mark Allan B. Meriales makmac213

View GitHub Profile
@makmac213
makmac213 / diktador.py
Created December 12, 2021 15:36
Auto-suggest next word
import re
from nltk import (
FreqDist,
ngrams,
word_tokenize
)
def tokenize_phrases(phrases):
ret = []
for phrase in phrases:
# homebrew
# https://brew.sh
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# git
$ brew install git
# pip
$ sudo easy_install pip
@makmac213
makmac213 / thon.py
Last active April 24, 2020 10:32
Lodi Petmalu
# wadpata alaws wamaga ):
VOWELS = ["a", "e", "i", "o", "u"]
ADD_S = ["n", "t", "w"]
def syllabicate(word):
# Yorme style syllabication
# TODO: Incomplete find other test cases
word = word.lower()
0x119E2c5b180D8d2Bee8c2Fca42E9f4443A4D6fB2
import json
import requests
from bottle import debug, request, route, run
GRAPH_URL = "https://graph.facebook.com/v2.6"
VERIFY_TOKEN = 'YOUR_VERIFY_TOKEN'
PAGE_TOKEN = 'YOUR_PAGE_TOKEN'
def send_to_messenger(ctx):
import json
import requests
from bottle import debug, request, route, run
def build_service_url(service_url, cid):
"""build the service url"""
service_url = '{0}/v3/conversations/{1}/activities/'.format(service_url, cid)
return service_url
@makmac213
makmac213 / hugotbot.py
Last active December 17, 2018 11:41
hugotbot.py
from nltk.chat.util import Chat, reflections
pairs = [
[
r"My name is (.*)",
['hello %1', '%1 mabuhay ka'],
],
[
r'hi',
['hello', 'kamusta', 'mabuhay',],
# export script
# export_script.js
print("subject,sender,recipient,created")
db.collectionname.find({'subject':/for you/}).foreach(function(email){
print(email.subject+","+email.sender+","+email.recipient+","+email.created);
});
# then run this line
$ mongo tablename export_script.js > export_file.csv
from django.contrib.auth.models import User
from django.db.models import Count
qs = (User.objects.all().
extra(select={
'm': "EXTRACT(month FROM date_joined)",
'd': "EXTRACT(day FROM date_joined)",
'y': "EXTRACT(year FROM date_joined)",
}).
values('d', 'm', 'y').
@makmac213
makmac213 / sitemap_status_crawler.py
Created March 10, 2016 18:38
Sitemap Status Crawler
import requests
from BeautifulSoup import BeautifulSoup
resp = requests.get('http://www.ofwguru.com/sitemap.xml')
soup = BeautifulSoup(resp.content)
urls = soup.findAll('url')
for url in urls:
loc = url.find('loc').string