Skip to content

Instantly share code, notes, and snippets.

@yishingene
yishingene / movielens.py
Created March 5, 2021 06:41 — forked from BarclayII/movielens.py
PinSage example implementation
import pandas as pd
import dgl
import os
import torch
class MovieLens(object):
def __init__(self, directory):
'''
directory: path to movielens directory which should have the three
files:
@yishingene
yishingene / imageToText.gs
Created August 4, 2019 11:26 — forked from tagplus5/imageToText.gs
google apps script image to text ocr
function doGet(request) {
if (request.parameters.url != undefined && request.parameters.url != "") {
var imageBlob = UrlFetchApp.fetch(request.parameters.url).getBlob();
var resource = {
title: imageBlob.getName(),
mimeType: imageBlob.getContentType()
};
var options = {
ocr: true
};
@yishingene
yishingene / batch_ocr.gs
Created August 4, 2019 11:25 — forked from rob0tca/batch_ocr.gs
Google Apps script for performing OCR on all JPEGS found in the specified Drive folder. Extracts text to a Google sheet, where it's mapped to the JPEG's filename.
function extractTextOnOpen() {
//ADD YOUR VALUES BELOW
var folderName = "[YOUR PROJECT FOLDER]";
var sheetId = "[YOUR SHEET ID]";
//Define folder
var folder = DriveApp.getFoldersByName(folderName).next();
var folderId = folder.getId();
@yishingene
yishingene / whatFilesHaveIShared.gs
Created May 11, 2019 09:46 — forked from danjargold/whatFilesHaveIShared.gs
Google script to list (on a Google Sheet) all files shared in your google drive, including all viewers, editors, and sharing permissions. Credit goes to @woodwardtw (https://gist.github.com/woodwardtw/22a199ecca73ff15a0eb) as this is an improvement on his code which only assesses a single folder and one level of sub-folders down.
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Sharing Access", "Sharing Permission", "Get Editors", "Get Viewers", "Date", "Size", "URL", "Download", "Description", "Type"]); //writes the headers
//var folder = DriveApp.getFolderById("INSERT_YOUR_FILE_ID");//that long chunk of random numbers/letters in the URL when you navigate to the folder
//getLooseFiles(folder, sheet);
//getSubFolders(folder, sheet);
//instead of getting folder by ID rather get all folders and cycle through each. Note this will miss loose files in parent directory.
var folder = DriveApp.getFolders()
@yishingene
yishingene / upload-files-with-flask.md
Created February 24, 2018 14:54 — forked from seanbehan/upload-files-with-flask.md
upload files to s3 with flask, PIL and tinys3

HTML form for file uploads

<!-- in templates/form.html -->
<form action="/upload" method="POST" enctype="multipart/form-data">
 <input type="file" name="logo">
 <button>Upload</button>
</form>
import requests
import json
import os
HEADER = {
'Content-type': 'application/json',
'Authorization': 'Bearer ' + 'Channel Access Token'
}
def lambda_handler(event, context):
股價收盤價抓取練習.py
只能抓取近一個月,因為網站提供資料有限
股價收盤價抓取練習.py
只能抓取近一個月,因為網站提供資料有限
繁簡轉換
參考:http://www.j4.com.tw/big-gb/
以 str.translate 做簡單的繁簡table轉換,但仍有繁簡字一對多的問題
@yishingene
yishingene / 財報.py
Created November 30, 2017 09:16 — forked from NEJmark/財報.py
# -*- coding: utf-8 -*-
import urllib
import lxml.etree as etree
url='http://mops.twse.com.tw/server-java/t164sb01?step=1&CO_ID=2330&SYEAR=2013&SSEASON=1&REPORT_ID=C'
response = urllib.urlopen(url)
html= response.read()
page = etree.HTML(html.decode('cp950'))
item_to_print=[u'基本每股盈餘合計',u'營業收入合計']
for tr in page.xpath('(.//tr[@class="even"]|.//tr[@class="odd"])'):