Skip to content

Instantly share code, notes, and snippets.

View beatobongco's full-sized avatar

Beato Bongco beatobongco

View GitHub Profile
@beatobongco
beatobongco / replace.py
Last active May 13, 2022 08:20
Replace non-english sentences
import re
import math
import enchant
d = enchant.Dict("en_US")
def replace_noneng_sents(text: str, replace_with_spaces=True,
split_regex=r"[\.\。\!\?\?]",
clean_regex=r"[^a-zA-Z\']",
threshold=0.5,
debug=False) -> str:
@beatobongco
beatobongco / ML_Links.md
Created October 3, 2019 02:46
Awesome links to get started with machine learning!
@beatobongco
beatobongco / scrape.js
Created September 3, 2019 09:30
Scraping a webpage via console
// Create an interval which will keep scrolling downwards
const interval = setInterval(() => {
window.scrollTo(0, document.body.scrollHeight)
}, 250)
// If there are no more items, you can call `clearInterval(interval)` to stop scrolling
// Now copy the below code to scrape data and download a file containing the data
;(() => {
// Define a function to scrape elements we want
@beatobongco
beatobongco / fastai_workshop_1.ipynb
Created April 9, 2019 04:16
FastAI_Workshop_1.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@beatobongco
beatobongco / bq.sql
Last active March 19, 2019 07:50
BQ puzzles
-- get hours on a project, 0 is no hours
SELECT
name,
ifnull(SUM(w.hours),
0) AS hours
FROM (
SELECT
DISTINCT(name),
id,
0 AS hours
@beatobongco
beatobongco / dataset_splitter.py
Created September 16, 2018 14:00
Split datasets
import shutil
import random
from pathlib import Path
from typing import List
def dataset_splitter(output_dir: str = 'output', classes: List[str] = [], num_train=0, num_validation=0):
"""In the current directory, take files of a class and randomly copy a certain number of training examples
and validation examples into a new output directory.
var cool = null
$.get('https://beatobongco.com/book-highlights/book/shoe-dog', function(a) {
var el = document.createElement('html')
el.innerHTML = a
cool = el
})
$('#raw-notes', cool).text() // gets contentes of div with id raw-notes
// 1. Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";
// 2. Run > setup
//
// 3. Publish > Deploy as web app
// - enter Project Version name and click 'Save New Version'
// - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)
//
// 4. Copy the 'Current web app URL' and post this in your form/script action
@beatobongco
beatobongco / bgc.css
Last active August 29, 2015 14:22
BGC CSS
.test {
width: 100%;
}
@beatobongco
beatobongco / queue.js
Created April 29, 2015 10:45
Useful for queueing animations
function Queue() {
this._sleep = 0
this.add = function(f, sleep) {
this._sleep += sleep
setTimeout(function(){
f()
}, this._sleep)
}
}