Skip to content

Instantly share code, notes, and snippets.

View dedSyn4ps3's full-sized avatar
💭
Working on new projects 💻 ☕

Ed Rutherford dedSyn4ps3

💭
Working on new projects 💻 ☕
View GitHub Profile
@dedSyn4ps3
dedSyn4ps3 / main.rs
Created September 12, 2022 02:26
This is a simple example of how a main.rs file may look for a Tauri app that provides the ability for the UI to communicate with the backend to make various requests and actions that should not be handled directly by the frontend.
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use reqwest;
use std::io::Read;
#[tauri::command]
fn get_data(address: String, endpoint: String) -> String {
@dedSyn4ps3
dedSyn4ps3 / Dashboard.js
Created September 22, 2022 04:02
Simple function to make a backend GET request
//////////////////////////////////////////////////////////////////////////////////
// Make call to Rust backend to query the Pi's flask server for sensor values //
//////////////////////////////////////////////////////////////////////////////////
callBackend() {
let i = localStorage.getItem("pi_address");
if (i == "") {
console.log("[!] No sensor address available -> Update device info using the SideDash tab... [!]");
this.setAddressModalVisible(true);
} else {
@dedSyn4ps3
dedSyn4ps3 / build-appimage.sh
Created September 22, 2022 04:33
Create an AppImage from a generated AppDir
# Download appimagetool
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage
# Make it executable
chmod a+x appimagetool-aarch64.AppImage
# Run the tool, specifying the AppDir that the `yarn tauri build` command generates
./appimagetool-aarch64.AppImage <project-directory>/src-tauri/target/release/bundle/appimage/<project-name>.AppDir
package main
import (
"context"
"fmt"
)
// App struct
type App struct {
ctx context.Context
@dedSyn4ps3
dedSyn4ps3 / wails-main.go
Last active October 12, 2022 19:40
Example Wails `main` file
package main
import (
"embed"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
//go:embed all:frontend/dist
@dedSyn4ps3
dedSyn4ps3 / CardGroup.jsx
Created October 12, 2022 19:28
Example components using MDBootstrap React
import React from 'react';
import {
MDBCard,
MDBCardImage,
MDBCardBody,
MDBCardTitle,
MDBCardText,
MDBRow,
MDBCol
} from 'mdb-react-ui-kit';
import { useState } from 'react';
import './App.css';
import { Greet } from "../wailsjs/go/main/App";
import TopNav from './TopNav';
import CardGroup from './CardGroup';
function App() {
const [resultText, setResultText] = useState("Please enter your name below 👇");
const [name, setName] = useState('');
@dedSyn4ps3
dedSyn4ps3 / App.js
Created November 5, 2022 03:46
Main react native project file for Medium article
import React from 'react';
import { useColorScheme } from 'react-native';
import { MD3LightTheme, MD3DarkTheme, Provider as PaperProvider } from 'react-native-paper';
import { AppNavigator } from './components/MainNavigator';
import { StatusBar } from 'expo-status-bar';
const MaterialLightTheme = {
...MD3LightTheme,
{
"name": "example-app",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
import React, { Component } from 'react';
import { ImageBackground, StyleSheet, View } from 'react-native';
import { Card, Title, Paragraph } from 'react-native-paper';
export default class ImageCard extends Component {
constructor(props) {
super(props);
}