Skip to content

Instantly share code, notes, and snippets.

View shibuiwilliam's full-sized avatar

shibuiwilliam shibuiwilliam

View GitHub Profile
import json
import operator
import uuid
from datetime import datetime
from pathlib import Path
from typing import Annotated, Any, Dict, List, Optional, TypedDict
from dotenv import load_dotenv
from langchain_core.messages import BaseMessage, HumanMessage, SystemMessage
from langchain_openai import AzureChatOpenAI
// SpawnManager.cs
// https://github.com/shibuiwilliam/ARWithWord/blob/main/ARWithWord/Assets/Scripts/SpawnManager.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
private fun initDistanceTable(){
for (i in 0 until Constants.maxNumMultiplePoints+1){
val tableRow = TableRow(this)
multipleDistanceTableLayout.addView(tableRow,
multipleDistanceTableLayout.width,
Constants.multipleDistanceTableHeight / (Constants.maxNumMultiplePoints + 1))
for (j in 0 until Constants.maxNumMultiplePoints+1){
val textView = TextView(this)
textView.setTextColor(Color.WHITE)
if (i==0){
private fun tapDistanceOfMultiplePoints(hitResult: HitResult){
if (placedAnchorNodes.size >= Constants.maxNumMultiplePoints){
clearAllAnchors()
}
ViewRenderable
.builder()
.setView(this, R.layout.point_text_layout)
.build()
.thenAccept{
it.isShadowReceiver = false
private fun tapDistanceOf2Points(hitResult: HitResult){
if (placedAnchorNodes.size == 0){
placeAnchor(hitResult, cubeRenderable!!)
}
else if (placedAnchorNodes.size == 1){
placeAnchor(hitResult, cubeRenderable!!)
val midPosition = floatArrayOf(
(placedAnchorNodes[0].worldPosition.x + placedAnchorNodes[1].worldPosition.x) / 2,
(placedAnchorNodes[0].worldPosition.y + placedAnchorNodes[1].worldPosition.y) / 2,
private fun measureDistanceFromCamera(){
val frame = arFragment!!.arSceneView.arFrame
if (placedAnchorNodes.size >= 1) {
val distanceMeter = calculateDistance(
placedAnchorNodes[0].worldPosition,
frame!!.camera.pose)
measureDistanceOf2Points(distanceMeter)
}
}
private fun placeAnchor(hitResult: HitResult,
renderable: Renderable){
val anchor = hitResult.createAnchor()
placedAnchors.add(anchor)
val anchorNode = AnchorNode(anchor).apply {
isSmoothed = true
setParent(arFragment!!.arSceneView.scene)
}
placedAnchorNodes.add(anchorNode)
@shibuiwilliam
shibuiwilliam / TensorflowOnSparkOnDocker
Last active October 21, 2021 09:01
TensorFlowOnSpark on Dockerfile
FROM ubuntu
MAINTAINER cvusk
# insert hostname on environmental variable
ENV HOSTNAME tensorflow.spark
# install prerequisites
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install apt-utils
@shibuiwilliam
shibuiwilliam / keras_fizzbuzz
Created February 11, 2017 12:44
fizzbuzz in Keras
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils
from keras.layers import Dense
from keras.models import Model
# create training data
def binary_encode(i, num_digits):