Skip to content

Instantly share code, notes, and snippets.

View oyiptong's full-sized avatar

Olivier Yiptong oyiptong

View GitHub Profile
@oyiptong
oyiptong / split.py
Created November 5, 2024 04:56
A program that splits a PDF document into multiple 15-page documents.
import sys
from PyPDF2 import PdfWriter, PdfReader
inputpdf = PdfReader(open("book_name.pdf", "rb"))
pages = list(range(0, len(inputpdf.pages)))
chunk_size = 15
page_chunks = [pages[i:i + chunk_size] for i in range(0, len(inputpdf.pages), chunk_size)]
@oyiptong
oyiptong / document_ai_ocr.py
Created November 5, 2024 04:54
A program that takes PDF chunks and sends them to Google's Document AI for OCR
from glob import glob
from google.api_core.client_options import ClientOptions
from google.cloud import documentai # type: ignore
# TODO(developer): Uncomment these variables before running the sample.
project_id = "PROJECT_ID"
location = "us" # Format is "us" or "eu"
file_paths = sorted(glob("document-chunk-*.pdf"))
processor_display_name = "BOOK_OCR_PROCESSOR" # Must be unique per project, e.g.: "My Processor"
@oyiptong
oyiptong / cpu_power.py
Created February 3, 2021 01:01 — forked from carlashley/cpu_power.py
CPU Power
#!/usr/bin/python
# A dictionary of available CPU's, COU scheduler limit, and CPU speed limit
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'power', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/IOKit/Power/CPUPower')
{
"teachers-heard": [
67,
24.907063197026023
],
"outbreak-plans": [
61,
22.676579925650557
],
"no-concerns": [
(function () {
api.register('font-js', function () {
var t0 = performance.now(); // If you insert a new font, please sort the list
var fonts = ['.Aqua Kana', '.Helvetica LT MM', '.Times LT MM', '18thCentury', '8514oem', 'AR BERKLEY', 'AR JULIAN', 'AR PL UKai CN', 'AR PL UMing CN', 'AR PL UMing HK', 'AR PL UMing TW', 'AR PL UMing TW MBE', 'Aakar', 'Abadi MT Condensed Extra Bold', 'Abadi MT Condensed Light', 'Abyssinica SIL', 'AcmeFont', 'Adobe Arabic', 'Agency FB', 'Aharoni', 'Aharoni Bold', 'Al Bayan', 'Al Bayan Bold', 'Al Bayan Plain', 'Al Nile', 'Al Tarikh', 'Aldhabi', 'Alfredo', 'Algerian', 'Alien Encounters', 'Almonte Snow', 'American Typewriter', 'American Typewriter Bold', 'American Typewriter Condensed', 'American Typewriter Light', 'Amethyst', 'Andale Mono', 'Andale Mono Version', 'Andalus', 'Angsana New', 'AngsanaUPC', 'Ani', 'AnjaliOldLipi', 'Aparajita', 'Apple Braille', 'Apple Braille Outline 6 Dot', 'Apple Braille Outline 8 Dot', 'Apple Braille Pinpoint 6 Dot', 'Apple Braille Pinpoint 8
@oyiptong
oyiptong / manifest.json
Created March 29, 2020 08:53
File Handling
{
"manifest_version": 2,
"description": "Native FS Demo Editor",
"name": "Native FS Editor",
"short_name": "nativefs_ed",
"start_url": ".",
"display": "standalone",
"background_color": "grey",
"icons": [
{
{
"wrapperType": "track",
"kind": "podcast",
"artistId": 974891224,
"collectionId": 360084272,
"trackId": 360084272,
"artistName": "Joe Rogan",
"collectionName": "The Joe Rogan Experience",
"trackName": "The Joe Rogan Experience",
"collectionCensoredName": "The Joe Rogan Experience",
{
"wrapperType": "track",
"kind": "podcast",
"collectionId": 1012570406,
"trackId": 1012570406,
"artistName": "Andy Frisella #100to0",
"collectionName": "The MFCEO Project",
"trackName": "The MFCEO Project",
"collectionCensoredName": "The MFCEO Project",
"trackCensoredName": "The MFCEO Project",

Keybase proof

I hereby claim:

  • I am oyiptong on github.
  • I am oyiptong (https://keybase.io/oyiptong) on keybase.
  • I have a public key ASCfEbnT6GNwRY-gV_LjiA0nmbWUg9cB0PzQzNG8Rbcnzwo

To claim this, I am signing this object:

// -- snip --
manager()->CreateSwapFileForURL(
url(),
base::BindOnce([](CreateFileWriterCallback callback) {
base::File::Error result,
const storage::FileSystemURL& swap_url) {
// Canned answer for now.
std::move(callback).Run(
NativeFileSystemError::New(base::File::FILE_OK),
nullptr);