row_id
int64
0
48.4k
init_message
stringlengths
1
342k
conversation_hash
stringlengths
32
32
scores
dict
44,577
can you parse a web page ?
9f3788f8e992b31d9a502628ba0844cb
{ "intermediate": 0.45256179571151733, "beginner": 0.2578517496585846, "expert": 0.28958645462989807 }
44,578
module EvalIdExpr ( evalIdExpr, testEvalIdExpr ) where import Test.QuickCheck import Data.List (lookup) an IdExpr is an expression-tree over integers and string identifiers data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) Assoc is a list of pairs mapping identifier strings to their values v. type Assoc v = [ (String, v) ] evalIdExpr returns evaluation of the IdExpr expression-tree given by its first argument, looking up the values of id's in the Assoc argument. If an id is not found in the Assoc argument, then its value should default to 0. Hint: use Data.List.lookup imported above. evalIdExpr :: IdExpr -> Assoc Int -> Int evalIdExpr _ = error "TODO" testEvalIdExpr = do print "*** test evalIdExpr" -- unit tests quickCheck $ counterexample "Leaf" $ evalIdExpr (Leaf 42) [] == 42 quickCheck $ counterexample "Add" $ evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 quickCheck $ counterexample "Sub" $ evalIdExpr (Sub (Leaf 33) (Leaf 22)) [] == 11 quickCheck $ counterexample "Mul" $ evalIdExpr (Mul (Leaf 31) (Leaf 4)) [] == 124 quickCheck $ counterexample "Uminus" $ evalIdExpr (Uminus (Leaf 33)) [] == (-33) quickCheck $ counterexample "Complex" $ evalIdExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) [] == (-200) -- id unit tests quickCheck $ counterexample "ok id lookup" $ evalIdExpr (Id "a") [("a", 42)] == 42 quickCheck $ counterexample "fail id lookup" $ evalIdExpr (Id "a") [("b", 42)] == 0 quickCheck $ counterexample "id lookup: a: ok, b: fail" $ evalIdExpr (Add (Id "a") (Id "b")) [("a", 42)] == 42 quickCheck $ counterexample "id lookup: a: ok, b: ok" $ evalIdExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == 64 quickCheck $ counterexample "complex id lookup" $ evalIdExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c"))) (Id "d"))) [("a", 4), ("b", 3), ("c", 33), ("d", 20)] == (-200) -- property-based tests -- id lookup quickCheck $ counterexample "random id lookup ok" $ (\ id1 val1 -> evalIdExpr (Id id1) [(id1, val1)] == val1) quickCheck $ counterexample "random id lookup fail" $ (\ id1 val1 -> evalIdExpr (Id id1) [(id1 ++ "x", val1)] == 0) -- property-based tests -- commutativity quickCheck $ counterexample "e1 + e2 == e2 + e1" $ (\ e1 e2 -> evalIdExpr (Add (Leaf e1) (Leaf e2)) [] == evalIdExpr (Add (Leaf e2) (Leaf e1)) []) quickCheck $ counterexample "e1 * e2 == e2 * e1" $ (\ e1 e2 -> evalIdExpr (Mul (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf e2) (Leaf e1)) []) -- associativity quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ (\ e1 e2 e3 -> evalIdExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3))) []) quickCheck $ counterexample "(e1 * e2) * e3 == e1 * (e2 * e3)" $ (\ e1 e2 e3 -> evalIdExpr (Mul (Mul (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Mul (Leaf e1) (Mul (Leaf e2) (Leaf e3))) []) -- subtraction quickCheck $ counterexample "e1 - e2 = -1*(e2 - e1)" $ (\ e1 e2 -> evalIdExpr (Sub (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf (-1)) (Sub (Leaf e2) (Leaf e1))) []) -- distributivity quickCheck $ counterexample "e1 * (e2 + e3) == e1*e2 + e1*e3" $ (\ e1 e2 e3 -> evalIdExpr (Mul (Leaf e1) (Add (Leaf e2) (Leaf e3))) [] == evalIdExpr (Add (Mul (Leaf e1) (Leaf e2)) (Mul (Leaf e1) (Leaf e3))) []) quickCheck $ counterexample "e1 * (e2 - e3) == e1*e2 - e1*e3" $ (\ e1 e2 e3 -> evalIdExpr (Mul (Leaf e1) (Sub (Leaf e2) (Leaf e3))) [] == evalIdExpr (Sub (Mul (Leaf e1) (Leaf e2)) (Mul (Leaf e1) (Leaf e3))) [])
7b66a9b85cef3e866ed1c341c40e064c
{ "intermediate": 0.3209313750267029, "beginner": 0.5037684440612793, "expert": 0.17530016601085663 }
44,579
module EvalIdExpr ( evalIdExpr, testEvalIdExpr ) where import Test.QuickCheck import Data.List (lookup) an IdExpr is an expression-tree over integers and string identifiers data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) Assoc is a list of pairs mapping identifier strings to their values v. type Assoc v = [ (String, v) ] evalIdExpr returns evaluation of the IdExpr expression-tree given by its first argument, looking up the values of id's in the Assoc argument. If an id is not found in the Assoc argument, then its value should default to 0. Hint: use Data.List.lookup imported above. evalIdExpr :: IdExpr -> Assoc Int -> Int evalIdExpr _ = error "TODO" testEvalIdExpr = do print "*** test evalIdExpr" -- unit tests quickCheck $ counterexample "Leaf" $ evalIdExpr (Leaf 42) [] == 42 quickCheck $ counterexample "Add" $ evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55
15daa0fa41b797dcb8a8bb9ed8c379e5
{ "intermediate": 0.47103166580200195, "beginner": 0.27908986806869507, "expert": 0.2498784214258194 }
44,580
module EvalIdExpr ( evalIdExpr, testEvalIdExpr ) where import Test.QuickCheck import Data.List (lookup) an IdExpr is an expression-tree over integers and string identifiers data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) Assoc is a list of pairs mapping identifier strings to their values v. type Assoc v = [ (String, v) ] evalIdExpr returns evaluation of the IdExpr expression-tree given by its first argument, looking up the values of id's in the Assoc argument. If an id is not found in the Assoc argument, then its value should default to 0. Hint: use Data.List.lookup imported above. evalIdExpr :: IdExpr -> Assoc Int -> Int evalIdExpr _ = error "TODO" testEvalIdExpr = do print "*** test evalIdExpr" -- unit tests quickCheck $ counterexample "Leaf" $ evalIdExpr (Leaf 42) [] == 42 quickCheck $ counterexample "Add" $ evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 quickCheck $ counterexample "Sub" $
e743c83f2e66e157b9df144566c90b1c
{ "intermediate": 0.4328415095806122, "beginner": 0.31482747197151184, "expert": 0.252331018447876 }
44,581
module EvalIdExpr ( evalIdExpr, testEvalIdExpr ) where import Test.QuickCheck import Data.List (lookup) an IdExpr is an expression-tree over integers and string identifiers data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) Assoc is a list of pairs mapping identifier strings to their values v. type Assoc v = [ (String, v) ] evalIdExpr returns evaluation of the IdExpr expression-tree given by its first argument, looking up the values of id's in the Assoc argument. If an id is not found in the Assoc argument, then its value should default to 0. Hint: use Data.List.lookup imported above. evalIdExpr :: IdExpr -> Assoc Int -> Int evalIdExpr _ = error "TODO" testEvalIdExpr = do print "*** test evalIdExpr" -- unit tests quickCheck $ counterexample "Leaf" $ evalIdExpr (Leaf 42) [] == 42 quickCheck $ counterexample "Add" $ evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 quickCheck $ counterexample "Sub" $ evalIdExpr (Sub (Leaf 33) (Leaf 22)) [] == 11 quickCheck $ counterexample "Mul" $ evalIdExpr (Mul (Leaf 31) (Leaf 4)) [] == 124 quickCheck $ counterexample "Uminus" $ evalIdExpr (Uminus (Leaf 33)) [] == (-33) quickCheck $ counterexample "Complex" $ evalIdExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) [] == (-200) -- id unit tests quickCheck $ counterexample "ok id lookup" $ evalIdExpr (Id "a") [("a", 42)] == 42 quickCheck $ counterexample "fail id lookup" $ evalIdExpr (Id "a") [("b", 42)] == 0 quickCheck $ counterexample "id lookup: a: ok, b: fail" $ evalIdExpr (Add (Id "a") (Id "b")) [("a", 42)] == 42 quickCheck $ counterexample "id lookup: a: ok, b: ok" $ evalIdExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == 64 quickCheck $ counterexample "complex id lookup" $ evalIdExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c"))) (Id "d"))) [("a", 4), ("b", 3), ("c", 33), ("d", 20)] == (-200) -- property-based tests -- id lookup quickCheck $ counterexample "random id lookup ok" $ (\ id1 val1 -> evalIdExpr (Id id1) [(id1, val1)] == val1) quickCheck $ counterexample "random id lookup fail" $ (\ id1 val1 -> evalIdExpr (Id id1) [(id1 ++ "x", val1)] == 0) -- property-based tests -- commutativity quickCheck $ counterexample "e1 + e2 == e2 + e1" $ (\ e1 e2 -> evalIdExpr (Add (Leaf e1) (Leaf e2)) [] == evalIdExpr (Add (Leaf e2) (Leaf e1)) []) quickCheck $ counterexample "e1 * e2 == e2 * e1" $ (\ e1 e2 -> evalIdExpr (Mul (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf e2) (Leaf e1)) []) -- associativity quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ (\ e1 e2 e3 -> evalIdExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3))) []) quickCheck $ counterexample "(e1 * e2) * e3 == e1 * (e2 * e3)" $ (\ e1 e2 e3 -> evalIdExpr (Mul (Mul (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Mul (Leaf e1) (Mul (Leaf e2) (Leaf e3))) []) -- subtraction quickCheck $ counterexample "e1 - e2 = -1*(e2 - e1)" $ (\ e1 e2 -> evalIdExpr (Sub (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf (-1)) (Sub (Leaf e2) (Leaf e1))) []) -- distributivity quickCheck $ counterexample "e1 * (e2 + e3) == e1*e2 + e1*e3" $ (\ e1 e2 e3 -> evalIdExpr (Mul (Leaf e1) (Add (Leaf e2) (Leaf e3))) [] == evalIdExpr (Add (Mul (Leaf e1) (Leaf e2)) (Mul (Leaf e1) (Leaf e3))) []) quickCheck $ counterexample "e1 * (e2 - e3) == e1*e2 - e1*e3" $ (\ e1 e2 e3 -> evalIdExpr (Mul (Leaf e1) (Sub (Leaf e2) (Leaf e3))) [] == evalIdExpr (Sub (Mul (Leaf e1) (Leaf e2)) (Mul (Leaf e1) (Leaf e3))) [])
759d3ca0b67e44493a9311e8dffc6db2
{ "intermediate": 0.3209313750267029, "beginner": 0.5037684440612793, "expert": 0.17530016601085663 }
44,582
import Test.QuickCheck import Data.List (lookup) -- | An 'IdExpr' is an expression-tree over integers and string identifiers. data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) -- | 'Assoc' is a list of pairs mapping identifier strings to their values v. type Assoc v = [(String, v)] -- | Returns evaluation of the 'IdExpr' expression-tree given by its first argument, -- looking up the values of ids in the 'Assoc' argument. If an id is not found -- in the 'Assoc' argument, then its value should default to 0. -- -- > evalIdExpr (Leaf 42) [] == 42 -- > evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 -- > evalIdExpr (Sub (Leaf 33) (Leaf 22)) [] == 11 -- > evalIdExpr (Mul (Leaf 31) (Leaf 4)) [] == 124 -- > evalIdExpr (Uminus (Leaf 33)) [] == (-33) -- > evalIdExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) [] == (-200) -- -- > evalIdExpr (Id "a") [("a", 42)] == 42 -- > evalIdExpr (Id "a") [("b", 42)] == 0 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42)] == 42 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == 64 -- > evalIdExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c"))) (Id "d"))) [("a", 4), ("b", 3), ("c", 33), ("d", 20)] == (-200) -- -- > quickCheck $ counterexample "random id lookup ok" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1, val1)] == val1 -- > quickCheck $ counterexample "random id lookup fail" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1 ++ "x", val1)] == 0 -- -- > quickCheck $ counterexample "e1 + e2 == e2 + e1" $ \ e1 e2 -> evalIdExpr (Add (Leaf e1) (Leaf e2)) [] == evalIdExpr (Add (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "e1 * e2 == e2 * e1" $ \ e1 e2 -> evalIdExpr (Mul (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ \ e1 e2 e3 -> evalIdExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3)))
78eb19bd9dd4addcf996e3cbace1ddfc
{ "intermediate": 0.3506323993206024, "beginner": 0.501710057258606, "expert": 0.14765754342079163 }
44,583
import Test.QuickCheck import Data.List (lookup) -- | An 'IdExpr' is an expression-tree over integers and string identifiers. data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) -- | 'Assoc' is a list of pairs mapping identifier strings to their values v. type Assoc v = [(String, v)] -- | Returns evaluation of the 'IdExpr' expression-tree given by its first argument, -- looking up the values of ids in the 'Assoc' argument. If an id is not found -- in the 'Assoc' argument, then its value should default to 0. -- -- > evalIdExpr (Leaf 42) [] == 42 -- > evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 -- > evalIdExpr (Sub (Leaf 33) (Leaf 22)) [] == 11 -- > evalIdExpr (Mul (Leaf 31) (Leaf 4)) [] == 124 -- > evalIdExpr (Uminus (Leaf 33)) [] == (-33) -- > evalIdExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) [] == (-200) -- -- > evalIdExpr (Id "a") [("a", 42)] == 42 -- > evalIdExpr (Id "a") [("b", 42)] == 0 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42)] == 42 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == 64 -- > evalIdExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c"))) (Id "d"))) [("a", 4), ("b", 3), ("c", 33), ("d", 20)] == (-200) -- -- > quickCheck $ counterexample "random id lookup ok" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1, val1)] == val1 -- > quickCheck $ counterexample "random id lookup fail" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1 ++ "x", val1)] == 0 -- -- > quickCheck $ counterexample "e1 + e2 == e2 + e1" $ \ e1 e2 -> evalIdExpr (Add (Leaf e1) (Leaf e2)) [] == evalIdExpr (Add (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "e1 * e2 == e2 * e1" $ \ e1 e2 -> evalIdExpr (Mul (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ \ e1 e2 e3 -> evalIdExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3)))
c5c7be7b9cae7c0bf15c943a0bd4fd84
{ "intermediate": 0.3506323993206024, "beginner": 0.501710057258606, "expert": 0.14765754342079163 }
44,584
import Test.QuickCheck import Data.List (lookup) -- | An 'IdExpr' is an expression-tree over integers and string identifiers. data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) -- | 'Assoc' is a list of pairs mapping identifier strings to their values v. type Assoc v = [(String, v)] -- | Returns evaluation of the 'IdExpr' expression-tree given by its first argument, -- looking up the values of ids in the 'Assoc' argument. If an id is not found -- in the 'Assoc' argument, then its value should default to 0. -- -- > evalIdExpr (Leaf 42) [] == 42 -- > evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 -- > evalIdExpr (Sub (Leaf 33) (Leaf 22)) [] == 11 -- > evalIdExpr (Mul (Leaf 31) (Leaf 4)) [] == 124 -- > evalIdExpr (Uminus (Leaf 33)) [] == (-33) -- > evalIdExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) [] == (-200) -- -- > evalIdExpr (Id "a") [("a", 42)] == 42 -- > evalIdExpr (Id "a") [("b", 42)] == 0 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42)] == 42 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == 64 -- > evalIdExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c"))) (Id "d"))) [("a", 4), ("b", 3), ("c", 33), ("d", 20)] == (-200) -- -- > quickCheck $ counterexample "random id lookup ok" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1, val1)] == val1 -- > quickCheck $ counterexample "random id lookup fail" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1 ++ "x", val1)] == 0 -- -- > quickCheck $ counterexample "e1 + e2 == e2 + e1" $ \ e1 e2 -> evalIdExpr (Add (Leaf e1) (Leaf e2)) [] == evalIdExpr (Add (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "e1 * e2 == e2 * e1" $ \ e1 e2 -> evalIdExpr (Mul (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ \ e1 e2 e3 -> evalIdExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3)))
b959702016253a780c600efcfbed3926
{ "intermediate": 0.3506323993206024, "beginner": 0.501710057258606, "expert": 0.14765754342079163 }
44,585
What is cloud computing?
bca529c070aa3b644577f9a288d1c70a
{ "intermediate": 0.26794907450675964, "beginner": 0.17525096237659454, "expert": 0.5568000674247742 }
44,586
In servicenow We have a requirement where we have a record on "Request" table and when a "Request" got created from a record producer it will creates a "Request" record and the record will be in "Pending" state once it gets created. So we have approve and reject buttons on the record level. Whenever user click on "Reject" button to reject the request then we are expecting a dialog box should be pop up on the record and ask the user to "Enter the reason for rejecting the request" If user gives any reason as comments on that dialog box then the "Request" record should get rejected and that comments should be updated in another record which is "Item" Record and it should go to "Closed Incomplete" state.
68133e907d95d487c57fd8f3742d7934
{ "intermediate": 0.4126865863800049, "beginner": 0.2737477719783783, "expert": 0.31356558203697205 }
44,587
Key: Number. Planetary type/Radius km/Distance AU from star Star: 1 Solar mass, 1 Solar radius, 5778 Kelvin System 1: 1. Rocky/2373 km/0.05 AU 2. Rocky/3311 km/0.11 AU 3. Rocky/6901 km/0.58 AU 4. Rocky/1203 km/0.67 AU 5. Rocky/7903 km/0.79 AU 6. Land-sea/6258 km/0.99 AU 7. Desert/5672 km/1.32 AU 8. Ice/6970 km/3.02 AU 9. Jovian/57893 km/6.22 AU 10. Jovian/84390 km/9.46 AU 11. Jovian/32585 km/14.1 AU 12. Jovian/57004 km/25.77 AU 13. Jovian/74103 km/38.41 AU System 2: 1. Rocky/5421 km/0.33 AU 2. Rocky/5089 km/0.58 AU 3. Venusian/6225 km/0.63 AU 4. Venusian/4268 km/0.72 AU 5. Land-sea/6349 km/1.08 AU 6. Land-sea/6799 km/1.25 AU 7. Rocky/1064 km/1.75 AU 8. Rocky/860 km/3.21 AU 9. Jovian/71405 km/6 AU 10. Jovian/60138 km/10.5 AU 11. Ice/9817 km/12.37 AU 12. Jovian/23670 km/19.95 AU 13. Jovian/84250 km/37.3 AU 14. Jovian/47891 km/48.47 AU System 3: 1. Rocky/1196 km/0.16 AU 2. Rocky/3268 km/0.3 AU 3. Venusian/5678 km/0.63 AU 4. Land-sea/6369 km/0.84 AU 5. Desert/4679 km/1.31 AU 6. Asteroid belt/1.95 AU 7. Rocky/5107 km/2.85 AU 8. Land-ammonia sea/6025 km/4.72 AU 9. Jovian/65690 km/7.17 AU 10. Jovian/71004 km/14.22 AU 11. Jovian/42581 km/27.01 AU 12. Jovian/17808 km/37.27 AU 13. Ice/8520 km/45.88 AU
f17d8e53765b09d98dd80ebdc0e41b99
{ "intermediate": 0.3454858958721161, "beginner": 0.2826393246650696, "expert": 0.37187477946281433 }
44,588
write linux command for seeing open port
a8c0df5a7b35472c005fe526a612116a
{ "intermediate": 0.3630819618701935, "beginner": 0.2896921634674072, "expert": 0.3472258448600769 }
44,589
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
9e798dc048229d9660e7fe35d9852503
{ "intermediate": 0.42011991143226624, "beginner": 0.21956782042980194, "expert": 0.36031225323677063 }
44,590
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
a4eaf7092ff48735f2c6ef5e32865e67
{ "intermediate": 0.42011991143226624, "beginner": 0.21956782042980194, "expert": 0.36031225323677063 }
44,591
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
0f7e67e4c94624c4fae21381af895e66
{ "intermediate": 0.42011991143226624, "beginner": 0.21956782042980194, "expert": 0.36031225323677063 }
44,592
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
db0eca854a0417a1d90811dfd8653946
{ "intermediate": 0.42011991143226624, "beginner": 0.21956782042980194, "expert": 0.36031225323677063 }
44,593
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
c9ba9a4a568b2f3464a6aca3d8b7e985
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,594
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
14d931b691895287dcfaad766afc6a50
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,595
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
2ba26677a9ece3fa3ce54369e6e1f952
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,596
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
8d25bf7604df7f337d00ae1db9047560
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,597
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
c54d9c1f757a26aff9c3d2f29db48926
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,598
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
1bbde52faf8ab2a13a60863b12415ec9
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,599
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
43cd47168b55fc4891302aca25a0c62c
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,600
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
244b49ead4a26357b15bb7c5d21b4d03
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,601
I want to program an atmega328p u and use it as a Stand alone, I have a arduino Uno Dip; How can I program it with my Arduino and also upload my code via Arduino Uno
6dfb3dc058af0053e6e822ee23100df4
{ "intermediate": 0.5045016407966614, "beginner": 0.23780448734760284, "expert": 0.2576938569545746 }
44,602
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
fe9ef5df900e6d166d941c5b6026c577
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,603
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
a1891af5ab3e69ff7133d6d139dc87b2
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,604
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
6ccc4516c6fdb107c9b2b57fbf02da9e
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,605
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
2ef41f2f0079999a4354257964b6bda8
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,606
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
1fa5259057bd7983bada218643c510bb
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,607
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
f6062495254bff83bc06c19f7ccb724f
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,608
please give me an idea of shell script which I can use to fetch required file for editing from a .tar.gz archive and then after editing add modified version of iti nto archive back !
2bf60bc8d28c45bb8495f5677184693b
{ "intermediate": 0.4217303991317749, "beginner": 0.20833274722099304, "expert": 0.36993685364723206 }
44,609
I'm using an arduino Uno, as a programmer for my ATmega328P U; I have code as shown below which is writhed in C language, I want to change it and compatible it to be used in ARduino IDE and upload it on my atmega328; keep in mind that I want to use this IC as a Stand alone and not with Arduino Uno board #define F_CPU 16000000UL // 16 MHz clock speed #include <avr/io.h> #include <util/delay.h> #define potPin 0 // Define potentiometer ADC channel (PC0 = ADC0) // Define digital I/O pins for LEDs - on PD1 to PD6 #define led1 PD1 #define led2 PD2 #define led3 PD3 #define led4 PD4 #define led5 PD5 #define led6 PD6 #define SAMPLES_TO_AVERAGE 10 // Number of samples to average for ADC void adc_init() { ADMUX = (1<<REFS0); // Select AVcc as the reference voltage and ADC0 as input channel ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); // Enable ADC and set prescaler to 128 } uint16_t adc_read(uint8_t ch) { // Select ADC channel with a safety mask and without changing the reference voltage selection ADMUX = (ADMUX & 0xF0) | (ch & 0x0F); // Start single conversion ADCSRA |= (1<<ADSC); // Wait until conversion is complete while (ADCSRA & (1<<ADSC)); return ADC; } uint16_t adc_read_average(uint8_t ch) { uint32_t sum = 0; for (int i = 0; i < SAMPLES_TO_AVERAGE; ++i) { sum += adc_read(ch); } return (uint16_t)(sum / SAMPLES_TO_AVERAGE); } int main(void) { // Set up the LED pins as output - updated for PD1 to PD6 DDRD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6); // Initialize ADC adc_init(); while(1) { // Read the value from the potentiometer and average it uint16_t potValue = adc_read_average(potPin); // Map the potentiometer value from the given range (65 - 337) to (0 - 1023) uint16_t mappedValue = (uint32_t)(potValue - 65) * 1023 / (337 - 65); // Define thresholds based on the number of LEDs uint16_t threshold1 = 170; // First threshold uint16_t threshold2 = 341; // Second threshold uint16_t threshold3 = 512; // Third threshold uint16_t threshold4 = 683; // Fourth threshold uint16_t threshold5 = 854; // Fifth threshold // Turn off all LEDs to start with - updated for PD1 to PD6 PORTD &= ~((1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6)); // Determine which LEDs to light up based on the mappedValue - updated for PD1 to PD6 if (mappedValue >= threshold5) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6); } else if (mappedValue >= threshold4) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5); } else if (mappedValue >= threshold3) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4); } else if (mappedValue >= threshold2) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3); } else if (mappedValue >= threshold1) { PORTD |= (1<<led1) | (1<<led2); } else { // Ensure led1 is always turned on regardless of the value PORTD |= (1<<led1); } // Small delay to reduce flickering _delay_ms(30); } }
fe2a8e4ade2cf144400152195a818a60
{ "intermediate": 0.3844984471797943, "beginner": 0.1771332025527954, "expert": 0.4383682906627655 }
44,611
Create Java code for a game like gta v
cc1e5e1713e5fb197035091a48ede4bf
{ "intermediate": 0.29437553882598877, "beginner": 0.40756741166114807, "expert": 0.29805701971054077 }
44,612
Create Java script for 3d person perspective
c1e7b37de7628546934bfaa2aadccec5
{ "intermediate": 0.4382568299770355, "beginner": 0.319151908159256, "expert": 0.2425912618637085 }
44,613
Create Java code for ai people crowd in game
410cd49057625aeca5564bc8a9ef2163
{ "intermediate": 0.30134421586990356, "beginner": 0.38156256079673767, "expert": 0.31709322333335876 }
44,614
tocuh command to create 10 files
86b0ea6a9d84997e1a431b6e0c6852da
{ "intermediate": 0.3748509883880615, "beginner": 0.2537415027618408, "expert": 0.37140750885009766 }
44,615
touch comand to create 15 text file in ubuntu
04106dc0ff1c3f761c6ab126cfc3e696
{ "intermediate": 0.39885807037353516, "beginner": 0.2326081395149231, "expert": 0.36853379011154175 }
44,616
hi
5fafa7fae07f1c704608ae95dfd22eb9
{ "intermediate": 0.3246487081050873, "beginner": 0.27135494351387024, "expert": 0.40399640798568726 }
44,617
salut j'ai besoin d'aide pour stocker des images dans ma db supabase avec flutter (dart): j'ai ce code pour l'instant et j'arrive à stocker les images dans ma db mais je sais pas si c'est bien: import 'package:allo/components/add_images.dart'; import 'package:allo/components/custom_check_box.dart'; import 'package:allo/components/custom_date_picker.dart'; import 'package:allo/components/custom_text_field.dart'; import 'package:allo/components/listing_categories.dart'; import 'package:allo/constants/app_colors.dart'; import 'package:allo/models/DB/annonce_db.dart'; import 'package:allo/utils/bottom_round_clipper.dart'; import 'package:allo/widgets/home.dart'; import 'package:allo/widgets/register_page.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:image_picker/image_picker.dart'; class AjoutAnnonce extends StatefulWidget { @override State<AjoutAnnonce> createState() => _AjoutAnnonceState(); } class _AjoutAnnonceState extends State<AjoutAnnonce> { ValueNotifier<List<XFile>> images = ValueNotifier<List<XFile>>([]); TextEditingController _texteAnnonceController = TextEditingController(); TextEditingController descriptionAnnonce = TextEditingController(); ValueNotifier<DateTime> dateAideAnnonce = ValueNotifier<DateTime>(DateTime.now()); ValueNotifier<List<String>> categorieAnnonce = ValueNotifier<List<String>>([]); ValueNotifier<bool> estUrgente = ValueNotifier<bool>(false); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.light, body: Stack( children: <Widget>[ Padding( padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 110.0), child: CustomScrollView( slivers: <Widget>[ SliverList( delegate: SliverChildListDelegate( [ AddImages(valueNotifier: images), CustomTextField( hint: "Recherche une perceuse...", label: "Titre de l'annonce", controller: _texteAnnonceController,), CustomTextField( hint: "Description de l'annonce", label: "Description", isArea: true, controller: descriptionAnnonce ), ListingCategories(lesCategories: [ "Perceuse", "Outils", "Visseuse", "Poulet", "Gode ceinture" ], isSelectable: true, isExpandable: true, selectedCategoriesNotifier: categorieAnnonce, ), SizedBox( height: 24, ), CustomDatePicker( hint: "Selectionner une date", label: "Date de fin de l'annonce", dateNotifier: dateAideAnnonce, ), CustomCheckBox( label: "Niveau d'urgence", hint: "Annonce urgente", isCheckedNotifier: estUrgente, ), SizedBox( height: 100, ), ], ), ), ], ), ), Positioned( top: 0, left: 0, child: Container( height: 110, width: MediaQuery.of(context).size.width, color: AppColors.light, alignment: Alignment.center, ), ), Positioned( top: 45, left: 100, child: Container( height: 45, width: MediaQuery.of(context).size.width, color: Colors.transparent, alignment: Alignment.centerLeft, child: Text("Nouvelle annonce", style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, fontFamily: "NeueRegrade", )), ), ), Positioned( top: 45, right: 25, child: InkWell( onTap: () { Navigator.pop(context); }, child: Container( height: 45, // same height as a FAB width: 45, // same width as a FAB decoration: BoxDecoration( color: AppColors.primary, // same color as your FAB borderRadius: BorderRadius.circular( 8000), // change this to your desired border radius ), child: Center( child: SvgPicture.asset("assets/icons/cross.svg"), // your icon ), ), ), ), Positioned( bottom: 0, left: 0, right: 0, child: Container( width: MediaQuery.of(context).size.width, height: 100, color: AppColors.light, padding: EdgeInsets.fromLTRB(0, 10, 0, 0), child: Align( alignment: Alignment.center, child: ElevatedButton( onPressed: () { print("Ajout de l'annonce"); print("nb images: ${images.value.length}"); print("Titre: ${_texteAnnonceController.text}"); print("Description: ${descriptionAnnonce.text}"); print("Date: ${dateAideAnnonce.value}"); print("Categorie: ${categorieAnnonce.value}"); print("Urgence: ${estUrgente.value}"); AnnonceDB.ajouterAnnonce(images.value, _texteAnnonceController.text, descriptionAnnonce.text, dateAideAnnonce.value, categorieAnnonce.value, estUrgente.value); }, style: ElevatedButton.styleFrom( shadowColor: Colors.transparent, padding: EdgeInsets.symmetric(vertical: 17, horizontal: 40), elevation: 0, backgroundColor: AppColors.primary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100), ), ), child: Text( "Ajouter l'annonce", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, fontFamily: "NeueRegrade", color: AppColors.dark, ), ), ), ), ), ) ], )); } } méthode pour la conversion xfile -> base64 static Future<String> xFileToBase64(XFile file) async { File imageFile = File(file.path); List<int> imageBytes = await imageFile.readAsBytesSync(); String base64Image = base64Encode(imageBytes); return base64Image; } méthode pour ajouter l'annonce: static void ajouterAnnonce( List<XFile> images, String titreAnnonce, String descriptionAnnonce, DateTime dateAideAnnonce, List<String> categorieAnnonce, bool estUrgente) async { try { String? myUUID = await UserBD.getMyUUID(); final response = await supabase.from('annonce').insert([ { 'titreannonce': titreAnnonce, 'descriptionannonce': descriptionAnnonce, 'datepubliannonce': DateTime.now().toIso8601String(), 'dateaideannonce': dateAideAnnonce.toIso8601String(), 'esturgente': estUrgente, 'etatannonce': 0, 'idutilisateur': myUUID, } ]).select('idannonce'); print('Response annonce: $response'); // on insère dans photo_annonce // photo: bytea // idannonce: uuid final idAnnonce = response[0]['idannonce']; for (var image in images) { final base64Image = await ImageConverter.xFileToBase64(image); final responseImage = await supabase.from('photo_annonce').insert([ { 'photo': base64Image, 'idannonce': idAnnonce, } ]); print('Response image: $responseImage'); } } catch (e) { print('Erreur lors de l\'ajout de l\'annonce: $e'); } }
6d7212ef14412b38c02adf8c789ee004
{ "intermediate": 0.3416573405265808, "beginner": 0.42732638120651245, "expert": 0.23101632297039032 }
44,618
instead of the grid-five-column, i have edited the cart grid to only need 3 columns so that i can move the order-total--amount to the right of the grid on desktop and bottom of grid on mobile. Rewrite the code to implement this: import styled from "styled-components"; import { useCartContext } from "./context/cart_context"; import CartItem from "./components/CartItem"; import { NavLink } from "react-router-dom"; import { Button } from "./styles/Button"; import FormatPrice from "./Helpers/FormatPrice"; import { useAuth0 } from "@auth0/auth0-react"; const Cart = () => { const { cart, clearCart, total_price, shipping_fee } = useCartContext(); // console.log("🚀 ~ file: Cart.js ~ line 6 ~ Cart ~ cart", cart); const { isAuthenticated, user } = useAuth0(); if (cart.length === 0) { return ( <EmptyDiv> <h3>No Cart in Item </h3> </EmptyDiv> ); } return ( <Wrapper> <div className="container"> <div className="cart-user--profile"> <h2 className="cart-user--name">Your Cart</h2> </div> <div className="cart_heading grid grid-five-column"> <p>Item</p> <p className="cart-hide">Price</p> <p>Remove</p> </div> <hr /> <div className="cart-item"> {cart.map((curElem) => { return <CartItem key={curElem.id} {...curElem} />; })} </div> <hr /> <div className="cart-two-button"> <NavLink to="/products"> <Button> continue Shopping </Button> </NavLink> <Button className="btn btn-clear" onClick={clearCart}> clear cart </Button> </div> {/* order total_amount */} <div className="order-total--amount"> <div className="order-total--subdata"> <div> <p>subtotal:</p> <p> <FormatPrice price={total_price} /> </p> </div> <hr /> <div> <p>order total:</p> <p> <FormatPrice price={shipping_fee + total_price} /> </p> </div> </div> </div> </div> </Wrapper> ); }; const EmptyDiv = styled.div` display: grid; place-items: center; height: 50vh; h3 { font-size: 4.2rem; text-transform: capitalize; font-weight: 300; color: black; } `; const Wrapper = styled.section` padding: 15rem 0; p, h3 { color: black; } button, btn { color: white; border-radius: 10px; } button:hover, btn:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } .grid-four-column { grid-template-columns: repeat(4, 1fr); } .grid-five-column { grid-template-columns: repeat(4, 1fr) 0.3fr; text-align: center; align-items: center; } .cart-heading { text-align: center; text-transform: uppercase; } hr { margin-top: 1rem; } .cart-item { padding: 3.2rem 0; display: flex; flex-direction: column; gap: 3.2rem; } .cart-user--profile { display: flex; justify-content: flex-start; align-items: center; gap: 1.2rem; margin-bottom: 5.4rem; img { width: 8rem; height: 8rem; border-radius: 50%; } h2 { font-size: 2.4rem; } } .cart-user--name { text-transform: capitalize; color: black; } .cart-image--name { /* background-color: red; */ align-items: center; display: grid; gap: 1rem; grid-template-columns: 0.4fr 1fr; text-transform: capitalize; text-align: left; img { max-width: 15rem; height: auto; object-fit: contain; color: transparent; border-radius: 10px; } .color-div { display: flex; align-items: center; justify-content: flex-start; gap: 1rem; .color-style { width: 1.4rem; height: 1.4rem; border-radius: 50%; } } } .cart-two-button { margin-top: 2rem; display: flex; justify-content: space-between; .btn-clear { background-color: #e74c3c; } } .amount-toggle { display: flex; justify-content: center; align-items: center; gap: 2.4rem; font-size: 1.4rem; button { border: none; background-color: #fff; cursor: pointer; } .amount-style { font-size: 2.4rem; color: ${({ theme }) => theme.colors.btn}; } } .remove_icn { display: flex; justify-content: center; align-items: center; } .remove_icon { font-size: 1.6rem; color: #e74c3c; cursor: pointer; } .order-total--amount { width: 100%; margin: 4.8rem 0; text-transform: capitalize; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; .order-total--subdata { border: 0.1rem solid #f0f0f0; box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22); border-radius: 24px; display: flex; flex-direction: column; gap: 1.8rem; padding: 3.2rem; } div { display: flex; gap: 3.2rem; justify-content: space-between; } div:last-child { background-color: #fafafa; } div p:last-child { font-weight: bold; color: black; } } @media (max-width: ${({ theme }) => theme.media.mobile}) { .grid-five-column { grid-template-columns: 1.5fr 1fr 0.5fr; } .cart-two-button { margin-top: 2rem; display: flex; justify-content: space-between; gap: 2.2rem; } .order-total--amount { width: 100%; text-transform: capitalize; justify-content: flex-start; align-items: flex-start; .order-total--subdata { width: 100%; border: 0.1rem solid #f0f0f0; display: flex; flex-direction: column; gap: 1.8rem; padding: 3.2rem; } } } `; export default Cart;
181d03b9a86f3e21fcdf03fe6bba962e
{ "intermediate": 0.34550338983535767, "beginner": 0.5133413076400757, "expert": 0.14115530252456665 }
44,619
How can i implement CinemachineVirtualCamera to use it as my camera in my unity project using KBCore.Refs; using MyProject; using UnityEngine; using Cinemachine; public class PlayerController : MonoBehaviour { [Header("References")] [SerializeField, Anywhere] CinemachineVirtualCamera virtualCamera; [SerializeField, Anywhere] InputReader input; [Header("Settings")] [SerializeField] private float moveSpeed = 3f; [SerializeField] private float jumpForce = 1f; [SerializeField] private float mouseSens = 2f; Transform mainCam; private void Awake() { mainCam = Camera.main.transform; } private void Update() { } } there is snippet of my code. Im using unity new input system to handle player input
6272402ce1d3230daa6a22fd612b3ce7
{ "intermediate": 0.6349285840988159, "beginner": 0.23707345128059387, "expert": 0.1279979944229126 }
44,620
create test project showing how multithreding works in python
e67d0d74633ee2f4bf46b323109ff509
{ "intermediate": 0.3226778209209442, "beginner": 0.1265726089477539, "expert": 0.5507495403289795 }
44,621
How to use mulesoft dataweave in spring boot ?
96fc4a4feef556ab90e1253ed622f8e5
{ "intermediate": 0.6102958917617798, "beginner": 0.08830921351909637, "expert": 0.30139487981796265 }
44,622
I have this code as below, this code reads a 10K ohm High power LED driver board, in the past I read the value and it is between 65 to 337 through ADC0 pin, and based on value turn 1 to 6 LEDs; I'm using 6 pcs of 2N2222 transistors collector pin of it connected to (-) pin of LED and (+) is connected to 100 ohm resistors and bases are connected to PD1 to PD6 pins of AVR ATmega328P U through 6pcs of 220 ohm resistors; I had this code as below which was for ATmega32A 40 pin; know I want to use 28 pin ATmega328P; take all necessary changes so it can be compatible with ATmega328 #define F_CPU 16000000UL // 16 MHz clock #include <avr/io.h> #include <util/delay.h> // Define potentiometer ADC channel (PA0 = ADC0) #define potPin 0 // Define digital I/O pins for LEDs - changed to use PD1 to PD6 #define led1 PD1 #define led2 PD2 #define led3 PD3 #define led4 PD4 #define led5 PD5 #define led6 PD6 #define SAMPLES_TO_AVERAGE 10 // Number of samples to average for ADC void adc_init() { // Initialize ADC ADMUX = (1<<REFS0); // Select AVcc as reference voltage and ADC0 as input channel ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); // Enable ADC and set prescaler to 128 } uint16_t adc_read(uint8_t ch) { // Select ADC channel with safety mask and without changing the reference voltage selection ADMUX = (ADMUX & 0xF0) | (ch & 0x0F); // Start single conversion ADCSRA |= (1<<ADSC); // Wait until conversion is complete while (ADCSRA & (1<<ADSC)); return ADC; } uint16_t adc_read_average(uint8_t ch) { uint32_t sum = 0; for (int i = 0; i < SAMPLES_TO_AVERAGE; ++i) { sum += adc_read(ch); } return (uint16_t)(sum / SAMPLES_TO_AVERAGE); } int main(void) { // Set up the LED pins as output - updated for PD1 to PD6 DDRD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6); // Initialize ADC adc_init(); while(1) { // Read the value from the potentiometer and average it uint16_t potValue = adc_read_average(potPin); // Map the potentiometer value from the given range (65 - 337) to (0 - 1023) uint16_t mappedValue = (uint32_t)(potValue - 65) * 1023 / (337 - 65); // Define thresholds based on the number of LEDs uint16_t threshold1 = 170; // First threshold uint16_t threshold2 = 341; // Second threshold uint16_t threshold3 = 512; // Third threshold uint16_t threshold4 = 683; // Fourth threshold uint16_t threshold5 = 854; // Fifth threshold // Turn off all LEDs to start with - updated for PD1 to PD6 PORTD &= ~((1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6)); // Determine which LEDs to light up based on the mappedValue - updated for PD1 to PD6 if (mappedValue >= threshold5) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6); } else if (mappedValue >= threshold4) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5); } else if (mappedValue >= threshold3) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4); } else if (mappedValue >= threshold2) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3); } else if (mappedValue >= threshold1) { PORTD |= (1<<led1) | (1<<led2); } else { // Ensure led1 is always turned on regardless of the value PORTD |= (1<<led1); } // Small delay to reduce flickering _delay_ms(30); } }
999f32c14fce76fd6901202acb1d82cb
{ "intermediate": 0.37304267287254333, "beginner": 0.40133023262023926, "expert": 0.2256270796060562 }
44,623
I am working on a indoor scene detection dataset from MIT with 67 classes. i want to use transfwer learning to get a 90% accuracy with around 5million parameters and less than 50 epochs on training set andf 85% accuracy on validation set. this is my current model base_model = EfficientNetB0(weights='imagenet', include_top=False, input_shape=(IMG_SIZE, IMG_SIZE, 3)) base_model.trainable = False model = Sequential([ base_model, GlobalAveragePooling2D(), Dense(256, activation='relu'), Dense(67, activation='softmax') ]) initial_learning_rate = 0.001 decay_rate = 0.9 momentum = 0.9 lr_schedule = tf.keras.optimizers.schedules.ExponentialDecay( initial_learning_rate, decay_steps=1000, decay_rate=decay_rate, staircase=True) optimizer = tf.keras.optimizers.SGD(learning_rate=lr_schedule, momentum=momentum) model.compile(optimizer=optimizer, loss='categorical_crossentropy', metrics=['accuracy']) model.build((None,IMG_SIZE, IMG_SIZE, 3)) # model.summary() return model strictly i require more than 50% accuracy in testing set. how can you imporve my model and get the results
5fa6102002e79d21b293d8934988861c
{ "intermediate": 0.33504170179367065, "beginner": 0.17113839089870453, "expert": 0.49381983280181885 }
44,624
I have this code as below, this code reads a 10K ohm High power LED driver board, in the past I read the value and it is between 65 to 337 through ADC0 pin, and based on value turn 1 to 6 LEDs; I’m using 6 pcs of 2N2222 transistors collector pin of it connected to (-) pin of LED and (+) is connected to 100 ohm resistors and bases are connected to PD1 to PD6 pins of AVR ATmega328P U through 6pcs of 220 ohm resistors; I had this code as below which was for ATmega32A 40 pin; know I want to use 28 pin ATmega328P; take all necessary changes so it can be compatible with ATmega328 #define F_CPU 16000000UL // 16 MHz clock #include <avr/io.h> #include <util/delay.h> // Define potentiometer ADC channel (PA0 = ADC0) #define potPin 0 // Define digital I/O pins for LEDs - changed to use PD1 to PD6 #define led1 PD1 #define led2 PD2 #define led3 PD3 #define led4 PD4 #define led5 PD5 #define led6 PD6 #define SAMPLES_TO_AVERAGE 10 // Number of samples to average for ADC void adc_init() { // Initialize ADC ADMUX = (1<<REFS0); // Select AVcc as reference voltage and ADC0 as input channel ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); // Enable ADC and set prescaler to 128 } uint16_t adc_read(uint8_t ch) { // Select ADC channel with safety mask and without changing the reference voltage selection ADMUX = (ADMUX & 0xF0) | (ch & 0x0F); // Start single conversion ADCSRA |= (1<<ADSC); // Wait until conversion is complete while (ADCSRA & (1<<ADSC)); return ADC; } uint16_t adc_read_average(uint8_t ch) { uint32_t sum = 0; for (int i = 0; i < SAMPLES_TO_AVERAGE; ++i) { sum += adc_read(ch); } return (uint16_t)(sum / SAMPLES_TO_AVERAGE); } int main(void) { // Set up the LED pins as output - updated for PD1 to PD6 DDRD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6); // Initialize ADC adc_init(); while(1) { // Read the value from the potentiometer and average it uint16_t potValue = adc_read_average(potPin); // Map the potentiometer value from the given range (65 - 337) to (0 - 1023) uint16_t mappedValue = (uint32_t)(potValue - 65) * 1023 / (337 - 65); // Define thresholds based on the number of LEDs uint16_t threshold1 = 170; // First threshold uint16_t threshold2 = 341; // Second threshold uint16_t threshold3 = 512; // Third threshold uint16_t threshold4 = 683; // Fourth threshold uint16_t threshold5 = 854; // Fifth threshold // Turn off all LEDs to start with - updated for PD1 to PD6 PORTD &= ~((1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6)); // Determine which LEDs to light up based on the mappedValue - updated for PD1 to PD6 if (mappedValue >= threshold5) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5) | (1<<led6); } else if (mappedValue >= threshold4) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4) | (1<<led5); } else if (mappedValue >= threshold3) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3) | (1<<led4); } else if (mappedValue >= threshold2) { PORTD |= (1<<led1) | (1<<led2) | (1<<led3); } else if (mappedValue >= threshold1) { PORTD |= (1<<led1) | (1<<led2); } else { // Ensure led1 is always turned on regardless of the value PORTD |= (1<<led1); } // Small delay to reduce flickering _delay_ms(30); } }
bac0831e3c472264527d5208bb8d0646
{ "intermediate": 0.38978394865989685, "beginner": 0.3505503833293915, "expert": 0.25966569781303406 }
44,625
Copilot/OS-Copilot/oscopilot/__init__.py", line 1, in <module> from .agents import * ImportError: attempted relative import with no known parent package
5bd0f6cf46bee7711954713c66358e82
{ "intermediate": 0.36620527505874634, "beginner": 0.3886396586894989, "expert": 0.24515508115291595 }
44,626
round down number to nearest 0.5 (lua 5.1) in one line
48e84addb7088e7d4cbc97718960c7d6
{ "intermediate": 0.3531145751476288, "beginner": 0.2952868342399597, "expert": 0.3515985608100891 }
44,627
j'ai une bd flutter pour sqflite : import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; class SqliteService { Future<void> onCreate(Database db, int version) async { await db.execute(""" CREATE TABLE Aventure ( idAventure INTEGER PRIMARY KEY AUTOINCREMENT, nomJoueur TEXT NOT NULL ) """); await db.execute(""" CREATE TABLE Difficulte ( idDifficulte INTEGER PRIMARY KEY AUTOINCREMENT, nom TEXT NOT NULL, nbTentative INTEGER NOT NULL, valeurMax INTEGER NOT NULL ) """); await db.execute(""" CREATE TABLE Niveau ( idNiveau INTEGER PRIMARY KEY AUTOINCREMENT, palier INTEGER NOT NULL, idDifficulte INTEGER NOT NULL, FOREIGN KEY(idDifficulte) REFERENCES Difficulte(idDifficulte) ) """); await db.execute(""" CREATE TABLE Partie ( idPartie INTEGER PRIMARY KEY AUTOINCREMENT, score INTEGER NOT NULL, nbMystere INTEGER NOT NULL, nbEssaisJoueur INTEGER NOT NULL, gagne INTEGER NOT NULL, dateDebut TEXT NOT NULL, dateFin TEXT NOT NULL, idAventure INTEGER, idNiveau INTEGER, FOREIGN KEY(idAventure) REFERENCES Aventure(idAventure), FOREIGN KEY(idNiveau) REFERENCES Niveau(idNiveau) ) """); await db.execute(""" CREATE TABLE Effectuer ( idAventure INTEGER NOT NULL, idPartie INTEGER NOT NULL, idNiveau INTEGER NOT NULL, complete INTEGER NOT NULL, PRIMARY KEY(idAventure, idPartie, idNiveau), FOREIGN KEY(idAventure) REFERENCES Aventure(idAventure), FOREIGN KEY(idPartie) REFERENCES Partie(idPartie), FOREIGN KEY(idNiveau) REFERENCES Niveau(idNiveau) ) """); await db.insert( 'Difficulte', {'nom': 'Facile', 'nbTentative': -1, 'valeurMax': 50}); await db.insert( 'Difficulte', {'nom': 'Moyen', 'nbTentative': 15, 'valeurMax': 150}); await db.insert('Difficulte', {'nom': 'Difficile', 'nbTentative': 10, 'valeurMax': 300}); } Future<Database> initializeDB() async { return openDatabase( join(await getDatabasesPath(), 'aventure.db'), onCreate: onCreate, onUpgrade: (db, oldVersion, newVersion) async { await db.execute(""" DROP TABLE IF EXISTS Aventure; DROP TABLE IF EXISTS Difficulte; DROP TABLE IF EXISTS Niveau; DROP TABLE IF EXISTS Partie; DROP TABLE IF EXISTS Effectuer; """); await onCreate(db, newVersion); }, version: 2, ); } } et j'ai cette page : import 'package:flutter/material.dart'; import 'package:mobile_tp/models/Difficulte.dart'; import 'package:mobile_tp/models/Niveau.dart'; import 'package:mobile_tp/models/Partie.dart'; import 'package:mobile_tp/screens/MysteryNumberScreen.dart'; import 'package:mobile_tp/services/AventureDB.dart'; import 'package:mobile_tp/services/DifficulteDB.dart'; import 'package:mobile_tp/services/EffectuerDB.dart'; import 'package:mobile_tp/services/NiveauDB.dart'; import 'package:mobile_tp/services/PartieDB.dart'; import 'package:sqflite/sqflite.dart'; class PageNiveaux extends StatefulWidget { final int totalNiveaux; final int idAventure; final Future<Database> database; PageNiveaux({ Key? key, required this.totalNiveaux, required this.idAventure, required this.database, }) : super(key: key); @override _PageNiveauxState createState() => _PageNiveauxState(); } class _PageNiveauxState extends State<PageNiveaux> { late List<Niveau> doneLevels = []; late AventureDB aventureDB; late PartieDB partieDB; late EffectuerDB effectuerDB; late NiveauDB niveauDB; late DifficulteDB difficulteDB; @override void initState() { super.initState(); aventureDB = AventureDB(database: widget.database); partieDB = PartieDB(database: widget.database); effectuerDB = EffectuerDB(database: widget.database); niveauDB = NiveauDB(database: widget.database); difficulteDB = DifficulteDB(database: widget.database); loadLevels(); } Future<void> loadLevels() async { final levels = await aventureDB.getLevelsWon(widget.idAventure); setState(() { doneLevels = levels; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Aventure'), ), body: Center( child: SingleChildScrollView( child: Column( children: List.generate(widget.totalNiveaux * 2 - 1, (index) { if (index % 2 == 0) { int niveau = widget.totalNiveaux - index ~/ 2; bool niveauGagne = doneLevels.any((niveauGagne) => niveauGagne.id == niveau); bool niveauPrecedentGagne = niveau == 1 || doneLevels .any((niveauGagne) => niveauGagne.id == niveau - 1); return GestureDetector( onTap: niveauPrecedentGagne ? () async { List<Difficulte> allDifficulties = await difficulteDB.getAll(); allDifficulties.forEach((difficulte) { print( 'Difficulte id: ${difficulte.id}, nom: ${difficulte.nomDifficulte}, nbTentatives: ${difficulte.nbTentatives}, valeurMax: ${difficulte.valeurMax}'); }); int idDifficulte; if (niveau <= 3) { idDifficulte = 1; } else if (niveau <= 7) { idDifficulte = 2; } else { idDifficulte = 3; } Difficulte difficulte = await niveauDB.getDifficulteById(idDifficulte); Partie nouvellePartie = Partie( score: 0, nbMystere: difficulte.valeurMax, nbEssais: difficulte.nbTentatives, gagnee: false, dateDebut: DateTime.now(), dateFin: DateTime.now(), idAventure: widget.idAventure, idNiveau: niveau, ); int idNouvellePartie = await partieDB.add(nouvellePartie); Navigator.push( context, MaterialPageRoute( builder: (context) => MysteryNumberScreen( database: widget.database, idPartie: idNouvellePartie, idNiveau: niveau, idDifficulte: difficulte.id, idAventure: widget.idAventure, effectuerDB: effectuerDB, ), ), ); } : null, child: CircleAvatar( backgroundColor: niveauGagne ? Colors.green : Colors.grey, child: Text(niveau.toString()), ), ); } else { return SizedBox(height: 20); } }), ), ), ), ); } } mais ça m'envoie cette erreur : E/flutter (31910): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: No difficulty found with id 1 E/flutter (31910): #0 NiveauDB.getDifficulteById (package:mobile_tp/services/NiveauDB.dart:39:7) E/flutter (31910): <asynchronous suspension> E/flutter (31910): #1 _PageNiveauxState.build.<anonymous closure>.<anonymous closure> (package:mobile_tp/screens/PageNiveaux.dart:90:31) E/flutter (31910): <asynchronous suspension> E/flutter (31910): et je ne comprends pas pourquoi
dae514e1c4423f2367c49642276c5d05
{ "intermediate": 0.23006421327590942, "beginner": 0.516556441783905, "expert": 0.25337934494018555 }
44,628
Products Unhandled Runtime Error TypeError: Cannot read properties of null (reading 'default') in my next.js Asked today Modified today Viewed 8 times 0 "use client" import { useKindeBrowserClient } from '@kinde-oss/kinde-auth-nextjs' import Image from 'next/image'; import React from 'react' function DashboardHeader() { const {user} = useKindeBrowserClient(); return ( <div> <Image src={user?.picture} alt='logo' width={40} height={40} /> </div> ) } export default DashboardHeader I am getting this error in my webapp, I m getting this error because of image tag in the provided code. I have noticed once I remove this image tag code, everything works fine. But the moment I write this image tag code, this issue pop up. I tried everything but can't solve. Please help ASAP
c39b01b76988970fe89c859706b4f2d2
{ "intermediate": 0.5659837126731873, "beginner": 0.30678024888038635, "expert": 0.1272360235452652 }
44,629
# imports import torch import torch.nn as nn import numpy as np import time import math import matplotlib.pyplot as plt from torch.utils.data import Dataset, DataLoader from torch.optim.lr_scheduler import StepLR from copy import deepcopy from ray import tune from ray.tune.integration.wandb import WandbLoggerCallback import wandb import torch from ray.tune.suggest.hyperopt import HyperOptSearch from utils.data import Data # position encoding class PositionalEncoding(nn.Module): def __init__(self, d_model, max_len=5000): super(PositionalEncoding, self).__init__() pe = torch.zeros(max_len, d_model) position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1) div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model)) pe[:, 0::2] = torch.sin(position * div_term) pe[:, 1::2] = torch.cos(position * div_term) pe = pe.unsqueeze(0).transpose(0, 1) self.register_buffer('pe', pe) def forward(self, x): return x + self.pe[:x.size(0), :] # transformer model class TransAm(nn.Module): def __init__(self,feature_size=100,num_layers=1,dropout=0.1, nhead=10): super(TransAm, self).__init__() self.model_type = 'Transformer' self.src_mask = None self.pos_encoder = PositionalEncoding(feature_size) self.encoder_layer = nn.TransformerEncoderLayer(d_model=feature_size, nhead=nhead, dropout=dropout) self.transformer_encoder = nn.TransformerEncoder(self.encoder_layer, num_layers=num_layers) self.decoder = nn.Linear(feature_size,1) self.init_weights() def init_weights(self): initrange = 0.1 self.decoder.bias.data.zero_() self.decoder.weight.data.uniform_(-initrange, initrange) def forward(self,src): if self.src_mask is None or self.src_mask.size(0) != len(src): device = src.device mask = self._generate_square_subsequent_mask(len(src)).to(device) self.src_mask = mask src = self.pos_encoder(src) output = self.transformer_encoder(src,self.src_mask)#, self.src_mask) output = self.decoder(output) return output def _generate_square_subsequent_mask(self, sz): mask = (torch.triu(torch.ones(sz, sz)) == 1).transpose(0, 1) mask = mask.float().masked_fill(mask == 0, float('-inf')).masked_fill(mask == 1, float(0.0)) return mask # config having various parameters for the search space config = { "feature_size": tune.choice([100]), "num_layers": tune.choice([1, 4, 8, 12]), "dropout": tune.uniform(0.05, 0.3), "lr": tune.loguniform(1e-4, 1e-2), "nhead": tune.choice([2, 5, 10, 25]), "lr_decay": tune.uniform(0.95, 0.99), "batch_size": tune.choice([8, 16, 32, 64]), "epochs": tune.choice([4, 8, 16, 32]) } # class TransAmTrainable(tune.Trainable): def __init__(self, config): super(TransAmTrainable, self).__init__(config) self.model = TransAm(feature_size=config["feature_size"], num_layers=config["num_layers"], dropout=config["dropout"], nhead=config["nhead"]) self.device = "cuda" if torch.cuda.is_available() else "cpu" self.model = self.model.to(self.device) self.criterion = nn.MSELoss() self.optimizer = torch.optim.SGD(self.model.parameters(), lr=config["lr"]) self.scheduler = StepLR(self.optimizer, step_size=1, gamma=config["lr_decay"]) self.input_window = 100 # number of input steps self.output_window = 1 # number of prediction steps, in this model its fixed to one self.dataset = Data(self.input_window, self.output_window) self.train_data, self.val_data = self.dataset.get_data() self.epochs = config["epochs"] self.batch_size = config["batch_size"] self.best_val_loss = float('inf') # Track best validation loss self.patience = 5 # Set patience for early stopping self.epochs_no_improve = 0 # Counter for epochs without improvement self.best_val_perplexity = float('inf') # Track best validation perplexity def step(self): train_loss = 0.0 for epoch in range(self.epochs): # Loop through defined epochs epoch_loss = self.train_batch(epoch) # Train and obtain batch loss train_loss += epoch_loss # Accumulate total training loss # After training, compute both validation loss and perplexity val_perplexity, val_loss = self.validation_metrics() # Assuming a new method validation_metrics that returns both # Log average training loss, validation loss, and validation perplexity using Weights & Biases (wandb) wandb.log({ "train_loss": train_loss / self.epochs, "val_loss": val_loss, "val_perplexity": val_perplexity }) # Scheduler step (for learning rate scheduling) self.scheduler.step() # Implement early stopping based on validation perplexity (or validation loss if more appropriate) if val_perplexity < self.best_val_perplexity: # Improvement found, update best metrics and reset counter self.best_val_perplexity = val_perplexity self.best_val_loss = val_loss # Save best validation loss as well self.epochs_no_improve = 0 else: # No improvement in perplexity, increase counter self.epochs_no_improve += 1 if self.epochs_no_improve >= self.patience: # Patience exceeded, trigger early stopping print("Early stopping triggered!") return {"val_loss": val_loss, "val_perplexity": val_perplexity, "epoch": epoch} # Return metrics to Ray Tune, including both loss and perplexity for validation return {"val_loss": val_loss, "val_perplexity": val_perplexity, "epoch": epoch} def train_batch(self, current_epoch): self.model.train() total_loss = 0.0 total_perplexity = 0.0 start_time = time.time() # Calculate the number of batches given the size of the training data and the batch size num_batches = (len(self.train_data) + self.batch_size - 1) // self.batch_size for batch_idx in range(0, len(self.train_data) - 1, self.batch_size): data, targets = self.dataset.get_batch(self.train_data, batch_idx, self.batch_size) data, targets = data.to(self.device), targets.to(self.device) self.optimizer.zero_grad() output = self.model(data) loss = self.criterion(output, targets) cur_loss = loss.item() # loss step by step loss.backward() torch.nn.utils.clip_grad_norm_(self.model.parameters(), 0.7) self.optimizer.step() total_loss += loss.item() total_perplexity += math.exp(cur_loss) # Updating total perplexity elapsed = time.time() - start_time # Calculate, log and return loss for entire step # print(f"| batch {batch_idx:5d}/{len(self.train_data) // self.batch_size:5d}" # f"| lr {self.scheduler.get_last_lr()[0]:02.6f}| " # f"| loss {cur_loss:5.5f} | ppl {math.exp(cur_loss):8.2f}") wandb.log({"step": batch_idx, "lr": self.scheduler.get_last_lr()[0], "elapsed_time_per_step(seconds)": elapsed * 1000, "loss": cur_loss, "perplexity": math.exp(cur_loss) # Perplexity }) # Calculating average loss and perplexity for the epoch avg_train_loss = total_loss / num_batches avg_train_perplexity = total_perplexity / num_batches # Logging average metrics for the epoch wandb.log({"epoch": current_epoch, "avg_loss": avg_train_loss, "avg_perplexity": avg_train_perplexity, # Logging the average training perplexity "elapsed_time_per_batch(seconds)": (time.time() - start_time) * 1000}) return avg_train_loss # Though we’re focusing on perplexity, returning average loss for possible additional uses. def validation_metrics(self): # Assuming validation_metrics returns both the validation loss and perplexity self.model.eval() total_loss = 0.0 with torch.no_grad(): for data, target in self.val_data: data, target = data.to(self.device), target.to(self.device) output = self.model(data) loss = self.criterion(output, target) total_loss += loss.item() avg_loss = total_loss / len(self.val_data) avg_perplexity = math.exp(avg_loss) # Assuming loss suitable for perplexity calculation return avg_perplexity, avg_loss def train_fn(config): if not wandb.run: wandb.init(project="transformer-time-series-1-perplexity", config=config) model = TransAmTrainable(config) result = model.step() tune.report(val_perplexity=result["val_perplexity"]) # Launch the Ray Tune experiment with HyperOpt search algorithm analysis = tune.run( tune.with_resources(train_fn, {"cpu": 4, "gpu": 4}), config=config, num_samples=10, search_alg=HyperOptSearch(metric="val_perplexity", mode="min"), callbacks=[WandbLoggerCallback(project="transformer-time-series-1-perplexity", api_key="f817db0b83a8e722f7adf0be33faca81b8a62273", # Replace with your actual API key log_config=True)], ) # Print the best trial results best_trial = analysis.get_best_trial("loss", "min", "last") print("Best trial config:", best_trial.config) print("Best trial final validation loss:", best_trial.last_result["loss"]) """ Libraries and their version """ # pip install pydantic==1.10.13 # conda install grpcio # for mac pip install grpcio dosent work, install with conda # pip install "ray[tune]==2.3.0" # ray 2.2 version I am getting below issue in above code: Traceback (most recent call last): File "/staging/users/tpadhi1/transformer-experiments/Hyper-Parameter-Tuning/hyperparameter-tuning.py", line 225, in <module> print("Best trial config:", best_trial.config) AttributeError: 'NoneType' object has no attribute 'config'
0e594a63bc6a7c95a447be80023b4ea6
{ "intermediate": 0.33945730328559875, "beginner": 0.472284197807312, "expert": 0.18825854361057281 }
44,630
Write a warband module script to get all parties on map
4e571d4ed1051f5093aa8dba0b93bd16
{ "intermediate": 0.4365195333957672, "beginner": 0.23816190659999847, "expert": 0.32531848549842834 }
44,631
hi
6f1eed768f69bf2a971465836c9009ff
{ "intermediate": 0.3246487081050873, "beginner": 0.27135494351387024, "expert": 0.40399640798568726 }
44,632
How to update PowerShell via the command-line?
f8f2536bfdac99a1709f8bd7d9eb0cd1
{ "intermediate": 0.3162500560283661, "beginner": 0.39431047439575195, "expert": 0.28943946957588196 }
44,633
Write
2f84f669b2394d07cf576aa5340ac7c9
{ "intermediate": 0.33310580253601074, "beginner": 0.3037976026535034, "expert": 0.3630966246128082 }
44,634
off the windows - display screen only using python , press r to turn on the screen, program must be running until i close
046695780e8477a7bd7a440682bdaa26
{ "intermediate": 0.373607873916626, "beginner": 0.22778935730457306, "expert": 0.39860275387763977 }
44,635
I am making a c++ sdl based game engine, and I just made the event manager but I don't know how to use the Subscribe method, can you show me the usage on how would be do for for example a KeyboardKeyDownEvent using a HandleKeyboardKeyDownEvent function? InputManager::InputManager() { // TODO: Should subscribe using EventManager::GetInstance().Subscribe(...) calling this->HandleKeyboardKeyDownEvent receiving a KeyboardKeyDownEvent. } class EventManager { public: static EventManager& GetInstance() noexcept; template<typename T> void Subscribe(std::function<void(std::shared_ptr<T>)> handler); ... } /** @brief Subscribe * * @todo: document this function */ template<typename T> void EventManager::Subscribe(std::function<void(std::shared_ptr<T>)>handler) { static_assert(std::is_base_of<Event, T>::value, "ERROR: T must be a subclass of Event"); auto wrapper = [handler](std::shared_ptr<Event> event) { handler(std::static_pointer_cast<T>(event)); }; subscribers[std::type_index(typeid(T))].push_back(wrapper); } class KeyboardKeyDownEvent : public KeyboardKeyBaseEvent { public: KeyboardKeyDownEvent(uint32_t windowID, Input::KeyCode keyCode); ~KeyboardKeyDownEvent() override = default; }; KeyboardKeyDownEvent::KeyboardKeyDownEvent(uint32_t windowID, Input::KeyCode keyCode) : KeyboardKeyBaseEvent(windowID, keyCode) { priority = 245; }
0b0cd6b0d3b2abe027bf02b34b028ce3
{ "intermediate": 0.7478318214416504, "beginner": 0.19978374242782593, "expert": 0.05238433927297592 }
44,636
import React, { useState } from "react"; import { View, Text, TouchableOpacity, Button } from "react-native"; import { FontAwesome6, Ionicons } from "@expo/vector-icons"; import { AntDesign } from "@expo/vector-icons"; import { supabase } from "../supabase"; import {ActivityIndicator, Card, IconButton, Paragraph} from "react-native-paper"; type FeedsProps = { id: string; title: string; content: string; }; export default function Feeds(id:any) { const [isLiked, setIsLiked] = useState(false); const [loading, setLoading] = React.useState(true); const [feeds, setFeeds] = React.useState([]); try { async function getFeeds() { const {data: any, error} = await supabase .from("feeds") .select("*"); if (error) { console.log("error", error); } setFeeds(data); setLoading(false); } } catch (error) { console.log("error", error); } return ( <View style={{ padding: 20 }} > {loading ? ( <ActivityIndicator animating={true} color="#000"/> ) : ( feeds.map((feed, index) => ( <Card key={index}> <Card.Title title={feed.title} subtitle={feed.content} /> <Card.Content> <Paragraph>{feed.content}</Paragraph> </Card.Content> <Card.Cover source={{ uri: "https://picsum.photos/700" }} /> <Card.Actions> <IconButton icon="heart" color={isLiked ? "red" : "black"} size={20} onPress={() => setIsLiked(!isLiked)} /> <IconButton icon="share" color="black" size={20} onPress={() => console.log("Shared")} /> </Card.Actions> </View> ); const styles = { button: { borderRadius: 25, width: 50, height: 50, backgroundColor: "blue", justifyContent: "center", alignItems: "center", }, buttonText: { color: "white", fontSize: 20, }, }; fix my code add getFeeds
d3f4e23c843861a24b1e30620f85da28
{ "intermediate": 0.4442290961742401, "beginner": 0.32648542523384094, "expert": 0.22928546369075775 }
44,637
help me in creating a pixel art game with pygame, i want it to be a 2D flat game, with the main character being a white cube that casts lights to the dark environment, i want the light coming from the main character to be raytraced, so that they look real, the enviornment shows the path of the light rays and reaction to the light showing relfections in the correspondant surfaces, i do not have an expercience with pygame, but i can trust that you can help me develop this game, don't be limited by the platform's limitation, if you can't generate the full code or you need more information just ask for it, split the code into multiple snippets so that you don't run out of tokens to generate
54867888cc2b295154430cafa1c8eaec
{ "intermediate": 0.5697862505912781, "beginner": 0.25928476452827454, "expert": 0.170928955078125 }
44,638
Write a simple website using HTML, CSS and JavaScript that displays something and it automatically refreshes for every 10 seconds
34f8425039f78f95d58c77a8fa4d139a
{ "intermediate": 0.41604772210121155, "beginner": 0.3163380026817322, "expert": 0.2676142454147339 }
44,639
import React, { useEffect, useState } from "react"; import { ActivityIndicator, View } from "react-native"; import {Card, IconButton, Paragraph} from "react-native-paper"; import {AntDesign, Ionicons} from '@expo/vector-icons'; import { supabase } from "../supabase"; const Feeds = () => { const [feeds, setFeeds] = useState([]); const [isLiked, setIsLiked] = useState(false); const [loading, setLoading] = useState(true); useEffect(() => { getFeeds(); }, []); async function getFeeds() { const {data, error} = await supabase .from('feeds') .select('*'); if (error) { console.log('error', error); } setFeeds(data); console.log('data', data); setLoading(false); } function deleteFeed(id: any) { try { supabase .from('feeds') .delete() .match({id}) .then(response => { console.log('response', response); }) } catch (error) { console.log('error', error); } } return ( <View> {loading ? ( <ActivityIndicator animating={true} color="#000"/> ) : ( feeds.map((feed, index) => ( <Card key={index}> <Card.Title title={feed.title} subtitle={feed.author} style={styles.text} /> <Card.Cover source={{ uri: feed.image }} /> <Card.Content> <Paragraph>{feed.content}</Paragraph> </Card.Content> <Card.Actions> <AntDesign name={isLiked ? "heart" : "hearto"} size={24} color="red" /> <Ionicons name="share-social" size={24} color="black" /> <IconButton icon={() => <AntDesign name="delete" size={24} color="black" />} onPress={() => deleteFeed(feed.id)} /> </Card.Actions> </Card> )) )} </View> ); } export default Feeds; const styles = { container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, text: { fontSize: 20, fontWeight: 'bold', }, }
3bf0957e018e5ba114d57bd41d43081d
{ "intermediate": 0.4601175785064697, "beginner": 0.37778815627098083, "expert": 0.16209420561790466 }
44,640
is there a huge statue of Buddha somewhere along the high speed railway connecting Shanghai and Nanjing, probably very close to the railway, north of it and closer to Shanghai than to Nanjing?
df2a16501bafb9f3479ea493fd15ecc0
{ "intermediate": 0.36047041416168213, "beginner": 0.283189982175827, "expert": 0.35633957386016846 }
44,641
lua_call = 5112 #(lua_call, <func_name>, <num_args>), #Calls the lua function with name <func_name>, using the lua stack to pass <num_args> arguments and to return values. The first argument is pushed first. All arguments get removed from the stack automatically. The last return value will be at the top of the stack.
e219e9b5d68076160ffb612a62b90392
{ "intermediate": 0.37468209862709045, "beginner": 0.3426954448223114, "expert": 0.28262239694595337 }
44,642
module EvalIdExpr ( evalIdExpr, testEvalIdExpr ) where import Test.QuickCheck import Data.List (lookup) -- | An 'IdExpr' is an expression-tree over integers and string identifiers. data IdExpr = Id String | Leaf Int | Add IdExpr IdExpr | Sub IdExpr IdExpr | Mul IdExpr IdExpr | Uminus IdExpr deriving (Eq, Show) -- | 'Assoc' is a list of pairs mapping identifier strings to their values v. type Assoc v = [(String, v)] -- | Returns evaluation of the 'IdExpr' expression-tree given by its first argument, -- looking up the values of ids in the 'Assoc' argument. If an id is not found -- in the 'Assoc' argument, then its value should default to 0. -- -- > evalIdExpr (Leaf 42) [] == 42 -- > evalIdExpr (Add (Leaf 33) (Leaf 22)) [] == 55 -- > evalIdExpr (Sub (Leaf 33) (Leaf 22)) [] == 11 -- > evalIdExpr (Mul (Leaf 31) (Leaf 4)) [] == 124 -- > evalIdExpr (Uminus (Leaf 33)) [] == (-33) -- > evalIdExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) [] == (-200) -- -- > evalIdExpr (Id "a") [("a", 42)] == 42 -- > evalIdExpr (Id "a") [("b", 42)] == 0 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42)] == 42 -- > evalIdExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == 64 -- > evalIdExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c"))) (Id "d"))) [("a", 4), ("b", 3), ("c", 33), ("d", 20)] == (-200) -- -- > quickCheck $ counterexample "random id lookup ok" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1, val1)] == val1 -- > quickCheck $ counterexample "random id lookup fail" $ \ id1 val1 -> evalIdExpr (Id id1) [(id1 ++ "x", val1)] == 0 -- -- > quickCheck $ counterexample "e1 + e2 == e2 + e1" $ \ e1 e2 -> evalIdExpr (Add (Leaf e1) (Leaf e2)) [] == evalIdExpr (Add (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "e1 * e2 == e2 * e1" $ \ e1 e2 -> evalIdExpr (Mul (Leaf e1) (Leaf e2)) [] == evalIdExpr (Mul (Leaf e2) (Leaf e1)) [] -- > quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ \ e1 e2 e3 -> evalIdExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalIdExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3)))
1fbd54d216dd72096f50323113283bf0
{ "intermediate": 0.41782891750335693, "beginner": 0.4033583402633667, "expert": 0.17881275713443756 }
44,643
how to create a knob in a track tcp, in reaper using walter
bebdeb9d1e7837b76022efed7c8829b5
{ "intermediate": 0.3982168436050415, "beginner": 0.1810758262872696, "expert": 0.4207073450088501 }
44,644
module EvalMaybeExpr (evalMaybeExpr, testEvalMaybeExpr) where import Test.QuickCheck import Data.List (lookup) data MaybeExpr = Id String | Leaf Int | Add MaybeExpr MaybeExpr | Sub MaybeExpr MaybeExpr | Mul MaybeExpr MaybeExpr | Uminus MaybeExpr deriving (Eq, Show) type Assoc a = [ (String, a) ] -- Return a Maybe wrapping the results of evaluating expr, looking up -- id's in assoc. If an id is not found in assoc, then the function -- should return Nothing. evalMaybeExpr :: MaybeExpr -> Assoc Int -> Maybe Int evalMaybeExpr (Id x) env = lookup x env evalMaybeExpr (Leaf x) _ = Just x evalMaybeExpr (Add e1 e2) env = liftA2 (+) (evalMaybeExpr e1 env) (evalMaybeExpr e2 env) evalMaybeExpr (Sub e1 e2) env = liftA2 (-) (evalMaybeExpr e1 env) (evalMaybeExpr e2 env) evalMaybeExpr (Mul e1 e2) env = liftA2 (*) (evalMaybeExpr e1 env) (evalMaybeExpr e2 env) evalMaybeExpr (Uminus e) env = fmap negate (evalMaybeExpr e env) testEvalMaybeExpr = do print "**** test evalMaybeExpr" -- Unit Tests quickCheck $ counterexample "Leaf" $ evalMaybeExpr (Leaf 42) [] == Just 42 quickCheck $ counterexample "Add" $ evalMaybeExpr (Add (Leaf 33) (Leaf 22)) [] == Just 55 quickCheck $ counterexample "Sub" $ evalMaybeExpr (Sub (Leaf 33) (Leaf 22)) [] == Just 11 quickCheck $ counterexample "Mul" $ evalMaybeExpr (Mul (Leaf 31) (Leaf 4)) [] == Just 124 quickCheck $ counterexample "Uminus" $ evalMaybeExpr (Uminus (Leaf 33)) [] == Just (-33) quickCheck $ counterexample "Complex" $ evalMaybeExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))))) [] == Just (-200) -- ID unit tests quickCheck $ counterexample "OK id lookup" $ evalMaybeExpr (Id "a") [("a", 42)] == Just 42 quickCheck $ counterexample "Fail id lookup" $ evalMaybeExpr (Id "a") [("b", 42)] == Nothing quickCheck $ counterexample "ID lookup: a: OK, b: Fail" $ evalMaybeExpr (Add (Id "a") (Id "b")) [("a", 42)] == Nothing quickCheck $ counterexample "ID lookup: a: OK, b: OK" $ evalMaybeExpr (Add (Id "a") (Id "b")) [("a", 42), ("b", 22)] == Just 64 quickCheck $ counterexample "Complex ID lookup" $ evalMaybeExpr (Mul (Id "a") (Sub (Add (Id "b") (Uminus (Id "c")))) [("a", 4), ("b", 3), ("c", 33), ("d", 20))] == Just (-200) -- Property-Based Tests -- ID Lookup quickCheck $ counterexample "Random ID lookup OK" $ (\id1 val1 -> evalMaybeExpr (Id id1) [(id1, val1)] == Just val1) quickCheck $ counterexample "Random ID lookup Fail" $ (\id1 val1 -> evalMaybeExpr (Id id1) [(id1 ++ "x", val1)] == Nothing) -- Commmutativity quickCheck $ counterexample "e1 + e2 == e2 + e1" $ (\e1 e2 -> evalMaybeExpr (Add (Leaf e1) (Leaf e2)) [] == evalMaybeExpr (Add (Leaf e2) (Leaf e1)) []) quickCheck $ counterexample "e1 * e2 == e2 * e1" $ (\e1 e2 -> evalMaybeExpr (Mul (Leaf e1) (Leaf e2)) [] == evalMaybeExpr (Mul (Leaf e2) (Leaf e1)) []) -- Associativity quickCheck $ counterexample "(e1 + e2) + e3 == e1 + (e2 + e3)" $ (\e1 e2 e3 -> evalMaybeExpr (Add (Add (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalMaybeExpr (Add (Leaf e1) (Add (Leaf e2) (Leaf e3))) []) quickCheck $ counterexample "(e1 * e2) * e3 == e1 * (e2 * e3)" $ (\e1 e2 e3 -> evalMaybeExpr (Mul (Mul (Leaf e1) (Leaf e2)) (Leaf e3)) [] == evalMaybeExpr (Mul (Leaf e1) (Mul (Leaf e2) (Leaf e3))) []) -- Subtraction quickCheck $ counterexample "e1 - e2 = -1*(e2 - e1)" $ (\e1 e2 -> evalMaybeExpr (Sub (Leaf e1) (Leaf e2)) [] == evalMaybeExpr (Mul (Leaf (-1)) (Sub (Leaf e2) (Leaf e1))) []) -- Distributivity quickCheck $ counterexample "e1 * (e2 + e3) == e1e2 + e1e3" $ (\e1 e2 e3 -> evalMaybeExpr (Mul (Leaf e1) (Add (Leaf e2) (Leaf e3))) [] == evalMaybeExpr (Add (Mul (Leaf e1) (Leaf e2)) (Mul (Leaf e1) (Leaf e3))) []) quickCheck $ counterexample "e1 * (e2 - e3) == e1e2 - e1e3" $ (\e1 e2 e3 -> evalMaybeExpr (Mul (Leaf e1) (Sub (Leaf e2) (Leaf e3))) [] == evalMaybeExpr (Sub (Mul (Leaf e1) (Leaf e2)) (Mul (Leaf e1) (Leaf e3))) []) When I'm running the above program I'm getting the error as ghci> :l "Main.hs" [1 of 6] Compiling EvalIdExpr ( EvalIdExpr.hs, interpreted ) [2 of 6] Compiling EvalIntExpr ( EvalIntExpr.hs, interpreted ) [3 of 6] Compiling EvalMaybeExpr ( EvalMaybeExpr.hs, interpreted ) EvalMaybeExpr.hs:58:57: error: parse error on input ‘)’ | 58 | [("a", 4), ("b", 3), ("c", 33), ("d", 20))] == Just (-200) | ^ Failed, two modules loaded. Fix the error and write the correct code
b76a97b8d6b551e0766829882f2654fe
{ "intermediate": 0.3244713246822357, "beginner": 0.5115814208984375, "expert": 0.1639472246170044 }
44,645
import random import difflib from transformers import BertTokenizer, BertForMaskedLM import torch tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') model = BertForMaskedLM.from_pretrained('bert-base-uncased') def get_bert_response(input_text): # Токенизация входного текста input_tokens = tokenizer.encode(input_text, return_tensors='pt') # Предсказание маскированных токенов with torch.no_grad(): outputs = model(input_tokens) predictions = outputs[0] # Получение индекса предсказанного токена predicted_index = torch.argmax(predictions[0, -1, :]).item() predicted_token = tokenizer.convert_ids_to_tokens([predicted_index])[0] return predicted_token # Пример использования input_text = "Let's see how this [MASK] works." predicted_token = get_bert_response(input_text) print(f"Predicted token: {predicted_token}") def load_responses(file_path): responses = {} with open(file_path, 'r', encoding='utf-8') as file: for line in file: parts = line.strip().split(':') if len(parts) >= 2: key = parts[0].strip() values = [value.strip() for value in parts[1:]] responses[key] = values return responses greetings = ["Привет!", "Приветствую!", "Здравствуй!"] file_path = "C:/Users/User/Documents/conversation.txt" responses = load_responses(file_path) def get_closest_match(input_str, options): matches = difflib.get_close_matches(input_str, options, n=1, cutoff=0.6) return matches[0] if matches else None def chatbot_response(user_input): if user_input in responses: return random.choice(responses[user_input]) closest_match = get_closest_match(user_input, responses.keys()) return random.choice(responses[closest_match]) if closest_match else "Извини, я не понимаю. Попробуйте спросить что-то другое." print("Привет! Я чат-бот. Поговори со мной!") while True: user_input = input("Вы: ") print("Бот:", chatbot_response(user_input)) перепиши улучшенный код добавь больше разума для улучшения сровнения строк данных с сообщением от пользователя
812ef9e0383f2474fdb7ad6c3b2ad31a
{ "intermediate": 0.39654266834259033, "beginner": 0.3947453796863556, "expert": 0.20871196687221527 }
44,646
import random import difflib from transformers import BertTokenizer, BertForMaskedLM import torch tokenizer = BertTokenizer.from_pretrained(‘bert-base-uncased’) model = BertForMaskedLM.from_pretrained(‘bert-base-uncased’) def get_bert_response(input_text): # Токенизация входного текста input_tokens = tokenizer.encode(input_text, return_tensors=‘pt’) # Предсказание маскированных токенов with torch.no_grad(): outputs = model(input_tokens) predictions = outputs[0] # Получение индекса предсказанного токена predicted_index = torch.argmax(predictions[0, -1, :]).item() predicted_token = tokenizer.convert_ids_to_tokens([predicted_index])[0] return predicted_token # Пример использования input_text = “Let’s see how this [MASK] works.” predicted_token = get_bert_response(input_text) print(f"Predicted token: {predicted_token}") def load_responses(file_path): responses = {} with open(file_path, ‘r’, encoding=‘utf-8’) as file: for line in file: parts = line.strip().split(‘:’) if len(parts) >= 2: key = parts[0].strip() values = [value.strip() for value in parts[1:]] responses[key] = values return responses greetings = [“Привет!”, “Приветствую!”, “Здравствуй!”] file_path = “C:/Users/User/Documents/conversation.txt” responses = load_responses(file_path) def get_closest_match(input_str, options): matches = difflib.get_close_matches(input_str, options, n=1, cutoff=0.6) return matches[0] if matches else None def chatbot_response(user_input): if user_input in responses: return random.choice(responses[user_input]) closest_match = get_closest_match(user_input, responses.keys()) return random.choice(responses[closest_match]) if closest_match else “Извини, я не понимаю. Попробуйте спросить что-то другое.” print(“Привет! Я чат-бот. Поговори со мной!”) while True: user_input = input("Вы: ") print(“Бот:”, chatbot_response(user_input)) перепиши улучшенный код добавь больше разума для улучшения сровнения строк данных с сообщением от пользователя
d59b1e7c9a4daf69bcd5f83e60d2c70e
{ "intermediate": 0.38464462757110596, "beginner": 0.3839178681373596, "expert": 0.2314375936985016 }
44,647
import Test.QuickCheck data PostfixExpr = Leaf Int | Add PostfixExpr PostfixExpr | Sub PostfixExpr PostfixExpr | Mul PostfixExpr PostfixExpr | Uminus PostfixExpr deriving (Eq, Show) postfixExpr :: String -> PostfixExpr postfixExpr str = foldl evalOp (Leaf 0) (words str) where evalOp acc op = case op of "+" -> Add acc (popStack) "-" -> Sub acc (popStack) "*" -> Mul acc (popStack) "uminus" -> Uminus acc num -> pushStack (Leaf (read num)) popStack = head exprs pushStack expr = expr : exprs exprs = tail $ reverse $ filter (/= "") $ words str testPostfixExpr = do print "******* test postfixExpr" quickCheck $ counterexample "Leaf" $ postfixExpr "42" == (Leaf 42) quickCheck $ counterexample "Add" $ postfixExpr "33 22 +" == (Add (Leaf 33) (Leaf 22)) quickCheck $ counterexample "Sub" $ postfixExpr "33 22 -" == (Sub (Leaf 33) (Leaf 22)) quickCheck $ counterexample "Mul" $ postfixExpr "31 4 *" == (Mul (Leaf 31) (Leaf 4)) quickCheck $ counterexample "Uminus" $ postfixExpr "33 uminus" == (Uminus (Leaf 33)) quickCheck $ counterexample "Complex" $ postfixExpr "4 3 33 uminus + 20 - *" == (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20)))
e4c7fc91bebc1293a41c0b2cf8dcf981
{ "intermediate": 0.32921740412712097, "beginner": 0.4694843292236328, "expert": 0.2012982815504074 }
44,648
module PostfixExpr ( postfixExpr, testPostfixExpr, PostfixExpr(..) ) where import Test.QuickCheck a PostFixExpr is an expression tree over integers data PostfixExpr = Leaf Int | Add PostfixExpr PostfixExpr | Sub PostfixExpr PostfixExpr | Mul PostfixExpr PostfixExpr | Uminus PostfixExpr deriving (Eq, Show) Given a string postfix containing a postfix expression involving integers, the usual binary arithmetic operators "+", "-", "*" as well as "uminus", return the corresponding PostfixExpr. You may disregard errors. Hints: + Use the Haskell function (words postfix) to split the postfix string into String tokens. + Iterate through the tokens using a [PostfixExpr] stack to track the currently unprocessed PostfixExpr's. + At each step of the iteration, look at the first unprocessed token: + If it is a string representing an operator, then replace its operands from the head of the stack with the PostfixExpr corresponding to the operator combined with its operands from the stack. + If the current unprocessed token is not an operator, assume it is an Int and use (read token) to build it into a Leaf. + Use pattern matching to match different types of tokens and to extract PostfixExpr operands from the head of the stack. + Use a local auxiliary function to perform each step of the iteration. + You can use a recursive implementation of the top-level function. But what is recommended is to set up your auxiliary function so that you can use it to foldl the token list into an accumulator representing the stack of unprocessed PostfixExpr's. + When there are no unprocessed tokens, the stack should contain a single PostfixExpr containing the value to be returned. postfixExpr :: String -> PostfixExpr postfixExpr _ = error "TODO" testPostfixExpr = do print "******* test postfixExpr" quickCheck $ counterexample "Leaf" $ postfixExpr "42" == (Leaf 42) quickCheck $ counterexample "Add" $ postfixExpr "33 22 +" == (Add (Leaf 33) (Leaf 22)) quickCheck $ counterexample "Sub" $ postfixExpr "33 22 -" == (Sub (Leaf 33) (Leaf 22)) quickCheck $ counterexample "Mul" $ postfixExpr "31 4 *" == (Mul (Leaf 31) (Leaf 4)) quickCheck $ counterexample "Uminus" $ postfixExpr "33 uminus" == (Uminus (Leaf 33)) quickCheck $ counterexample "Complex" $ postfixExpr "4 3 33 uminus + 20 - *" == (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20)))
a996039b15c79e7c215ca08eb480bbae
{ "intermediate": 0.5267694592475891, "beginner": 0.29092127084732056, "expert": 0.18230919539928436 }
44,649
hi i wanna connect an app to my telegram account to auto respond and more via python
1f2b1afade903308a6a6837cb87e17e8
{ "intermediate": 0.6141078472137451, "beginner": 0.10791613161563873, "expert": 0.2779760956764221 }
44,650
I get this error: Traceback (most recent call last): File "c:\Users\L14\Documents\Projets\My_Game\main.py", line 20, in <module> main() File "c:\Users\L14\Documents\Projets\My_Game\main.py", line 15, in main game_instance.run() File "c:\Users\L14\Documents\Projets\My_Game\game.py", line 86, in run self.draw_orb_light((self.screen), orb_center_pos, 30) TypeError: Game.draw_orb_light() takes 3 positional arguments but 4 were given ;when i run this code: import pygame from game import Game from settings import SCREEN_WIDTH, SCREEN_HEIGHT def main(): # Initialize Pygame pygame.init() # Set up the display screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Game Title") # Initialize and run the game game_instance = Game(screen) game_instance.run() pygame.quit() if __name__ == '__main__': main() ;This is the code inside game.py : import pygame import random import math from settings import * class Game: def __init__(self, screen): self.screen = screen self.running = False self.cube_pos = [SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2] self.cube_size = 20 self.cube_speed = 2 self.light_orb = (random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)) self.player_score = 0 self.ai_score = 0 self.ai_pos = [random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)] self.ai_size = 20 self.ai_speed = 0.1 self.font = pygame.font.SysFont(None, 24) def draw_scores(self, player_score, ai_score): score_text = self.font.render(f"Player: {player_score} | AI: {ai_score}", True, WHITE) self.screen.blit(score_text, (10, 10)) def move_towards(self, ai_pos, target_pos, speed): dx, dy = target_pos[0] - ai_pos[0], target_pos[1] - ai_pos[1] dist = max(math.sqrt(dx ** 2 + dy ** 2), 1) move_dx, move_dy = dx / dist * speed, dy / dist * speed return [ai_pos[0] + move_dx, ai_pos[1] + move_dy] def draw_player_light(self, position, max_radius): step = 255 // max_radius for i in range(max_radius): radius = max_radius - i alpha = 255 - (i * step) surface = pygame.Surface((2*radius, 2*radius), pygame.SRCALPHA) pygame.draw.circle(surface, (255, 255, 255, alpha), (radius, radius), radius) self.screen.blit(surface, (position[0] - radius, position[1] - radius)) def draw_orb_light(self, position, max_radius): step = 255 // max_radius for i in range(max_radius): radius = max_radius - i alpha = 255 - (i * step) color = (255 - 255*(i/max_radius), 255 - 255*(i/max_radius), 0, alpha) surface = pygame.Surface((2*radius, 2*radius), pygame.SRCALPHA) pygame.draw.circle(surface, color, (radius, radius), radius) self.screen.blit(surface, (position[0] - radius, position[1] - radius)) def run(self): self.running = True while self.running: for event in pygame.event.get(): if event.type == pygame.QUIT: self.running = False self.screen.fill(BLACK) keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: self.cube_pos[0] -= self.cube_speed if keys[pygame.K_RIGHT]: self.cube_pos[0] += self.cube_speed if keys[pygame.K_UP]: self.cube_pos[1] -= self.cube_speed if keys[pygame.K_DOWN]: self.cube_pos[1] += self.cube_speed cube_rect = pygame.Rect(self.cube_pos[0], self.cube_pos[1], self.cube_size, self.cube_size) self.cube_pos[0] = max(min(self.cube_pos[0], SCREEN_WIDTH - self.cube_size), 0) self.cube_pos[1] = max(min(self.cube_pos[1], SCREEN_HEIGHT - self.cube_size), 0) pygame.draw.rect(self.screen, WHITE, cube_rect) self.ai_pos = self.move_towards(self.ai_pos, self.light_orb, self.ai_speed) pygame.draw.rect(self.screen, (255, 0, 0), (*self.ai_pos, self.ai_size, self.ai_size)) self.ai_pos = ( max(min(self.ai_pos[0], SCREEN_WIDTH - self.ai_size), 0), max(min(self.ai_pos[1], SCREEN_HEIGHT - self.ai_size), 0) ) orb_center_pos = (self.light_orb[0], self.light_orb[1]) self.draw_orb_light((self.screen), orb_center_pos, 30) player_center_pos = (self.cube_pos[0] + self.cube_size // 2, self.cube_pos[1] + self.cube_size // 2) self.draw_player_light(self.screen, player_center_pos, 50) orb_rect = pygame.Rect(self.light_orb[0] - 5, self.light_orb[1] - 5, 10, 10) if cube_rect.colliderect(orb_rect): self.player_score += 1 self.light_orb = (random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)) elif orb_rect.collidepoint(self.ai_pos): self.ai_score += 1 self.light_orb = (random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)) self.draw_scores(self.screen, self.player_score, self.ai_score) pygame.display.flip()
8977ed1d9a54b5f2a24754eee5d6305e
{ "intermediate": 0.36244919896125793, "beginner": 0.45169761776924133, "expert": 0.18585319817066193 }
44,651
This is the content of game.py file, and i want to use modernGL to give my game a better look by utilizing shaders, don't be limited by the platform limitations, split the code generation if you run out of tokens, here is the code of game.py: import pygame import random import math from settings import * class Particle: def __init__(self, x, y, color, ttl=90): self.x = x self.y = y self.color = color self.ttl = ttl # Time to live, in frames self.vel = pygame.math.Vector2(random.uniform(-2, 2), random.uniform(-2, 2)) # Random velocity def update(self): self.x += self.vel.x self.y += self.vel.y self.ttl -= 1 # Decrease life time def draw(self, screen): if self.ttl > 0: pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), 3) class Game: def __init__(self, screen): self.screen = screen self.running = False self.cube_pos = [SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2] self.cube_size = 20 self.cube_speed = 2 self.light_orb = (random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)) self.player_score = 0 self.ai_score = 0 self.ai_pos = [random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)] self.ai_size = 20 self.ai_speed = 0.1 self.font = pygame.font.SysFont(None, 24) self.particles = [] def draw_scores(self, player_score, ai_score): score_text = self.font.render(f"Player: {player_score} | AI: {ai_score}", True, WHITE) self.screen.blit(score_text, (10, 10)) def move_towards(self, ai_pos, target_pos, speed): dx, dy = target_pos[0] - ai_pos[0], target_pos[1] - ai_pos[1] dist = max(math.sqrt(dx ** 2 + dy ** 2), 1) move_dx, move_dy = dx / dist * speed, dy / dist * speed return [ai_pos[0] + move_dx, ai_pos[1] + move_dy] def draw_player_light(self, position, max_radius): step = 255 // max_radius for i in range(max_radius): radius = max_radius - i alpha = 255 - (i * step) surface = pygame.Surface((2*radius, 2*radius), pygame.SRCALPHA) pygame.draw.circle(surface, (255, 255, 255, alpha), (radius, radius), radius) self.screen.blit(surface, (position[0] - radius, position[1] - radius)) def draw_orb_light(self, position, max_radius): step = 255 // max_radius for i in range(max_radius): radius = max_radius - i alpha = 255 - (i * step) color = (255 - 255*(i/max_radius), 255 - 255*(i/max_radius), 0, alpha) surface = pygame.Surface((2*radius, 2*radius), pygame.SRCALPHA) pygame.draw.circle(surface, color, (radius, radius), radius) self.screen.blit(surface, (position[0] - radius, position[1] - radius)) def resolve_collision(self, rect1, rect2): # A simplistic approach to simulate physics by exchanging velocities temp_speed = self.cube_speed self.cube_speed = self.ai_speed self.ai_speed = temp_speed # Adjust positions slightly to avoid sticking if rect1.x < rect2.x: rect1.x -= 10 rect2.x += 10 else: rect1.x += 10 rect2.x -= 10 def run(self): self.running = True while self.running: for event in pygame.event.get(): if event.type == pygame.QUIT: self.running = False self.screen.fill(BLACK) keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: self.cube_pos[0] -= self.cube_speed if keys[pygame.K_RIGHT]: self.cube_pos[0] += self.cube_speed if keys[pygame.K_UP]: self.cube_pos[1] -= self.cube_speed if keys[pygame.K_DOWN]: self.cube_pos[1] += self.cube_speed cube_rect = pygame.Rect(self.cube_pos[0], self.cube_pos[1], self.cube_size, self.cube_size) ai_rect = pygame.Rect(self.ai_pos[0], self.ai_pos[1], self.ai_size, self.ai_size) # Check for collision and resolve if cube_rect.colliderect(ai_rect): self.resolve_collision(cube_rect, ai_rect) self.cube_pos[0] = max(min(self.cube_pos[0], SCREEN_WIDTH - self.cube_size), 0) self.cube_pos[1] = max(min(self.cube_pos[1], SCREEN_HEIGHT - self.cube_size), 0) pygame.draw.rect(self.screen, WHITE, cube_rect) self.ai_pos = self.move_towards(self.ai_pos, self.light_orb, self.ai_speed) pygame.draw.rect(self.screen, (255, 0, 0), (*self.ai_pos, self.ai_size, self.ai_size)) self.ai_pos = ( max(min(self.ai_pos[0], SCREEN_WIDTH - self.ai_size), 0), max(min(self.ai_pos[1], SCREEN_HEIGHT - self.ai_size), 0) ) orb_center_pos = (self.light_orb[0], self.light_orb[1]) self.draw_orb_light(orb_center_pos, 30) player_center_pos = (self.cube_pos[0] + self.cube_size // 2, self.cube_pos[1] + self.cube_size // 2) self.draw_player_light(player_center_pos, 20) orb_rect = pygame.Rect(self.light_orb[0] - 5, self.light_orb[1] - 5, 10, 10) # Inside the collision detection section for the light orb if cube_rect.colliderect(orb_rect): self.player_score += 1 if ai_rect.colliderect(orb_rect): self.ai_score += 1 # Generate particles for _ in range(80): # Number of particles self.particles.append(Particle(orb_center_pos[0], orb_center_pos[1], (255, 255, 255))) # Yellow particles self.light_orb = (random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT)) # Updating particles for particle in self.particles[:]: particle.update() if particle.ttl <= 0: self.particles.remove(particle) # Drawing particles for particle in self.particles: particle.draw(self.screen) self.draw_scores(self.player_score, self.ai_score) pygame.display.flip()
8c0713850159f5cdc80f0e4fd985d104
{ "intermediate": 0.4343327283859253, "beginner": 0.3615531623363495, "expert": 0.20411410927772522 }
44,652
module Main (main) where import TestUtils import EvalIntExpr (testEvalIntExpr) import EvalIdExpr (testEvalIdExpr) import EvalMaybeExpr (testEvalMaybeExpr) import PostfixExpr (testPostfixExpr) import Test.QuickCheck toSingletonLists :: [e] -> [[e]] toSingletonLists _ = error "TODO" testToSingletonLists = do print "******* toSingletonLists" quickCheck $ counterexample "ints" $ toSingletonLists [ 5, 7, 2 ] == [ [5], [7], [2] ] quickCheck $ counterexample "chars" $ toSingletonLists [ 'a', 'x', 'd' ] == [ "a", "x", "d" ] quickCheck $ counterexample "empty" $ toSingletonLists [] == ([] :: [[Int]]) listMap :: (a -> b -> c) -> a -> [b] -> [c] listMap _ _ _ = error "TODO" testListMap = do print "******* listMap" quickCheck $ counterexample "add" $ listMap (+) 5 [1, 2, 3] == [6, 7, 8] quickCheck $ counterexample "sub" $ listMap (-) 5 [1, 2, 3] == [4, 3, 2] quickCheck $ counterexample "mul" $ listMap (*) 5 [1, 2, 3] == [5, 10, 15] quickCheck $ counterexample "empty" $ listMap (-) 5 [] == [] member :: Eq e => e -> [e] -> Bool member _ _ = error "TODO" testMember = do print "******* member" quickCheck $ counterexample "ints first" $ member 5 [ 5, 7, 2 ] == True quickCheck $ counterexample "ints last" $ member 2 [ 5, 7, 2 ] == True quickCheck $ counterexample "ints mid" $ member 7 [ 5, 7, 2 ] == True quickCheck $ counterexample "ints fail" $ member 4 [ 5, 7, 2 ] == False quickCheck $ counterexample "empty" $ member 4 [] == False selectNApart :: Int -> [e] -> [e] selectNApart _ _ = error "TODO" testSelectNApart = do print "******* selectNApart" quickCheck $ counterexample "2-apart" $ selectNApart 2 [0..10] == [0, 2, 4, 6, 8, 10] quickCheck $ counterexample "2-apart chars" $ selectNApart 2 ['a'..'z'] == "acegikmoqsuwy" quickCheck $ counterexample "3-apart" $ selectNApart 3 [0..20] == [0, 3, 6, 9, 12, 15, 18] quickCheck $ counterexample "5-apart" $ selectNApart 5 [0..21] == [0, 5, 10, 15, 20] quickCheck $ counterexample "empty" $ selectNApart 5 ([]::[Int]) == [] ------------------------ Functions in Separate Files -------------------- -- #5: 15-points -- implement the specified function in EvalIntExpr.hs -- #6: 15-points -- implement the specified function in EvalIdExpr.hs -- #7: 20-points -- implement the specified function in EvalMaybeExpr.hs -- #8: 20-points -- implement the specified function in PostfixExpr.hs allTests = [ (Skip testToSingletonLists), (Skip testListMap), (Skip testMember), (Skip testSelectNApart), (Skip testEvalIntExpr), (Skip testEvalIdExpr), (Skip testEvalMaybeExpr), (Skip testPostfixExpr) ] main = do mapM_ id tests where only = onlyTests allTests tests = if (length only > 0) then only else runTests allTests For toSingletonLists use the map function to transform a list of elements e into a list of singleton lists [e]. Must use map only. Hint: use map with a section. For listMap return a list containing f a b for each element b in list. Hint: use the map function or a list comprehension For member use foldl to implement member e list which returns True if e is a member of list. Must use foldl only, cannot use elem Hint: define folding function using a lambda or local let/where definition. For selectNApart, Given an Int n and a list of elements e, return a list containing the elements of the list at index 0, n, 2n, 3n, 4n, and so on Hint: use drop For Tests, Can mark test suites with following test statuses: Only: run only these tests and other tests marked Only. Run: run these tests when no tests are marked Only. Skip: skip these tests. Ensure that all test suites are set to Run.
df0978140a9f243e8d20547d647ac235
{ "intermediate": 0.34335896372795105, "beginner": 0.45357275009155273, "expert": 0.20306828618049622 }
44,653
module Main (main) where import TestUtils import EvalIntExpr (testEvalIntExpr) import EvalIdExpr (testEvalIdExpr) import EvalMaybeExpr (testEvalMaybeExpr) import PostfixExpr (testPostfixExpr) import Test.QuickCheck toSingletonLists :: [e] -> [[e]] toSingletonLists = map (\x -> [x]) testToSingletonLists = do print "******* toSingletonLists" quickCheck $ counterexample "ints" $ toSingletonLists [ 5, 7, 2 ] == [ [5], [7], [2] ] quickCheck $ counterexample "chars" $ toSingletonLists [ 'a', 'x', 'd' ] == [ "a", "x", "d" ] quickCheck $ counterexample "empty" $ toSingletonLists [] == ([] :: [[Int]]) listMap :: (a -> b -> c) -> a -> [b] -> [c] listMap f a = map (f a) testListMap = do print "******* listMap" quickCheck $ counterexample "add" $ listMap (+) 5 [1, 2, 3] == [6, 7, 8] quickCheck $ counterexample "sub" $ listMap (-) 5 [1, 2, 3] == [4, 3, 2] quickCheck $ counterexample "mul" $ listMap (*) 5 [1, 2, 3] == [5, 10, 15] quickCheck $ counterexample "empty" $ listMap (-) 5 [] == [] member :: Eq e => e -> [e] -> Bool member e = foldl (\acc x -> acc || x == e) False testMember = do print "******* member" quickCheck $ counterexample "ints first" $ member 5 [ 5, 7, 2 ] == True quickCheck $ counterexample "ints last" $ member 2 [ 5, 7, 2 ] == True quickCheck $ counterexample "ints mid" $ member 7 [ 5, 7, 2 ] == True quickCheck $ counterexample "ints fail" $ member 4 [ 5, 7, 2 ] == False quickCheck $ counterexample "empty" $ member 4 [] == False selectNApart :: Int -> [e] -> [e] selectNApart n xs = map snd $ filter (\(i, _) -> i `mod` n == 0) $ zip [0..] xs testSelectNApart = do print "******* selectNApart" quickCheck $ counterexample "2-apart" $ selectNApart 2 [0..10] == [0, 2, 4, 6, 8, 10] quickCheck $ counterexample "2-apart chars" $ selectNApart 2 ['a'..'z'] == "acegikmoqsuwy" quickCheck $ counterexample "3-apart" $ selectNApart 3 [0..20] == [0, 3, 6, 9, 12, 15, 18] quickCheck $ counterexample "5-apart" $ selectNApart 5 [0..21] == [0, 5, 10, 15, 20] quickCheck $ counterexample "empty" $ selectNApart 5 ([]::[Int]) == [] ------------------------ Functions in Separate Files -------------------- -- #5: 15-points -- implement the specified function in EvalIntExpr.hs -- #6: 15-points -- implement the specified function in EvalIdExpr.hs -- #7: 20-points -- implement the specified function in EvalMaybeExpr.hs -- #8: 20-points -- implement the specified function in PostfixExpr.hs allTests = [ (Run testToSingletonLists), (Run testListMap), (Run testMember), (Run testSelectNApart), (Skip testEvalIntExpr), (Skip testEvalIdExpr), (Skip testEvalMaybeExpr), (Skip testPostfixExpr) ] main = do mapM_ id tests where only = onlyTests allTests tests = if (length only > 0) then only else runTests allTests
9df4f7c573140764d1b3a29f96bf35fe
{ "intermediate": 0.35125982761383057, "beginner": 0.5001527667045593, "expert": 0.1485874205827713 }
44,654
i want to backup ubuntu users with their password and then restore it
7dca2360ed8da77d6fcd42f8ab2eaa14
{ "intermediate": 0.349688857793808, "beginner": 0.23447497189044952, "expert": 0.4158361852169037 }
44,655
write code for an app for windows 10 for a quick preview of video files .mov. the app opens preview of a video file in explorer by pressing spacebar. pressing <;> makes video jump forward 10 frames. pressing <l> makes video jump backward 10 frames. pressing <p> makes video pause.pressing <p> again makes video play again. pressing <alt> makes video rotate 180 degree instantly. pressing spacebar again closes preview and returns focus back to the explorer app.
7b3e12e1fb10b04db93b751a4554f48f
{ "intermediate": 0.43499037623405457, "beginner": 0.20864877104759216, "expert": 0.3563608229160309 }
44,656
check this code: #[arg( long = "ignore-exon", help = "Flag to ignore upstream 5' end", default_missing_value("true"), default_value("false"), num_args(0..=1), require_equals(true), action = ArgAction::Set, )] pub skip_exon: bool, #[arg( long = "var-five-end", help = "Number of nucleotides to ignore from 5' end", value_name = "FLAG", default_value_t = 0, require )] pub nt_5_end: usize, I want to make the following: If ignore-exon is true (if --ignore-exon is specified), var-five-end should not be specified
1d202eeaa339a3f67170d2c229398eb5
{ "intermediate": 0.3537060022354126, "beginner": 0.4664449691772461, "expert": 0.17984899878501892 }
44,657
Hi, how are you?
593b0dcbc63150b2491a56bb107c26cd
{ "intermediate": 0.39029815793037415, "beginner": 0.2846156358718872, "expert": 0.32508620619773865 }
44,658
How to create uml editing software in C#
81b734624bb229da7fad51ddaa066c3a
{ "intermediate": 0.3679986000061035, "beginner": 0.388400137424469, "expert": 0.2436012625694275 }
44,659
write an ahk script that presses \ every 3-3.05 seconds and is turned off or paused with ]
a292a3390cf86e62b127f1a9c21df211
{ "intermediate": 0.2866865396499634, "beginner": 0.23431448638439178, "expert": 0.47899895906448364 }
44,660
i have a csv file i want to delete some of its columns i want to delete columns between: c1_h_volume_adi to c1_h_hist_short_long c2_h_volume_adi to c2_h_hist_short_long ... c24_h_volume_adi to c24_h_hist_short_long give me proper python code
6379351ff4f3b7891782bee4d5b7e61d
{ "intermediate": 0.35351064801216125, "beginner": 0.42762047052383423, "expert": 0.21886885166168213 }
44,661
i have 340 historical data files each has between 1000 rows i want to train a general LSTM model on all of them , i have a column "y_2d" that i want the model to predict it for each row i want the window size to be 30 i dont want to merge all csv files give me the proper python code
26fa452c2fc441c0e1af412620831fb0
{ "intermediate": 0.3200507164001465, "beginner": 0.1353309005498886, "expert": 0.5446184277534485 }
44,662
I created new files for Rasa: nlu.yml, rules.yml, stories.yml, actions.py. How do I proceed?
5f384e251cdaa9bc76a57f56ebbb30f8
{ "intermediate": 0.4175052046775818, "beginner": 0.22362324595451355, "expert": 0.3588714897632599 }
44,663
i have a csv file i want to drop between 2 column give me proper python code
58496eab219e4e28277f2705e212d9a5
{ "intermediate": 0.4119412899017334, "beginner": 0.28377431631088257, "expert": 0.30428439378738403 }
44,664
i have a problem can you help me?
4adc72d7f7e1d636fad64ddb386e132f
{ "intermediate": 0.39149391651153564, "beginner": 0.28812581300735474, "expert": 0.3203803300857544 }
44,665
create pentagram in vanilla html code with five independed tringles. align each triangle in 72 deg correctly clockwise. output vanilla html and corresponding css stylings code.
11b10756fd98e3f578f519f4e2268914
{ "intermediate": 0.4747534990310669, "beginner": 0.2169191986322403, "expert": 0.3083272874355316 }
44,666
create pentagram in vanilla html code with five independed tringles. align each triangle in 72 deg correctly clockwise. output vanilla html and corresponding css stylings code. Creating a pentagram using HTML and CSS by aligning five independent triangles at 72-degree intervals can be a bit intricate because CSS does not directly support drawing triangles through a straightforward property. Instead, you can use the CSS border trick to create triangles and then rotate and position them to form a pentagram. Here is a simple way to achieve this by creating a container for the pentagram and then adding five divs, each representing a triangle. Each triangle is then rotated and positioned appropriately to form the pentagram. ### HTML <!DOCTYPE html> <html lang=“en”> <head> <meta charset=“UTF-8”> <title>Pentagram</title> <link rel=“stylesheet” href=“style.css”> </head> <body> <div class=“pentagram”> <div class=“triangle” style=“–rotation: 0deg;”></div> <div class=“triangle” style=“–rotation: 72deg;”></div> <div class=“triangle” style=“–rotation: 144deg;”></div> <div class=“triangle” style=“–rotation: 216deg;”></div> <div class=“triangle” style=“–rotation: 288deg;”></div> </div> </body> </html> ### CSS (style.css) body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #f0f0f0; } .pentagram { position: relative; width: 200px; height: 200px; } .triangle { --size: 90px; position: absolute; width: 0; height: 0; border-left: calc(var(–size) / 2) solid transparent; border-right: calc(var(–size) / 2) solid transparent; border-bottom: var(–size) solid black; /* Change color if needed */ transform-origin: 50% 100%; transform: rotate(var(–rotation)) translateY(-35%); } This example shows how to create a pentagram by using pure HTML and CSS. Here’s how it works: 1. The .pentagram class forms a container for the entire shape. It’s sized and positioned to center the pentagram on the page. 2. Each .triangle represents one of the vertices of the pentagram. They’re created using the CSS trick of setting borders on an element with a 0 width and height. The borders are manipulated in such a way that they appear as triangles. 3. A custom property (--rotation) is used to rotate each triangle the correct amount. The triangles are rotated around their bottom point using transform-origin. 4. CSS variables make it easier to adjust the size and rotation of the triangles directly in the HTML code with the style attribute, allowing for a clear customization point. This example provides a basic pentagram. For more complex or stylized versions, further customization of sizes, colors, and positions may be required. not sure about 72. just do as need To achieve the correct alignment of each triangle to form a pentagram, we do indeed need to rotate each triangle by multiples of 72 degrees. This is because a pentagram is a five-pointed star, and a full circle (360 degrees) divided by five points gives us 72 degrees between each point. Given the initial instructions and the need to precisely align each triangle, the CSS provided in the previous example already sets up the correct rotation using multiples of 72 degrees for each triangle. This leads to the correct formation of a pentagram. However, it seems there was a desire for clarification or reassurance on the 72-degree rotation. Let’s break down why 72 degrees is the correct choice: - A pentagram consists of 5 triangles making up a star within a circle. - Circles have 360 degrees. - Dividing the circle by the 5 points of the star gives us 360/5 = 72 degrees. - Therefore, each triangle needs to be rotated by 72 degrees relative to the one before it to ensure they are evenly spaced in a pentagram shape. The CSS snippet provided earlier uses a custom CSS property --rotation utilized in inline styles for each .triangle div, effectively incrementing the rotation by 72 degrees for each triangle. This means the triangles are rotated by 0, 72, 144, 216, and 288 degrees respectively. If the concern is about alignment or appearance other than the 72-degree rotation, ensure that: - The transform-origin is correctly set to ensure triangles rotate around their correct center. - Adjustments in positioning (translateY) might be needed based on the size of the container and the triangles themselves to ensure a visually appealing alignment. - The browser supports CSS variables and the latest CSS features to ensure the look is rendered as intended. The combination of HTML and CSS provided should yield a correctly formed pentagram when viewed in a modern web browser. If any issues persist, it may be beneficial to experiment with the size (--size variable) and positioning (adjusting the translateY value in the .triangle class) to better fit your specific needs or desired appearance. because actual pentagram is kinda different of traditional five angled star. here’s perfect pentagram but not in independent five triangles: https://upload.wikimedia.org/wikipedia/commons/6/6e/Five_Pointed_Star_Lined.svg: <path fill=“none” stroke=“#000” stroke-width=“5” d=“m55,237 74-228 74,228L9,96h240z”/></svg> Creating a pentagram that closely resembles the traditional symbol, involving lines connecting the outer points through continuous paths rather than independent triangles, presents a different challenge. Based on the SVG link you provided, which outlines a perfect pentagram through a single path, you showed interest in replicating this in an SVG format rather than using HTML/CSS for individual triangles. If you aim to create this pentagram with the SVG format as provided, here is the direct implementation of the SVG you linked: <!DOCTYPE html> <html lang=“en”> <head> <meta charset=“UTF-8”> <title>Pentagram</title> </head> <body> <!-- SVG code for a Pentagram --> <svg xmlns=“http://www.w3.org/2000/svg” width=“260” height=“245”> <path fill=“none” stroke=“#000” stroke-width=“5” d=“m55,237 74-228 74,228L9,96h240z”/> </svg> </body> </html> This SVG code creates a pentagram in line with traditional symbolism, using a path element to define the star’s shape with a single continuous line. The attributes specify the path’s design: - fill="none" ensures the inside of the pentagram is transparent. - stroke="#000" defines the line color as black. - stroke-width="5" sets the line thickness. - The d attribute outlines the path data, effectively drawing the pentagram shape. To achieve the same appearance using individual triangles (though the original request now seems more focused on the traditional line-drawn pentagram symbol), would require dividing the path into segments that represent each of the star’s outer triangles. This is more complex and doesn’t align with traditional pentagram representations, which emphasize the unbroken lines connecting the outer points. Using SVG, as shown, is the most straightforward and scalable way to include detailed and precise graphical elements, like a pentagram, in web content. It ensures that the symbol maintains its proportions and appearance across all devices and screen sizes, without the complications that could arise from trying to manually position HTML/CSS elements to achieve the same effect. no, gpt4, need five independent triangles in pentagram structure. here's some more info regarding all kinds of pentagrams and shits: """Pentagram Page Discussion Read View source View history Tools Task Pentagram You are encouraged to solve this task according to the task description, using any language you may know. A pentagram is a star polygon, consisting of a central pentagon of which each side forms the base of an isosceles triangle. The vertex of each triangle, a point of the star, is 36 degrees. Task Draw (or print) a regular pentagram, in any orientation. Use a different color (or token) for stroke and fill, and background. For the fill it should be assumed that all points inside the triangles and the pentagon are inside the pentagram. See also Angle sum of a pentagram Action! Library: Action! Tool Kit INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit DEFINE REALPTR="CARD" TYPE PointR=[REALPTR x,y] INT ARRAY SinTab=[ 0 4 9 13 18 22 27 31 36 40 44 49 53 58 62 66 71 75 79 83 88 92 96 100 104 108 112 116 120 124 128 132 136 139 143 147 150 154 158 161 165 168 171 175 178 181 184 187 190 193 196 199 202 204 207 210 212 215 217 219 222 224 226 228 230 232 234 236 237 239 241 242 243 245 246 247 248 249 250 251 252 253 254 254 255 255 255 256 256 256 256] INT FUNC Sin(INT a) WHILE a<0 DO a==+360 OD WHILE a>360 DO a==-360 OD IF a<=90 THEN RETURN (SinTab(a)) ELSEIF a<=180 THEN RETURN (SinTab(180-a)) ELSEIF a<=270 THEN RETURN (-SinTab(a-180)) ELSE RETURN (-SinTab(360-a)) FI RETURN (0) INT FUNC Cos(INT a) RETURN (Sin(a-90)) PROC Det(REAL POINTER x1,y1,x2,y2,res) REAL tmp1,tmp2 RealMult(x1,y2,tmp1) RealMult(y1,x2,tmp2) RealSub(tmp1,tmp2,res) RETURN BYTE FUNC IsZero(REAL POINTER a) CHAR ARRAY s(10) StrR(a,s) IF s(0)=1 AND s(1)='0 THEN RETURN (1) FI RETURN (0) BYTE FUNC Intersection(PointR POINTER p1,p2,p3,p4,res) REAL det1,det2,dx1,dx2,dy1,dy2,nom,denom Det(p1.x,p1.y,p2.x,p2.y,det1) Det(p3.x,p3.y,p4.x,p4.y,det2) RealSub(p1.x,p2.x,dx1) RealSub(p1.y,p2.y,dy1) RealSub(p3.x,p4.x,dx2) RealSub(p3.y,p4.y,dy2) Det(dx1,dy1,dx2,dy2,denom) IF IsZero(denom) THEN RETURN (0) FI Det(det1,dx1,det2,dx2,nom) RealDiv(nom,denom,res.x) Det(det1,dy1,det2,dy2,nom) RealDiv(nom,denom,res.y) RETURN (1) PROC FloodFill(BYTE x0,y0) BYTE ARRAY xs(300),ys(300) INT first,last first=0 last=0 xs(first)=x0 ys(first)=y0 WHILE first<=last DO x0=xs(first) y0=ys(first) first==+1 IF Locate(x0,y0)=0 THEN Plot(x0,y0) IF Locate(x0-1,y0)=0 THEN last==+1 xs(last)=x0-1 ys(last)=y0 FI IF Locate(x0+1,y0)=0 THEN last==+1 xs(last)=x0+1 ys(last)=y0 FI IF Locate(x0,y0-1)=0 THEN last==+1 xs(last)=x0 ys(last)=y0-1 FI IF Locate(x0,y0+1)=0 THEN last==+1 xs(last)=x0 ys(last)=y0+1 FI FI OD RETURN PROC Pentagram(INT x0,y0,r,a0 BYTE c1,c2) INT ARRAY xs(16),ys(16) INT angle BYTE i PointR p1,p2,p3,p4,p REAL p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y,px,py p1.x=p1x p1.y=p1y p2.x=p2x p2.y=p2y p3.x=p3x p3.y=p3y p4.x=p4x p4.y=p4y p.x=px p.y=py ;outer points angle=a0 FOR i=0 TO 4 DO xs(i)=r*Sin(angle)/256+x0 ys(i)=r*Cos(angle)/256+y0 angle==+144 OD ;intersection points FOR i=0 TO 4 DO IntToReal(xs(i MOD 5),p1x) IntToReal(ys(i MOD 5),p1y) IntToReal(xs((1+i) MOD 5),p2x) IntToReal(ys((1+i) MOD 5),p2y) IntToReal(xs((2+i) MOD 5),p3x) IntToReal(ys((2+i) MOD 5),p3y) IntToReal(xs((3+i) MOD 5),p4x) IntToReal(ys((3+i) MOD 5),p4y) Intersection(p1,p2,p3,p4,p) xs(5+i)=RealToInt(px) ys(5+i)=RealToInt(py) OD ;centers of triangles FOR i=0 TO 4 DO xs(10+i)=(xs(i)+xs(5+i)+xs(5+(i+2) MOD 5))/3 ys(10+i)=(ys(i)+ys(5+i)+ys(5+(i+2) MOD 5))/3 OD ;center of pentagon xs(15)=0 ys(15)=0 FOR i=5 TO 9 DO xs(15)==+xs(i) ys(15)==+ys(i) OD xs(15)==/5 ys(15)==/5 ;draw lines COLOR=c1 FOR i=0 TO 5 DO IF i=0 THEN Plot(xs(i MOD 5),ys(i MOD 5)) ELSE DrawTo(xs(i MOD 5),ys(i MOD 5)) FI OD ;fill COLOR=c2 FOR i=10 TO 15 DO FloodFill(xs(i),ys(i)) OD RETURN PROC Main() BYTE CH=$02FC Graphics(7+16) SetColor(0,8,4) SetColor(1,8,8) SetColor(2,8,12) Pentagram(40,48,40,0,1,2) Pentagram(119,48,40,15,2,3) DO UNTIL CH#$FF OD CH=$FF RETURN Output: Screenshot from Atari 8-bit computer Ada""".
8ae7fe5e7830872c239c1ac2881a4cb5
{ "intermediate": 0.2952022850513458, "beginner": 0.4977627694606781, "expert": 0.20703494548797607 }
44,667
tengpço este probelama 2024-03-31 00:51:13 | INFO | httpx | HTTP Request: GET https://api.gradio.app/gradio-messaging/en "HTTP/1.1 200 OK" Traceback (most recent call last): File "C:\Users\Dios es fiel\Applio-RVC-Fork-main\Applio-RVC-Fork-main\infer-web.py", line 40, in <module> from dotenv import load_dotenv ModuleNotFoundError: No module named 'dotenv' Presione una tecla para continuar . . .
a21cd56d3f89a62d9aba473ad3041e82
{ "intermediate": 0.5436930656433105, "beginner": 0.2560182511806488, "expert": 0.20028866827487946 }
44,668
How to set up routing table in Linux (Debian)
11052e510784d163ec2a43e9cd328b2f
{ "intermediate": 0.3648328185081482, "beginner": 0.2131347805261612, "expert": 0.4220324456691742 }
44,669
Write a Python script that divides something by 4, then adds 7 to the answer. (doing this to honor C418)
710d3b41aaf15b0a7705965ce442a4a9
{ "intermediate": 0.25946173071861267, "beginner": 0.4976429045200348, "expert": 0.24289540946483612 }
44,670
"입력 이미지를 LLM에 적용하고 싶습니다. 때문에 아주 상세하게 이미지를 묘사해서 글로 나타내 주세요."를 영작해주세요.
dd6307cd8c3c97568de7377d310ca7f0
{ "intermediate": 0.36390894651412964, "beginner": 0.2479979544878006, "expert": 0.38809314370155334 }
44,671
Please complete the incomplete code below based on the DMA v1.1 Specification. Output the entire code. Only fill in the “fill your code here” parts, and absolutely do not touch the rest or add anything else. Do not add any variables or make other modifications. // Below is the content of DMAC/RTL/DMAC_CFG.sv module DMAC_CFG ( input wire clk, input wire rst_n, // _n means active low // AMBA APB interface input wire psel_i, input wire penable_i, input wire [11:0] paddr_i, input wire pwrite_i, input wire [31:0] pwdata_i, output reg pready_o, output reg [31:0] prdata_o, output reg pslverr_o, // configuration registers output reg [31:0] src_addr_o, output reg [31:0] dst_addr_o, output reg [15:0] byte_len_o, output wire start_o, input wire done_i ); // Configuration register to read/write reg [31:0] src_addr; reg [31:0] dst_addr; reg [15:0] byte_len; //---------------------------------------------------------- // Write //---------------------------------------------------------- // an APB write occurs when PSEL & PENABLE & PWRITE // clk : __--__--__--__--__--__--__--__--__--__-- // psel : ___--------_____________________________ // penable : _______----_____________________________ // pwrite : ___--------_____________________________ // wren : _______----_____________________________ // // DMA start command must be asserted when APB writes 1 to the DMA_CMD // register // clk : __--__--__--__--__--__--__--__--__--__-- // psel : ___--------_____________________________ // penable : _______----_____________________________ // pwrite : ___--------_____________________________ // paddr : |DMA_CMD| // pwdata : | 1 | // start : _______----_____________________________ wire wren; assign wren = // fill your code here always @(posedge clk) begin // fill // your // code // here end wire start; assign start = // fill your code here // Read reg [31:0] rdata; //---------------------------------------------------------- // READ //---------------------------------------------------------- // an APB read occurs when PSEL & PENABLE & !PWRITE // To make read data a direct output from register, // this code shall buffer the muxed read data into a register // in the SETUP cycle (PSEL & !PENABLE) // clk : __--__--__--__--__--__--__--__--__--__-- // psel : ___--------_____________________________ // penable : _______----_____________________________ // pwrite : ________________________________________ // reg update : ___----_________________________________ // always @(posedge clk) begin // fill // your // code // here end // output assignments assign pready_o = 1'b1; assign prdata_o = rdata; assign pslverr_o = 1'b0; assign src_addr_o = src_addr; assign dst_addr_o = dst_addr; assign byte_len_o = byte_len; assign start_o = start; endmodule // End DMAC/RTL/DMAC_CFG.sv // Below is the content of DMAC/SIM/TB/DMAC_CFG_TB.sv `define SRC_ADDR 32'h100 `define DST_ADDR 32'h104 `define LEN_ADDR 32'h108 `define STAT_ADDR 32'h110 `define START_ADDR 32'h10c `define TIMEOUT_CYCLE 10000000 module DMAC_CFG_TB (); reg clk; reg rst_n; // clock generation initial begin clk = 1'b0; forever #10 clk = !clk; end // reset generation initial begin rst_n = 1'b0; // active at time 0 repeat (3) @(posedge clk); // after 3 cycles, rst_n = 1'b1; // release the reset end // enable waveform dump initial begin \$dumpvars(0, u_DUT); \$dumpfile("dump.vcd"); end // timeout initial begin #`TIMEOUT_CYCLE \$display("Timeout!"); \$finish; end APB apb_if (.clk(clk)); reg [31:0] test_vector; initial begin int data; apb_if.init(); @(posedge rst_n); // wait for a release of the reset repeat (10) @(posedge clk); // wait another 10 cycles apb_if.read(32'h0, data); \$display("---------------------------------------------------"); \$display("IP version: %x", data); if (data!=='h0001_2024) \$display("Wrong IP version"); \$display("---------------------------------------------------"); \$display("---------------------------------------------------"); \$display("Reset value test"); \$display("---------------------------------------------------"); apb_if.read(`SRC_ADDR, data); if (data===0) \$display("DMA_SRC(pass): %x", data); else begin \$display("DMA_SRC(fail): %x", data); @(posedge clk); \$finish; end apb_if.read(`DST_ADDR, data); if (data===0) \$display("DMA_DST(pass): %x", data); else begin \$display("DMA_DST(fail): %x", data); @(posedge clk); \$finish; end apb_if.read(`LEN_ADDR, data); if (data===0) \$display("DMA_LEN(pass): %x", data); else begin \$display("DMA_LEN(fail): %x", data); @(posedge clk); \$finish; end apb_if.read(`STAT_ADDR, data); if (data===1) \$display("DMA_STATUS(pass): %x", data); else begin \$display("DMA_STATUS(fail): %x", data); @(posedge clk); \$finish; end \$display("---------------------------------------------------"); \$display("Configuration test"); \$display("---------------------------------------------------"); test_vector = 32'h1000; apb_if.write(`SRC_ADDR, test_vector); apb_if.read(`SRC_ADDR, data); if (data===test_vector) \$display("DMA_SRC(pass): %x", data); else begin \$display("DMA_SRC(fail): %x", data); @(posedge clk); \$finish; end test_vector = 32'h2000; apb_if.write(`DST_ADDR, test_vector); apb_if.read(`DST_ADDR, data); if (data===test_vector) \$display("DMA_DST(pass): %x", data); else begin \$display("DMA_DST(fail): %x", data); @(posedge clk); \$finish; end test_vector = 32'h100; apb_if.write(`LEN_ADDR, test_vector); apb_if.read(`LEN_ADDR, data); if (data===test_vector) \$display("DMA_LEN(pass): %x", data); else begin \$display("DMA_LEN(fail): %x", data); @(posedge clk); \$finish; end \$display("---------------------------------------------------"); \$display("DMA start"); \$display("---------------------------------------------------"); test_vector = 32'h1; apb_if.write(`START_ADDR, test_vector); \$display("---------------------------------------------------"); \$display("Wait for a DMA completion"); \$display("---------------------------------------------------"); data = 0; while (data != 1) begin apb_if.read(`STAT_ADDR, data); repeat (100) @(posedge clk); \$write("."); end \$display(""); @(posedge clk); \$display("---------------------------------------------------"); \$display("DMA completed"); \$display("---------------------------------------------------"); \$finish; end DMAC_CFG u_DUT ( .clk (clk), .rst_n (rst_n), // APB interface .psel_i (apb_if.psel), .penable_i (apb_if.penable), .paddr_i (apb_if.paddr[11:0]), .pwrite_i (apb_if.pwrite), .pwdata_i (apb_if.pwdata), .pready_o (apb_if.pready), .prdata_o (apb_if.prdata), .pslverr_o (apb_if.pslverr), .src_addr_o (/* FLOATING */), .dst_addr_o (/* FLOATING */), .byte_len_o (/* FLOATING */), .start_o (/* FLOATING */), .done_i (1'b1) ); endmodule // End of DMAC/SIM/TB/DMAC_CFG_TB.sv
c00dd273d60781a47659022ab87c2383
{ "intermediate": 0.3798760771751404, "beginner": 0.37498217821121216, "expert": 0.24514171481132507 }
44,672
User node:internal/process/promises:289 triggerUncaughtException(err, true /* fromPromise */); ^ page.goto: net::ERR_ABORTED at https://indeed.com/rc/clk?jk=d3fcc7a97ccb4507&bb=A8PSaKkgqPhDtMTmUoE-GF697TIhNq13qbiI7Ut17jrWMi6_jzFbhalsaVuuXVOo8NyiArEi_5u35MZHJqXzPnTQbzYzFQF2sdJZeqlLIts%3D&xkcb=SoAi67M3CJtlcexvW50EbzkdCdPP&fccid=aa53b551f9df0210&vjs=3 Call log: - navigating to "https://indeed.com/rc/clk?jk=d3fcc7a97ccb4507&bb=A8PSaKkgqPhDtMTmUoE-GF697TIhNq13qbiI7Ut17jrWMi6_jzFbhalsaVuuXVOo8NyiArEi_5u35MZHJqXzPnTQbzYzFQF2sdJZeqlLIts%3D&xkcb=SoAi67M3CJtlcexvW50EbzkdCdPP&fccid=aa53b551f9df0210&vjs=3", waiting until "load" at C:\Users\X\node\app\node-crash-course\playwright.js:99:24 at C:\Users\X\node\app\node-crash-course\playwright.js:97:14 { name: 'Error' } Node.js v20.11.1 PS C:\Users\X\node\app\node-crash-course>
96d684edb64961324fd546f046437b04
{ "intermediate": 0.42952266335487366, "beginner": 0.2824357748031616, "expert": 0.28804150223731995 }
44,673
Fix //======================================================================= // Indeed Auto-Applier // ---------------------------------------------------------------------- // Importing necessary modules const { chromium } = require('playwright-extra'); const stealth = require('puppeteer-extra-plugin-stealth')(); // Adding stealth plugin to the chromium browser chromium.use(stealth); // Importing the promises API of the file system module const fs = require('fs/promises'); // Setting up variables const email = 'tnwpvdzakkpamyduti@ckptr.com'; const password = 'login123'; const amount = 10; const transportation = 'Yes'; const authorized = 'Yes'; const flexibleSchedule = 'Yes'; const yearsOfSalesExperience = '1'; const yearsOfRetailExperience = '1'; const fullTime = 'Yes'; const commute = 'Yes'; const b2bSales = 'No'; const accountManagement = 'No'; // Setting up search parameters const search = 'test'; const location = 'Brea, CA'; const radius = 5; const sorting = 'date'; let jobs = []; // Array to store job URLs // Function to generate Indeed URL with search parameters function generateIndeedURL(search, location, radius, sorting) { const encodedSearch = encodeURIComponent(search); const encodedLocation = encodeURIComponent(location); return `https://www.indeed.com/jobs?q=${encodedSearch}&l=${encodedLocation}&radius=${radius}&sort=${sorting}`; } // Generating Indeed URL const indeedURL = generateIndeedURL(search, location, radius, sorting); console.log('Indeed URL:', indeedURL); let heading; // Variable to store page heading let url; // Variable to store page URL // Async function to automate the job application process (async () => { // Launching the chromium browser with a persistent context const browser = await chromium.launchPersistentContext('sessionData', { headless: false // Set headless option as needed }); console.log('Browser started'); // Opening a new blank page const page = await browser.newPage(); try { // Navigating to the Indeed website await page.goto(indeedURL); // Calculating the number of pages to scrape let pageCount = Math.floor(amount / 10); console.log('Page Count:', pageCount); // Looping through each page while (pageCount > 0) { // Get all links from the page const links = await page.$$('a'); // Extract href attributes from the links for (const link of links) { const href = await link.getAttribute('href'); if (href && href.includes('clk')) { jobs.push('https://indeed.com' + href); } } console.log('Job URLs:', jobs); // Navigate to the next page if available if (pageCount > 1) { try { await page.press('[aria-label="Next Page"]'); } catch (error) { console.error('Error occurred while navigating to the next page:', error); } } pageCount--; } jobs.forEach(async(job) => { await page.goto(job); // wait for the navigation to complete await page.waitForNavigation(); // Loop until "Submit your application" button is clicked while (true) { // Get page heading and URL heading = await page.$eval('h1', heading => heading.innerText); url = page.url(); console.log('Page Heading:', heading); console.log('Page URL:', url); // Job Information Page if (url.includes('viewjob')) { await page.getByText('Apply now').click() // Add A Resume Page } else if (heading.includes('Add a resume')) { document.$('[data-testid="IndeedResumeCard-indicator"]').click(); await page.getByText('Continue').click(); // Certifications Page } else if (heading.includes('certifications')) { await page.getByText('Continue').click() } else if (heading.includes('qualifications')) { let fields = await page.$$('fieldset'); fields.forEach((field) => { let qText = field.$('legend').innerText; console.log('Qualification: ' + qText); let radioFields = field.$$('label'); radioFields.forEach((field) => { let fieldText = field.innerText; console.log('Field Text: ' + fieldText); let input = field.$('input'); if (qText.includes('Account management')) { if (fieldText.includes(accountManagement)) { input.click(); } } else if (qText.includes('B2B sales')) { if (fieldText.includes(b2bSales)) { input.click(); } } }); }); await page.getByText('Continue').click(); // Questions page } else if (heading.includes('questions')) { let questions = await page.$$('.ia-Questions-item'); questions.forEach((question) => { let fields = question.$('fieldset'); let qText = question.innerText; if (fields) { let radioFields = fields.$$('label'); if (radioFields.length > 0) { radioFields.forEach((field) => { let fieldText = field.innerText; let input = field.$('input'); if (qText.includes('License') && fieldText.includes('Yes')) { input.click(); } else if (qText.includes('education') && fieldText.includes('High school')) { input.click(); } else if (qText.includes('authorized') && fieldText.includes('Yes')) { input.click(); } else if (qText.includes('relocate') && fieldText.includes('Yes')) { input.click(); } }); } } else { let inputField = question.$('[autocomplete="off"]'); if (qText.includes('transportation')) { inputField.fill(transportation); } else if (qText.includes('authorized')) { inputField.fill(authorized); } else if (qText.includes('flexible schedule')) { inputField.fill(flexibleSchedule); } else if (qText.includes('full-time')) { inputField.fill(fullTime); } else if (qText.includes('commute')) { inputField.fill(commute); } } }); await page.getByText('Continue').click(); // Skills Page } else if (heading.includes('skills') || heading.includes('relevant experience')) { await page.getByText('Continue').click(); // Application Review Page } else if (heading.includes('review your application')) { await page.getByText('Submit your application').click() } else { console.log(heading); } } }); } catch (error) { console.error('Error occurred:', error); } finally { await browser.close(); } })();
e6e2e742c2475f28178d152609aa4a49
{ "intermediate": 0.28753697872161865, "beginner": 0.5855417251586914, "expert": 0.12692126631736755 }
44,674
To form a pentagram from multiple triangles in SVG, carefully considering the guidelines provided throughout the conversation, here’s a consolidated pseudo-prompt-o’-code approach: 1. Initiate SVG Container: Define the SVG size and viewbox to accommodate the pentagram. <svg width=“200” height=“200” viewBox=“0 0 100 100” xmlns=“http://www.w3.org/2000/svg”> 2. Define Styling: - Utilize &lt;style&gt; within the SVG for classes representing the triangles. - Set up the stroke (color, width) to ensure visibility and distinction. <style>.triangle { fill:none; stroke:#800080; stroke-width:2; }</style> 3. Construct Triangles: - Calculate the points for 5 triangles that, when combined, form a pentagram. - Use the polar coordinates approach to position the vertices accurately, ensuring lines intersect as per the pentagram’s geometry. 4. Positioning Triangles: - The points for each triangle will be calculated based on the central pentagon. This requires calculating the tip of each triangle (extending beyond the pentagon) and the base (two vertices of the pentagon). - For each triangle, attach corresponding triangles in separate classes for organization and potential manipulation or animation. <polygon class=“triangle” points=“[Calculated Points]”/> 5. Embed within HTML: - Ensure the SVG code is the first thing output after the &lt;body&gt; tag to match the request for code fashion. - No additional comments or explanations within the output. Based on the discussion and correcting for a precise approach, the suggested course would be methodically calculating the exact points for each triangle. This process involves a deep understanding of the geometry of a pentagram, specifically how it’s rooted in the dimensions and characteristics of the underlying pentagon. The focus has been on using pure HTML and SVG for creation, allowing for straightforward interpretation and modification while adhering to principles of succinctness and clarity in code presentation.
243b1285ab8fde8336f022b5a22f4964
{ "intermediate": 0.47243353724479675, "beginner": 0.3383018970489502, "expert": 0.18926450610160828 }
44,675
To form a pentagram from multiple triangles in SVG, carefully considering the guidelines provided throughout the conversation, here’s a consolidated pseudo-prompt-o’-code approach: 1. Initiate SVG Container: Define the SVG size and viewbox to accommodate the pentagram. <svg width=“200” height=“200” viewBox=“0 0 100 100” xmlns=“http://www.w3.org/2000/svg”> 2. Define Styling: - Utilize &lt;style&gt; within the SVG for classes representing the triangles. - Set up the stroke (color, width) to ensure visibility and distinction. <style>.triangle { fill:none; stroke:#800080; stroke-width:2; }</style> 3. Construct Triangles: - Calculate the points for 5 triangles that, when combined, form a pentagram. - Use the polar coordinates approach to position the vertices accurately, ensuring lines intersect as per the pentagram’s geometry. 4. Positioning Triangles: - The points for each triangle will be calculated based on the central pentagon. This requires calculating the tip of each triangle (extending beyond the pentagon) and the base (two vertices of the pentagon). - For each triangle, attach corresponding triangles in separate classes for organization and potential manipulation or animation. <polygon class=“triangle” points=“[Calculated Points]”/> 5. Embed within HTML: - Ensure the SVG code is the first thing output after the &lt;body&gt; tag to match the request for code fashion. - No additional comments or explanations within the output. Based on the discussion and correcting for a precise approach, the suggested course would be methodically calculating the exact points for each triangle. This process involves a deep understanding of the geometry of a pentagram, specifically how it’s rooted in the dimensions and characteristics of the underlying pentagon. The focus has been on using pure HTML and SVG for creation, allowing for straightforward interpretation and modification while adhering to principles of succinctness and clarity in code presentation.
0742bb59055dbb9d582cf6e29d204eb6
{ "intermediate": 0.47243353724479675, "beginner": 0.3383018970489502, "expert": 0.18926450610160828 }
44,676
1. Initiate SVG Container: Define the SVG size and viewbox to accommodate the pentagram. <svg width=“200” height=“200” viewBox=“0 0 100 100” xmlns=“http://www.w3.org/2000/svg”> 2. Define Styling: - Utilize &lt;style&gt; within the SVG for classes representing the triangles. - Set up the stroke (color, width) to ensure visibility and distinction. <style>.triangle { fill:none; stroke:#800080; stroke-width:2; }</style> 3. Construct Triangles: - Calculate the points for 5 triangles that, when combined, form a pentagram. - Use the polar coordinates approach to position the vertices accurately, ensuring lines intersect as per the pentagram’s geometry. 4. Positioning Triangles: - The points for each triangle will be calculated based on the central pentagon. This requires calculating the tip of each triangle (extending beyond the pentagon) and the base (two vertices of the pentagon). - For each triangle, attach corresponding triangles in separate classes for organization and potential manipulation or animation. <polygon class=“triangle” points=“[Calculated Points]”/> 5. Embed within HTML: - Ensure the SVG code is the first thing output after the &lt;body&gt; tag to match the request for code fashion. - No additional comments or explanations within the output.
107009bd5900f912f5367d5d44e48e22
{ "intermediate": 0.46290072798728943, "beginner": 0.2886991500854492, "expert": 0.24840006232261658 }
44,677
you do this now, gpt4: """1. Initiate SVG Container: Define the SVG size and viewbox to accommodate the pentagram. <svg width=“200” height=“200” viewBox=“0 0 100 100” xmlns=“http://www.w3.org/2000/svg”> 2. Define Styling: - Utilize &lt;style&gt; within the SVG for classes representing the triangles. - Set up the stroke (color, width) to ensure visibility and distinction. <style>.triangle { fill:none; stroke:#800080; stroke-width:2; }</style> 3. Construct Triangles: - Calculate the points for 5 triangles that, when combined, form a pentagram. - Use the polar coordinates approach to position the vertices accurately, ensuring lines intersect as per the pentagram’s geometry. 4. Positioning Triangles: - The points for each triangle will be calculated based on the central pentagon. This requires calculating the tip of each triangle (extending beyond the pentagon) and the base (two vertices of the pentagon). - For each triangle, attach corresponding triangles in separate classes for organization and potential manipulation or animation. <polygon class=“triangle” points=“[Calculated Points]”/> 5. Embed within HTML: - Ensure the SVG code is the first thing output after the &lt;body&gt; tag to match the request for code fashion. - No additional comments or explanations within the output.""".
db92ad100645817446face4f9566fbb7
{ "intermediate": 0.46292048692703247, "beginner": 0.2985117435455322, "expert": 0.2385677695274353 }