Skip to content

Instantly share code, notes, and snippets.

View BetterProgramming's full-sized avatar

BetterProgramming

View GitHub Profile
struct SideBarStack<SidebarContent: View, Content: View>: View {
let sidebarContent: SidebarContent
let mainContent: Content
let sidebarWidth: CGFloat
@Binding var showSidebar: Bool
init(sidebarWidth: CGFloat, showSidebar: Binding<Bool>, @ViewBuilder sidebar: ()->SidebarContent, @ViewBuilder content: ()->Content) {
self.sidebarWidth = sidebarWidth
self._showSidebar = showSidebar
#!/bin/bash
# Firebase service account decrypt
- openssl aes-256-cbc -K $encrypted_XXXXXXXXXXXX_key -iv $encrypted_XXXXXXXXXXXX_iv
-in service-account.json.enc -out service-account.json -d
# Install Google Cloud SDK
wget --quiet --output-document=/tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
mkdir -p /opt
tar zxf /tmp/google-cloud-sdk.tar.gz --directory /opt
/opt/google-cloud-sdk/install.sh --quiet
/// An animatable modifier that is used for observing animations for a given animatable value.
struct AnimationCompletionObserverModifier<Value>: AnimatableModifier where Value: VectorArithmetic {
/// While animating, SwiftUI changes the old input value to the new target value using this property. This value is set to the old value until the animation completes.
var animatableData: Value {
didSet {
notifyCompletionIfFinished()
}
}
// Search view
HStack {
HStack {
//search bar magnifying glass image
Image(systemName: "magnifyingglass").foregroundColor(.secondary)
//search bar text field
TextField("search", text: self.$searchText, onEditingChanged: { isEditing in
self.showCancelButton = true
})
import React from 'react';
const Iframe = (props) => {
let iframe_ref = null;
const writeHTML = (frame) => {
if (!frame) {
return;
}
iframe_ref = frame;
let doc = frame.contentDocument;
doc.open();
module.exports = {
webpack: function (config, env) {
return config;
},
jest: function (config) {
return config;
},
// configFunction is the original react-scripts function that creates the
// Webpack Dev Server config based on the settings for proxy/allowedHost.
// react-scripts injects this into your function (so you can use it to
senders:
smsSender: {
messageTitle: "Hello from ThunderOTP!",
messageTemplate: "Your OTP is: #{otp}, you must take care of it's valid for 5 minutes.",
otpLength: 5,
useLetters: false,
useDigits: true,
ttlMinutes: 5,
accountSid: "secret",
serviceKey: "secret",
class AuthorizedClientsAuthProvider(
private val config: Config
): AuthenticationProvider(config), KoinComponent {
private val authorizedClientsRepository by inject<AuthorizedClientsRepository>()
override suspend fun onAuthenticate(context: AuthenticationContext) {
context.call.request.headers[config.headerName]?.let { clientId ->
if(authorizedClientsRepository.exists(clientId)) {
context.principal(UserIdPrincipal(clientId))
} else {
throw UnauthorizedClientException("Authorization Failed")
fun Application.configureRouting() {
install(StatusPages) {
exception<RequestValidationException> { call, cause ->
call.respond(HttpStatusCode.BadRequest,
ErrorType.REQUEST_VALIDATION_FAILED.toErrorResponseDTO().copy(details = cause.reasons.joinToString()))
}
configureAuthorizedClientsStatusPages()
configureOtpStatusPages()
}
routing {
graalvmNative {
binaries {
named("main") {
fallback.set(false)
verbose.set(true)
buildArgs.add("--initialize-at-build-time=io.ktor,kotlin,ch.qos.logback,kotlinx.serialization,org.slf4j,io.netty")
buildArgs.add("--initialize-at-build-time=kotlinx.coroutines")
buildArgs.add("--initialize-at-run-time=io.netty.channel.DefaultFileRegion")
buildArgs.add("--initialize-at-run-time=io.netty.channel.epoll.Native")
buildArgs.add("--initialize-at-run-time=io.netty.channel.epoll.Epoll")