Skip to content

Instantly share code, notes, and snippets.

View feliperyan's full-sized avatar

Felipe Ryan feliperyan

View GitHub Profile
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
/// CameraApp is the Main Application.
class CameraView extends StatefulWidget {
/// Default Constructor
const CameraView({super.key});
@override
State<CameraView> createState() => _CameraViewState();
from flask import Flask, send_file, render_template_string
from google.cloud import storage
import os
import io
app = Flask(__name__)
# Configure the environment variable for GCS credentials
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/your/service-account-file.json"
@feliperyan
feliperyan / main.py
Created February 29, 2024 04:15
JSON Output Gemini
import json
import logging
from typing import List, Dict, Any
from langchain_google_vertexai import VertexAI
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from langchain.output_parsers import OutputFixingParser
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.runnables.base import RunnableSerializable
import asyncio
from quart import Quart, request
app = Quart(__name__)
@app.route('/', methods=['GET'])
async def sleep():
await asyncio.sleep(4)
print("received request")
return 'Slept for 400ms'
@feliperyan
feliperyan / ip_change_notifier.py
Created October 22, 2020 04:52
Notify me on Slack when my external IP changes
from urllib.request import urlopen
from urllib import request
resp = urlopen("https://api.ipify.org")
ip = resp.read().decode('utf-8').strip()
f = open('last_ip.txt', 'r+')
last_ip = f.read().strip()
if (ip != last_ip):
@feliperyan
feliperyan / geofenceevents.js
Created October 23, 2019 15:53
platform events lightning web component variable scope shenanigans
import { LightningElement, track } from 'lwc';
import { subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled } from 'lightning/empApi';
export default class Geofenceevent extends LightningElement {
@track channelName = '/event/GeoFenceTrip__e';
@track isSubscribeDisabled = false;
@track isUnsubscribeDisabled = !this.isSubscribeDisabled;
subscription = {};
@feliperyan
feliperyan / multiple-workers-stopping.go
Last active July 29, 2019 15:13
Example of telling multiple go routines to stop and waiting for them to all stop.
package main
import (
"fmt"
"time"
)
func doSomework(imDone chan bool, stopMe chan bool, breakTime int, name string) {
outer:
for {
@feliperyan
feliperyan / drone_test.go
Created July 17, 2019 14:03
Testing the drone_simulation
package main
import (
"testing"
"fmt"
)
func getDrone() *Drone {
d := &Drone{}
d.CurrentPosition = GPSCoord{3, 3}
@feliperyan
feliperyan / drone_simulation.go
Created July 17, 2019 14:01
Will convert getPositionTowardsDestination() to interpolation next!
package main
import (
"fmt"
"math"
)
type GPSCoord struct {
Lat float64
Lon float64
@feliperyan
feliperyan / websocket_graceful.go
Last active April 23, 2021 14:55
An attempt to gracefully shutdown websockets on go using gorilla/websockets
package main
import (
"context"
"fmt"
"github.com/gorilla/websocket"
"log"
"net/http"
"os"
"os/signal"