row_id
int64
0
48.4k
init_message
stringlengths
1
342k
conversation_hash
stringlengths
32
32
scores
dict
18,892
How do I make firejail disable seccomp (since it's enabled in a profile)?
0c29ccacdf662136ddab9ea627bd0dde
{ "intermediate": 0.4609399437904358, "beginner": 0.2385786920785904, "expert": 0.30048131942749023 }
18,893
aa16b5c3-2da8-4fe9-84ce-b8e46a49c374,0 convert this string to list flutter
c075b4895234980d0efdd4172b71a784
{ "intermediate": 0.3951660394668579, "beginner": 0.31769272685050964, "expert": 0.28714123368263245 }
18,894
dockerd-current[5283]: time="2023-08-30T15:24:37.222616540+08:00" level=error msg="Handler for POST /v1.26/containers/usm/start returned error: No such container: usm"报错是什么意思,如何解决
045ddfabd18feb5b72ac1e7c30d9e4a7
{ "intermediate": 0.3393920958042145, "beginner": 0.3713527321815491, "expert": 0.28925517201423645 }
18,895
is it good practice to connect airflow dag script to work with postgresql that outside docker container? what is best practice if i need to do scraping with airflow docker and save information in postgresql?
56969def3037dcf77a5dd1f2961d9aad
{ "intermediate": 0.6465583443641663, "beginner": 0.19383583962917328, "expert": 0.15960578620433807 }
18,896
Whats wrong with this code function sayHi() { console.log(name); console.log(age); var name = "Lydia"; let age = 21; } sayHi();
c67f648e724456b766c31c1432f0e0df
{ "intermediate": 0.27986204624176025, "beginner": 0.5187994837760925, "expert": 0.20133845508098602 }
18,897
nested difference between keys js return key and value js
00aed61204738393ac7b2c11342b3c57
{ "intermediate": 0.32566988468170166, "beginner": 0.3100414276123047, "expert": 0.36428871750831604 }
18,898
raise e arcgisscripting.ExecuteError: ERROR 000464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (Dissolve).
6981eafed907eb678259dbfa622b53ab
{ "intermediate": 0.3861440122127533, "beginner": 0.2726275622844696, "expert": 0.3412283658981323 }
18,899
Hi
64a0c19c744d6f47c7bae25403d0a0ae
{ "intermediate": 0.33010533452033997, "beginner": 0.26984941959381104, "expert": 0.400045245885849 }
18,900
Исправь этот код таким образом, чтобы он не выводил пустые объекты и ключи без значений const differenceKeys = (origObj, newObj) => { const changes = {} if (Object.is(origObj, newObj)) { return undefined } if (!newObj || typeof newObj !== "object") { return newObj } Object.keys(origObj || {}) .concat(Object.keys(newObj || {})) .forEach((key) => { if ( newObj.hasOwnProperty(key) !== origObj.hasOwnProperty(key) && !Object.is(origObj[key], newObj[key]) ) { changes[key] = newObj[key] } if (typeof newObj[key] === "object" && typeof origObj[key] === "object") { const value = differenceKeys(origObj[key], newObj[key]) if (value !== undefined) { changes[key] = value } } }) return changes }
e4e1506279e37d8f9403bf12c8dc0c47
{ "intermediate": 0.3959372937679291, "beginner": 0.34976544976234436, "expert": 0.2542972266674042 }
18,901
Do you know of wasm runtimes that support serialization the entire execution state at a certain point, to be resumed later?
511a458b36e715c4be22dcfd8d0d8ed4
{ "intermediate": 0.5325562953948975, "beginner": 0.0911024734377861, "expert": 0.3763412535190582 }
18,902
SharedPreferences save bool flutter
f0ffde65fd7c382bb622d9487f5a89dc
{ "intermediate": 0.36605310440063477, "beginner": 0.30372050404548645, "expert": 0.3302263915538788 }
18,903
Что не так в этом коде, какая ошибка? List<FraudCheck> checks = fraudCheckManager.getFraudCheckList(null). stream().filter(p -> FraudCheckType.CARD_IS_BLOCKED.name().equals(p.getType())).findFirst().orElse(null).collect(Collectors.toList());
42ff4600811ab8eb8f6502cc16115fbf
{ "intermediate": 0.3903399109840393, "beginner": 0.3262595236301422, "expert": 0.2834005653858185 }
18,904
Query in SQL a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
62236781b9fd300438a5b3c0489c2761
{ "intermediate": 0.4247136414051056, "beginner": 0.2922931909561157, "expert": 0.2829931378364563 }
18,905
I have columns A, B, C, D in table in Power BI. How to create another table with only ditinct values of A, B, and C using DAX?
361419a977b6801751f3da965232ab1d
{ "intermediate": 0.45388081669807434, "beginner": 0.14794771373271942, "expert": 0.39817148447036743 }
18,906
kotlin Cannot create an instance of class com.example.myapplication.Models.NoteViewModel
9cd57f2f6ffca3b9ccb4777e0b3b8611
{ "intermediate": 0.4045555293560028, "beginner": 0.3513322174549103, "expert": 0.2441122680902481 }
18,907
Write me a java method which will get a string and return double value from the string
91815d9041718bcba9eb7d31cce4450e
{ "intermediate": 0.5397362112998962, "beginner": 0.26944729685783386, "expert": 0.1908165067434311 }
18,908
Hi there!
27e72d0bb2ea393ee62e52a5ba383c9f
{ "intermediate": 0.32267293334007263, "beginner": 0.25843358039855957, "expert": 0.4188934564590454 }
18,909
import {createSlice} from "@reduxjs/toolkit"; import {HYDRATE} from "next-redux-wrapper"; import {InitialTradeItem} from "../hooks/rustWsServer"; export interface TradeItem { price: number; quantity: number; side: "Buy" | "Sell"; timestamp: number; radius: number; } interface OrderClusterSlice { trades: {[key: string]: Array<TradeItem>}; } const initialState: OrderClusterSlice = { trades: {}, }; export const orderClustersSlice = createSlice({ name: "orderClustersSlice", initialState, reducers: { pushOrderClusterTrades(state, action) { }, }, extraReducers: (builder) => { builder.addCase(HYDRATE, (state, action) => { return { ...state, ...action, }; }); }, }); export const { setOrderClusterTrades, pushOrderClusterTrades, } = orderClustersSlice.actions; export default orderClustersSlice.reducer; создать редакс на подобие этого, только с данными - interface PreparedOrderQuantity { quantity: number; unit: "coin" | "usd"; } {[key: string]: PreparedOrderQuantity[]} { "BTCUDST": [ { quantity: 100, unit: "coin", }, { quantity: 500, unit: "usd", }, { quantity: 2000, unit: "usd", }, { quantity: 1000, unit: "usd", }, { quantity: 7, unit: "usd", }, ] }
f6e5fa875f2a5434b645dbcc177af1c9
{ "intermediate": 0.5749667882919312, "beginner": 0.25887084007263184, "expert": 0.166162371635437 }
18,910
write a function in javascript to select an element from an array according to a given weight for each element
c5ab311cfb33118a5d3c8e41f457f484
{ "intermediate": 0.3674008250236511, "beginner": 0.2512371242046356, "expert": 0.38136205077171326 }
18,911
The following script does not work. Can you correct it please. Please keep the FastLed library. #define LED_PIN 6 #define COLOR_ORDER GRB #define CHIPSET WS2811 #define NUM_LEDS 30 #define BRIGHTNESS 100 #define FRAMES_PER_SECOND 60 #define BUTTON_PIN 2 bool gReverseDirection = false; int currentPalette = 0; int buttonState = HIGH; int prevButtonState = HIGH; CRGB leds[NUM_LEDS]; CRGBPalette16 gPal; void setup() { delay(3000); // sanity delay FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); pinMode(BUTTON_PIN, INPUT_PULLUP); // Set initial button state buttonState = digitalRead(BUTTON_PIN); prevButtonState = buttonState; // This first palette is the basic ‘black body radiation’ colors, // which run from black to red to bright yellow to white. // gPal = HeatColors_p; // These are other ways to set up the color palette for the ‘fire’. // First, a gradient from black to red to yellow to white – similar to HeatColors_p // (GPAL A) // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White); // Second, this palette is like the heat colors, but blue/aqua instead of red/yellow // (GPAL B) // gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White); // Third, here’s a simpler, three-step gradient, from black to red to white // (GPAL C) gPal = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::Yellow); } void loop() { // Update button state buttonState = digitalRead(BUTTON_PIN); // Detect button press to toggle palette if (buttonState == LOW && prevButtonState == HIGH) { currentPalette++; if (currentPalette > 2) { currentPalette = 0; } // Clear the LED strip fill_solid(leds, NUM_LEDS, CRGB::Black); FastLED.show(); delay(250); // Debounce delay } prevButtonState = buttonState; // Add entropy to random number generator; we use a lot of it. random16_add_entropy( random()); // Update palette based on currentPalette variable switch (currentPalette) { case 0: gPal = CRGBPalette16( CRGB::Red, CRGB::Red, CRGB::Yellow, CRGB::White); break; case 1: gPal = CRGBPalette16( CRGB::Aqua, CRGB::Blue, CRGB::Aqua, CRGB::White); break; case 2: gPal = CRGBPalette16( CRGB::Green, CRGB::Green, CRGB::Yellow); break; } Fire2012WithPalette(); // run simulation frame, using palette colors FastLED.show(); // display this frame FastLED.delay(500 / FRAMES_PER_SECOND); } #define COOLING 55 #define SPARKING 120 #define FALLING 50 //********************************************************************************************// // PLAY WITH FALLING, COOLING AND SPARKLING void Fire2012WithPalette() { // Array of temperature readings at each simulation cell static uint8_t heat[NUM_LEDS]; // Step 1. Cool down every cell a little for( int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts ‘up’ and diffuses a little for(int k = NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; } // Step 3. Randomly ignite new ‘sparks’ of heat near the bottom if( random8() < FALLING ) { int y = random8(7); heat[y] = qadd8( heat[y], random8(160,255) ); } // Step 4. Map from heat cells to LED colors for( int j = 0; j < NUM_LEDS; j++) { // Scale the heat value from 0-255 down to 0-240 // for best results with color palettes. uint8_t colorindex = scale8( heat[j], 240); CRGB color = ColorFromPalette( gPal, colorindex); int pixelnumber; if( gReverseDirection ) { pixelnumber = (NUM_LEDS-1) - j; } else { pixelnumber = j; } leds[pixelnumber] = color; } }
e99154bf77699e598e5a7aba09ef254c
{ "intermediate": 0.40627896785736084, "beginner": 0.42747804522514343, "expert": 0.16624291241168976 }
18,912
Using the standard cin >> object, accept input into a variable that can hold decimals called number. Using Input, Processing, Output (IPO), calculate the square of the number, the cube of the number, and the number/2.0. Output each of the results to the screen for the user. Be sure to be descriptive in terms of what the output results represent. Type your fully working program via the Essay prompt.
89676e69b604130c232cc429aab73af2
{ "intermediate": 0.4047185480594635, "beginner": 0.3144267499446869, "expert": 0.2808546721935272 }
18,913
Product Rank = RANKX(ALLSELECTED(Products[Product name M3]), [Promo Days] && [% of Promo Volume]) How to fix that formula to rank by two columns?
42b8f0e06f7a0c7effa1bfac4698ef06
{ "intermediate": 0.3677949011325836, "beginner": 0.2036224603652954, "expert": 0.42858263850212097 }
18,914
Explain punjab
7d8cc24e1157805fd0adc03771746b8f
{ "intermediate": 0.43202081322669983, "beginner": 0.4117147922515869, "expert": 0.15626440942287445 }
18,915
Give me code of space engine in c++
64df03e99e34a2611338a19eaa66c088
{ "intermediate": 0.2725594937801361, "beginner": 0.2777840495109558, "expert": 0.44965648651123047 }
18,916
Напиши код быстрого преобразования Фурье на java. Расчёт массива exp множителей и массива индексов должен быть отдельно от функции расчёта БПФ. Пример использования
4b738639912e5b45c4072e50209ce64f
{ "intermediate": 0.4263856112957001, "beginner": 0.25109270215034485, "expert": 0.32252174615859985 }
18,917
how to turn the line "k/x - (x**p)/m" into the equation k/x -(x**p)/m in Python
72439786226480d53b260d8fcb1b0fd6
{ "intermediate": 0.3151604235172272, "beginner": 0.3043646514415741, "expert": 0.3804749548435211 }
18,918
If I select years 2022 and 2023, the function produces a rusult, but if I only select 2023 it does not yields anything. Please modify the function ROI vs LY = VAR ROI_CY = CALCULATE( DIVIDE(SUM('Customer_SKU_Share_Month'[SUM_GP])-SUM('Customer_SKU_Share_Month'[SUM_Log]),SUM('Customer_SKU_Share_Month'[SUM_Disc])), FILTER('Customer_SKU_Share_Month', 'Customer_SKU_Share_Month'[SUM_TotVol] <> 0 && 'Customer_SKU_Share_Month'[SUM_PromoVol] <> 0 && 'Customer_SKU_Share_Month'[Year] = MAX('Customer_SKU_Share_Month'[Year]) && NOT(ISERROR('Customer_SKU_Share_Month'[ROI(share, add%)_log2])) )) VAR ROI_LY = CALCULATE( DIVIDE(SUM('Customer_SKU_Share_Month'[SUM_GP])-SUM('Customer_SKU_Share_Month'[SUM_Log]),SUM('Customer_SKU_Share_Month'[SUM_Disc])), FILTER('Customer_SKU_Share_Month', 'Customer_SKU_Share_Month'[SUM_TotVol] <> 0 && 'Customer_SKU_Share_Month'[SUM_PromoVol] <> 0 && 'Customer_SKU_Share_Month'[Year] = MAX('Customer_SKU_Share_Month'[Year])-1 && NOT(ISERROR('Customer_SKU_Share_Month'[ROI(share, add%)_log2])) )) RETURN IF(ISNUMBER(ROI_LY),(ROI_CY-ROI_LY)*100,"")
3248f57fc198cd32f62a4bf8ab07a345
{ "intermediate": 0.2396533340215683, "beginner": 0.578272819519043, "expert": 0.18207381665706635 }
18,919
const [selectVisible, setSelectVisible] = useState(false); const preparedQuantities = useSelector( (state: AppState) => state.preparedQuantitiesSlice?.preparedQuantities[symbol] ); const dispatch = useDispatch(); const handleSelect = (quantity: PreparedOrderQuantity) => { dispatch( setPreparedQuantities({ key: symbol, quantities: [quantity], }) ); setSelectVisible(false); }; return <Box height="100%" position="relative"> <Box ref={containerRef} className={`${styles.canvasWrapper} scroll-block`}> <canvas ref={canvasRef} className={styles.canvas} width={canvasSize?.width} height={canvasSize?.height} /> </Box> {!showVolumeSettings && ( <Box onClick={() => setSelectVisible(true)} position="absolute" sx={{ backgroundColor: (theme) => theme.palette.secondary.light, bottom: 0, width: "100%", height: "26px", display: "flex", justifyContent: "space-evenly", alignItems: "center", }} > <Typography fontSize={13} sx={{whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis"}} > {volumeAsDollars ? (volume / orderPrice).toFixed(precision?.quantity) : volume} </Typography> <Button variant="text" color="black" onClick={() => setShowVolumeSettings(true)} sx={{height: 26, width: 10, p: .5}} > + </Button> </Box> )} {selectVisible && ( <select> {preparedQuantities?.map((quantity, index) => ( <option key={index} onClick={() => handleSelect(quantity)}> {quantity.quantity} {quantity.unit} </option> ))} </select> )} </Box>; }; <Typography fontSize={13} sx={{whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis"}} > {volumeAsDollars ? (volume / orderPrice).toFixed(precision?.quantity) : volume} </Typography> сделать селектом, кликаем и открывается селект из mui, если preparedQuantities селект пустой, то по клику на селект setShowVolumeSettings(true)
226c5345ee04b29bf859ad8797eba816
{ "intermediate": 0.25445252656936646, "beginner": 0.5694286227226257, "expert": 0.17611892521381378 }
18,920
export interface PreparedOrderQuantity { quantity: number; unit: "coin" | "usd"; } preparedQuantities: {[key: string]: PreparedOrderQuantity[]}; const preparedQuantities = useSelector((state: AppState) => state.preparedQuantitiesSlice?.preparedQuantities[symbol]); сделать сохранение в локалсторедж а когда достаем из локалсторедж, если есть они то setPreparedQuantities(state, action: PayloadAction<{ key: string, quantities: PreparedOrderQuantity[] }>) { const {key, quantities} = action.payload; state.preparedQuantities[key] = quantities; }, сохранять в локалсторедж так же по ключу, доставать из локалсторедж так же по ключу. если в локалсторедж уже есть такой объект, то не сохранять
8e7fb0dcf23cbe2a51ade22556fce67d
{ "intermediate": 0.4607379734516144, "beginner": 0.3388980031013489, "expert": 0.20036403834819794 }
18,921
After using "sudo -u bob" as "alice", how do I start a new logind session for bob?
eaf3af8aa526b0b94d02b165e95db2ca
{ "intermediate": 0.47300708293914795, "beginner": 0.20170752704143524, "expert": 0.3252854347229004 }
18,922
The following script is ment te switch between 3 colormodes with a 3 position swich on my Futaba RC transmitter. I can change between red and green. The middle position of the switch stays red and it should be blue. Can you change the script and give me the full version. #include <FastLED.h> #define LED_PIN 6 #define COLOR_ORDER GRB #define CHIPSET WS2811 #define NUM_LEDS 30 #define BRIGHTNESS 100 #define FRAMES_PER_SECOND 60 CRGB leds[NUM_LEDS]; CRGBPalette16 gPal; // Futaba RC Receiver variables #define RC_PIN A0 #define RC_MIN 1000 #define RC_MAX 2000 #define RC_MID 1500 #define RC_DEADZONE 100 int currentPalette = 0; int prevRCValue = RC_MID; void setup() { delay(3000); // sanity delay FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); // This first palette is the basic ‘black body radiation’ colors, // which run from black to red to bright yellow to white. // gPal = HeatColors_p; // These are other ways to set up the color palette for the ‘fire’. // First, a gradient from black to red to yellow to white – similar to HeatColors_p // (GPAL A) // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White); // Second, this palette is like the heat colors, but blue/aqua instead of red/yellow // (GPAL B) // gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White); // Third, here’s a simpler, three-step gradient, from black to red to white // (GPAL C) gPal = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::Yellow); } void loop() { // Read RC receiver value int rcValue = pulseIn(RC_PIN, HIGH, 25000); rcValue = constrain(rcValue, RC_MIN, RC_MAX); // Check if RC receiver value is within the deadzone if (abs(rcValue - RC_MID) < RC_DEADZONE) { rcValue = RC_MID; } // Toggle color mode based on RC receiver value if (rcValue < RC_MID && prevRCValue >= RC_MID) { currentPalette--; if (currentPalette < 0) { currentPalette = 2; } } else if (rcValue >= RC_MID && prevRCValue < RC_MID) { currentPalette++; if (currentPalette > 2) { currentPalette = 0; } } prevRCValue = rcValue; // Add entropy to random number generator; we use a lot of it. random16_add_entropy( random()); // Update palette based on currentPalette variable switch (currentPalette) { case 0: gPal = CRGBPalette16( CRGB::Red, CRGB::Red, CRGB::Yellow, CRGB::White); break; case 1: gPal = CRGBPalette16( CRGB::Aqua, CRGB::Blue, CRGB::Aqua, CRGB::White); break; case 2: gPal = CRGBPalette16( CRGB::Green, CRGB::Green, CRGB::Yellow); break; } Fire2012WithPalette(); // run simulation frame, using palette colors FastLED.show(); // display this frame FastLED.delay(1000 / FRAMES_PER_SECOND); } #define COOLING 55 #define SPARKING 120 #define FALLING 50 //********************************************************************************************// // PLAY WITH FALLING, COOLING AND SPARKLING void Fire2012WithPalette() { // Array of temperature readings at each simulation cell static uint8_t heat[NUM_LEDS]; // Step 1. Cool down every cell a little for( int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts ‘up’ and diffuses a little for(int k = NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; } // Step 3. Randomly ignite new ‘sparks’ of heat near the bottom if( random8() < FALLING ) { int y = random8(7); heat[y] = qadd8( heat[y], random8(160,255) ); } // Step 4. Map from heat cells to LED colors for( int j = 0; j < NUM_LEDS; j++) { // Scale the heat value from 0-255 down to 0-240 // for best results with color palettes. uint8_t colorindex = scale8( heat[j], 240); CRGB color = ColorFromPalette( gPal, colorindex); leds[j] = color; } }
e55fe9c6ea5b3a2e9bd78922e89207a2
{ "intermediate": 0.27484890818595886, "beginner": 0.37048107385635376, "expert": 0.3546700179576874 }
18,923
load csv to python
7c5860955822392b51541e554389fe39
{ "intermediate": 0.34214460849761963, "beginner": 0.25467124581336975, "expert": 0.403184175491333 }
18,924
This code will With following script I want to change 3 modes colored LEDs. I want to swicht with a 3 positionswitch on my futaba radiocontrol. De first 2 positions of the switch color the LED's RED, the last position green. In the middle position LEDs should mainly color blue. Can you help me find the error and correct it. Can you give me the full corrected version. #include <FastLED.h> #define LED_PIN 6 #define COLOR_ORDER GRB #define CHIPSET WS2811 #define NUM_LEDS 30 #define BRIGHTNESS 100 #define FRAMES_PER_SECOND 60 CRGB leds[NUM_LEDS]; CRGBPalette16 gPal; // Futaba RC Receiver variables #define RC_PIN A0 #define RC_MIN 1000 #define RC_MAX 2000 #define RC_MID 1500 #define RC_DEADZONE 100 int currentPalette = 0; int prevRCValue = RC_MID; void setup() { delay(3000); // sanity delay FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); FastLED.setBrightness(BRIGHTNESS); gPal = CRGBPalette16(CRGB::Red, CRGB::Blue, CRGB::Green, CRGB::Yellow); } void loop() { // Read RC receiver value int rcValue = pulseIn(RC_PIN, HIGH, 25000); rcValue = constrain(rcValue, RC_MIN, RC_MAX); // Check if RC receiver value is within the deadzone if (abs(rcValue - RC_MID) < RC_DEADZONE) { rcValue = RC_MID; } // Toggle color mode based on RC receiver value if (rcValue < RC_MID && prevRCValue >= RC_MID) { currentPalette--; if (currentPalette < 0) { currentPalette = 2; } } else if (rcValue >= RC_MID && prevRCValue < RC_MID) { currentPalette++; if (currentPalette > 2) { currentPalette = 0; } } prevRCValue = rcValue; // Update palette based on currentPalette variable switch (currentPalette) { case 0: gPal = CRGBPalette16(CRGB::Red, CRGB::Blue, CRGB::Green, CRGB::Yellow); break; case 1: gPal = CRGBPalette16(CRGB::Aqua, CRGB::Blue, CRGB::Aqua, CRGB::White); break; case 2: gPal = CRGBPalette16(CRGB::Green, CRGB::Green, CRGB::Yellow); break; } Fire2012WithPalette(); // run simulation frame, using palette colors FastLED.show(); // display this frame FastLED.delay(1000 / FRAMES_PER_SECOND); } #define COOLING 55 #define SPARKING 120 #define FALLING 50 //********************************************************************************************// // PLAY WITH FALLING, COOLING AND SPARKLING void Fire2012WithPalette() { // Array of temperature readings at each simulation cell static uint8_t heat[NUM_LEDS]; // Step 1. Cool down every cell a little for (int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8(heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts ‘up’ and diffuses a little for (int k = NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3; } // Step 3. Randomly ignite new ‘sparks’ of heat near the bottom if (random8() < FALLING) { int y = random8(7); heat[y] = qadd8(heat[y], random8(160, 255)); } // Step 4. Map from heat cells to LED colors for (int j = 0; j < NUM_LEDS; j++) { // Scale the heat value from 0-255 down to 0-240 // for best results with color palettes. uint8_t colorindex = scale8(heat[j], 240); CRGB color = ColorFromPalette(gPal, colorindex); leds[j] = color; } }
780944b3008198c63c87f93d59ef7ec7
{ "intermediate": 0.284196674823761, "beginner": 0.37881848216056824, "expert": 0.3369848430156708 }
18,925
Create a multer middleware for uploading csv only
4f889586692873eb262b30c9bce3e943
{ "intermediate": 0.4301721155643463, "beginner": 0.1890680342912674, "expert": 0.3807598054409027 }
18,926
I have a LED strip and 3 modes (red, mainly blue, mainly green). I want to switch between the colors with 3 position switch. But the midle position of the switch does nog give blue but also red. Can you help me? #include <FastLED.h> #define LED_PIN 6 #define COLOR_ORDER GRB #define CHIPSET WS2811 #define NUM_LEDS 30 #define BRIGHTNESS 100 #define FRAMES_PER_SECOND 60 CRGB leds[NUM_LEDS]; CRGBPalette16 gPal; // Futaba RC Receiver variables #define RC_PIN A0 #define RC_MIN 1000 #define RC_MAX 2000 #define RC_MID 1500 #define RC_DEADZONE 100 int currentPalette = 0; int prevRCValue = RC_MID; void setup() { delay(3000); // sanity delay FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); FastLED.setBrightness(BRIGHTNESS); gPal = CRGBPalette16(CRGB::Red, CRGB::Blue, CRGB::Green, CRGB::Yellow); } void loop() { // Read RC receiver value int rcValue = pulseIn(RC_PIN, HIGH, 25000); rcValue = constrain(rcValue, RC_MIN, RC_MAX); // Check if RC receiver value is within the deadzone if (abs(rcValue - RC_MID) < RC_DEADZONE) { rcValue = RC_MID; } // Toggle color mode based on RC receiver value if (rcValue < RC_MID && prevRCValue >= RC_MID) { currentPalette--; if (currentPalette < 0) { currentPalette = 2; } } else if (rcValue >= RC_MID && prevRCValue < RC_MID) { currentPalette++; if (currentPalette > 2) { currentPalette = 0; } } prevRCValue = rcValue; // Update palette based on currentPalette variable switch (currentPalette) { case 0: // gPal = CRGBPalette16(CRGB::Red, CRGB::Blue, CRGB::Green, CRGB::Yellow); gPal = CRGBPalette16(CRGB::Red); break; case 1: // gPal = CRGBPalette16(CRGB::Aqua, CRGB::Blue, CRGB::Aqua, CRGB::White); gPal = CRGBPalette16(CRGB::Aqua, CRGB::Blue, CRGB::Aqua, CRGB::White); break; case 2: gPal = CRGBPalette16(CRGB::Green, CRGB::Green, CRGB::Yellow); break; } Fire2012WithPalette(); // run simulation frame, using palette colors FastLED.show(); // display this frame FastLED.delay(1000 / FRAMES_PER_SECOND); } #define COOLING 55 #define SPARKING 120 #define FALLING 50 void Fire2012WithPalette() { // Array of temperature readings at each simulation cell static uint8_t heat[NUM_LEDS]; // Step 1. Cool down every cell a little for (int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8(heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts ‘up’ and diffuses a little for (int k = NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3; } // Step 3. Randomly ignite new ‘sparks’ of heat near the bottom if (random8() < FALLING) { int y = random8(7); heat[y] = qadd8(heat[y], random8(160, 255)); } // Step 4. Map from heat cells to LED colors for (int j = 0; j < NUM_LEDS; j++) { // Scale the heat value from 0-255 down to 0-240 // for best results with color palettes. uint8_t colorindex = scale8(heat[j], 240); // Switch statement to set color effect based on currentPalette variable CRGB color; switch (currentPalette) { case 0: color = ColorFromPalette(gPal, colorindex); break; case 1: color = ColorFromPalette(gPal, colorindex, 255, LINEARBLEND); break; case 2: color = ColorFromPalette(gPal, colorindex, 255, LINEARBLEND); break; } leds[j] = color; } }
2c879f4f0144aa1e185812a32981b4ff
{ "intermediate": 0.34697043895721436, "beginner": 0.4318172335624695, "expert": 0.22121234238147736 }
18,927
Create a multer middleware for uploading a csv file. I dont want to store it. I only want to process it
60ab4d386d9dde8a359c10b4614bedf7
{ "intermediate": 0.6171795129776001, "beginner": 0.15936456620693207, "expert": 0.22345589101314545 }
18,928
useEffect(() => { const savedQuantities = localStorage.getItem("preparedQuantities"); // console.log(savedQuantities); if (savedQuantities) { const parsedQuantities = JSON.parse(savedQuantities); if (parsedQuantities && parsedQuantities.hasOwnProperty(symbol)) { const quantities = parsedQuantities[symbol]; // console.log(quantities); dispatch(setPreparedQuantities({ key: symbol, quantities: quantities, })); } else { // Ключ не существует в сохраненных данных } } else { // Нет сохраненных данных } }, []); const handleCheckClick = () => { const orderQuantity: PreparedOrderQuantity = {quantity: quantitySelected, unit: volumeAsDollarsCheck ? "usd" : "coin"}; dispatch(addPreparedQuantity({ key: symbol, quantity: orderQuantity, })); setQuantity(orderQuantity); // localStorage.setItem("preparedQuantities", JSON.stringify({[symbol]: preparedQuantities})); setShowQuantitySettings(false); setVolumeAsDollars(volumeAsDollarsCheck); }; нужно сетать в localStorage не новым объектом, а по ключу добавлять к имеющимся объектам preparedQuantities
bd6806e9ec1006cc94e44079734f89bb
{ "intermediate": 0.29956358671188354, "beginner": 0.39620116353034973, "expert": 0.3042352497577667 }
18,929
PreparedOrderQuantity { quantity: number; unit: "coin" | "usd"; } const preparedQuantities = useSelector((state: AppState) => state.preparedQuantitiesSlice?.preparedQuantities[symbol]); //PreparedOrderQuantity[] useEffect(() => { const savedQuantities = localStorage.getItem("preparedQuantities"); // console.log(savedQuantities); if (savedQuantities) { const parsedQuantities = JSON.parse(savedQuantities); if (parsedQuantities && parsedQuantities.hasOwnProperty(symbol)) { const quantities = parsedQuantities[symbol]; // console.log(quantities); dispatch(setPreparedQuantities({ key: symbol, quantities: quantities, })); } else { // Ключ не существует в сохраненных данных } } else { // Нет сохраненных данных } }, []); const handleCheckClick = () => { const orderQuantity: PreparedOrderQuantity = {quantity: quantitySelected, unit: volumeAsDollarsCheck ? "usd" : "coin"}; dispatch(addPreparedQuantity({ key: symbol, quantity: orderQuantity, })); setQuantity(orderQuantity); // localStorage.setItem("preparedQuantities", JSON.stringify({[symbol]: preparedQuantities})); setShowQuantitySettings(false); setVolumeAsDollars(volumeAsDollarsCheck); }; нужно сетать в localStorage не новым объектом, а по ключу добавлять к имеющимся объектам preparedQuantities. так же если в preparedQuantities уже есть orderQuantity, то не сетать в localStorage
744f0ff011a60802e326ed89abcbccdd
{ "intermediate": 0.3321826457977295, "beginner": 0.34082892537117004, "expert": 0.3269883990287781 }
18,930
Выведи на экран полученные джанные : package com.example.test_999 import android.annotation.SuppressLint import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import com.example.test_999.databinding.ActivityMainBinding import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import okhttp3.OkHttpClient import okhttp3.Request import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import retrofit2.create class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding = ActivityMainBinding.inflate(layoutInflater) val view =binding.root setContentView(view) val client = OkHttpClient() val request = Request.Builder() .url("https://moviesminidatabase.p.rapidapi.com/movie/imdb_id/byTitle/Hobbit/") .get() .addHeader("X-RapidAPI-Key", "f07b384df4msh0cb75ecf6213a0cp19d05ajsn1c71118107fb") .addHeader("X-RapidAPI-Host", "moviesminidatabase.p.rapidapi.com") .build() val response = client.newCall(request).execute() } }
c911a979e409510a3ca76c0369c23d92
{ "intermediate": 0.5675503611564636, "beginner": 0.25633734464645386, "expert": 0.17611229419708252 }
18,931
PreparedOrderQuantity { quantity: number; unit: “coin” | “usd”; } const preparedQuantities = useSelector((state: AppState) => state.preparedQuantitiesSlice?.preparedQuantities[symbol]); //PreparedOrderQuantity[] useEffect(() => { const savedQuantities = localStorage.getItem(“preparedQuantities”); // console.log(savedQuantities); if (savedQuantities) { const parsedQuantities = JSON.parse(savedQuantities); if (parsedQuantities && parsedQuantities.hasOwnProperty(symbol)) { const quantities = parsedQuantities[symbol]; // console.log(quantities); dispatch(setPreparedQuantities({ key: symbol, quantities: quantities, })); } else { // Ключ не существует в сохраненных данных } } else { // Нет сохраненных данных } }, []); const handleCheckClick = () => { const orderQuantity: PreparedOrderQuantity = {quantity: quantitySelected, unit: volumeAsDollarsCheck ? “usd” : “coin”}; dispatch(addPreparedQuantity({ key: symbol, quantity: orderQuantity, })); setQuantity(orderQuantity); // localStorage.setItem(“preparedQuantities”, JSON.stringify({[symbol]: preparedQuantities})); setShowQuantitySettings(false); setVolumeAsDollars(volumeAsDollarsCheck); }; нужно сетать в localStorage не новым объектом, а по ключу добавлять к имеющимся объектам preparedQuantities. так же если в preparedQuantities уже есть orderQuantity, то не сетать в localStorage
ed7b012b110225b35dcd4c51200bf3fc
{ "intermediate": 0.32125765085220337, "beginner": 0.4084281027317047, "expert": 0.27031418681144714 }
18,932
fix this code. # Retrieve Text for the open inquiry query = """SELECT iat.id as id, inquiry_id, file_name, file_ext FROM inquiry_attach_tbl iat LEFT JOIN inquiry_tbl it ON iat.inquiry_id = it.id WHERE raw_text IS NULL AND it.received_date > '20220901';""" try: with connection.connect(**mydbconfig) as mydb: mycursor = mydb.cursor() mycursor.execute(query) query = mycursor.fetchone() except connection.Error as err: print({ 'error': { 'message': 'An error occurred while processing the query.', 'details': str(err), 'code': 500 } }) except Exception as e: print({ 'error': { 'message': 'An unexpected error occurred.', 'details': str(e), 'code': 500 } }) this gives me one row of the query. i want all rows
0ef8fc129c062ed6563be5b7bf123e9d
{ "intermediate": 0.40165385603904724, "beginner": 0.4629099369049072, "expert": 0.1354362964630127 }
18,933
<?xml version="1.0" encoding="utf-8"?> <ComboSkill> <!-- ;Commonserver.cfg里面ShieldComboMissOptionOn默认设置1,打怪出现MISS时连击中断,可以自己改为0,那么不会中断 <!-- ;关闭全职业连击时,使用官方原始的战士3连击,必须完成220级任务之后才能使用连击! <!-- EnableCombo ;开启全职业连击 0 关闭 / 1 三连击 / 2 二连击 --> <!-- ComboIntervalTime ;;2次连击间隔时间(此功能请配合游戏点数来设置) 单位:毫秒 1000毫秒=1秒 默认 0 <!-- ComboDamgeInc ;;2次连击间隔时间(此功能请配合游戏点数来设置) 单位:毫秒 1000毫秒=1秒 默认 0 <!-- UseNewCombo ;是否使用新的自定义连击方式 (1使用 0 不使用)(既使用CustomComboAttack.txt自定义设置连击方式 --> <Config EnableCombo="1" ComboIntervalTime="3" ComboDamgeInc="0" UseNewCombo="1"> <!-- CLASS_DK --> <Class index="0" check_quest="6"> <!-- 法师 --> <SkillListFirst> <Skill index="1"/> <!-- 毒咒 --> <Skill index="2"/> <!-- 陨石 --> <Skill index="3"/> <!-- 掌心雷 --> <Skill index="4"/> <!-- 火球 --> <Skill index="5"/> <!-- 火龙 --> <Skill index="7"/> <!-- 冰封 --> <Skill index="379"/> <!-- 掌心雷强化 --> <Skill index="384"/> <!-- 毒咒强化 --> <Skill index="378"/> <!-- 火龙强化 --> <Skill index="389"/> <!-- 冰封术强化 --> </SkillListFirst> <SkillListSecond> <Skill index="8"/> <!-- 龙卷风 --> <Skill index="9"/> <!-- 黑龙波 --> <Skill index="10"/> <!-- 地狱火 --> <Skill index="12"/> <!-- 极光 --> <Skill index="14"/> <!-- 毁灭烈焰 --> <Skill index="38"/> <!-- 毒炎 --> <Skill index="39"/> <!-- 暴风雪 --> <Skill index="381"/> <!-- 毁灭烈焰强化 --> <Skill index="387"/> <!-- 毒炎强化 --> <Skill index="391"/> <!-- 暴风雪强化 --> <Skill index="393"/> <!-- 暴风雪精通 --> </SkillListSecond> </Class> <Class index="1" check_quest="3"> <!-- CLASS_DK --> <SkillListFirst> <Skill index="19"/> <!-- 地裂斩 --> <Skill index="328"/> <!-- 地裂斩强化 --> <Skill index="329"/> <!-- 牙突刺强化 --> <Skill index="326"/> <!-- 旋风斩强化 --> <Skill index="327"/> <!-- 天地十字剑强化 --> <Skill index="20"/> <!-- 牙突刺 --> <Skill index="21"/> <!-- 升龙击 --> <Skill index="22"/> <!-- 旋风斩 --> <Skill index="23"/> <!-- 天地十字剑 --> </SkillListFirst> <SkillListSecond> <Skill index="41"/> <!-- 霹雳回旋斩 --> <Skill index="42"/> <!-- 雷霆裂闪 --> <Skill index="43"/> <!-- 袭风刺 --> <Skill index="232"/> <!-- 致命一击 --> <Skill index="344"/> <!-- 血腥风暴 --> <Skill index="339"/> <!-- 袭风刺熟练 --> <Skill index="330"/> <!-- 霹雳回旋斩强化 --> <Skill index="332"/> <!-- 霹雳回旋斩精通 --> <Skill index="331"/> <!-- 雷霆裂闪强化 --> <Skill index="333"/> <!-- 霹雳回旋斩精通 --> <Skill index="342"/> <!-- 袭风刺精通 --> </SkillListSecond> </Class> <Class index="2" check_quest="6"> <!-- CLASS_FE --> <SkillListFirst> <Skill index="24"/> <!-- 多重箭 --> <Skill index="414"/> <!-- 多重箭强化 --> <Skill index="418"/> <!-- 多重箭精通 --> </SkillListFirst> <SkillListSecond> <Skill index="46"/> <!-- 天堂之箭 --> <Skill index="51"/> <!-- 冰封箭 --> <Skill index="52"/> <!-- 穿透箭 --> <Skill index="424"/> <!-- 冰箭强化 --> <Skill index="235"/> <!-- 五重箭 --> <Skill index="411"/> <!-- 五重箭强化 --> <Skill index="431"/> <!-- 五重箭精通 --> </SkillListSecond> </Class> <Class index="3" check_quest="6"> <!-- CLASS_MG --> <SkillListFirst> <Skill index="73"/> <!-- 幻魔光束 --> <Skill index="57"/> <!-- 风舞回旋斩 --> <Skill index="56"/> <!-- 天雷闪 --> <Skill index="482"/> <!-- 天雷闪强化 --> <Skill index="22"/> <!-- 旋风斩 --> <Skill index="7"/> <!-- 冰封 --> <Skill index="489"/> <!-- 冰封强化 --> <Skill index="491"/> <!-- 冰封精通 --> </SkillListFirst> <SkillListSecond> <Skill index="41"/> <!-- 霹雳回旋斩 --> <Skill index="236"/> <!-- 火剑袭 --> <Skill index="492"/> <!-- 火剑袭强化 --> <Skill index="494"/> <!-- 火剑袭精通 --> <Skill index="55"/> <!-- 玄月斩 --> <Skill index="493"/> <!-- 玄月斩精通 --> <Skill index="237"/> <!-- 闪电轰顶 --> <Skill index="496"/> <!-- 闪电轰顶强化 --> <Skill index="12"/> <!-- 极光 --> </SkillListSecond> </Class> <Class index="4" check_quest="6"> <!-- CLASS_DL --> <SkillListFirst> <Skill index="78"/> <!-- 火舞旋风 --> <Skill index="518"/> <!-- 火舞旋风强化 --> <Skill index="520"/> <!-- 火舞旋风精通 --> </SkillListFirst> <SkillListSecond> <Skill index="74"/> <!-- 神圣火焰 --> <Skill index="61"/> <!-- 星云火链 --> <Skill index="508"/> <!-- 星云火链强化 --> <Skill index="514"/> <!-- 星云火链精通 --> <Skill index="65"/> <!-- 圣极光 --> <Skill index="519"/> <!-- 闪电之舞强化 --> <Skill index="62"/> <!-- 地裂 --> <Skill index="512"/> <!-- 地裂强化 --> <Skill index="516"/> <!-- 地裂精通 --> <Skill index="238"/> <!-- 黑暗之力 --> </SkillListSecond> </Class> <Class index="5" check_quest="6"> <!-- CLASS_SU --> <SkillListFirst> <Skill index="7"/> <!-- 冰封 --> <Skill index="214"/> <!-- 摄魂咒 --> <Skill index="458"/> <!-- 摄魂咒强化 --> <Skill index="462"/> <!-- 摄魂咒精通 --> </SkillListFirst> <SkillListSecond> <Skill index="230"/> <!-- 烈光闪 --> <Skill index="456"/> <!-- 烈光闪强化 --> <Skill index="215"/> <!-- 链雷咒 --> <Skill index="455"/> <!-- 链雷咒强化 --> </SkillListSecond> </Class> <Class index="6" check_quest="6"> <!-- CLASS_RF --> <SkillListFirst> <Skill index="261"/> <!-- 斗气爆裂拳 --> <Skill index="262"/> <!-- 回旋踢 --> <Skill index="558"/> <!-- 回旋踢强化 --> <Skill index="562"/> <!-- 回旋踢精通 --> <Skill index="552"/> <!-- 斗气爆裂拳强化 --> <Skill index="555"/> <!-- 斗气爆裂拳精通 --> </SkillListFirst> <SkillListSecond> <Skill index="263"/> <!-- 幽冥光速拳 --> <Skill index="264"/> <!-- 炎龙拳 --> <Skill index="265"/> <!-- 嗜血之龙 --> <Skill index="269"/> <!-- 冲锋 --> <Skill index="270"/> <!-- 神圣气旋 --> <Skill index="564"/> <!-- 嗜血之龙强化 --> <Skill index="566"/> <!-- 嗜血之龙精通 --> <Skill index="559"/> <!-- 幽冥光速拳强化 --> <Skill index="563"/> <!-- 幽冥光速拳精通 --> </SkillListSecond> </Class> </ComboSkill>
ecc37ce992ae48beef13458298f7da82
{ "intermediate": 0.23713566362857819, "beginner": 0.5632440447807312, "expert": 0.19962023198604584 }
18,934
I want to turn the LED blue when the switch is in the middle position The LED strip does not turn blue when the switch is in the middle position because the middle position of the switch is not included in the switch cases that define the different palettes. The switch cases are currently set to change the palette based on whether the RC receiver value is less than or greater than the RC_MID value. In the provided code, the middle position of the switch is not accounted for, hence the LEDs will not turn blue in this position. To include the middle position of the switch, a new switch case should be added to set the LEDs to blue when the RC receiver value is equal to the RC_MID value. Can you make the changes for me and give me the full script? #include <FastLED.h> #define LED_PIN 6 #define COLOR_ORDER GRB #define CHIPSET WS2812 #define NUM_LEDS 30 #define BRIGHTNESS 100 #define FRAMES_PER_SECOND 60 CRGB leds[NUM_LEDS]; CRGBPalette16 gPal; // Futaba RC Receiver variables #define RC_PIN A0 #define RC_MIN 1000 #define RC_MAX 2000 #define RC_MID 1500 #define RC_DEADZONE 100 int currentPalette = 0; int prevRCValue = RC_MID; void setup() { delay(3000); // sanity delay FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); // This first palette is the basic ‘black body radiation’ colors, // which run from black to red to bright yellow to white. // gPal = HeatColors_p; // These are other ways to set up the color palette for the ‘fire’. // First, a gradient from black to red to yellow to white – similar to HeatColors_p // (GPAL A) // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White); // Second, this palette is like the heat colors, but blue/aqua instead of red/yellow // (GPAL B) gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White ); // Third, here’s a simpler, three-step gradient, from black to red to white // (GPAL C) // gPal = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::Yellow); } void loop() { // Read RC receiver value int rcValue = pulseIn(RC_PIN, HIGH, 25000); rcValue = constrain(rcValue, RC_MIN, RC_MAX); // Check if RC receiver value is within the deadzone if (abs(rcValue - RC_MID) < RC_DEADZONE) { rcValue = RC_MID; } // Toggle color mode based on RC receiver value if (rcValue < RC_MID && prevRCValue >= RC_MID) { currentPalette--; if (currentPalette < 0) { currentPalette = 2; } } else if (rcValue >= RC_MID && prevRCValue < RC_MID) { currentPalette++; if (currentPalette > 2) { currentPalette = 0; } } prevRCValue = rcValue; // Add entropy to random number generator; we use a lot of it. random16_add_entropy( random()); // Update palette based on currentPalette variable switch (currentPalette) { case 0: gPal = CRGBPalette16( CRGB::Red, CRGB::Red, CRGB::Yellow, CRGB::White); break; case 1: // This is the new palette with a blue color gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White ); break; case 2: gPal = CRGBPalette16( CRGB::Green, CRGB::Green, CRGB::Yellow); break; } Fire2012WithPalette(); // run simulation frame, using palette colors FastLED.show(); // display this frame FastLED.delay(1000 / FRAMES_PER_SECOND); } #define COOLING 55 #define SPARKING 120 #define FALLING 50 //**************************************************************** //********************************************************************************************// // PLAY WITH FALLING, COOLING AND SPARKLING void Fire2012WithPalette() { // Array of temperature readings at each simulation cell static uint8_t heat[NUM_LEDS]; // Step 1. Cool down every cell a little for( int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts ‘up’ and diffuses a little for(int k = NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; } // Step 3. Randomly ignite new ‘sparks’ of heat near the bottom if( random8() < FALLING ) { int y = random8(7); heat[y] = qadd8( heat[y], random8(160,255) ); } // Step 4. Map from heat cells to LED colors for( int j = 0; j < NUM_LEDS; j++) { // Scale the heat value from 0-255 down to 0-240 // for best results with color palettes. uint8_t colorindex = scale8( heat[j], 240); CRGB color = ColorFromPalette( gPal, colorindex); leds[j] = color; } }
d3e9f4f7d1ce6c5ae3f60161fc5c6883
{ "intermediate": 0.46220332384109497, "beginner": 0.4121673107147217, "expert": 0.12562941014766693 }
18,935
if calls_utility.is_bits(index_mask, calls_utility.obj_calls) then 'vars.delete'; vars(0).name := 'TABLE_NAME'; vars(0).value := 'table_name; vars(1).name := 'INDEX_NAME'; vars(1).value := 'table_name' || '_PK'; vars(2).name := 'UNIQUE'; vars(2).value := 'unique'; vars(3).name := 'FIELDS'; vars(3).value := 'call_id'; vars(4).name := 'INDEX_ATTRIBUTES_SPEC'; vars(4).value := 'pstn_calls_table_unique_index_attributes'; vars(5).name := 'INDEX_TABLESPACE_NAME'; vars(5).value := 'BIS_CALLS'; sql_engine.execute(calls_utility.appl_id, 'create_any_table_index', vars); end if; какой запрос получится
2084127d25522f8aa8e27f6a54ca5ab2
{ "intermediate": 0.31347784399986267, "beginner": 0.3709823191165924, "expert": 0.3155398368835449 }
18,936
The below code is throwing an error. import csv from "csv-parser"; export const processCSV= (buffer: Buffer): Promise<any[]> => { return new Promise((resolve, reject) => { const csvResults: any[] = []; csv.parse(buffer) .on("error", (error) => { reject("Failed to process CSV file"); }) .on("data", (row) => { csvResults.push(row); }) .on("end", () => { resolve(csvResults); }); }); } TypeError: csv.parse is not a function
6effc281fbd3ad84e826d891cd1e094e
{ "intermediate": 0.440382719039917, "beginner": 0.3455602824687958, "expert": 0.21405699849128723 }
18,937
I have a WS2812 LEDstrip connected to an arduino uno and an receiver. I want to change the color of the strip from red to blue and green (3 colors). I want to use my Futaba RC transmitter and change the colors with a 3 position switch on the transmitter. Can you write a script for me?
6fc35a36d69779a824b64402cb323778
{ "intermediate": 0.4056386351585388, "beginner": 0.36892053484916687, "expert": 0.22544078528881073 }
18,938
Property 'pipe' does not exist on type 'Buffer'.
2083e7abfc6b1ee58ce29c8bc1d211f2
{ "intermediate": 0.4565715789794922, "beginner": 0.301064133644104, "expert": 0.24236427247524261 }
18,939
Выведи полученные данные на экран : package com.example.test_999 import retrofit2.Call import retrofit2.Callback import retrofit2.Response import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory // Ваш эксперимент может импортировать больше, чем я делаю, // но я оставлю только используемые здесь импорты. import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import com.example.test_999.databinding.ActivityMainBinding import okhttp3.OkHttpClient import okhttp3.Request class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) val client = OkHttpClient() val request = Request.Builder() .url("https://online-movie-database.p.rapidapi.com/auto-complete?q=game%20of%20thr") .get() .addHeader("X-RapidAPI-Key", "f07b384df4msh0cb75ecf6213a0cp19d05ajsn1c71118107fb") .addHeader("X-RapidAPI-Host", "online-movie-database.p.rapidapi.com") .build() val response = client.newCall(request).execute() } }
97dc13118cf678dbf124f72df55f52e1
{ "intermediate": 0.47455936670303345, "beginner": 0.3611361086368561, "expert": 0.16430450975894928 }
18,940
is there a way in python to send packets on an ip addres
83d08cc97d7276a9908f46c0ed21e03b
{ "intermediate": 0.5043333768844604, "beginner": 0.12270689010620117, "expert": 0.3729597330093384 }
18,941
Выведи полученные данные на экран
ea4160999e9f4edb9c37bbaa8ea67165
{ "intermediate": 0.28218844532966614, "beginner": 0.26465609669685364, "expert": 0.453155517578125 }
18,942
did you used backticks in template literals? I cannot see that code in chat. can you redo it in norml old fashion without backticks in template literals? also, align all control, title, buttons and progress bar horizontally in one line at top, put them all in one flexible container in there.: <!DOCTYPE html> <html> <head> <title>Text2Image Interface</title> <style> body { background-color: black; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; } .container { text-align: center; } .progress-bar { width: 300px; height: 20px; background-color: white; margin: 20px auto; } .progress-bar-filled { height: 100%; background-color: green; transition: width 0.3s ease-in-out; } </style> </head> <body> <div class='container'> <h1 style='color: white;'>Text2Image Interface</h1> <input id='inputText' type='text' value='Astronaut riding a horse'> <button onclick='generateImage()' style='margin: 10px;'>Generate Image</button> <br> <div class='progress-bar'> <div id='progressBarFilled' class='progress-bar-filled'></div> </div> <div id='imageContainer'></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.getElementById('progressBarFilled'); const imageContainer = document.getElementById('imageContainer'); async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: Bearer ${modelToken} }, method: 'POST', body: JSON.stringify(data) }); const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; // Display progress bar while waiting for model progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; // Wait for model to load await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = 5; while (retryAttempts < maxRetryAttempts) { try { const response = await query({ 'inputs': inputText }); const url = URL.createObjectURL(response); const img = document.createElement('img'); img.src = url; img.style.maxWidth = '100%'; imageContainer.innerHTML = ''; imageContainer.appendChild(img); break; } catch (error) { console.error(error); retryAttempts++; } } // Increase progress bar width after successful response progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
c502463384be682c80dcfbd1b8bb2254
{ "intermediate": 0.38118642568588257, "beginner": 0.47226279973983765, "expert": 0.14655078947544098 }
18,943
Где конкретно я могу посмотреть результат ? package com.example.test_999 import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.example.test_999.databinding.ActivityMainBinding import okhttp3.OkHttpClient import retrofit2.Call import retrofit2.Callback import retrofit2.Response import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) val retrofit = Retrofit.Builder() .baseUrl("https://moviesminidatabase.p.rapidapi.com/") // Указываем базовый URL .addConverterFactory(GsonConverterFactory.create()) // Указываем конвертер .client(createOkHttpClient()) .build() val service = retrofit.create(ApiService::class.java) val call = service.getMovies("game of thrones") call.enqueue(object : Callback<List<Movie>> { override fun onResponse(call: Call<List<Movie>>, response: Response<List<Movie>>) { if (response.isSuccessful) { val movies = response.body() // Выводим полученные данные на экран movies?.forEach { println(it.toString()) } } else { // Обработка ошибки, например, вывод сообщения об ошибке на экран println("Ошибка: ${response.code()}") } } override fun onFailure(call: Call<List<Movie>>, t: Throwable) { // Обработка ошибки, например, вывод сообщения об ошибке на экран t.printStackTrace() } }) } private fun createOkHttpClient(): OkHttpClient { return OkHttpClient.Builder() .addInterceptor { chain -> val newRequest = chain.request().newBuilder() .addHeader("X-RapidAPI-Key", "f07b384df4msh0cb75ecf6213a0cp19d05ajsn1c71118107fb") .addHeader("X-RapidAPI-Host", "moviesminidatabase.p.rapidapi.com") .build() chain.proceed(newRequest) } .build() } }
366eee8fc69a86f7dcd8664e01b582fe
{ "intermediate": 0.36712267994880676, "beginner": 0.5501343011856079, "expert": 0.08274296671152115 }
18,944
Now there is an endpoint that generates a packing slip for one order which i have put below called generating package slip for one order Now i need to create a new endpoint that will generate a Packing Slip for multiple orders. The document format is the same as for one order. General header with logo. Heading "Packing slip" Further for each order: Order number (we add, in one order is missing) Client name Client's height, client's weight. A table with a list of items in an order. async generatePackageSlip(order: OrderEntity) { const pdf = new jsPdf({ orientation: 'portrait', compress: true, }); const logo = await readFile( path.resolve(__dirname, '../assets/logo.png'), ); pdf.addImage( Buffer.from(logo).toString('base64'), 'PNG', pdf.internal.pageSize.width / 2 - 12.5, 10, 25, 25, ); pdf.setFontSize(32).text( 'Packing Slip', pdf.internal.pageSize.width / 2, 50, { align: 'center', }, ); pdf.setFontSize(12); const addText = (inputValue: string, x: number, y: number) => { const arrayOfNormalAndBoldText = inputValue.split('**'); arrayOfNormalAndBoldText.map((text, i) => { pdf.setFont(pdf.getFont().fontName, 'bold'); if (i % 2 === 0) { pdf.setFont(pdf.getFont().fontName, 'normal'); } pdf.text(text, x, y); x = x + pdf.getTextWidth(`${text}${i > 0 ? ' ' : ''}`); }); }; const headerStartLine = 64; let lineHeight = 6; addText( `Customer Name: **${order.deliveryName}**`, 20, headerStartLine, ); addText( order.deliveryNotes ? `Order Notes: **${order.deliveryNotes}**` : '', 20, headerStartLine + lineHeight, ); addText( order.customerHeight ? `Customer Height: **${order.customerHeight}cm**` : '', 20, headerStartLine + lineHeight * 2, ); addText( order.customerWeight ? `Customer Weight: **${order.customerWeight}kg**` : '', 80, headerStartLine + lineHeight * 2, ); pdf.setDrawColor('#828282'); lineHeight = 8; const drawSquare = (x1: number, y1: number, x2: number, y2: number) => { pdf.line(x1, y1, x1, y2); pdf.line(x1, y2, x2, y2); pdf.line(x2, y2, x2, y1); pdf.line(x2, y1, x1, y1); }; const addTable = (y: number, item: IOrderItem) => { const lines = []; let jacketSize = ''; let trousersSize = ''; let shirtSize = ''; let kidsSize = ''; let suitCondition = ''; switch (item.category) { case 'suits and tuxedos': case 'kids collection': case 'suit sale': case 'kids collection sale': case 'clearance suits sale': jacketSize = item.meta['Size of Jacket/Shirt'] ?? item.meta['Size of Jacket'] ?? null; trousersSize = item.meta['Size of Trousers'] ?? null; suitCondition = item.meta['Suit Condition'] ?? null; shirtSize = item.meta['Size of Jacket/Shirt'] ?? item.meta['Size of Shirt'] ?? null; kidsSize = item.meta['Size of Kids'] ?? null; if (kidsSize) { lines.push( `Kids Size: ${kidsSize ? `**${kidsSize}**` : ''}`, ); } if (jacketSize) { lines.push( `Jacket Size: ${ jacketSize ? `**${jacketSize}**` : '' }`, ); } if (trousersSize) { lines.push( `Trousers Size: ${ trousersSize ? `**${trousersSize}**` : '' }`, ); } if (shirtSize) { lines.push( `Shirt Size: ${ shirtSize ? `**${shirtSize}**` : '' }`, ); } if (suitCondition) { lines.push( `Suit Condition: ${ suitCondition ? `**${suitCondition}**` : '' }`, ); } if (item.packageDescription) { const str = item.packageDescription; const regex = /(a|the|includes)\s+/gi; const arr = str .split(/(,|\s+and\s+)/) .map((subItem: string) => subItem.replace(regex, '').trim(), ) .filter( (subItem: string) => !/tux|suit/i.test(subItem), ) .filter( (subItem) => subItem !== ',' && subItem !== 'and', ); arr.forEach((subItem) => { if ( subItem.includes('Tie') || subItem.includes('Bowtie') ) { const color = subItem .replace('Bowtie', '') .replace('Tie', '') .trim(); if (subItem.includes('Tie')) { lines.push(`Tie: **${color}**`); } else { lines.push(`Bowtie: **${color}**`); } } if (subItem.includes('Vest')) { const color = subItem .replace('Vest', '') .trim(); lines.push(`Vest: **${color}**`); } if (subItem.includes('Belt')) { const color = subItem .replace('Belt', '') .trim(); lines.push(`Belt: **${color}**`); } if (subItem.includes('Pocket Square')) { const color = subItem .replace('Pocket Square', '') .trim(); lines.push(`Pocket Square: **${color}**`); } }); } else { lines.push('Tie/Bowtie'); lines.push('Vest'); lines.push('Belt'); lines.push('Pocket Square'); } break; case 'shirt': break; case 'jacket': } const k = 0.3; const lastY = y + lineHeight * (lines.length + 1) + lineHeight * k; const endPoint = pdf.internal.pageSize.height - 20; if (lastY > endPoint) { pdf.addPage(); y = 20; } for ( let i = 0; i < lines.length + (lines.length > 0 ? 3 : 2); i++ ) { pdf.line( 20, y + lineHeight * (i - 1) + lineHeight * k, pdf.internal.pageSize.width - 20, y + lineHeight * (i - 1) + lineHeight * k, ); } pdf.line( 20, y + lineHeight * -1 + lineHeight * k, 20, y + lineHeight * (lines.length > 0 ? lines.length + 1 : 0) + lineHeight * k, ); pdf.line( pdf.internal.pageSize.width - 20, y + lineHeight * -1 + lineHeight * k, pdf.internal.pageSize.width - 20, y + lineHeight * (lines.length > 0 ? lines.length + 1 : 0) + lineHeight * k, ); const squareSize = lineHeight * 0.5; const header = [`**${item.title}**`]; if (item.meta['Package Name']) { header.push(`Package - **${item.meta['Package Name']}**`); } if (item.meta['Backup Suit']) { header.push(`Backup Suit - **${item.meta['Backup Suit']}**`); } if (item.category === 'shirt' && item.meta['Size of Shirt']) { header.push(`Size - **${item.meta['Size of Shirt']}**`); } if ( item.category === 'new shirt sale' && item.meta['Size of New Shirt Sale'] ) { header.push( `Size - **${item.meta['Size of New Shirt Sale']}**`, ); } if (item.category === 'jacket' && item.meta['Size of Jacket']) { header.push(`Size - **${item.meta['Size of Jacket']}**`); } if ( item.category === 'new jacket sale' && item.meta['Size of New Jacket Sale'] ) { header.push( `Size - **${item.meta['Size of New Jacket Sale']}**`, ); } if ( item.category === 'jacket sale' && item.meta['Size of Jacket Sale'] ) { header.push(`Size - **${item.meta['Size of Jacket Sale']}**`); } if (item.category === 'shoes' && item.meta['Size of Shoes']) { header.push(`Size - **${item.meta['Size of Shoes']}**`); } if ( item.category === 'shoe sale' && item.meta['Size of Shoe Sale'] ) { header.push(`Size - **${item.meta['Size of Shoe Sale']}**`); } if (item.category === 'vest' && item.meta['Size of Vest']) { header.push(`Size - **${item.meta['Size of Vest']}**`); } if ( item.category === 'new vest sale' && item.meta['Size of New Vest Sale'] ) { header.push(`Size - **${item.meta['Size of New Vest Sale']}**`); } if ( item.category === 'vest sale' && item.meta['Size of Vest Sale'] ) { header.push(`Size - **${item.meta['Size of Vest Sale']}**`); } drawSquare( 24, y - lineHeight * k - squareSize * 0.3, 24 + squareSize, y - lineHeight * k + squareSize * 0.7, ); addText(header.join(' '), 24 + squareSize * 1.5, y); if (lines.length !== 0) { addText('Items to include:', 24, y + lineHeight); addText( 'Sent? (Tick when included in order)', 74, y + lineHeight, ); for (let i = 0; i < lines.length; i++) { drawSquare( 24, y + lineHeight * (2 + i) - lineHeight * k - squareSize * 0.3, 24 + squareSize, y + lineHeight * (2 + i) - lineHeight * k + squareSize * 0.7, ); addText( lines[i] as string, 24 + squareSize * 1.5, y + lineHeight * (2 + i), ); } } else { return y + lineHeight + lineHeight * k; } return y + lineHeight * (lines.length + 2) + lineHeight * k; }; let lastY = 84; for (const item of order.items) { lastY = addTable(lastY + 5, item); } return Buffer.from(pdf.output('arraybuffer')); } this si
1dba20d94c8515a57ed83c165853d811
{ "intermediate": 0.3375089168548584, "beginner": 0.4679301679134369, "expert": 0.1945609301328659 }
18,945
Bulk insert in mongoose, after checking if it exists
fe8eb81b4fa08de1839ad26a5ac2da96
{ "intermediate": 0.4729713201522827, "beginner": 0.22213324904441833, "expert": 0.3048954904079437 }
18,946
fix this code: "inquiry"+str(df_with_status.inquiry_id)
20ea4acd53d0c899656a8640b1e1dc85
{ "intermediate": 0.4075031578540802, "beginner": 0.39474332332611084, "expert": 0.19775351881980896 }
18,947
how get "Break Action" from HingeJoint2D in my script ? (Unity Engine)
914c656605ec599e53756bd146464f1f
{ "intermediate": 0.7231884002685547, "beginner": 0.161852166056633, "expert": 0.11495944857597351 }
18,948
How do I create a reflowable epub that has page numbers for both a Mac and a PC system?
b419b639ced4232cf76a3220b6d2b0b9
{ "intermediate": 0.4674416780471802, "beginner": 0.1752236932516098, "expert": 0.35733455419540405 }
18,949
compare list1 to list2
2579d40e4e95355ebec35271dc3b1f49
{ "intermediate": 0.351800799369812, "beginner": 0.26829248666763306, "expert": 0.37990671396255493 }
18,950
now there's some issue with that: "error "Model hogiahien/counterfeit-v30-edited is currently loading" estimated_time 20. <--need to catch that time value returned from AI model and use it in actual progressbar to determine the overall progression counter that will count how much seconds left in dependence of that time returned form an AI model. also, need to resend the same query automatically (with 1-2 sec addiditional reserve to overall timeout returned from AI model) and need to add an interface element to activate auto-queue (like radiobutton) and a number of attempts adjuster to queue to model.: <!DOCTYPE html> <html> <head> <title>Text2Image Interface</title> <style> body { background-color: black; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; } .container { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } .control-container { display: flex; align-items: center; justify-content: center; margin-bottom: 20px; position: sticky; top: 0; background-color: rgba(0, 0, 0, 0.8); z-index: 1; } .input-field { margin-right: 10px; } .progress-bar { width: 100%; height: 20px; background-color: white; margin-bottom: 20px; position: sticky; top: 0; z-index: 1; } .progress-bar-filled { height: 100%; background-color: green; transition: width 0.3s ease-in-out; position: absolute; top: 0; left: 0; } .image-container { display: flex; align-items: center; justify-content: center; width: 100%; height: 100vh; overflow: hidden; position: relative; } .image-wrapper { width: 100%; height: 0; padding-bottom: 56.25%; / Maintain aspect ratio of 16:9 */ position: absolute; top: 0; left: 0; } </style> </head> <body> <div class='container'> <h1 style='color: white;'>Text2Image Interface</h1> <div class='control-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> <button onclick='generateImage()' style='margin: 10px;'>Generate Image</button> </div> <div class='progress-bar'> <div id='progressBarFilled' class='progress-bar-filled'></div> </div> <div class='image-container' id='imageContainer'></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.getElementById('progressBarFilled'); const imageContainer = document.getElementById('imageContainer'); async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: 'Bearer ' + modelToken }, method: 'POST', body: JSON.stringify(data) }); const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; // Display progress bar while waiting for model progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; // Wait for model to lend await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = 5; while (retryAttempts < maxRetryAttempts) { try { const cacheBuster = new Date().getTime(); // Get current timestamp const response = await query({ 'inputs': inputText, 'cacheBuster': cacheBuster }); const url = URL.createObjectURL(response); const imgWrapper = document.createElement('div'); imgWrapper.classList.add('image-wrapper'); const img = document.createElement('img'); img.src = url; img.style.position = 'absolute'; img.style.top = '0'; img.style.left = '0'; img.style.width = '100%'; img.style.height = '100%'; imgWrapper.appendChild(img); imageContainer.innerHTML = ''; imageContainer.appendChild(imgWrapper); break; } catch (error) { console.error(error); retryAttempts++; } } // Increase progress bar width after successful response progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
9fb683c8aaf50e1b1c3a108bc74ddfbb
{ "intermediate": 0.37914764881134033, "beginner": 0.38632848858833313, "expert": 0.2345239520072937 }
18,951
now there's some issue with that: "error "Model hogiahien/counterfeit-v30-edited is currently loading" estimated_time 20." <--the problem here is to catch that specific timeout number from JSON header response returned and use it in actual progress bar... <--need to catch that time value returned from AI model and use it in actual progressbar to determine the overall progression counter that will count how much seconds left in dependence of that time returned form an AI model. also, need to resend the same query automatically (with 1-2 sec addiditional reserve to overall timeout returned from AI model) and need to add an interface element to activate auto-queue (like radiobutton) and a number of attempts adjuster to queue to model.: <!DOCTYPE html> <html> <head> <title>Text2Image Interface</title> <style> body { background-color: black; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; } .container { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } .control-container { display: flex; align-items: center; justify-content: center; margin-bottom: 20px; position: sticky; top: 0; background-color: rgba(0, 0, 0, 0.8); z-index: 1; } .input-field { margin-right: 10px; } .progress-bar { width: 100%; height: 20px; background-color: white; margin-bottom: 20px; position: sticky; top: 0; z-index: 1; } .progress-bar-filled { height: 100%; background-color: green; transition: width 0.3s ease-in-out; position: absolute; top: 0; left: 0; } .image-container { display: flex; align-items: center; justify-content: center; width: 100%; height: 100vh; overflow: hidden; position: relative; } .image-wrapper { width: 100%; height: 0; padding-bottom: 56.25%; / Maintain aspect ratio of 16:9 */ position: absolute; top: 0; left: 0; } </style> </head> <body> <div class='container'> <h1 style='color: white;'>Text2Image Interface</h1> <div class='control-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> <button onclick='generateImage()' style='margin: 10px;'>Generate Image</button> </div> <div class='progress-bar'> <div id='progressBarFilled' class='progress-bar-filled'></div> </div> <div class='image-container' id='imageContainer'></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.getElementById('progressBarFilled'); const imageContainer = document.getElementById('imageContainer'); async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: 'Bearer ' + modelToken }, method: 'POST', body: JSON.stringify(data) }); const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; // Display progress bar while waiting for model progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; // Wait for model to lend await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = 5; while (retryAttempts < maxRetryAttempts) { try { const cacheBuster = new Date().getTime(); // Get current timestamp const response = await query({ 'inputs': inputText, 'cacheBuster': cacheBuster }); const url = URL.createObjectURL(response); const imgWrapper = document.createElement('div'); imgWrapper.classList.add('image-wrapper'); const img = document.createElement('img'); img.src = url; img.style.position = 'absolute'; img.style.top = '0'; img.style.left = '0'; img.style.width = '100%'; img.style.height = '100%'; imgWrapper.appendChild(img); imageContainer.innerHTML = ''; imageContainer.appendChild(imgWrapper); break; } catch (error) { console.error(error); retryAttempts++; } } // Increase progress bar width after successful response progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
d55d615029e4cd2d19640f79586bf4ba
{ "intermediate": 0.38245946168899536, "beginner": 0.3834531605243683, "expert": 0.23408736288547516 }
18,952
const orderQuantity: PreparedOrderQuantity = {quantity: quantitySelected, unit: volumeAsDollarsCheck ? "usd" : "coin"}; const savedQuantity = localStorage.getItem("preparedQuantity"); if (savedQuantity) { const parsedQuantity = JSON.parse(savedQuantity); if (parsedQuantity.hasOwnProperty(symbol)) { parsedQuantity[symbol] = orderQuantity; localStorage.setItem("preparedQuantity", JSON.stringify({[symbol]: orderQuantity})); } else { // localStorage.setItem("preparedQuantity", JSON.stringify({[symbol]: newQuantitiy})); } } если parsedQuantity.hasOwnProperty(symbol)), то бы заменяем по ключу по symbol orderQuantity, иначе нужно добавлять новый объект с новым ключом
06ada212ec8459bf3e8a32a4b71e261e
{ "intermediate": 0.3776969015598297, "beginner": 0.3715679347515106, "expert": 0.25073516368865967 }
18,953
need to make text no-wrap: .container { position:absolute; text-align: left; margin: 0; display:flex; word-wrap:no-wrap; }
a57ca6eb80485f8b711ebfbeb245c1dc
{ "intermediate": 0.456561803817749, "beginner": 0.22554874420166016, "expert": 0.3178894817829132 }
18,954
I have class CatDownloaderV2 with fun downloadCats(count: Int, onNext : (Cat) -> Unit, onComplete : () -> Unit, onError : () -> Null): List<Cat?> and I made val catDownloaderV2 = CatDownloaderV2(). Now I want to catDownloaderV2.downloadCats() passing CATS_COUNT,showCat(),showError(),showComplete() as parameters. How do I do this?
cd033e766011f9ac93850ba461193b4b
{ "intermediate": 0.36982518434524536, "beginner": 0.5403791069984436, "expert": 0.08979575335979462 }
18,955
Испраь ошибки в этом коде : package com.example.test_999 import android.os.Bundle import android.util.Log import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.example.test_999.databinding.ActivityMainBinding import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.ResponseBody import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Call import retrofit2.Callback import retrofit2.Response class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) val interceptor = HttpLoggingInterceptor() interceptor.level = HttpLoggingInterceptor.Level.BODY val client = OkHttpClient.Builder() .addInterceptor(interceptor) .build() val request = Request.Builder() .url("https://online-movie-database.p.rapidapi.com/auto-complete?q=game of thr") .get() .addHeader("X-RapidAPI-Key", "f07b384df4msh0cb75ecf6213a0cp19d05ajsn1c71118107fb") .addHeader("X-RapidAPI-Host", "online-movie-database.p.rapidapi.com") .build() client.newCall(request).enqueue(object : Callback<ResponseBody> { override fun onFailure(call: Call<ResponseBody>, t: Throwable) { // Обработка ошибки при выполнении запроса Toast.makeText(applicationContext, "Ошибка при выполнении запроса", Toast.LENGTH_SHORT).show() } override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) { if (response.isSuccessful) { val responseData = response.body()?.string() // Вывод полученных данных в Logcat Log.d("MainActivity", "Response: $responseData") } else { // Обработка ошибки при получении ответа от сервера Toast.makeText(applicationContext, "Ошибка при получении ответа от сервера", Toast.LENGTH_SHORT).show() } } }) } }Type mismatch: inferred type is `<no name provided>` but Callback was expected
b072f03aded98217822bc70cb60a6e93
{ "intermediate": 0.42328375577926636, "beginner": 0.4081987738609314, "expert": 0.16851744055747986 }
18,956
в этом коде : client.newCall(request).enqueue(object : Callback<ResponseBody> { override fun onFailure(call: Call<ResponseBody>, t: Throwable) { // Обработка ошибки при выполнении запроса Toast.makeText(applicationContext, "Ошибка при выполнении запроса", Toast.LENGTH_SHORT).show() } override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) { if (response.isSuccessful) { val responseData = response.body()?.string() // Вывод полученных данных в Logcat Log.d("MainActivity", "Response: $responseData") } else { // Обработка ошибки при получении ответа от сервера Toast.makeText(applicationContext, "Ошибка при получении ответа от сервера", Toast.LENGTH_SHORT).show() } } }) Ошибка : Type mismatch: inferred type is `<no name provided>` but Callback was expected
3c0239f07874a71038a56e7ac446e347
{ "intermediate": 0.3680160939693451, "beginner": 0.30781757831573486, "expert": 0.32416629791259766 }
18,957
can you do this image container output from text2image AI response to be inside some canvas element, because it simply covers the entire screen and all control container when the image output appears from that text2image AI. then need to place that image canvas output below control container. also you probably can remove these inline styles, as they no longer need to anyone. also, need to make sure that these styles used inside javascript to maintain the aspect-ratio of the image coming from text2image AI response, so it can fit on full width in canvas element. (also, don’t use any backticks in template literals, do it in normal old fashion through + and '. ): <html> <head> <title>Text2Image AI</title> </head> <body> <div id='container' class='container'> <h1 id='title' style='color: midnightblue; margin-top: 0px; margin-right: 10px;'>T2I UI</h1> <div id='controlContainer' class='control-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> <button onclick='generateImage()' style='margin: 0px;'>Generate Image</button> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> </div> <div> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> </div> <div class='progress-bar'> <div id='progressBarFilled' class='progress-bar-filled'></div><div id='imageContainer' class='image-container'></div> </div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.getElementById('progressBarFilled'); const imageContainer = document.getElementById('imageContainer'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const imgWrapper = document.createElement('div'); imgWrapper.classList.add('image-wrapper'); const img = document.createElement('img'); img.src = url; img.style.position = 'absolute'; img.style.top = '0'; img.style.left = '0'; img.style.width = '100%'; imgWrapper.appendChild(img); imageContainer.innerHTML = ''; imageContainer.appendChild(imgWrapper); clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
cfa02d5305508f7411ea9ca2d089a19e
{ "intermediate": 0.284699410200119, "beginner": 0.46770066022872925, "expert": 0.24759989976882935 }
18,958
can you do this image container output from text2image AI response to be inside some canvas element, because it simply covers the entire screen and all control container when the image output appears from that text2image AI. then need to place that image canvas output below control container. also you probably can remove these inline styles, as they no longer need to anyone. also, need to make sure that these styles used inside javascript to maintain the aspect-ratio of the image coming from text2image AI response, so it can fit on full width in canvas element. (also, don’t use any backticks in template literals, do it in normal old fashion through + and '. ): <html> <head> <title>Text2Image AI</title> </head> <body> <div id='container' class='container'> <h1 id='title' style='color: midnightblue; margin-top: 0px; margin-right: 10px;'>T2I UI</h1> <div id='controlContainer' class='control-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> <button onclick='generateImage()' style='margin: 0px;'>Generate Image</button> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> </div> <div> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> </div> <div class='progress-bar'> <div id='progressBarFilled' class='progress-bar-filled'></div><div id='imageContainer' class='image-container'></div> </div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.getElementById('progressBarFilled'); const imageContainer = document.getElementById('imageContainer'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const imgWrapper = document.createElement('div'); imgWrapper.classList.add('image-wrapper'); const img = document.createElement('img'); img.src = url; img.style.position = 'absolute'; img.style.top = '0'; img.style.left = '0'; img.style.width = '100%'; imgWrapper.appendChild(img); imageContainer.innerHTML = ''; imageContainer.appendChild(imgWrapper); clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
adbe0c4088ae758f27b0b143443ce1df
{ "intermediate": 0.284699410200119, "beginner": 0.46770066022872925, "expert": 0.24759989976882935 }
18,959
how can i increment a certain position in a for loop in C++?
e138ed8fccb72e47025b51bf2a3243e5
{ "intermediate": 0.23854494094848633, "beginner": 0.581601619720459, "expert": 0.17985345423221588 }
18,960
fix this Rust code
ca824e3974ea77fa3b0f221e4a18764e
{ "intermediate": 0.24238349497318268, "beginner": 0.530829668045044, "expert": 0.2267867773771286 }
18,962
in this Rust code, will the `println!` only run if `run_tauri_app` returns an error?
2272733b696e79456736d8e1453ec471
{ "intermediate": 0.3815494775772095, "beginner": 0.4151483476161957, "expert": 0.2033022791147232 }
18,963
need that canvas to stay at bottom always below all other elements auto-flexible and centered. any ideas? (also, don’t use any backticks in template literals, do it in normal old fashion through + and '. ): <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> .container { display: flex; flex-direction: row; align-items: center; } .control-container { display: flex; flex-direction: row; align-items: center; margin-top: 20px; } .input-field { margin-bottom: 10px; } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; height: 100%; border:red solid 1px; } .progress-bar { width: 100%; height: 10px; background-color: #f2f2f2; margin-top: 20px; margin-bottom: 40px; } .progress-bar-filled { width: 0%; height: 10%; background-color: green; } </style> </head> <body> <div class='container'> <h1 class='title' style='color: midnightblue; margin-top: 0px; margin-right: 10px;'>T2I UI</h1> <div class='control-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> <button onclick='generateImage()' style='margin: 0px;'>Generate Image</button> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> </div> <div> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> </div> <canvas id='imageCanvas' class='image-canvas'></canvas> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
dae8eb1b4c9d5c6b1c60b4e5a7682c59
{ "intermediate": 0.33721569180488586, "beginner": 0.4559345543384552, "expert": 0.20684978365898132 }
18,964
How do I program a digital odometer in C++?
1ec0e388404ef646965d94eae44f3a76
{ "intermediate": 0.3031153380870819, "beginner": 0.2755586802959442, "expert": 0.4213259816169739 }
18,965
i have a egpu on my mac, i installed more ram unto my computer, what is something else that i can do to my computer to process video rendering quicker?
d71566677728f2976581976f34c82c8a
{ "intermediate": 0.38244521617889404, "beginner": 0.271198034286499, "expert": 0.34635668992996216 }
18,966
when you set “.input-field-container” to “position: absolute;” it got flexed and expanded on full window width normally, but covers all other elements. need that title,input,button to stay in one single inline horizontal row at the most-left-top corner, without any margins or paddings and in one single horizontal line and this input should auto-flex with attached button to it on full window width. try to think a bit before you output something. ha-ha.: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { height: 100%; margin: 0; padding: 0; } .container { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; height: 100vh; } .control-container { display: flex; flex-direction: row; align-items: flex-start; margin: 0; } .control-container h1 { margin: 0; } .input-field-container { position: absolute; left: 0; top: 0; width: calc(100% - 48px); } .input-field { width: 100%; box-sizing: border-box; } .gen-button-container { margin-left: 10px; } .gen-button { margin: 0; } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 99%; margin-top: auto; margin-bottom: auto; border: red solid 1px; } .progress-bar { width: 100%; height: 10px; background-color: #f2f2f2; } .progress-bar-filled { width: 0%; height: 10%; background-color: green; } </style> </head> <body> <div class='container'> <div class='control-container'> <h1 class='title' style='color: midnightblue; margin-top: 0;'>T2I UI</h1> <div class='input-field-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> </div> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button'>Gen Img</button> </div> </div> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> </div> <canvas id='imageCanvas' class='image-canvas'></canvas> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
88ec7c554c7e08cbab6c09792a9ba17b
{ "intermediate": 0.30547505617141724, "beginner": 0.41796785593032837, "expert": 0.27655717730522156 }
18,967
when you set “.input-field-container” to “position: absolute;” it got flexed and expanded on full window width normally, but covers all other elements. need that title,input,button to stay in one single inline horizontal row at the most-left-top corner, without any margins or paddings and in one single horizontal line and this input should auto-flex with attached button to it on full window width. try to think a bit before you output something. ha-ha.: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { height: 100%; margin: 0; padding: 0; } .container { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; height: 100vh; } .control-container { display: flex; flex-direction: row; align-items: flex-start; margin: 0; } .control-container h1 { margin: 0; } .input-field-container { position: absolute; left: 0; top: 0; width: calc(100% - 48px); } .input-field { width: 100%; box-sizing: border-box; } .gen-button-container { margin-left: 10px; } .gen-button { margin: 0; } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 99%; margin-top: auto; margin-bottom: auto; border: red solid 1px; } .progress-bar { width: 100%; height: 10px; background-color: #f2f2f2; } .progress-bar-filled { width: 0%; height: 10%; background-color: green; } </style> </head> <body> <div class='container'> <div class='control-container'> <h1 class='title' style='color: midnightblue; margin-top: 0;'>T2I UI</h1> <div class='input-field-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> </div> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button'>Gen Img</button> </div> </div> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> </div> <canvas id='imageCanvas' class='image-canvas'></canvas> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
f923d39921878b9ae9263e0ae51f13d3
{ "intermediate": 0.30547505617141724, "beginner": 0.41796785593032837, "expert": 0.27655717730522156 }
18,968
when you set “.input-field-container” to “position: absolute;” it got flexed and expanded on full window width normally, but covers all other elements. need that title,input,button to stay in one single inline horizontal row at the most-left-top corner, without any margins or paddings and in one single horizontal line and this input should auto-flex with attached button to it on full window width. try to think a bit before you output something. ha-ha.: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { height: 100%; margin: 0; padding: 0; } .container { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; height: 100vh; } .control-container { display: flex; flex-direction: row; align-items: flex-start; margin: 0; } .control-container h1 { margin: 0; } .input-field-container { position: absolute; left: 0; top: 0; width: calc(100% - 48px); } .input-field { width: 100%; box-sizing: border-box; } .gen-button-container { margin-left: 10px; } .gen-button { margin: 0; } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 99%; margin-top: auto; margin-bottom: auto; border: red solid 1px; } .progress-bar { width: 100%; height: 10px; background-color: #f2f2f2; } .progress-bar-filled { width: 0%; height: 10%; background-color: green; } </style> </head> <body> <div class='container'> <div class='control-container'> <h1 class='title' style='color: midnightblue; margin-top: 0;'>T2I UI</h1> <div class='input-field-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> </div> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button'>Gen Img</button> </div> </div> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> </div> <canvas id='imageCanvas' class='image-canvas'></canvas> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
a79fc54d13eac5d303b93e626a17058f
{ "intermediate": 0.30547505617141724, "beginner": 0.41796785593032837, "expert": 0.27655717730522156 }
18,969
what does unwrap() do in Rust
64e46a54616fd46ed11fb77386a8bbae
{ "intermediate": 0.3749985098838806, "beginner": 0.2169853001832962, "expert": 0.40801623463630676 }
18,970
hi how install google chrome in my kali
abee64fca58a39dcf0a0dd939a8c3937
{ "intermediate": 0.4848114550113678, "beginner": 0.2633701264858246, "expert": 0.25181838870048523 }
18,971
when you set “.input-field-container” to “position: absolute;” it got flexed and expanded on full window width normally, but covers all other elements. need that title,input,button to stay in one single inline horizontal row at the most-left-top corner, without any margins or paddings and in one single horizontal line and this input should auto-flex with attached button to it on full window width. try to think a bit before you output something. ha-ha.: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { height: 100%; margin: 0; padding: 0; } .container { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; height: 100vh; } .control-container { display: flex; flex-direction: row; align-items: flex-start; margin: 0; } .control-container h1 { margin: 0; } .input-field-container { position: absolute; left: 0; top: 0; width: calc(100% - 48px); } .input-field { width: 100%; box-sizing: border-box; } .gen-button-container { margin-left: 10px; } .gen-button { margin: 0; } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 99%; margin-top: auto; margin-bottom: auto; border: red solid 1px; } .progress-bar { width: 100%; height: 10px; background-color: #f2f2f2; } .progress-bar-filled { width: 0%; height: 10%; background-color: green; } </style> </head> <body> <div class='container'> <div class='control-container'> <h1 class='title' style='color: midnightblue; margin-top: 0;'>T2I UI</h1> <div class='input-field-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> </div> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button'>Gen Img</button> </div> </div> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> </div> <canvas id='imageCanvas' class='image-canvas'></canvas> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
ae97f0c22eb3839b806b62cd2d12cf3e
{ "intermediate": 0.30547505617141724, "beginner": 0.41796785593032837, "expert": 0.27655717730522156 }
18,972
looking at the meant SCA rest API 2.0 how do I pass in the barer key? I’m trying to access the API using to get command but I am not sure how to pass the use your key as well and I am trying to do this in a go program.
4c5f188cd0c32b4300b2bc98a79e48d9
{ "intermediate": 0.8548271059989929, "beginner": 0.06665593385696411, "expert": 0.07851695269346237 }
18,973
when you set “.input-field-container” to “position: absolute;” it got flexed and expanded on full window width normally, but covers all other elements. need that title,input,button to stay in one single inline horizontal row at the most-left-top corner, without any margins or paddings and in one single horizontal line and this input should auto-flex with attached button to it on full window width. try to think a bit before you output something. ha-ha.: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { height: 100%; margin: 0; padding: 0; } .container { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; height: 100vh; } .control-container { display: flex; flex-direction: row; align-items: flex-start; margin: 0; } .control-container h1 { margin: 0; } .input-field-container { position: absolute; left: 0; top: 0; width: calc(100% - 48px); } .input-field { width: 100%; box-sizing: border-box; } .gen-button-container { margin-left: 10px; } .gen-button { margin: 0; } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 99%; margin-top: auto; margin-bottom: auto; border: red solid 1px; } .progress-bar { width: 100%; height: 10px; background-color: #f2f2f2; } .progress-bar-filled { width: 0%; height: 10%; background-color: green; } </style> </head> <body> <div class='container'> <div class='control-container'> <h1 class='title' style='color: midnightblue; margin-top: 0;'>T2I UI</h1> <div class='input-field-container'> <input id='inputText' type='text' value='Astronaut riding a horse' class='input-field'> </div> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button'>Gen Img</button> </div> </div> <div> <input type='checkbox' id='autoQueueCheckbox'> <label for='autoQueueCheckbox'>Auto Queue</label> <label for='numAttemptsInput'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> </div> <canvas id='imageCanvas' class='image-canvas'></canvas> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'blue'; } </script> </body> </html>
3a673d5a32ab6c5795e3220bd956aeff
{ "intermediate": 0.30547505617141724, "beginner": 0.41796785593032837, "expert": 0.27655717730522156 }
18,974
Get the index of value in the list using C#
323c66ac7faff7e5deb5a8ffd2f47404
{ "intermediate": 0.3852209150791168, "beginner": 0.30277252197265625, "expert": 0.31200656294822693 }
18,975
make a poc for cve 2020-2551
18fca55d3210af099d1ff753621e91b6
{ "intermediate": 0.3147156238555908, "beginner": 0.33138588070869446, "expert": 0.35389846563339233 }
18,976
js代码报错:Uncaught ReferenceError: jQuery is not defined
25647097b0b3b9bc0743a9ec9c87ca4f
{ "intermediate": 0.3893544673919678, "beginner": 0.41268685460090637, "expert": 0.19795863330364227 }
18,977
SELECT [BusinessEntityID] ,[JobTitle] ,[BirthDate] ,[MaritalStatus] ,[Gender] ,[HireDate] FROM [AdventureWorks2019].[HumanResources].[Employee] get me all male and female workers separetly using udf function
1725ae08c7937227eefa5c3275f1b7e0
{ "intermediate": 0.3607451915740967, "beginner": 0.3834550082683563, "expert": 0.2557998299598694 }
18,978
Create a function that returns the mean of all digits. Examples mean(42) ➞ 3 mean(12345) ➞ 3 mean(666) ➞ 6 Notes The mean of all digits is the sum of digits / how many digits there are (e.g. mean of digits in 512 is (5+1+2)/3(number of digits) = 8/3=2). The mean will always be an integer. solve in javascript
175aa1d34d3ae81eedfdd26dcd1b6ce2
{ "intermediate": 0.39095601439476013, "beginner": 0.29557496309280396, "expert": 0.3134690225124359 }
18,979
JSONObject["owner_full_org_name"] is not a string. java报了一个这个错
1d8f43615f164705e3c281346ea9671f
{ "intermediate": 0.39031755924224854, "beginner": 0.31728705763816833, "expert": 0.2923954129219055 }
18,980
Write a matlab code for adding two numbers
f629b89d6ceebe8a6ae4bd00412efd43
{ "intermediate": 0.2895587384700775, "beginner": 0.20992524921894073, "expert": 0.5005160570144653 }
18,981
I need write testing system to valiadate hardware parameters with expected for specific device model. Code should detect model version according CPU and Chipset, then loads related to this model yaml file with key:value where key is some hardware parameter and value is some value, for example, RAM: 15GB. Each key also have associated poweshell scripts used to get value from system. Script runs powershell, gets value and then compairs it with expected value. It also should saves results into some json file to be loaded into server later. So it is some kind of HW tester. Can you write some python script which do the same but uses pytest module and it's features?
bd556a16f24a2d5608cf3e582900b991
{ "intermediate": 0.582281768321991, "beginner": 0.12378280609846115, "expert": 0.2939354479312897 }
18,982
select 'nancy' as name, reverse('nancy') as reversedname --homework #1: do reverse job with WHILE statement on mysql
0f3db2d8a3a24db0bde28cc46e89d2a3
{ "intermediate": 0.448158323764801, "beginner": 0.2310776263475418, "expert": 0.32076406478881836 }
18,983
The role of present_queue_vblank in xorg
252b2f54a7398e397d2593fa466bf8aa
{ "intermediate": 0.23645949363708496, "beginner": 0.21700651943683624, "expert": 0.54653400182724 }
18,984
do reverse job with WHILE statement, select 'nancy' as name, reverse('nancy') as reversedname
d4fcc920a193768fb57f21bf5140a609
{ "intermediate": 0.37841445207595825, "beginner": 0.21586713194847107, "expert": 0.4057184159755707 }
18,985
is there any way to extend spaces in “dashed” border inbetween colored lines? try implement this method for border to “.image-canvas”. maybe need to do that from within javascript styling itself for canvas?: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { margin: 0; padding: 0; background-color:midnightblue; color:white; } h1{ background: radial-gradient(circle at top center, #929, #519); color: brightblue; border-radius: 2px; padding: 2px; font-size: var(--font-size, 22px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px darkmagenta; text-stroke: 1px darkmagenta; } .container { display: flex; flex-direction: column; justify-content: left; align-items: left; height: 70vh; flex-wrap: wrap; } .control-container { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; margin: 0; } .input-field-container { position: absolute; display: flex; width: 100%; align-items: center; justify-content: center; } .input-field { display:flex; width: 100%; height: 32px; box-sizing: border-box; background-color:#010130; color:#aa50ff; border:1px solid darkmagenta; border-radius:6px; padding:5px; align-items: center; justify-content: center; font-size: var(--font-size, 16px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); } .gen-button-container { position: relative; } .gen-button { margin: 0; background: radial-gradient(circle at top center, #929, #519); color: white; border-radius: 6px; padding: 2px; font-size: var(--font-size, 16px); --font-family: var(--font-family, monospace); --font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); text-shadow: 0px 0px 0.1px rgba(255, 255, 255, 1); } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; background-color:#010130; margin-top: auto; margin-bottom: auto; border: darkmagenta dashed 2px; } .progress-bar { width: 100%; height: 2px; position:absolute; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; background-color: black; margin-top:80px; } .progress-bar-filled { width: 0%; height: 10px; background-color: green; } .independent-container { width: 100%; position:relative; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; align-items: center; margin-top: 50px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px; } </style> </head> <body> <div class='container'> <div class='control-container'> <div class='input-field-container'> <h1 class='title' style='margin-left: 10px;margin-right: 10px;margin-top: 10px;'>T2I AI UI</h1> <input id='inputText' type='text' value='armoured girl riding an armored cock' class='input-field' style='flex: 1;margin-top: -6px;'> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button' style='border-style:none;height: 32px;margin-left: 10px;margin-right: 10px;margin-top: -6px;'>Gen Img</button> </div> </div> </div> <div class='independent-container'> <label for='autoQueueCheckbox' style='margin-left: 10px;margin-right: 5px;'>Auto Queue:</label> <input type='checkbox' id='autoQueueCheckbox'> <label for='numAttemptsInput' style='margin-left: 10px;margin-right: 5px;'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1' max='9' style='width: 64px;height: 16px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px;'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> <canvas id='imageCanvas' class='image-canvas'></canvas></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'darkmagenta'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.height = '2px'; progressBarFilled.style.backgroundColor = 'green'; } </script> </body> </html>
7de727f38b7ed877bba02e0b65f634e7
{ "intermediate": 0.3534749448299408, "beginner": 0.38265228271484375, "expert": 0.26387280225753784 }
18,986
is there any way to extend spaces in “dashed” border inbetween colored lines? try implement this method for border to “.image-canvas”. maybe need to do that from within javascript styling itself for canvas?: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { margin: 0; padding: 0; background-color:midnightblue; color:white; } h1{ background: radial-gradient(circle at top center, #929, #519); color: brightblue; border-radius: 2px; padding: 2px; font-size: var(--font-size, 22px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px darkmagenta; text-stroke: 1px darkmagenta; } .container { display: flex; flex-direction: column; justify-content: left; align-items: left; height: 70vh; flex-wrap: wrap; } .control-container { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; margin: 0; } .input-field-container { position: absolute; display: flex; width: 100%; align-items: center; justify-content: center; } .input-field { display:flex; width: 100%; height: 32px; box-sizing: border-box; background-color:#010130; color:#aa50ff; border:1px solid darkmagenta; border-radius:6px; padding:5px; align-items: center; justify-content: center; font-size: var(--font-size, 16px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); } .gen-button-container { position: relative; } .gen-button { margin: 0; background: radial-gradient(circle at top center, #929, #519); color: white; border-radius: 6px; padding: 2px; font-size: var(--font-size, 16px); --font-family: var(--font-family, monospace); --font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); text-shadow: 0px 0px 0.1px rgba(255, 255, 255, 1); } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; background-color:#010130; margin-top: auto; margin-bottom: auto; border: darkmagenta dashed 2px; } .progress-bar { width: 100%; height: 2px; position:absolute; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; background-color: black; margin-top:80px; } .progress-bar-filled { width: 0%; height: 10px; background-color: green; } .independent-container { width: 100%; position:relative; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; align-items: center; margin-top: 50px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px; } </style> </head> <body> <div class='container'> <div class='control-container'> <div class='input-field-container'> <h1 class='title' style='margin-left: 10px;margin-right: 10px;margin-top: 10px;'>T2I AI UI</h1> <input id='inputText' type='text' value='armoured girl riding an armored cock' class='input-field' style='flex: 1;margin-top: -6px;'> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button' style='border-style:none;height: 32px;margin-left: 10px;margin-right: 10px;margin-top: -6px;'>Gen Img</button> </div> </div> </div> <div class='independent-container'> <label for='autoQueueCheckbox' style='margin-left: 10px;margin-right: 5px;'>Auto Queue:</label> <input type='checkbox' id='autoQueueCheckbox'> <label for='numAttemptsInput' style='margin-left: 10px;margin-right: 5px;'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1' max='9' style='width: 64px;height: 16px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px;'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> <canvas id='imageCanvas' class='image-canvas'></canvas></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'darkmagenta'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.height = '2px'; progressBarFilled.style.backgroundColor = 'green'; } </script> </body> </html>
4780f2f0a5a4318abf263f04bb4953bb
{ "intermediate": 0.3534749448299408, "beginner": 0.38265228271484375, "expert": 0.26387280225753784 }
18,987
Write python function remove text word more than 300 word
14728cd7153fdb057995c346852fbd89
{ "intermediate": 0.31904271245002747, "beginner": 0.3363088369369507, "expert": 0.34464845061302185 }
18,988
is there any way to extend spaces in “dashed” border inbetween punctuation lines? try implement this method for border to “.image-canvas”. maybe need to do that from within javascript styling itself for canvas? no, inbetween dashes themselves. then you would need to do a criss-cross equal grid linear gradient from to right and to top, to achieve this intricate dashed border in gradient. also, you would need to make a pseudo dummy background on place of that canvas with a solid background and a bit lower overall dimension, for border to be visible behind it, and also for canvas to be able to output an image from AI generator. try output full implemented correctly code, without javascript.: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { margin: 0; padding: 0; background-color:midnightblue; color:white; } h1{ background: radial-gradient(circle at top center, #929, #519); color: brightblue; border-radius: 2px; padding: 2px; font-size: var(--font-size, 22px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px darkmagenta; text-stroke: 1px darkmagenta; } .container { display: flex; flex-direction: column; justify-content: left; align-items: left; height: 70vh; flex-wrap: wrap; } .control-container { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; margin: 0; } .input-field-container { position: absolute; display: flex; width: 100%; align-items: center; justify-content: center; } .input-field { display:flex; width: 100%; height: 32px; box-sizing: border-box; background-color:#010130; color:#aa50ff; border:1px solid darkmagenta; border-radius:6px; padding:5px; align-items: center; justify-content: center; font-size: var(--font-size, 16px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); } .gen-button-container { position: relative; } .gen-button { margin: 0; background: radial-gradient(circle at top center, #929, #519); color: white; border-radius: 6px; padding: 2px; font-size: var(--font-size, 16px); --font-family: var(--font-family, monospace); --font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); text-shadow: 0px 0px 0.1px rgba(255, 255, 255, 1); } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; background-color:#010130; margin-top: auto; margin-bottom: auto; border-style: dashed; border-width: 2px; border-color: darkmagenta; border-spacing: 50px; } .progress-bar { width: 100%; height: 2px; position:absolute; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; background-color: black; margin-top:80px; } .progress-bar-filled { width: 0%; height: 10px; background-color: green; } .independent-container { width: 100%; position:relative; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; align-items: center; margin-top: 50px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px; } </style> </head> <body> <div class='container'> <div class='control-container'> <div class='input-field-container'> <h1 class='title' style='margin-left: 10px;margin-right: 10px;margin-top: 10px;'>T2I AI UI</h1> <input id='inputText' type='text' value='armoured girl riding an armored cock' class='input-field' style='flex: 1;margin-top: -6px;'> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button' style='border-style:none;height: 32px;margin-left: 10px;margin-right: 10px;margin-top: -6px;'>Gen Img</button> </div> </div> </div> <div class='independent-container'> <label for='autoQueueCheckbox' style='margin-left: 10px;margin-right: 5px;'>Auto Queue:</label> <input type='checkbox' id='autoQueueCheckbox'> <label for='numAttemptsInput' style='margin-left: 10px;margin-right: 5px;'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1' max='9' style='width: 64px;height: 16px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px;'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> <canvas id='imageCanvas' class='image-canvas'></canvas></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'darkmagenta'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.height = '2px'; progressBarFilled.style.backgroundColor = 'green'; } </script> </body> </html>
d15487939f49f9c09d3af7ec5ef85e2d
{ "intermediate": 0.42272821068763733, "beginner": 0.3047899007797241, "expert": 0.2724818289279938 }
18,989
How can I write the code below so that it only runs if N53 = "Reschedule Service": =IF($A53<>"",IF(DAY($A53) <= DAY(DATE(YEAR($A53), MONTH(A$56) + 1, 1) - 15), "Date is closer to Previous Month", "Date is closer to Next Month"),"")
a1510fe87e6d4c466c33b3742911dc06
{ "intermediate": 0.3290981948375702, "beginner": 0.4797001779079437, "expert": 0.1912015825510025 }
18,990
need that ".input-field" to be centered vertically among h1 and button: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { margin: 0; padding: 0; background-color:midnightblue; color:white; } h1{ background: radial-gradient(circle at top center, #929, #519); color: brightblue; border-radius: 2px; padding: 2px; font-size: var(–font-size, 22px); font-family: var(–font-family, monospace); font-weight: var(–font-weight, bold); -webkit-text-stroke: 1px darkmagenta; text-stroke: 1px darkmagenta; } .container { display: flex; flex-direction: column; justify-content: left; align-items: left; height: 70vh; flex-wrap: wrap; } .control-container { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; margin: 0; } .input-field-container { position: absolute; display: flex; width: 100%; align-items: center; justify-content: center; } .input-field { display:flex; width: 100%; height: 40px; box-sizing: border-box; background-color:#010130; color:#aa50ff; border:1px solid darkmagenta; border-radius:6px; padding:5px; align-items: center; justify-content: center; font-size: var(--font-size, 16px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); } .gen-button-container { position: relative; } .gen-button { margin: 0; background: radial-gradient(circle at top center, #929, #519); color: white; border-radius: 6px; padding: 2px; font-size: var(–font-size, 16px); --font-family: var(–font-family, monospace); --font-weight: var(–font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); text-shadow: 0px 0px 0.1px rgba(255, 255, 255, 1); } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; background: linear-gradient(to right, darkmagenta 1px, transparent 1px) 0 0, linear-gradient(to right, darkmagenta 1px, transparent 1px) 0 100%, linear-gradient(to top, darkmagenta 1px, transparent 1px) 0 0, linear-gradient(to top, darkmagenta 1px, transparent 1px) 100% 0; background-size: 25% 100%, 25% 200px, 100% 25%, 100% 25%; background-repeat: repeat-x, repeat-x, repeat-y, repeat-y; background-position: top left, bottom left, top left, top right; background-color: #010130; margin-top: auto; margin-bottom: auto; border-style: double dashed; border-width: 2px; border-color: darkmagenta; border-spacing: 100px;margin-top: 0px; } .image-canvas:before { content: ''; position: absolute; top: 2px; left: 2px; width: calc(100% - 4px); height: calc(100% - 4px); background-color: #010130; z-index: -1; } .progress-bar { width: 100%; height: 2px; position:absolute; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; background-color: black; margin-top:100px; } .progress-bar-filled { width: 0%; height: 10px; background-color: green; } .independent-container { width: 100%; position:relative; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; align-items: center; margin-top: 60px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px; } </style> </head> <body> <div class='container'> <div class='control-container'> <div class='input-field-container'> <h1 class='title' style='margin-left: 10px;margin-right: 10px;margin-top: 10px;'>T2I AI UI</h1> <input id='inputText' type='text' value='armoured girl riding an armored cock' class='input-field' style='flex: 1;margin-top: -6px;'> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button' style='border-style:none;height: 32px;margin-left: 10px;margin-right: 10px;margin-top: -6px;'>Gen Img</button> </div> </div> </div> <div class='independent-container'> <label for='autoQueueCheckbox' style='margin-left: 10px;margin-right: 5px;'>Auto Queue:</label> <input type='checkbox' id='autoQueueCheckbox'> <label for='numAttemptsInput' style='margin-left: 10px;margin-right: 5px;'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1' max='9' style='width: 64px;height: 16px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px;'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> <canvas id='imageCanvas' class='image-canvas'></canvas></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'darkmagenta'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.height = '2px'; progressBarFilled.style.backgroundColor = 'green'; } </script> </body> </html>
78201d0c8959e9eef0b848177e5cadaf
{ "intermediate": 0.30605003237724304, "beginner": 0.3894081115722656, "expert": 0.3045419156551361 }
18,991
analyze and find wtf is or may be wrong with this code: <!DOCTYPE html> <html> <head> <title>Text2Image AI</title> <style> html, body { margin: 0; padding: 0; background-color:midnightblue; color:white; } h1{ background: radial-gradient(circle at top center, #929, #519); color: brightblue; border-radius: 2px; padding: 2px; font-size: var(–font-size, 22px); font-family: var(–font-family, monospace); font-weight: var(–font-weight, bold); -webkit-text-stroke: 1px darkmagenta; text-stroke: 1px darkmagenta; } .container { display: flex; flex-direction: column; justify-content: left; align-items: left; height: 70vh; flex-wrap: wrap; } .control-container { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; margin: 0; } .input-field-container { position: absolute; display: flex; width: 100%; align-items: center; justify-content: center; } .input-field { display:flex; width: 100%; height: 40px; box-sizing: border-box; background-color:#010130; color:#aa50ff; border:1px solid darkmagenta; border-radius:6px; padding:5px; align-items: center; justify-content: center; font-size: var(--font-size, 16px); font-family: var(--font-family, monospace); font-weight: var(--font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); } .gen-button-container { position: relative; } .gen-button { margin: 0; background: radial-gradient(circle at top center, #929, #519); color: white; border-radius: 6px; padding: 2px; font-size: var(–font-size, 16px); --font-family: var(–font-family, monospace); --font-weight: var(–font-weight, bold); -webkit-text-stroke: 1px rgba(139, 0, 139, 0.5); text-stroke: 1px rgba(139, 0, 139, 1); text-shadow: 0px 0px 0.1px rgba(255, 255, 255, 1); } .image-canvas { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; background: linear-gradient(to right, darkmagenta 1px, transparent 1px) 0 0, linear-gradient(to right, darkmagenta 1px, transparent 1px) 0 100%, linear-gradient(to top, darkmagenta 1px, transparent 1px) 0 0, linear-gradient(to top, darkmagenta 1px, transparent 1px) 100% 0; background-size: 25% 100%, 25% 200px, 100% 25%, 100% 25%; background-repeat: repeat-x, repeat-x, repeat-y, repeat-y; background-position: top left, bottom left, top left, top right; background-color: #010130; margin-top: auto; margin-bottom: auto; border-style: double dashed; border-width: 2px; border-color: darkmagenta; border-spacing: 100px;margin-top: 0px; } .image-canvas:before { content: ''; position: absolute; top: 2px; left: 2px; width: calc(100% - 4px); height: calc(100% - 4px); background-color: #010130; z-index: -1; } .progress-bar { width: 100%; height: 2px; position:absolute; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; background-color: black; margin-top:100px; } .progress-bar-filled { width: 0%; height: 10px; background-color: green; } .independent-container { width: 100%; position:relative; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; align-items: center; margin-top: 60px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px; } </style> </head> <body> <div class='container'> <div class='control-container'> <div class='input-field-container'> <h1 class='title' style='margin-left: 10px;margin-right: 10px;margin-top: 10px;'>T2I AI UI</h1> <input id='inputText' type='text' value='armoured girl riding an armored cock' class='input-field' style='flex: 1;margin-top: -6px;'> <div class='gen-button-container'> <button onclick='generateImage()' class='gen-button' style='border-style:none;height: 32px;margin-left: 10px;margin-right: 10px;margin-top: -6px;'>Gen Img</button> </div> </div> </div> <div class='independent-container'> <label for='autoQueueCheckbox' style='margin-left: 10px;margin-right: 5px;'>Auto Queue:</label> <input type='checkbox' id='autoQueueCheckbox'> <label for='numAttemptsInput' style='margin-left: 10px;margin-right: 5px;'>Retry Attempts:</label> <input type='number' id='numAttemptsInput' value='5' min='1' max='9' style='width: 64px;height: 16px; background-color:#010130; color:#aabbee; border:1px solid darkmagenta; border-radius:6px;'> </div> <div class='progress-bar'> <div class='progress-bar-filled'></div> <canvas id='imageCanvas' class='image-canvas'></canvas></div> </div> <script> const modelUrl = 'https://api-inference.huggingface.co/models/hogiahien/counterfeit-v30-edited'; const modelToken = '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'; const progressBarFilled = document.querySelector('.progress-bar-filled'); const imageCanvas = document.getElementById('imageCanvas'); const ctx = imageCanvas.getContext('2d'); let estimatedTime = 0; async function query(data) { const response = await fetch(modelUrl, { headers: { Authorization: "Bearer " + modelToken }, method: 'POST', body: JSON.stringify(data) }); const headers = response.headers; const estimatedTimeString = headers.get('estimated_time'); estimatedTime = parseFloat(estimatedTimeString) * 1000; const result = await response.blob(); return result; } async function generateImage() { const inputText = document.getElementById('inputText').value; const numAttempts = parseInt(document.getElementById('numAttemptsInput').value); progressBarFilled.style.width = '0%'; progressBarFilled.style.backgroundColor = 'green'; await new Promise(resolve => setTimeout(resolve, 1000)); let retryAttempts = 0; const maxRetryAttempts = numAttempts; let autoQueueActive = false; while (retryAttempts < maxRetryAttempts) { try { const startTime = Date.now(); const timeLeft = Math.floor(estimatedTime / 1000); const interval = setInterval(() => { const elapsedTime = Math.floor((Date.now() - startTime) / 1000); const progress = Math.floor((elapsedTime / timeLeft) * 100); progressBarFilled.style.width = progress + '%'; }, 1000); const cacheBuster = new Date().getTime(); const response = await query({ inputs: inputText, cacheBuster }); const url = URL.createObjectURL(response); const img = new Image(); img.onload = function() { const aspectRatio = img.width / img.height; const canvasWidth = imageCanvas.offsetWidth; const canvasHeight = Math.floor(canvasWidth / aspectRatio); imageCanvas.width = canvasWidth; imageCanvas.height = canvasHeight; ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; img.src = url; clearInterval(interval); progressBarFilled.style.width = '100%'; progressBarFilled.style.backgroundColor = 'darkmagenta'; break; } catch (error) { console.error(error); retryAttempts++; } if (autoQueueActive) { const timeout = estimatedTime + 2000; await new Promise(resolve => setTimeout(resolve, timeout)); } autoQueueActive = document.getElementById('autoQueueCheckbox').checked; } progressBarFilled.style.width = '100%'; progressBarFilled.style.height = '2px'; progressBarFilled.style.backgroundColor = 'green'; } </script> </body> </html>
0bdd8db3b8e37e24bf128d10add1d213
{ "intermediate": 0.3470740020275116, "beginner": 0.3877478539943695, "expert": 0.26517823338508606 }
18,992
Use java to write me a pixel painting program, length and width of 500 by 500, the style is impressionistic, symmetrical pattern
d8393c4e673fe0d7e6a9a2c6cd909e04
{ "intermediate": 0.4485262334346771, "beginner": 0.2927422523498535, "expert": 0.258731484413147 }