Skip to content

Instantly share code, notes, and snippets.

@yishingene
yishingene / pointer.go
Last active July 28, 2022 02:15
Golang pointer
package main
import "fmt"
type person struct {
name string
}
func main() {
p := person{"Richard"}
@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 / Future_async_await.dart
Created June 1, 2019 15:32
Future, implement using async, await
import 'dart:async';
main() async {
print('about to fetch data!');
var result = await get('http://www.google.com');
print(result);
}
@yishingene
yishingene / Future_dart.dart
Last active June 1, 2019 15:27
Future implemented in Dart , print something first, then show get function completed message after 3 seconds by using future
import 'dart:async';
main(){
print('about to fetch data!');
get('http://www.google.com').then(
(result){
print(result);
@yishingene
yishingene / named_cosntructor_ex.dart
Created May 30, 2019 02:33
Notion of named constructor
import 'dart:math';
void main(){
final myPoint = new Point.zero();
print(myPoint);
final myPoint_somevalue = new Point(2,3);
print(myPoint_somevalue);
@yishingene
yishingene / main.dart
Last active May 28, 2019 05:22
Practice on DartPad
//撲克牌專案12
void main() {
var deck = new Deck();
print(deck);
deck.removeCard('Diamonds','Ace');
print(deck);
}
// collection of cards
@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>