use opencv::prelude::*;
use opencv::core::{Mat, CV_8UC4};
unsafe {
let height = 1080;
let width = 1920;
let mat = Mat::new_rows_cols_with_data(
height,
width,
CV_8UC4,
my_dib_data,
Mat_AUTO_STEP
).unwrap();
um::wingdi::DeleteObject(hbitmap as shared::windef::HGDIOBJ);
um::wingdi::DeleteDC(HDC_compatible_DC);
um::winuser::ReleaseDC(ptr::null_mut(), HDC_screen);
}
use std::env;
use std::os::windows::process::CommandExt;
use std::process::Command;
use std::sync::RwLock;
use tauri;
const CREATE_NO_WINDOW: u32 = 0x08000000;
pub struct MyClass {
some_var: String,
child: RwLock<Option<std::process::Child>>,
}
impl MyClass {
pub fn new(some_var: &str) -> MyClass {
MyClass {
some_var: some_var.to_string(),
child: RwLock::new(None),
}
}
pub fn execute(&self) {
let child = Command::new(env::current_dir().unwrap().join("my_app.exe"))
.arg("some args")
.arg(
env::current_dir()
.unwrap()
.join("data")
.join(format!("{}.json", "more data")),
)
.creation_flags(CREATE_NO_WINDOW)
.spawn()
.expect("ERROR: Failed to start the child process");
let mut child_lock = self.child.write().unwrap();
*child_lock = Some(child);
}
}
#[tauri::command]
fn my_actual_handler(some_var: &str) {
let my_class = MyClass::new(some_var);
my_class.execute();
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![my_actual_handler])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
use diesel::prelude::*;
use serde_json::Value;
use std::collections::HashMap;
fn apply_filters<T>(mut query: T, filters: &HashMap<String, Value>) -> T
where
T: diesel::query_builder::AsQuery,
T::Query: diesel::query_builder::QueryFragment<diesel::pg::Pg> + Query,
{
for (key, value) in filters {
match value {
Value::String(s) => {
query = query.filter(diesel::dsl::sql(&format!("{} = '{}'", key, s)));
},
// Сюда можно закинуть остальные типы
_ => {}
}
}
query
}
async fn get_list(
pool: web::Data<DatabasePool>,
list: web::Json<List>
) -> Result<HttpResponse, ApiError> {
use schema::users::dsl::*;
let base_query = users.into_boxed(); // Пример базового запроса
let query_with_filters = apply_filters(base_query, &list.filters.unwrap_or_default());
}
use mlua::Lua;
fn main() -> mlua::Result<()> {
let lua = Lua::new();
lua.load(r#"
print("Hello from Lua!")
"#).exec()?;
Ok(())
}
extern "C" {
fn c_function(arg: c_int) -> c_int;
}
fn main() {
unsafe {
c_function(5);
}
}
use libloading::{Library, Symbol};
fn main() {
let lib = Library::new("path_to_library.so").unwrap();
unsafe {
let func: Symbol<unsafe extern fn() -> ()> = lib.get(b"my_function").unwrap();
func();
}
}
background: linear-gradient(0deg, #E7E7DC, #E7E7DC), url(AdobeStock_435181524.jpg), url(howen-KnEbPy08uQE-unsplash.jpg), url(AdobeStock_326192775.jpg);
background: rgba(217, 217, 217, 0.01);
backdrop-filter: blur(235px);
@Module({
imports: [MailerModule.forRoot({
transport: environment.SmtpDetails,
defaults: {
from: environment.SmtpEmail,
},
template: {
dir: path,
adapter: new EjsAdapter(),
options: {
strict: true,
},
},
})
})
const emailData = await this.mailerService.sendMail({
to: emailTo,
from: 'user@test.com',
subject: 'Testing Nest Mailermodule with template',
template: 'notification',
context: { // Data to be sent to template engine.
"code": 'cf1a3f828287',
"username": 'john doe',
},
});
import { useRef } from "react";
const Item = ({ element, renderIn }) => {
const node = useRef(null);
const chooseThis = (event) => {
renderIn.current.appendChild(node.current);
};
return (
<li onClick={chooseThis}>
<h1 ref={node}>{element}</h1>
</li>
);
};
const List = ({ elements, renderIn }) => (
<ul>
{elements.map((element) => (
<Item element={element} renderIn={renderIn} />
))}
</ul>
);
const App = () => {
const elements = ["one", "two", "three"];
const renderIn = useRef(null);
return (
<>
<h1>
Chosen one: <div style={{ color: "red" }} ref={renderIn}></div>
</h1>
<List elements={elements} renderIn={renderIn} />
</>
);
};
export default App;
import { useRef, useEffect } from "react";
const Item = ({ element, pushNode }) => {
const node = useRef(null);
useEffect(() => {
pushNode(node);
}, [node]);
return <li ref={node}>{element}</li>;
};
const List = ({ elements, pushNode }) => {
return (
<ul>
{elements.map((element) => (
<Item element={element} pushNode={pushNode} />
))}
</ul>
);
};
const App = () => {
const elements = ["one", "two", "three"];
const nodes = [];
const pushNode = (node) => nodes.push(node);
const paintRed = (event) => {
nodes.forEach((node) => {
node.current.style.color = "red";
});
};
return (
<>
<List elements={elements} pushNode={pushNode} />
<button onClick={paintRed}>Paint it red</button>
</>
);
};
export default App;
const selectedAnswersCounts = listCheckbox.filter(checkbox => checkbox.checked).length
const form = document.querySelector('#form')
form.addEventListener('submit', onSubmit)
function onSubmit (event) {
event.preventDefault()
let listCheckbox = document.querySelectorAll('.i-6')
listCheckbox = [...listCheckbox]
const selectedAnswersCounts = listCheckbox.filter(checkbox => checkbox.checked).length
// Проверяем выбран ли хотябы один ответ
if (!listCheckbox.some(checkbox => checkbox.checked)) {
alert('Вы не выбрали ни одного ответа')
}
else{
form.addEventListener('submit', onSubmit)
alert('Вы подтверждаете действие?');
}
// Узнаем сколько всего правильных ответов
const rightAnswersCount = listCheckbox.filter(checkbox => Number(checkbox.value) === 1).length
// Узнаем сколько всего не правильных ответов
const wrongAnswerCount = listCheckbox.length - rightAnswersCount
// Узнаем количество правильных ответов
const rightAnswers = listCheckbox.filter(checkbox => Number(checkbox.value) === 1 && checkbox.checked).length
// Узнаем количество не правильных ответов
const wrongAnswer = listCheckbox.filter(checkbox => Number(checkbox.value) === 0 && checkbox.checked).length
// Уведомляем пользователя
alert(`Вы выбрали ${rightAnswers} вариантов из ${rightAnswersCount} правильных`);
/*alert(`Вы ответили не правильно на ${wrongAnswer} из ${wrongAnswerCount}`)*/
//Вывод ответа с процентами
alert(`Процент правильных ответов: ${(rightAnswers / selectedAnswersCounts) * 100}`);
/*alert(`Процент неправильных ответов: ${(wrongAnswer / wrongAnswerCount) * 100}`)*/
}
/* Скрипт правильных и неправильных ответов */
let button = document.getElementById('btn-1');
button.addEventListener('click', function(e) {
document.querySelectorAll('.i-6').forEach(item => {
let checkbox = item.closest('div');
if (item.checked && Number(item.value)) {
checkbox.classList.add("right");
checkbox.classList.remove("false");
} else if (item.checked) {
checkbox.classList.add("false");
checkbox.classList.remove("right");
} else {
chekcbox.classList.remove("right");
chekcbox.classList.remove("false");
}
})
});
const TopNavigation: FC = () => {
const { opened, setOpened } = useData()
const { state: cityState } = useCityState()
const { dispatch } = useNavigationDispatch()
const { state: navigationState } = useNavigationState()
const navRef = useRef(null)
useEffect(() => {
dispatch({ type: 'setTopNavHeight', payload: { topNavHeight: navRef.current.offsetHeight } })
}, [])
return (
<Navigation
size='tiny'
fixed
dispatch={dispatch}
transparent={navigationState.transparent}
borderBottom='white'
backgroundColor={navigationState.transparent ? 'transparent' : 'slightlyGray'}
>
<Layout justifyContent='center'>
<Box
maxWidth={['90%', '90%', '1200px']}
width='100%'
height='48px'
ref={navRef}
alignSelf='center'
alignItems='center'
>
<CityPinIcon
color={navigationState.transparent ? 'white' : ''}
width='10px'
height='13px'
/>
<Layout flexBasis='8px' />
<Text
fontSize='small'
lineHeight='normal'
color={navigationState.transparent ? 'white' : 'dustyGray'}
cursor='pointer'
onClick={() => setOpened(true)}
>
{cityState.city.name}
</Text>
<Layout flexGrow={1} />
<TopBarList />
</Box>
</Layout>
<CityModal onClose={() => setOpened(false)} opened={opened} />
</Navigation>
)
}
export default TopNavigation
import React from 'react'
import Helmet from 'react-helmet'
import { useIntl } from 'react-intl'
import messages from './messages'
export const Seo = () => {
const intl = useIntl()
const title = intl.formatMessage(messages.title)
const description = intl.formatMessage(messages.description)
return (
<Helmet
htmlAttributes={{ lang: intl.locale }}
title={title}
titleTemplate={`%s | ${title}`}
meta={[
{
name: 'description',
content: description,
},
{
property: 'og:title',
content: title,
},
{
property: 'og:description',
content: description,
},
{
property: 'og:type',
content: 'website',
},
{
name: 'twitter:card',
content: 'summary',
},
{
name: 'twitter:title',
content: title,
},
{
name: 'twitter:description',
content: description,
},
]}
/>
)
}
import { Router, Route, IndexRoute, Redirect, IndexRedirect } from 'react-router'
import React from 'react';
export default (
<Router>
<Route path="/">
<IndexRoute/>
<Route path="test" />
<Route path="posts(/:page)" />
<Route path="article/:hrefTitle" />
<Route path="tags/:tagName" />
<Route path="tags/pages/(:page)" />
<Route path="archive(/:searchKey)" />
<Redirect path="*" to="/" />
</Route>
</Router>
)