This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('@google-cloud/functions-framework'); | |
const express = require('express'); | |
const app = express(); | |
// GET /myFunction | |
app.get('/', async (req, res) => { | |
res.status(200).send('Default route'); | |
}); | |
// GET /myFunction/other |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/pkg/errors" | |
) | |
// Custom Error Type | |
type InvalidInputError struct { | |
Field string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If I have an integer between 4 and 5 called avg and I have another integer between 5000 and 100000 called count how could I logarithmically reduce the avg integer as the count gets closer to its maximum value? Can you write me a function to do this in rust? | |
fn logarithmic_reduce(avg: f64, count: u32, max_count: u32) -> f64 { | |
// Ensure count does not exceed max_count to prevent negative logarithm values | |
let clamped_count = count.min(max_count); | |
// Scale factor to ensure the reduction effect | |
let scale = (clamped_count as f64) / (max_count as f64); | |
// Logarithmic reduction effect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tokio::runtime::Runtime; | |
async fn async_task() -> i32 { | |
// Your asynchronous code here | |
42 | |
} | |
fn main() { | |
let rt = Runtime::new().unwrap(); | |
let result = rt.block_on(async_task()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define a struct called Person | |
struct Person { | |
name: String, | |
age: u8, | |
} | |
impl Person { | |
// Method to create a new person | |
fn new(name: &str, age: u8) -> Person { | |
Person { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: This batch file does a `cargo build` and if successful, moves the credentials.json file into the build dir. | |
@ECHO ON | |
set "DIR=%~dp0" | |
set "FILE=credentials.json" | |
echo %DIR% | |
cargo %1 | |
IF %errorlevel% == 0 ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.amd.com/en/support/linux-drivers | |
// In order to have visualping detect the Ubuntu version change, we first need VisualPing to expand all the <details> elements: | |
document.querySelectorAll('details.os-group').forEach((el) => { el.setAttribute('open', true) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl \ | |
--header "Content-Type: application/json" \ | |
--header "Authorization: Bearer abc123" \ | |
--request POST \ | |
--data '{"username":"xyz","password":"xyz"}' \ | |
http://localhost:3000/api/myendpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select { | |
appearance: none; | |
width: 100%; | |
transition-property: background, color, padding, margin; | |
transition-duration: 150ms; | |
outline-width: 0.125rem; | |
outline-style: solid; | |
outline-color: transparent; | |
outline-offset: 0.125rem; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// Usage: | |
<button id="counter" type="button"></button> | |
import { setupCounter } from './counter.js' | |
setupCounter(document.querySelector('#counter')) | |
*/ | |
export function setupCounter(element) { |
NewerOlder