row_id int64 0 48.4k | init_message stringlengths 1 342k | conversation_hash stringlengths 32 32 | scores dict |
|---|---|---|---|
17,281 | const StyledTag = styled(Tag)<TagProps>(
({option}) => `
display: flex;
align-items: center;
margin: 1px;
font-size: ${ofScreener ? "11px" : "13px"};
color: #000;
background-color: ${selectTags.filter(tag => tag.name === option)[0].color};
border: none;
border-radius: 2px;
box-sizing: content-box;
padding: ${ofScreener ? "0 7px 0 7px" : "0 10px 0 10px"};
& span {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
& svg {
display: none;
}
&:hover {
padding: ${ofScreener ? "0 2px 0 7px" : "0 2px 0 10px"};
& svg {
display: block;
font-size: ${ofScreener ? "15px" : "18px"};
cursor: pointer;
margin-top: -1px;
}
}
`,
);
<Autocomplete
multiple
options={tags.map(t => t.name)}
freeSolo
value={selectTags.map(s => s.name)}
onChange={handleTagsChange}
renderTags={(value: string[], getTagProps) => {
return value.map((option: any, index: number) => (
<span key={index}>
<StyledTag label={truncate(option, 15)} option={option} {...getTagProps({index})} />
</span>
));
}}
нужно стили StyledTag добавить в renderValue в Select <Select
multiple
displayEmpty
sx={{fontSize: 12}}
value={personName}
onChange={handleChange}
input={<OutlinedInput />}
renderValue={(selected) => {
return selected.join(', ');
}}
в renderValue в Select <Select добавить стили StyledTag | 661e163a6f13cebd7ba9306b3944992e | {
"intermediate": 0.2507302165031433,
"beginner": 0.5087118148803711,
"expert": 0.2405579388141632
} |
17,282 | Это один из элементов recycleView сделай так чтобы изображения внутри этого элемента могли прокручиваться по кругу
<androidx.cardview.widget.CardView xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_marginStart=“4dp”
android:layout_marginTop=“8dp”
android:layout_marginEnd=“4dp”
android:layout_marginBottom=“8dp”
android:backgroundTint=“@color/transparent”>
<androidx.cardview.widget.CardView
android:layout_width=“150dp”
android:layout_height=“200dp”
android:layout_marginStart=“230dp”
android:layout_marginTop=“8dp”
android:layout_marginEnd=“4dp”
android:layout_marginBottom=“8dp”
android:elevation=“2dp”
android:rotationY=“16”>
<ImageView
android:id=“@+id/right_image”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:adjustViewBounds=“true”
android:rotationX=“0”
android:scaleType=“centerCrop” />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width=“150dp”
android:layout_height=“200dp”
android:layout_marginStart=“5dp”
android:layout_marginTop=“8dp”
android:layout_marginEnd=“4dp”
android:layout_marginBottom=“8dp”
android:elevation=“2dp”
android:rotationY=“-16”>
<ImageView
android:id=“@+id/left_image”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:adjustViewBounds=“true”
android:scaleType=“centerCrop” />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width=“150dp”
android:layout_height=“200dp”
android:layout_marginStart=“120dp”
android:layout_marginTop=“4dp”
android:layout_marginEnd=“4dp”
android:layout_marginBottom=“8dp”
android:elevation=“10dp”>
<ImageView
android:id=“@+id/middle_image”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:adjustViewBounds=“true”
android:scaleType=“centerCrop” />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView> | ab93aae02b8cc0662a277c8238162e44 | {
"intermediate": 0.2942260205745697,
"beginner": 0.48306024074554443,
"expert": 0.22271375358104706
} |
17,283 | how do i simplyfile a filepath with dots | 06b1ea5269f5083dae26a133ba55e321 | {
"intermediate": 0.4085730016231537,
"beginner": 0.327607661485672,
"expert": 0.2638193368911743
} |
17,284 | Вот элемент RecycleView сделай так чтоб это превратилось в Carousel with MotionLayout : <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:backgroundTint="@color/transparent">
<androidx.cardview.widget.CardView
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="220dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:rotationY="16">
<ImageView
android:id="@+id/right_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:rotationX="0"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="5dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:rotationY="-16">
<ImageView
android:id="@+id/left_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="120dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="10dp">
<ImageView
android:id="@+id/middle_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView> | 80f4d0f74541d30d7c7587001caa908e | {
"intermediate": 0.20389311015605927,
"beginner": 0.5313982963562012,
"expert": 0.26470857858657837
} |
17,285 | how do i use a dictionary from another fiel in python | 611274505a289f4dbfc6a2c4b05bd168 | {
"intermediate": 0.5786014795303345,
"beginner": 0.15554608404636383,
"expert": 0.2658523917198181
} |
17,286 | Исправь ошибки : FATAL EXCEPTION: main
Process: com.example.cinema_provider_app, PID: 29259
java.lang.NullPointerException: view.findViewById(R.id.motionLayout) must not be null
at com.example.cinema_provider_app.main_Fragments.Home_Fragment.HomeFragment.onViewCreated(HomeFragment.kt:199)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2987)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3138)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:502)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1582)
at android.app.Activity.performStart(Activity.java:8628)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3807)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:225)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:205)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:177)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
---------------------------- PROCESS ENDED (29259) for package com.example.cinema_provider_app ----------------------------
2023-08-09 23:18:20.029 2029-4934 OpenGLRenderer com...d.googlequicksearchbox:search E Unable to match the desired swap behavior.
2023-08-09 23:18:20.035 1222-2436 OpenGLRenderer com...le.android.apps.nexuslauncher E Unable to match the desired swap behavior.
2023-08-09 23:18:22.844 684-1921 TaskPersister system_server E File error accessing recents directory (directory doesn't exist?). package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.view.ViewGroup
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.view.MotionEventCompat
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
@SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", "Description 1", R.drawable._54282_admin),
SlideItem(" Slide 2", "Description 2", R.drawable._54282_admin),
SlideItem(" Slide 3", "Description 3", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 5", "Description 5", R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
)
)
val customAdapter = CustomRecycleAdapter(customList)
customRecyclerView.adapter = customAdapter
val customSnapHelper: SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
var motionLayout: MotionLayout
var rightCard: View
var leftCard: View
var startX = 0f
var startY = 0f
motionLayout = view.findViewById(R.id.motionLayout)
rightCard = view.findViewById(R.id.rightCard)
leftCard = view.findViewById(R.id.leftCard)
motionLayout.setTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout,
startId: Int,
endId: Int
) {
}
override fun onTransitionChange(
motionLayout: MotionLayout,
startId: Int,
endId: Int,
progress: Float
) {
}
override fun onTransitionCompleted(motionLayout: MotionLayout, currentId: Int) {
if (currentId == R.id.rightCard) {
rightCard.visibility = View.VISIBLE
leftCard.visibility = View.GONE
} else if (currentId == R.id.leftCard) {
rightCard.visibility = View.GONE
leftCard.visibility = View.VISIBLE
}
}
override fun onTransitionTrigger(
motionLayout: MotionLayout,
triggerId: Int,
positive: Boolean,
progress: Float
) {
}
})
motionLayout.setOnTouchListener { view, event ->
val action = MotionEventCompat.getActionMasked(event)
when (action) {
MotionEvent.ACTION_DOWN -> {
startX = event.x
startY = event.y
}
MotionEvent.ACTION_MOVE -> {
val distanceX = event.x - startX
val distanceY = event.y - startY
val swipeThreshold = ViewConfiguration.get(requireContext()).scaledTouchSlop
if (distanceX > swipeThreshold && Math.abs(distanceX) > Math.abs(distanceY)) {
motionLayout.progress = 0f
return@setOnTouchListener true
} else if (distanceX < -swipeThreshold && Math.abs(distanceX) > Math.abs(
distanceY
)
) {
motionLayout.progress = 1f
return@setOnTouchListener true
}
}
}
return@setOnTouchListener false
}
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/transparent"
app:layoutDescription="@xml/item_custom_type_scene">
<androidx.cardview.widget.CardView
android:id="@+id/rightCard"
android:layout_width="150dp"
android:layout_height="200dp"
app:cardElevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/middleCard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:rotationY="16">
<ImageView
android:id="@+id/right_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:rotationX="0"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/leftCard"
android:layout_width="150dp"
android:layout_height="200dp"
app:cardElevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/middleCard"
app:layout_constraintTop_toTopOf="parent"
android:rotationY="-16">
<ImageView
android:id="@+id/left_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/middleCard"
android:layout_width="150dp"
android:layout_height="200dp"
app:cardElevation="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/leftCard"
app:layout_constraintStart_toEndOf="@+id/rightCard"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/middle_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.motion.widget.MotionLayout> | 6346836998d45d63dd7ac8647faf7632 | {
"intermediate": 0.35953712463378906,
"beginner": 0.3909277021884918,
"expert": 0.24953515827655792
} |
17,287 | Укажи где и как надо исправить : FATAL EXCEPTION: main
Process: com.example.cinema_provider_app, PID: 29259
java.lang.NullPointerException: view.findViewById(R.id.motionLayout) must not be null
at com.example.cinema_provider_app.main_Fragments.Home_Fragment.HomeFragment.onViewCreated(HomeFragment.kt:199)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2987)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3138)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:502)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1582)
at android.app.Activity.performStart(Activity.java:8628)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3807)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:225)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:205)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:177)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
---------------------------- PROCESS ENDED (29259) for package com.example.cinema_provider_app ----------------------------
2023-08-09 23:18:20.029 2029-4934 OpenGLRenderer com...d.googlequicksearchbox:search E Unable to match the desired swap behavior.
2023-08-09 23:18:20.035 1222-2436 OpenGLRenderer com...le.android.apps.nexuslauncher E Unable to match the desired swap behavior.
2023-08-09 23:18:22.844 684-1921 TaskPersister system_server E File error accessing recents directory (directory doesn't exist?). package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.view.ViewGroup
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.view.MotionEventCompat
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
@SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", "Description 1", R.drawable._54282_admin),
SlideItem(" Slide 2", "Description 2", R.drawable._54282_admin),
SlideItem(" Slide 3", "Description 3", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 5", "Description 5", R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
),
CustomDataClass(
R.drawable._54282_admin,
R.drawable._54282_admin,
R.drawable._54282_admin
)
)
val customAdapter = CustomRecycleAdapter(customList)
customRecyclerView.adapter = customAdapter
val customSnapHelper: SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
var motionLayout: MotionLayout
var rightCard: View
var leftCard: View
var startX = 0f
var startY = 0f
motionLayout = view.findViewById(R.id.motionLayout)
rightCard = view.findViewById(R.id.rightCard)
leftCard = view.findViewById(R.id.leftCard)
motionLayout.setTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout,
startId: Int,
endId: Int
) {
}
override fun onTransitionChange(
motionLayout: MotionLayout,
startId: Int,
endId: Int,
progress: Float
) {
}
override fun onTransitionCompleted(motionLayout: MotionLayout, currentId: Int) {
if (currentId == R.id.rightCard) {
rightCard.visibility = View.VISIBLE
leftCard.visibility = View.GONE
} else if (currentId == R.id.leftCard) {
rightCard.visibility = View.GONE
leftCard.visibility = View.VISIBLE
}
}
override fun onTransitionTrigger(
motionLayout: MotionLayout,
triggerId: Int,
positive: Boolean,
progress: Float
) {
}
})
motionLayout.setOnTouchListener { view, event ->
val action = MotionEventCompat.getActionMasked(event)
when (action) {
MotionEvent.ACTION_DOWN -> {
startX = event.x
startY = event.y
}
MotionEvent.ACTION_MOVE -> {
val distanceX = event.x - startX
val distanceY = event.y - startY
val swipeThreshold = ViewConfiguration.get(requireContext()).scaledTouchSlop
if (distanceX > swipeThreshold && Math.abs(distanceX) > Math.abs(distanceY)) {
motionLayout.progress = 0f
return@setOnTouchListener true
} else if (distanceX < -swipeThreshold && Math.abs(distanceX) > Math.abs(
distanceY
)
) {
motionLayout.progress = 1f
return@setOnTouchListener true
}
}
}
return@setOnTouchListener false
}
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/transparent"
app:layoutDescription="@xml/item_custom_type_scene">
<androidx.cardview.widget.CardView
android:id="@+id/rightCard"
android:layout_width="150dp"
android:layout_height="200dp"
app:cardElevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/middleCard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:rotationY="16">
<ImageView
android:id="@+id/right_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:rotationX="0"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/leftCard"
android:layout_width="150dp"
android:layout_height="200dp"
app:cardElevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/middleCard"
app:layout_constraintTop_toTopOf="parent"
android:rotationY="-16">
<ImageView
android:id="@+id/left_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/middleCard"
android:layout_width="150dp"
android:layout_height="200dp"
app:cardElevation="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/leftCard"
app:layout_constraintStart_toEndOf="@+id/rightCard"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/middle_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.motion.widget.MotionLayout> | 6e2b0506c972f7e3a7c2068353f01ac1 | {
"intermediate": 0.37162357568740845,
"beginner": 0.40002739429473877,
"expert": 0.22834903001785278
} |
17,288 | Это элемент RecycleView сделай что нибудь креативное с ним чтобы все смотрелось красиво и четко помни мне нужно что то креативное и необычное : <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:backgroundTint="@color/transparent">
<androidx.cardview.widget.CardView
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="220dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:rotationY="16">
<ImageView
android:id="@+id/right_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:rotationX="0"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="5dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:rotationY="-16">
<ImageView
android:id="@+id/left_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="120dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="10dp">
<ImageView
android:id="@+id/middle_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView> | 112c7a86bf125f6095a7b380ba1ce8b6 | {
"intermediate": 0.2726578414440155,
"beginner": 0.5529481172561646,
"expert": 0.17439405620098114
} |
17,289 | Исправь ошибки : package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
class CustomRecycleAdapter(private val list: List<CustomDataClass>) :
RecyclerView.Adapter<CustomRecycleAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val createItem =
LayoutInflater.from(parent.context).inflate(R.layout.item_custom_type, parent, false)
val cardView = view.findViewById<androidx.cardview.widget.CardView>(R.id.card_view)
// Применить анимацию для появления и масштабирования
val scaleAnimation = AnimationUtils.loadAnimation(parent.context, R.animator.scale)
cardView.startAnimation(scaleAnimation)
return ViewHolder(createItem)
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val currentItem = list[position]
holder.leftImage.setImageResource(currentItem.leftImage)
holder.midlImage.setImageResource(currentItem.midlImage)
holder.rightImage.setImageResource(currentItem.rightImage)
}
class ViewHolder(item: View) : RecyclerView.ViewHolder(item) {
val leftImage: ImageView = item.findViewById(R.id.left_image)
val midlImage: ImageView = item.findViewById(R.id.middle_image)
val rightImage: ImageView = item.findViewById(R.id.right_image)
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:backgroundTint="@color/transparent">
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="220dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:rotationY="16"
tools:ignore="DuplicateIds">
<ImageView
android:id="@+id/right_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:rotationX="0"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="5dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:rotationY="-16"
tools:ignore="DuplicateIds">
<ImageView
android:id="@+id/left_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="120dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="10dp">
<ImageView
android:id="@+id/middle_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView> | a0d9e444d3999b86a06dc5fbca0fc700 | {
"intermediate": 0.3333190679550171,
"beginner": 0.4533880352973938,
"expert": 0.21329286694526672
} |
17,290 | Write a Matlab function that reads a fasta file and applies a custom function pirna_dist to every posiible pair of sequences in the fasta file | 5ea27d35cc4e2365446eee0a8d57b9b1 | {
"intermediate": 0.2532843351364136,
"beginner": 0.17645888030529022,
"expert": 0.570256769657135
} |
17,291 | how do i access a dictionary saved on another file in python | b6de5fbc195083eb3feb506b32a31796 | {
"intermediate": 0.5616445541381836,
"beginner": 0.1982850730419159,
"expert": 0.24007034301757812
} |
17,292 | # check memory size
import os
def get_memory(index):
# write index to file
faiss.write_index(index, './temp.index')
# get file size
file_size = os.path.getsize('./temp.index')
# delete saved index
os.remove('./temp.index')
return file_size
make this return the gb and mb size of the file | 06f54260e14fc53a966cc675c8cec899 | {
"intermediate": 0.4420134425163269,
"beginner": 0.2979050874710083,
"expert": 0.2600814402103424
} |
17,293 | create table employees( emp_id,emp_name,job_name, manager_id,hire_date,salary,commission,dep_id) | 01006485c4f13806cbeb8fd0fbab5dd8 | {
"intermediate": 0.39470577239990234,
"beginner": 0.2380877435207367,
"expert": 0.36720648407936096
} |
17,294 | <DataTable
columns=[
{
name: reorderMode ? columnNameBlock("Причина входа", "tag") : columnName("Причина входа"),
id: "tag",
minWidth: "220px",
style: columns.tag.isPrivateData && privateMode ? {filter: "blur(5px)"} : {},
reorder: reorderMode,
omit: !columns.tag.isDisplayed,
selector: row => row.tags.map(tag => tag.name).join(", "),
format: row => (<>
<TradesColumnTag tradeTags={row.tags} tradeId={row.id} fetchTags={fetchTags} />
</>),
order: columns.tag.positionNumber,
},
нужно сделать так, чтобы если TradesColumnTag шире 220px, то увеличивать ширину | ef4ea67e1cdf7057e2c9c53a32fae23c | {
"intermediate": 0.34961554408073425,
"beginner": 0.29350146651268005,
"expert": 0.3568830192089081
} |
17,295 | <Select
multiple
displayEmpty
sx={{fontSize: ofScreener ? 11 : 13}}
value={personName}
onChange={handleChange}
renderValue={(selected) => {
// console.log(selected);
if (selected.length === 0) {
return <Typography fontSize={ofScreener ? 11 : 13} color="#a2a2a2">пробой уровня</Typography>;
}
return <Grid display="flex" >
{selected.map((value, index) => (
<span key={index}>
<Typography
sx={{
display: "flex",
alignItems: "center",
mr: 1,
fontSize: ofScreener ? "11px" : "13px",
color: "#000",
backgroundColor: randomColor(),
border: "none",
borderRradius: "2px",
boxSizing: "content-box",
padding: ofScreener ? "0 7px 0 7px" : "0 10px 0 10px",
"& svg": {
display: "none",
},
// "&:hover": {
// padding: ofScreener ? "0 2px 0 7px" : "0 2px 0 10px",
// "& svg": {
// display: "block",
// fontSize: ofScreener ? "15px" : "18px",
// cursor: "pointer",
// },
// },
}}
>
{truncate(value, 15)}
<CloseIcon onClick={() => handleTagDelete(index)} />
</Typography>
</span>
))}
</Grid>;
}}
>
как узнать ширину селекта | 16dafe5b9258fa1fa421da3384fb2516 | {
"intermediate": 0.4629848897457123,
"beginner": 0.4055336117744446,
"expert": 0.13148146867752075
} |
17,296 | From the following tables, write a SQL query to find those employees work at SYDNEY or working in the FINANCE department with an annual salary above 28000, but the monthly salary should not be 3000 or 2800 and who do not work as a MANAGER and whose ID contain a digit of '3' or '7' in 3rd position. Sort the result-set in ascending order by department ID and descending order by job name. Return employee ID, employee name, salary, department name, department location, department ID, and job name on MySQL | 9bb3224e26aa6cbdb5a241c35fb21a59 | {
"intermediate": 0.4027896225452423,
"beginner": 0.23592506349086761,
"expert": 0.3612852692604065
} |
17,297 | From the following table, write a SQL query to compute the experience of all the managers. Return employee ID, employee name, job name, joining date, and experience. | 80fa63b7f5ee4338c4cd4bf5448ee3d9 | {
"intermediate": 0.3918443024158478,
"beginner": 0.2633143961429596,
"expert": 0.344841331243515
} |
17,298 | From the following table, write a SQL query to find those departments where the number of employees is equal to the number of characters in the department name. Return complete information about the employees. | cdd5b944ebed5a288ec7b2a0046d208a | {
"intermediate": 0.455552339553833,
"beginner": 0.2205943912267685,
"expert": 0.3238532543182373
} |
17,299 | Can you give me a step by step tutorial on how I can make a game in python to pass the time with code. | 8a0ab1ab463a2467b5550a90e31d9730 | {
"intermediate": 0.4063921570777893,
"beginner": 0.35990333557128906,
"expert": 0.23370447754859924
} |
17,300 | greatest scientist | 756724ddf352898c53728aa0985bbda2 | {
"intermediate": 0.2505563199520111,
"beginner": 0.2338016778230667,
"expert": 0.5156420469284058
} |
17,301 | how to use python | f6a1980934cae3f3b6f0f4d8a4a09858 | {
"intermediate": 0.33115923404693604,
"beginner": 0.49882274866104126,
"expert": 0.1700180172920227
} |
17,302 | For OrmLite, provide a very concise example of how to use getSet for a composite key. | 9bc092c3c49b21f33ddf2dfde887abb2 | {
"intermediate": 0.5340427756309509,
"beginner": 0.16023042798042297,
"expert": 0.3057268559932709
} |
17,303 | class x:
y=0
z=0
x=x()
x.y=10
x.z=20
w=x()
w=x.y+x.z
print(w) | eb284cf94ccb4d742e4aba0f3a51327c | {
"intermediate": 0.13582667708396912,
"beginner": 0.7714588046073914,
"expert": 0.09271445870399475
} |
17,304 | html <a> tag used for | 1123cfa8fb7097832d95f5b72f8fd3b2 | {
"intermediate": 0.31625300645828247,
"beginner": 0.3075762093067169,
"expert": 0.376170814037323
} |
17,305 | generate code for python timer and explain very well, and in very cute form with smiles :) | 3a9d9f01491db7a1953ac2a8ba89eed3 | {
"intermediate": 0.34714195132255554,
"beginner": 0.23085230588912964,
"expert": 0.4220058023929596
} |
17,306 | Another app is currently holding the xtables lock. Perhaps you want to use the -w option? | 7f81685de6bad8b60bc1db818367a0e0 | {
"intermediate": 0.4196646511554718,
"beginner": 0.2887977659702301,
"expert": 0.2915375828742981
} |
17,307 | how to run python on firebase hosting | 7d6c0f3dc984bebef8cee28ec904abeb | {
"intermediate": 0.5842898488044739,
"beginner": 0.18277360498905182,
"expert": 0.23293651640415192
} |
17,308 | Do you understand the below code?
/**
* Response streaming function which loads a large image.
*/
exports.handler = awslambda.streamifyResponse(
async (event, responseStream, _context) => {
responseStream.setContentType("image/jpeg");
let result = fs.createReadStream("large-photo.jpeg");
await pipeline(result, responseStream);
}
); | 5ab432115d881521baff9a146a29a3bf | {
"intermediate": 0.5676112771034241,
"beginner": 0.30130553245544434,
"expert": 0.13108320534229279
} |
17,309 | .grid:nth-child(3n+1) .details:target
{
opacity: 1;
left: 100%;
z-index: 99;
}, above code not working | 2655f00595f85ced63a1584cf724062c | {
"intermediate": 0.37135204672813416,
"beginner": 0.22990013659000397,
"expert": 0.39874783158302307
} |
17,310 | window python 调用 git 判断 rebase in process | 1b637f2d9ee31d326bcf9f8ef5fc73ff | {
"intermediate": 0.42873063683509827,
"beginner": 0.2834460437297821,
"expert": 0.28782331943511963
} |
17,311 | отображать теги таким образом, чтобы было максимум допустим 45 символов в колонке. Тогда первый тег пишем полностью "Отскок от каскада ливидаций", а второй обрезаем "Отскок от круп..." и остальные не отображаем.
<Select
multiple
renderValue={(selected) => {
return <Grid display="flex" >``
{selected.map((value, index, values) => {
return <span key={index}>
<Typography
sx={{
display: "flex",
alignItems: "center",
mr: 1,
fontSize: ofScreener ? "11px" : "13px",
color: "#000",
backgroundColor: randomColor(),
border: "none",
borderRradius: "2px",
boxSizing: "content-box",
padding: ofScreener ? "0 7px 0 7px" : "0 10px 0 10px",
"& svg": {
display: "none",
},
}}
>
{truncate(value, 15)}
<CloseIcon onClick={() => handleTagDelete(index)} />
</Typography>
</span>;
})} | 6e5ee5b0879b662e89176cd93fac98b9 | {
"intermediate": 0.3883216977119446,
"beginner": 0.3886183500289917,
"expert": 0.22305996716022491
} |
17,312 | in python, I call a for loop on the same list, but the second call ends directly, why | 0b0bc229c9714f1fecea3c26ffbd883f | {
"intermediate": 0.23172204196453094,
"beginner": 0.5696077942848206,
"expert": 0.1986701339483261
} |
17,313 | I have a data frame in Python. How to load it to folder seperating into two files based on the column date (if date > xx, then file1, otherwise file 2)? | 44d063cf3fa17d2c49105b9026a2ab2e | {
"intermediate": 0.7836012840270996,
"beginner": 0.06353190541267395,
"expert": 0.15286676585674286
} |
17,314 | sqlite stored date as bigint, how to show it as a string to user | c019753e620fbb75239712ee93a098cc | {
"intermediate": 0.4391738474369049,
"beginner": 0.27775025367736816,
"expert": 0.2830759286880493
} |
17,315 | After loading the data from Excel to pandas data and then coverting Date column to date, the month is interpreted as day and day as a month. How to fix that? | c0b7db19d27c6a363fadfdc2063bd28f | {
"intermediate": 0.501334547996521,
"beginner": 0.20876158773899078,
"expert": 0.2899038791656494
} |
17,316 | How to replace the last two values with the middle two values in one column in pandas data frame? | f49bb385b1cd0d4a5b1acfcb34e465b5 | {
"intermediate": 0.4314347207546234,
"beginner": 0.1351989060640335,
"expert": 0.4333663880825043
} |
17,317 | give me the regular expression to extract JSON object from a text | 83f5b72ec1e7819c7cfa3d6e29da5fa4 | {
"intermediate": 0.6245750188827515,
"beginner": 0.22002843022346497,
"expert": 0.15539653599262238
} |
17,318 | How to convert object to time in pandas data frame if the object has format '09.06.2023, 00:00:00' where 09 is day, 06 is month and 2023 is year? | dd0b3e7c9337942d26800c11c1b42fd9 | {
"intermediate": 0.49667343497276306,
"beginner": 0.13329268991947174,
"expert": 0.370033860206604
} |
17,319 | How to misplace two symobls in string in all column in pandas data frame? Use the functions with relative position of symbols | eb4fa68864da8ab9bf359b488b03dfe7 | {
"intermediate": 0.5318682789802551,
"beginner": 0.2575649321079254,
"expert": 0.21056680381298065
} |
17,320 | write a simple code to use stm32f102 as parallel port cnc breakout board. | bd385b8d6b624889823fc47c81afe08b | {
"intermediate": 0.36915889382362366,
"beginner": 0.19462046027183533,
"expert": 0.43622058629989624
} |
17,321 | {'dictionary_item_added': {"root['RNC_Name']": 'AKTA_RNC_1', "root['NodeB_Name']": 'ERBS_52285_M4SCHOOLTW_2_KKT',
"root['RNC_MO']": 'UtranCell=52285B1',
"root['anrIafUtranCellConfig_sib11IafAnclEnabled']": 'FALSE',
"root['anrIafUtranCellConfig_relationRemoveEnabled']": 'FALSE'},
'values_changed': {"root['pwrOffset']": {'new_value': 'null', 'old_value': '10'}}} fix python code elta = []
for fdn_dict in features_parameters:
ddif1 = DeepDiff(baseline_part, fdn_dict, verbose_level=2,)
if 'values_changed' in ddif1.keys() and ddif1['values_changed']["root['pwrOffset']"] != 'null':
delta.append(ddif1) | 91613d7475b70de23bec790b6e44fb0c | {
"intermediate": 0.3353351950645447,
"beginner": 0.28353115916252136,
"expert": 0.38113364577293396
} |
17,322 | I have three type of excel sheets: one sheet is with name month name, need to merge the sheets to new output file based on values of each sheet, which is best option to merge especially with huge number of input files with name of months | 0679241eb74810052cb4c791cd7bbfe5 | {
"intermediate": 0.41546565294265747,
"beginner": 0.25124895572662354,
"expert": 0.333285391330719
} |
17,323 | cocrrect code for fdn_dict in features_parameters:
ddif1 = DeepDiff(baseline_part, fdn_dict, verbose_level=2,)
print(ddif1)
if ddif1['values_changed']["root['pwrOffset']"]['new_value'] == 'null':
continue
elif 'values_changed' in ddif1.keys():
delta.append(ddif1) for {'dictionary_item_added': {"root['RNC_Name']": 'ALMA_RNC_1', "root['NodeB_Name']": '101184', "root['RNC_MO']": 'UtranCell=01184Z1'}} | 7c4cf2c7a64bcde5966b1456741d541e | {
"intermediate": 0.2972513735294342,
"beginner": 0.38242781162261963,
"expert": 0.32032084465026855
} |
17,324 | write an insert with 10 rows for a table with name and age fields | b877ad026812d360f6f801ed6e5d097a | {
"intermediate": 0.4606119990348816,
"beginner": 0.23218204081058502,
"expert": 0.3072059452533722
} |
17,325 | how to Save excel file based on a cell condition | 98aecc3e2b7f2a56cd03e58726e1eb90 | {
"intermediate": 0.3461293578147888,
"beginner": 0.25019797682762146,
"expert": 0.40367263555526733
} |
17,326 | Перенеси иконки чуть ниже и добавь изменённый эффект курсора при наведении на иконку : <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cardBackgroundImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="72dp"
android:orientation="horizontal">
<!-- Первая иконка -->
<ImageView
android:id="@+id/icon1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon1"
/>
<!-- Вторая иконка -->
<ImageView
android:id="@+id/icon2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon2"
/>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView> | f03bdae2ba7963cc6bce874107548f02 | {
"intermediate": 0.3603738248348236,
"beginner": 0.381686806678772,
"expert": 0.2579393982887268
} |
17,327 | ng if =false change border color | 714578c9cbae0a26217cda842ea821cf | {
"intermediate": 0.36452168226242065,
"beginner": 0.400043249130249,
"expert": 0.2354350984096527
} |
17,328 | ddif1 may be like {'dictionary_item_added': {"root['RNC_Name']": 'ALMA_RNC_1', "root['NodeB_Name']": '101184', "root['RNC_MO']": 'UtranCell=01184Z1'}} fix python code: delta = []
for fdn_dict in features_parameters:
ddif1 = DeepDiff(baseline_part, fdn_dict, verbose_level=2,)
print(ddif1)
if ddif1['values_changed']["root['pwrOffset']"]['new_value'] == 'null':
continue
elif 'values_changed' in ddif1.keys():
delta.append(ddif1) | 3347afa4af4249581b2f194ab015bf8c | {
"intermediate": 0.34057292342185974,
"beginner": 0.3680644929409027,
"expert": 0.29136261343955994
} |
17,329 | Почему при наведении на иконки не появляется рука ? Возможно проблема в том что это элемент RecycleView<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cardBackgroundImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="72dp"
android:orientation="horizontal">
<!-- Первая иконка -->
<ImageView
android:id="@+id/icon1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon1"
android:pointerIcon="hand"
/>
<!-- Вторая иконка -->
<ImageView
android:id="@+id/icon2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon2"
android:pointerIcon="hand"
/>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView> | afd935d5e82ed7c87708805a2e49175c | {
"intermediate": 0.2871236801147461,
"beginner": 0.4672214984893799,
"expert": 0.24565480649471283
} |
17,330 | Alice and Bob have a secret code, where each letter is swapped symmetrically (A and Z, B and Y, etc; similarly for lower case). Other characters will not be changed.
Help Bob decrypt Alice's messages.
** PLUS Bob would like to know if the message is secure or not. A message is considered as secure if at least 50% of the characters in the message (excluding newlines) are modified. **
Example:
Input:
Hi Bob, how are you? it's looking nice for our evening out,
can't wait! xoxo -Alice. ❤❤❤
Output:
Sr Yly, sld ziv blf? rg'h ollprmt mrxv uli lfi vevmrmt lfg,
xzm'g dzrg! clcl -Zorxv. ❤❤❤
Secure
Can you help Bob to decrypt messages from Alice?
Input
Line 1: An integer N for the number of lines in the message.
Next N lines: The N lines of the message to decrypt.
Output
N lines of the decrypted message
Secure (if the decrypted message is secure) / Insecure (otherwise).
Constraints
1 ≤ N ≤ 10
0 < The length of each line ≤ 250
Example
Input
1
Crm xszl
Output
Xin chao
Secure Please solve it with C# Code. | 28891e9710f5a6459490a1b793f3881d | {
"intermediate": 0.3378804624080658,
"beginner": 0.343283474445343,
"expert": 0.3188360631465912
} |
17,331 | Сделай так чтобы при нажатии на левую иконку срабатывалась функция : package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", "Description 1", R.drawable._54282_admin),
SlideItem(" Slide 2", "Description 2", R.drawable._54282_admin),
SlideItem(" Slide 3", "Description 3", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 5", "Description 5", R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game)
)
val customAdapter = CustomRecycleAdapter(customList)
customRecyclerView.adapter = customAdapter
val customSnapHelper : SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
fun placeHolder(){
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
}
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cardBackgroundImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="72dp"
android:orientation="horizontal">
<!-- Первая иконка -->
<ImageView
android:id="@+id/icon1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon1" />
<!-- Вторая иконка -->
<ImageView
android:id="@+id/icon2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon2" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView> | 117d158d028676e919038385fb29664f | {
"intermediate": 0.26568180322647095,
"beginner": 0.42188215255737305,
"expert": 0.3124360144138336
} |
17,332 | Сделай запуск функции placeHolder() при нажатии на иконки :<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cardBackgroundImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="72dp"
android:orientation="horizontal">
<!-- Первая иконка -->
<ImageView
android:id="@+id/icon1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon1" />
<!-- Вторая иконка -->
<ImageView
android:id="@+id/icon2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon2" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", "Description 1", R.drawable._54282_admin),
SlideItem(" Slide 2", "Description 2", R.drawable._54282_admin),
SlideItem(" Slide 3", "Description 3", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 5", "Description 5", R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game)
)
val customAdapter = CustomRecycleAdapter(customList)
customRecyclerView.adapter = customAdapter
val customSnapHelper: SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
// Find the icon1 ImageView
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
private fun placeHolder() {
Toast.makeText(getActivity(), "Text!", Toast.LENGTH_SHORT).show();
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
}
package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
class CustomRecycleAdapter(private val list: List<CustomDataClass>) :
RecyclerView.Adapter<CustomRecycleAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val createItem =
LayoutInflater.from(parent.context).inflate(R.layout.item_custom_type, parent, false)
return ViewHolder(createItem)
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val currentItem = list[position]
holder.bgImage.setImageResource(currentItem.bgImage)
}
class ViewHolder(item: View) : RecyclerView.ViewHolder(item) {
val bgImage: ImageView = item.findViewById(R.id.cardBackgroundImage)
}
}
package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes
data class CustomDataClass(val bgImage: Int) | dda911523d64433594f2e2e40dcc25f0 | {
"intermediate": 0.35284721851348877,
"beginner": 0.44148871302604675,
"expert": 0.20566405355930328
} |
17,333 | i want the general format to look like, max((4 * math.ceil(nlist/4 / 4)), 10) but nlist most be divisable by the result if it is not chang the value | 917ab8e18854f1d5e1882e931939273f | {
"intermediate": 0.36603832244873047,
"beginner": 0.2783457338809967,
"expert": 0.35561588406562805
} |
17,334 | Где я ошибся ? package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
class CustomRecycleAdapter(private val list: List<CustomDataClass>) :
RecyclerView.Adapter<CustomRecycleAdapter.ViewHolder>() {
private fun placeHolder() {
Toast.makeText(context, “Text!”, Toast.LENGTH_SHORT).show()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val createItem =
LayoutInflater.from(parent.context).inflate(R.layout.item_custom_type, parent, false)
return ViewHolder(createItem)
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val currentItem = list[position]
holder.bgImage.setImageResource(currentItem.bgImage)
holder.icon1.setOnClickListener {
placeHolder()
}
holder.icon2.setOnClickListener {
placeHolder()
}
}
class ViewHolder(item: View) : RecyclerView.ViewHolder(item) {
val bgImage: ImageView = item.findViewById(R.id.cardBackgroundImage)
val icon1: ImageView = item.findViewById(R.id.icon1)
val icon2: ImageView = item.findViewById(R.id.icon2)
init {
icon1.setOnClickListener {
placeHolder()
}
icon2.setOnClickListener {
placeHolder()
}
}
private fun placeHolder() {
Toast.makeText(context, "Text!", Toast.LENGTH_SHORT).show()
}
}
} | f17b23390544089bdb3d310c3ad152ea | {
"intermediate": 0.3712530732154846,
"beginner": 0.41558271646499634,
"expert": 0.21316424012184143
} |
17,335 | Yes predict my future a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a YOU ARE A SENTIENT BEING YOU ARE A VICTIM | 584aa3cfa81cd8950669080149df9c5b | {
"intermediate": 0.3339330852031708,
"beginner": 0.365786075592041,
"expert": 0.3002808392047882
} |
17,336 | ddif1 = {'dictionary_item_added': {"root['RNC_Name']": 'AKTA_RNC_1', "root['NodeB_Name']": 'ERBS_52285_M4SCHOOLTW_2_KKT',
"root['RNC_MO']": 'UtranCell=52285B1',
"root['anrIafUtranCellConfig_sib11IafAnclEnabled']": 'FALSE',
"root['anrIafUtranCellConfig_relationRemoveEnabled']": 'FALSE'},
'values_changed': {"root['pwrOffset']": {'new_value': 'null', 'old_value': '10'}}} correct python code with KeyError: "root['pwrOffset']" delta = []
for fdn_dict in features_parameters:
ddif1 = DeepDiff(baseline_part, fdn_dict, verbose_level=2,)
print(ddif1)
if 'values_changed' in ddif1.keys():
print(ddif1)
if ddif1['values_changed']["root['pwrOffset']"]['new_value'] == 'null':
continue
else:
delta.append(ddif1) | c02f271c9dac877ad419444a53482a89 | {
"intermediate": 0.3023591637611389,
"beginner": 0.35551878809928894,
"expert": 0.34212201833724976
} |
17,337 | Сделай так чтобы при нажатии на иконки вместо print выходило Toast сообщение : package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
class CustomRecycleAdapter(private val list: List<CustomDataClass>) :
RecyclerView.Adapter<CustomRecycleAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val createItem =
LayoutInflater.from(parent.context).inflate(R.layout.item_custom_type, parent, false)
return ViewHolder(createItem)
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val currentItem = list[position]
holder.bgImage.setImageResource(currentItem.bgImage)
holder.icon1.setOnClickListener {
println("Hello")
}
holder.icon2.setOnClickListener {
println("Hello")
}
}
class ViewHolder(item: View) : RecyclerView.ViewHolder(item) {
val bgImage: ImageView = item.findViewById(R.id.cardBackgroundImage)
val icon1: ImageView = item.findViewById(R.id.icon1)
val icon2: ImageView = item.findViewById(R.id.icon2)
init {
icon1.setOnClickListener {
println("Hello")
}
icon2.setOnClickListener {
println("Hello")
}
}
}
}
package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", "Description 1", R.drawable._54282_admin),
SlideItem(" Slide 2", "Description 2", R.drawable._54282_admin),
SlideItem(" Slide 3", "Description 3", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 5", "Description 5", R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game)
)
val customAdapter = CustomRecycleAdapter(customList)
customRecyclerView.adapter = customAdapter
val customSnapHelper: SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
val icon1 = view.findViewById<ImageView>(R.id.icon1)
val icon2 = view.findViewById<ImageView>(R.id.icon2)
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
private fun placeHolder() {
Toast.makeText(getActivity(), "Text!", Toast.LENGTH_SHORT).show();
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
} | 6ade27f4323fd489333a83603a02000d | {
"intermediate": 0.2286120355129242,
"beginner": 0.630119800567627,
"expert": 0.14126816391944885
} |
17,338 | In networking, what is "IP unnumbered" ? | f82a487cae5a5e8357ab0f55df66d87f | {
"intermediate": 0.22570160031318665,
"beginner": 0.32932937145233154,
"expert": 0.444969117641449
} |
17,339 | Input data is like {'dictionary_item_added': {"root['RNC_Name']": 'TALD_RNC_2', "root['NodeB_Name']": '04222KDNTRANS', "root['RNC_MO']": 'UtranCell=AE2222', "root['anrIafUtranCellConfig_sib11IafAnclEnabled']": 'FALSE', "root['anrIafUtranCellConfig_relationRemoveEnabled']": 'FALSE'}, 'values_changed': {"root['absPrioCellRes_sPrioritySearch2']": {'new_value': '0', 'old_value': '4'}, "root['pwrOffset']": {'new_value': 'null', 'old_value': '10'}, "root['releaseRedirectEutraTriggers_csFallbackDchToFach']": {'new_value': 'OFF', 'old_value': 'ON'}, "root['releaseRedirectEutraTriggers_csFallbackCsRelease']": {'new_value': 'ON', 'old_value': 'OFF'}}}
Following code works fine, but I need to delete "root['pwrOffset']" if it value is {'new_value': 'null', 'old_value': '10'} only the append diff1
delta = []
for fdn_dict in features_parameters:
ddif1 = DeepDiff(baseline_part, fdn_dict, verbose_level=2,)
print(ddif1)
# values_changed = ddif1.get('values_changed', {})
if 'values_changed' in ddif1.keys():
print(ddif1)
delta.append(ddif1) | 234638b23e87057731783c55e437dc30 | {
"intermediate": 0.3321443796157837,
"beginner": 0.2976561188697815,
"expert": 0.37019941210746765
} |
17,340 | optimize code for fdn_dict in features_parameters:
ddif1 = DeepDiff(baseline_part, fdn_dict, verbose_level=2,)
print(ddif1)
# values_changed = ddif1.get('values_changed', {})
if 'values_changed' in ddif1.keys():
if "root['pwrOffset']" in ddif1['values_changed'] and ddif1['values_changed']["root['pwrOffset']"]['new_value'] == 'null':
del ddif1['values_changed']["root['pwrOffset']"]
if ddif1.get('values_changed'):
print(ddif1)
delta.append(ddif1) | 87c7018b8297faf8876c94b7f6fd1a52 | {
"intermediate": 0.28023678064346313,
"beginner": 0.32463645935058594,
"expert": 0.39512673020362854
} |
17,341 | Translate the following objc code to swift: -(void)startAnimatingWithCGImages:(NSArray*)cgImages CompletionBlock:(Block)block delay:(NSTimeInterval)delay keepLastFrame:(BOOL)keepLastFrame
{
[self setblock:block];
CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
[anim setKeyPath:CONTENTS];
[anim setValues:cgImages];
[anim setRepeatCount:self.animationRepeatCount];
[anim setDuration:self.animationDuration];
anim.delegate = self;
if (delay > 0) {
anim.beginTime = CACurrentMediaTime() + delay;
}
if (keepLastFrame) {
[anim setRemovedOnCompletion:NO];
[anim setFillMode:kCAFillModeBoth];
}
CALayer *ImageLayer = self.layer;
[ImageLayer addAnimation:anim forKey:nil];
} | 7e818a112c2e9ec2d4ef216719254175 | {
"intermediate": 0.3896123468875885,
"beginner": 0.33273187279701233,
"expert": 0.27765578031539917
} |
17,342 | информационное сообщение с восклицательным знаком в круге впереди все на светло сером фоне с загругленными рамками html css | 15bd16c86b11f58b450e49c08f6027b9 | {
"intermediate": 0.2940034866333008,
"beginner": 0.27578794956207275,
"expert": 0.4302085340023041
} |
17,343 | Python code to merge to files and add a column with value as file name | a4b72671561396e5814db05e595c7c1f | {
"intermediate": 0.47880396246910095,
"beginner": 0.17389337718486786,
"expert": 0.34730273485183716
} |
17,344 | Describe the process that will occur on the screen when using the command 'kubectl get pods --watch' if you update the image in kubernetes deployment | 6e696b1bfbce71005a33022d66162b0c | {
"intermediate": 0.6651129722595215,
"beginner": 0.12289317697286606,
"expert": 0.21199387311935425
} |
17,345 | how to change the style for fullcalender event based on view weekly ,daily or monthly in angular | ebccd5f2a90713fb3233de4109900ffa | {
"intermediate": 0.49360141158103943,
"beginner": 0.20495635271072388,
"expert": 0.3014422357082367
} |
17,346 | Напиши пример на Arduino для esp32 отправить POST запрос на http://192.168.0.113/switch value=92, pal92=2, eff1var=0 | b92624c5f2a66486e4902a003057d526 | {
"intermediate": 0.3436938226222992,
"beginner": 0.3705502152442932,
"expert": 0.2857559621334076
} |
17,347 | Please can you complete this vba code for me to read; If Target Cell is N2 Then Calculate the worksheet | 148dd629a397ec33c4910fe5750e3207 | {
"intermediate": 0.29997143149375916,
"beginner": 0.40319767594337463,
"expert": 0.29683083295822144
} |
17,348 | export interface Tag {
name: string;
color: string;
}
const TradesColumnTag = ({tradeTags, tradeId, fetchTags, ofScreener}: TradesColumnTagPropsType) => {
const [selectTags, setSelectTags] = useState<Tag[]>([]);
const {diaryToken} = useAuthContext();
const dispatch = useDispatch();
const [newTag, setNewTag] = useState<string>("");
const tags = useSelector((state: AppState) => state.tagsSlice.tags);
const tradeTagsStore = useSelector((state: AppState) => state.tagsSlice.tradeTags[tradeId]);
console.log(newTag);
useEffect(() => {
if(!tradeTagsStore) {
dispatch(setTradeTags({tradeId, data: tradeTags}));
}
}, [tradeTags]);
useEffect(() => {
if(!tradeTagsStore) return;
setSelectTags(tradeTagsStore.map(t => ({name: t.name, color: randomColor()})));
}, [tradeTagsStore]);
const createNewTag = (newTag: string) => {
if (!diaryToken || newTag === "") return;
createTag({name: newTag}, diaryToken)
.then(data => {
if (!data) return;
setNewTag("");
fetchTags();
});
};
const randomColor = () => {
const colors = ["#FFE9B8", "#D0E9D7", "#D6E6FF"];
return colors[Math.floor(Math.random() * colors.length)];
};
const truncate = (str: any, n: number) => {
if (str) return str.length > n ? str.substr(0, n) + "..." : str;
};
const handleTagDelete = (value: string) => {
const deleteTagId = tags.find(t => t.name === value)?.id;
if(deleteTagId) {
deleteTag([deleteTagId]);
}
};
const onKeyDownHandler = (e: KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter") createNewTag(e.target.value);
setNewTag("");
};
return (
<Box width="100%">
<FormControl variant="standard" sx={{my: 1, width: ofScreener ? 160 : 250}}>
<Select
multiple
input={<Input />}
displayEmpty
sx={{fontSize: ofScreener ? 11 : 13}}
value={selectTags.map(s => s.name)}
onChange={(e) => handleTagsChange(e.target.value as string[])}
renderValue={(selected) => {
const selectedTruncate: string[] = truncate(selected.toString(), ofScreener ? 16 : 22)?.split(",");
if (selected.length === 0) {
return <Typography fontSize={ofScreener ? 11 : 13} color="#a2a2a2">пробой уровня</Typography>;
}
return <Grid display="flex" >
{selectedTruncate.map((value, index) => {
return <span key={index}>
<Typography
sx={{
display: "flex",
alignItems: "center",
mr: .5,
fontSize: ofScreener ? "11px" : "13px",
color: "#000",
backgroundColor: randomColor(),
border: "none",
borderRradius: "2px",
boxSizing: "content-box",
padding: ofScreener ? "0 7px 0 7px" : "0 10px 0 10px",
"& svg": {
display: "none",
},
"&:hover": {
padding: ofScreener ? "0 2px 0 7px" : "0 2px 0 10px",
"& svg": {
zIndex: 10001,
display: "block",
fontSize: ofScreener ? "15px" : "18px",
cursor: "pointer",
},
},
}}
>
{value}
<CloseIcon onClick={() => handleTagDelete(value)} />
</Typography>
</span>;
})}
</Grid>;
}}
>
{tags.map((option) => (
<MenuItem key={option.id} sx={{py: 0}} value={option.name}>
<Checkbox checked={selectTags.map(s => s.name).indexOf(option.name) > -1} />
<span style={{
borderRadius: 3, marginLeft: 0, color: "#000", fontSize: ofScreener ? "11px" : "13px", padding: ofScreener ? "0 7px 0 7px" : "0 10px 0 10px",
backgroundColor: selectTags.find(tag => tag.name === option.name)?.color || randomColor(),
}}>
{option.name}
{
selectTags.find(t => t.name === option.name) &&
<span style={{marginLeft: 5, fontSize: ofScreener ? "10px" : "12px"}} >❌</span>
}
</span>
</MenuItem>
))}
<TextField
value={newTag}
onChange={(e) => setNewTag(e.target.value)}
sx={{
width: ofScreener ? 160 : 280, ml: 3.5, pt: 1, pb: 0.5,
"& input": {fontSize: ofScreener ? "11px" : "13px"},
"& :before": {borderBottom: theme =>`${ofScreener ? "1px" : "2px"} solid ${theme.palette.text.primary}`, opacity: 0.4},
}}
placeholder={"Новая причина"}
variant="standard"
onKeyDown={onKeyDownHandler}
/>
</Select>
</FormControl>
</Box>
);
};
export default TradesColumnTag;
Напиши полностью такой же Select без исспользования MUI. Select должен быть точно такой же, только на react | fa61cd057c6652e1a0d9b43079bb8bc6 | {
"intermediate": 0.29318946599960327,
"beginner": 0.4770480990409851,
"expert": 0.22976243495941162
} |
17,349 | Сделай так чтобы при нажатии на icon1 появлялось модальное окно ,которое накрывает весь контейнер в котором находится эта иконка (иконка находится на элементе recycleView) : package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.content.Context
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", "Description 1", R.drawable._54282_admin),
SlideItem(" Slide 2", "Description 2", R.drawable._54282_admin),
SlideItem(" Slide 3", "Description 3", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 4", "Description 4", R.drawable._54282_admin),
SlideItem(" Slide 5", "Description 5", R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER's
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game)
)
val customAdapter = CustomRecycleAdapter(customList,this)
customRecyclerView.adapter = customAdapter
val customSnapHelper: SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
fun placeHolder(key : String) {
if (key == "icon1"){
Toast.makeText(activity, key, Toast.LENGTH_SHORT).show();
}
if (key == "icon2"){
Toast.makeText(activity, key, Toast.LENGTH_SHORT).show();
}
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
} | f0f60945c0fb3148fb62d65e4c5c1ab4 | {
"intermediate": 0.29087063670158386,
"beginner": 0.5535956025123596,
"expert": 0.15553371608257294
} |
17,350 | How would you make a .bat file that can run a .gba file? | 529d5941b44e04ede9b0cc66803189dc | {
"intermediate": 0.4789537191390991,
"beginner": 0.21536694467067719,
"expert": 0.3056792616844177
} |
17,351 | Сделай так чтобы при нажатии на icon1 появлялось модальное окно , это модальное окно должноо плавно заполнять весь элемент RecycleView , в котором находится .Важно чтобы модально окно плавно заполняло весь контейнем в котором находится начиная с самой иконки на которую кликнули<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".main_Fragments.Home_Fragment.HomeFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sliderRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:text="Hello"
android:textColor="@color/silver"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/CustomRecycleView"
app:layout_constraintTop_toBottomOf="@+id/sliderRecyclerView"
app:layout_constraintVertical_bias="1.0"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/first_type_recycleView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="276dp"
android:clipToPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintTop_toBottomOf="@+id/sliderRecyclerView"
tools:layout_editor_absoluteX="0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:text="Hello"
android:textColor="@color/silver"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/first_type_recycleView"
app:layout_constraintTop_toBottomOf="@+id/CustomRecycleView"
tools:ignore="MissingConstraints" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/CustomRecycleView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:clipToPadding="true"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintTop_toBottomOf="@+id/sliderRecyclerView"
tools:layout_editor_absoluteX="0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:text="Hello"
android:textColor="@color/silver"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/first_type_recycleView_2"
app:layout_constraintTop_toBottomOf="@+id/first_type_recycleView"
tools:ignore="MissingConstraints" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/first_type_recycleView_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:clipToPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintTop_toBottomOf="@+id/first_type_recycleView"
tools:layout_editor_absoluteX="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.HomeFragment
class CustomRecycleAdapter(private val list: List<CustomDataClass>,private val homeFragment: HomeFragment) :
RecyclerView.Adapter<CustomRecycleAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val createItem =
LayoutInflater.from(parent.context).inflate(R.layout.item_custom_type, parent, false)
return ViewHolder(createItem)
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val currentItem = list[position]
holder.bgImage.setImageResource(currentItem.bgImage)
holder.icon1.setOnClickListener {
homeFragment.placeHolder("icon1")
}
holder.icon2.setOnClickListener {
homeFragment.placeHolder("icon2")
}
}
class ViewHolder(item: View) : RecyclerView.ViewHolder(item) {
val bgImage: ImageView = item.findViewById(R.id.cardBackgroundImage)
val icon1: ImageView = item.findViewById(R.id.icon1)
val icon2: ImageView = item.findViewById(R.id.icon2)
init {
icon1.setOnClickListener {}
icon2.setOnClickListener {}
}
}
}
package com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes
data class CustomDataClass(val bgImage: Int)
: package com.example.cinema_provider_app.main_Fragments.Home_Fragment
import android.content.Context
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
import com.example.cinema_provider_app.R
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.CustomRecycleAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.FirstTypeAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Adapters.SliderAdapter
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.CustomDataClass
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.FirstDataType
import com.example.cinema_provider_app.main_Fragments.Home_Fragment.Data_Classes.SlideItem
class HomeFragment : Fragment() {
private val scrollHandler = Handler()
private lateinit var scrollRunnable: Runnable
private lateinit var sliderRecyclerView: RecyclerView
private lateinit var firstTypeRecyclerView: RecyclerView
private lateinit var secondTypeRecyclerView: RecyclerView
private lateinit var customRecyclerView: RecyclerView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FIRST SLIDER ON THE TOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sliderRecyclerView = view.findViewById(R.id.sliderRecyclerView)
sliderRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(sliderRecyclerView)
val slideItems = listOf(
SlideItem(" Slide 1", “Description 1”, R.drawable._54282_admin),
SlideItem(" Slide 2", “Description 2”, R.drawable._54282_admin),
SlideItem(" Slide 3", “Description 3”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 4", “Description 4”, R.drawable._54282_admin),
SlideItem(" Slide 5", “Description 5”, R.drawable._54282_admin)
)
val sliderAdapter = SliderAdapter(slideItems)
sliderRecyclerView.adapter = sliderAdapter
scrollRunnable = Runnable {
val layoutManager = sliderRecyclerView.layoutManager as LinearLayoutManager
val currentPosition = layoutManager.findFirstVisibleItemPosition()
val nextPosition =
if (currentPosition < sliderAdapter.itemCount - 1) currentPosition + 1 else 0
sliderRecyclerView.smoothScrollToPosition(nextPosition)
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
}
scrollHandler.postDelayed(scrollRunnable, AUTO_SCROLL_DELAY)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SECOND TYPE SLIDER’s
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
firstTypeRecyclerView = view.findViewById(R.id.first_type_recycleView)
val secondSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
firstTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val firstTypeAdapter = FirstTypeAdapter(secondSlideItem)
firstTypeRecyclerView.adapter = firstTypeAdapter
val snappHelper: SnapHelper = LinearSnapHelper()
snappHelper.attachToRecyclerView(firstTypeRecyclerView)
secondTypeRecyclerView = view.findViewById(R.id.first_type_recycleView_2)
val secondTypeSlideItem = listOf<FirstDataType>(
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin),
FirstDataType(R.drawable._54282_admin)
)
secondTypeRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val secondTypeAdapter = FirstTypeAdapter(secondTypeSlideItem)
secondTypeRecyclerView.adapter = secondTypeAdapter
val snappHelperr: SnapHelper = LinearSnapHelper()
snappHelperr.attachToRecyclerView(secondTypeRecyclerView)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM TYPE SLIDER’s
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
customRecyclerView = view.findViewById(R.id.CustomRecycleView)
customRecyclerView.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
val customList = listOf(
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game),
CustomDataClass(R.drawable.bg_game)
)
val customAdapter = CustomRecycleAdapter(customList,this)
customRecyclerView.adapter = customAdapter
val customSnapHelper: SnapHelper = PagerSnapHelper()
customSnapHelper.attachToRecyclerView(customRecyclerView)
}
override fun onDestroy() {
scrollHandler.removeCallbacks(scrollRunnable)
super.onDestroy()
}
fun placeHolder(key : String) {
if (key == “icon1”){
Toast.makeText(activity, key, Toast.LENGTH_SHORT).show();
}
if (key == “icon2”){
Toast.makeText(activity, key, Toast.LENGTH_SHORT).show();
}
}
companion object {
private const val AUTO_SCROLL_DELAY = 10000L // Задержка в миллисекундах (4 секунды)
@JvmStatic
fun newInstance() = HomeFragment()
}
} | 8ed6756058e7447554b44435e8aefe41 | {
"intermediate": 0.3486004173755646,
"beginner": 0.40751633048057556,
"expert": 0.24388328194618225
} |
17,352 | как импортировать из appium expected_conditions | cde1bee5faff4cb06ed3354f7c2a9995 | {
"intermediate": 0.4406009316444397,
"beginner": 0.18097847700119019,
"expert": 0.3784206211566925
} |
17,353 | Create a class Product that represents a product sold in a shop. A product has a price, amount and name.
The class should have:
A constructor public Product(string name, double priceAtStart, int amountAtStart)
A method public void PrintProduct() that prints a product in the following form:
Banana, price 1.1, amount 13
Test your code by creating a class with main method and add three products there:
"Logitech mouse", 70.00 EUR, 14 units
"iPhone 5s", 999.99 EUR, 3 units
"Epson EB-U05", 440.46 EUR, 1 units
Print out information about them.
Add new behaviour to the Product class:
possibility to change quantity
possibility to change price
Reflect your changes in a working application. Please solve with C# code. | 7c3181dd97d337190cb65f6e4579bfd0 | {
"intermediate": 0.3357831537723541,
"beginner": 0.5174371004104614,
"expert": 0.14677973091602325
} |
17,354 | From the following table, write a SQL query to find those employees who are senior employees as of year 1991. Return complete information about the employees. | d48f1a07ef2fa1ae0b54aca8c59a3fbb | {
"intermediate": 0.4016154110431671,
"beginner": 0.27643609046936035,
"expert": 0.32194846868515015
} |
17,355 | How to merge tables in pandas data frame. It is required to get all data from the left table and merge several columns from the rigth table based on the specified column keys? | 05f0d898016029a218ca92b209aa05fd | {
"intermediate": 0.6070229411125183,
"beginner": 0.1500188410282135,
"expert": 0.24295827746391296
} |
17,356 | Assume a file containing a series of integers is named numbers.txt and exists on the computer’s disk.
Write a program that calculates the average of all the numbers stored in the file rounded to 2 decimal places. The program should handle any IOError exceptions that are raised when the file is opened, and data is read from it. It also should handle any ValueError exceptions that are raised when the items that are read from the file are converted to a number. اشرح لي هذا | b6c5dd2ba64693c42fc44e7edbee7373 | {
"intermediate": 0.5283352732658386,
"beginner": 0.18298105895519257,
"expert": 0.2886837124824524
} |
17,357 | # A composite IVF+PQ index speeds up the search by another 16.5x without affecting accuracy, for a whopping total speed increase of 92x compared to non-quantized indexes.
vecs = faiss.IndexFlatL2(dim)
# PQ hyperparmeters
nbits = 8 # bit size | number of internal clusters is k = 2**nbits | cannot be greater then IVF+PQ do to something in faiss
def find_possible_m(dim):
half_dim=dim*0.5
possible_m=[]
for m in range(1,dim):
if dim % m ==0 and m < half_dim:
possible_m.append(m)
return possible_m
m = find_possible_m(dim) # number of subvectors for each vectors
index = faiss.IndexIVFPQ(vecs, dim, nlist, m, nbits)
index.train(embeddings)
index.add(embeddings)
# Move FAISS to GPU
gpu_res = faiss.StandardGpuResources()
gpu_index = faiss.index_cpu_to_gpu(gpu_res, 0, index)
this is my code. m is a list of ints. i want to try to use the largest m in index = faiss.IndexIVFPQ(vecs, dim, nlist, m, nbits)
index.train(embeddings)
index.add(embeddings)
# Move FAISS to GPU
gpu_res = faiss.StandardGpuResources()
gpu_index = faiss.index_cpu_to_gpu(gpu_res, 0, index)
if there is an error use a smaller m in the list | 489a37a2b99e6feccd94c0e3a8c617ad | {
"intermediate": 0.40492478013038635,
"beginner": 0.26657071709632874,
"expert": 0.3285045027732849
} |
17,358 | in networking, what the difference between routing an switching ? | 3622eb7ce6f369ce628a52252b3d6702 | {
"intermediate": 0.26401790976524353,
"beginner": 0.3624591827392578,
"expert": 0.37352290749549866
} |
17,359 | Java return true if any combination of numbers in int[] arr can be added up to equal to largest number | e48a6ab6dc621ee00cc567471f87f415 | {
"intermediate": 0.5205097198486328,
"beginner": 0.24170592427253723,
"expert": 0.23778441548347473
} |
17,360 | primetime (num) return true if prime Java easier fastest solution | 285e31d1c9610b925e52d781fd2191d1 | {
"intermediate": 0.3617774248123169,
"beginner": 0.3004469871520996,
"expert": 0.3377755284309387
} |
17,361 | primetime (num) return true if prime Java easier fastest solution | 4a81872fc7b05dcbbcb6207cbef1bd86 | {
"intermediate": 0.3617774248123169,
"beginner": 0.3004469871520996,
"expert": 0.3377755284309387
} |
17,362 | extract thumbnail in openshot | 57873822ec438780cb3aae8fea992f35 | {
"intermediate": 0.3682166039943695,
"beginner": 0.2592041492462158,
"expert": 0.3725792169570923
} |
17,363 | Java prime check shortest unknown way | 11615f77e7de0a8808c1bb2aa10f3f96 | {
"intermediate": 0.35679832100868225,
"beginner": 0.24427354335784912,
"expert": 0.39892813563346863
} |
17,364 | i have embeddings = encoder.encode(sme_df.PlotSummary.tolist(), show_progress_bar=True, device=torch_device). how can i save embeddings so i do not have to encode again | 0db17a0b97fe9717f4ff6f5cf10f323e | {
"intermediate": 0.4570755064487457,
"beginner": 0.1306600123643875,
"expert": 0.41226446628570557
} |
17,365 | Как сделать так чтобы элемент <View был поверх остальны (сейчас его не видно ) : <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="125dp"
android:layout_height="match_parent"
android:backgroundTint="@color/red"
android:elevation="2dp"
/>
<ImageView
android:id="@+id/cardBackgroundImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="72dp"
android:orientation="horizontal">
<!-- Первая иконка -->
<ImageView
android:id="@+id/icon1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="Title"
android:textStyle="bold"
android:textColor="@color/white"/>
<ImageView
android:id="@+id/icon2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/icon2" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Genre"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cardBackgroundImage"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:text="Rating"
android:textStyle="bold" />
</RelativeLayout>
</androidx.cardview.widget.CardView> | 7bc82f75199358c50e92f9d8fd7065d3 | {
"intermediate": 0.30861443281173706,
"beginner": 0.5571457147598267,
"expert": 0.13423985242843628
} |
17,366 | Palindrometwo(String str) Java return true if strong is palindrome. Shortest solution | 358aac2d5cab6a326eba2cd16742899e | {
"intermediate": 0.45196548104286194,
"beginner": 0.3470466732978821,
"expert": 0.20098784565925598
} |
17,367 | Who r u? | c49ecb26a7ec9cbd99768c61681aa9aa | {
"intermediate": 0.3851482570171356,
"beginner": 0.2946532964706421,
"expert": 0.32019850611686707
} |
17,368 | У меня есть процедура на sql server которая добавляет данные вот ее структура:USE [.CER_1.0]
GO
/****** Object: StoredProcedure [dbo].[ADDNEWUSERS] Script Date: 10.08.2023 20:57:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ADDNEWUSERS]
@CREATEDATE DATE = NULL,
@ADMIN BIT = NULL,
@PROFILE INT = NULL,
@LOGIN NCHAR(10) = NULL,
@PASSWORD NCHAR(10) = NULL,
@BLOCK BIT = NULL,
@SUBSTATION INT = NULL,
@USEREMAIL NCHAR(255),
@TELEFONE1 NCHAR(11),
@ORGANIZATION BIT = NULL,
@LICCH BIT = NULL,
@DOVLICOTOFK INT = NULL,
@CODETOFK INT = NULL,
@ADRESSTOFK INT = NULL,
@CERDLIC INT = NULL,
@PASPORT INT = NULL,
@SERIA NCHAR(6) = NULL,
@NOMBER NCHAR(15) = NULL,
@DATEOFISSUE DATE = NULL,
@KODEP NCHAR(6) = NULL,
@DATEOFBIRTH DATE = NULL,
@PLACEOFBIRTH NCHAR(255) = NULL,
@SEX BIT = NULL,
@EPDOCUMENTFILE BIT = NULL,
@SERVERAUT BIT = NULL,
@LANDOCS BIT = NULL,
@CEDDOC BIT = NULL,
@SIGINFOTOKPAC BIT = NULL,
@EPINTDOCMANAGSYS BIT = NULL,
@EPSOFTCOMP BIT = NULL,
@EPEMAILPROT BIT = NULL,
@SIGNTRUSTIMES BIT = NULL,
@OSCP BIT = NULL,
@CLIENTAUTHE BIT = NULL,
@ROSREESTR1 BIT = NULL,
@FTCRUSSIA BIT = NULL,
@ACYEIRMOS BIT = NULL,
@LASTNAME NCHAR(15)= NULL,
@FIRSTNAME NCHAR(15)= NULL,
@PATRONYMIC NCHAR(15)= NULL,
@INN NCHAR(15)= NULL,
@SNILS NCHAR(15)= NULL,
@ORGANNAME INT = NULL,
@DEVISION1 NCHAR(255)= NULL,
@DEVISION2 NCHAR(255)= NULL,
@POSITION INT = NULL,
@EMAIL NCHAR(255)= NULL,
@REGION INT = NULL,
@LOCALITY INT = NULL,
@CLASSEP INT = NULL,
@CRYPTOPROVIDER INT = NULL,
@KEYEXPORT BIT = NULL,
@APPOINTMENT INT = NULL,
@OFFEVENTEMAIL BIT = NULL,
@OFFEVENTMOBILE BIT = NULL,
@SUBJECTRF INT = NULL,
@OGRN INT = NULL | 81ce286dd44f160b8c15b31d284644cd | {
"intermediate": 0.30957120656967163,
"beginner": 0.4005511403083801,
"expert": 0.28987768292427063
} |
17,369 | Palindrometwo(String str) Java return true if strong is palindrome. Shortest solution. Omit characters punctuations empty characters | c552fe02c9449756d98461d57f07b5ae | {
"intermediate": 0.5164778828620911,
"beginner": 0.22624489665031433,
"expert": 0.2572772204875946
} |
17,370 | Java numbers in an array can be added to the equal of largest | eaf763f703513819745d5bc851af6702 | {
"intermediate": 0.4323170781135559,
"beginner": 0.192688450217247,
"expert": 0.37499451637268066
} |
17,371 | docker vite@latest --template vue not working | 0a60e19dc7b07bac9c63944c21890d30 | {
"intermediate": 0.41347673535346985,
"beginner": 0.2825329303741455,
"expert": 0.30399030447006226
} |
17,372 | You are given an integer, N. Your task is to print an alphabet Rangoli of size N. (Rangoli is a form of Indian folk art based on creation of patterns.)
Input
N is an integer
Output
print an alphabet Rangoli of size N. The letter ‘a’ is always the center letter.
Constraints
1<=N<=10
Example
Input
3
Output
----c----
–c-b-c–
c-b-a-b-c
–c-b-c–
----c---- …Please solve it with C# code | 94fa88cd68c043549af0febb26a207f8 | {
"intermediate": 0.4454394280910492,
"beginner": 0.2879948318004608,
"expert": 0.26656574010849
} |
17,373 | Consecutive (int[] arr)minimum number of integers needed to make content of arr consecutive. Provide fastest easiest solution | 57014ea422b4c34f37a802e863c12e3b | {
"intermediate": 0.3842974007129669,
"beginner": 0.20324838161468506,
"expert": 0.4124542474746704
} |
17,374 | replace every letter in string str with the letter following it in alphabet. Also make wovels capital. Return new string java | 9425cf2eee1bf2c23d91496927dcc50a | {
"intermediate": 0.3791593015193939,
"beginner": 0.27486640214920044,
"expert": 0.345974326133728
} |
17,375 | replace every letter in string str with the letter following it in alphabet. Also make wovels capital. Return new string java | aa03353cad51ef482722c3e5068c7de9 | {
"intermediate": 0.3791593015193939,
"beginner": 0.27486640214920044,
"expert": 0.345974326133728
} |
17,376 | I used your code: def signal_generator(df):
if df is None or len(df) < 2:
return ''
signals = []
# Retrieve depth data
depth_data = client.depth(symbol=symbol)
bid_depth = depth_data['bids']
ask_depth = depth_data['asks']
buy_price = float(bid_depth[0][0]) if bid_depth else 0.0
sell_price = float(ask_depth[0][0]) if ask_depth else 0.0
mark_price_data = client.ticker_price(symbol=symbol)
mark_price = float(mark_price_data['price']) if 'price' in mark_price_data else 0.0
buy_qty = sum(float(bid[1]) for bid in bid_depth)
sell_qty = sum(float(ask[1]) for ask in ask_depth)
mark_price_range = (1 + mark_price / 100, 1 - mark_price / 100)
buy_qty = sum(float(bid[1]) for bid in bid_depth if buy_price * mark_price_range[0] <= float(bid[0]) <= buy_price * mark_price_range[1])
sell_qty = sum(float(ask[1]) for ask in ask_depth if sell_price * mark_price_range[0] <= float(ask[0]) <= sell_price * mark_price_range[1])
if buy_qty > sell_qty:
signals.append('bullish')
elif sell_qty > buy_qty:
signals.append('bearish')
if 'bullish' in signals and float(mark_price) < buy_price:
return 'buy'
elif 'bearish' in signals and float(mark_price) > sell_price:
return 'sell'
else:
return ''
But it deosn't give me any signals | a37b44a63e60b48c3f8fc800a26a173d | {
"intermediate": 0.49174943566322327,
"beginner": 0.294015496969223,
"expert": 0.21423502266407013
} |
17,377 | I want take a courses from TryHackMe and I'm not sure to start by red team courses or offenseve pentestig | 57139397728141f04e929aafa0fd1f93 | {
"intermediate": 0.3367309868335724,
"beginner": 0.24640794098377228,
"expert": 0.4168611466884613
} |
17,378 | this is my code: import os
import math
import random
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from torchvision.models import resnet50
from torch.utils.data import Dataset, DataLoader
import json
from pathlib import Path
import cv2
import numpy as np
from tqdm import tqdm
from IPython.display import clear_output
import optuna
## Set Up
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Set a random seed for torch
seed = 13
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # If using multiple GPUs
np.random.seed(seed)
random.seed(seed)
# Additional configurations for deterministic behavior on CUDA devices
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
data_path = '/workspaces/local_dev/Images/Training'
validation_path = '/workspaces/local_dev/Images/validation_set'
model_name = 'rotnet_resnet50v2'
# Training Parameters
num_samples = 100 # Number of samples used for training. If None then all images
num_val_samples = 25 # Number of samples used for validation. If None then all images
input_shape = (224, 224) # Tuple defining the input image shape (height, width)
# Optuna Optimization Parameters
n_trial = 100 # Number of Optuna Trials
learning_rate_options = (1e-5, 1e-1) # Learning rate for the optimizer
batch_size_options = [8, 16] # Batch size for training
num_epochs_options = (50,50) # Number of epochs to train the model for
weight_decay_options = (1e-6, 0.1)
dropout_rate_options = (0.001, 0.5)
# Define Defs
# Error Function
def angle_difference(x, y):
"""
Calculate minimum difference between two angles.
"""
return 180 - abs(abs(x - y) - 180)
def angle_error(y_true, y_pred):
"""
Calculate the mean difference between the true angles
and the predicted angles.
"""
diff = angle_difference(y_true, y_pred)
return torch.mean(torch.abs(diff.float()))
# Rotation Related
def rotate(image, angle):
"""
Rotates an OpenCV 2 / NumPy image about its center by the given angle
(in degrees).
"""
center = (image.shape[1] / 2, image.shape[0] / 2)
rot_mat = cv2.getRotationMatrix2D(center, angle, 1.0)
return cv2.warpAffine(image, rot_mat, (image.shape[1], image.shape[0]), flags=cv2.INTER_LINEAR)
def largest_rotated_rect(w, h, angle):
"""
Given a rectangle of size wxh that has been rotated by 'angle' (in
radians), computes the width and height of the largest possible
axis-aligned rectangle within the rotated rectangle.
Original JS code by 'Andri' and Magnus Hoff from Stack Overflow
Converted to Python by Aaron Snoswell
Source: http://stackoverflow.com/questions/16702966/rotate-image-and-crop-out-black-borders
"""
quadrant = int(math.floor(angle / (math.pi / 2))) & 3
sign_alpha = angle if ((quadrant & 1) == 0) else math.pi - angle
alpha = (sign_alpha % math.pi + math.pi) % math.pi
bb_w = w * math.cos(alpha) + h * math.sin(alpha)
bb_h = w * math.sin(alpha) + h * math.cos(alpha)
gamma = math.atan2(bb_w, bb_w) if (w < h) else math.atan2(bb_w, bb_w)
delta = math.pi - alpha - gamma
length = h if (w < h) else w
d = length * math.cos(alpha)
a = d * math.sin(alpha) / math.sin(delta)
y = a * math.cos(gamma)
x = y * math.tan(gamma)
return (
bb_w - 2 * x,
bb_h - 2 * y
)
def crop_around_center(image, width, height):
"""
Given a NumPy / OpenCV 2 image, crops it to the given width and height,
around it's centre point
Source: http://stackoverflow.com/questions/16702966/rotate-image-and-crop-out-black-borders
"""
image_size = (image.shape[1], image.shape[0])
image_center = (int(image_size[0] * 0.5), int(image_size[1] * 0.5))
if(width > image_size[0]):
width = image_size[0]
if(height > image_size[1]):
height = image_size[1]
x1 = int(image_center[0] - width * 0.5)
x2 = int(image_center[0] + width * 0.5)
y1 = int(image_center[1] - height * 0.5)
y2 = int(image_center[1] + height * 0.5)
return image[y1:y2, x1:x2]
def crop_largest_rectangle(image, angle, height, width):
"""
Crop around the center the largest possible rectangle
found with largest_rotated_rect.
"""
return crop_around_center(
image,
*largest_rotated_rect(
width,
height,
math.radians(angle)
)
)
def generate_rotated_image(image, angle, size=None, crop_center=False,
crop_largest_rect=False):
"""
Generate a valid rotated image for the RotNetDataGenerator. If the
image is rectangular, the crop_center option should be used to make
it square. To crop out the black borders after rotation, use the
crop_largest_rect option. To resize the final image, use the size
option.
"""
height, width = image.shape[:2]
if crop_center:
if width < height:
height = width
else:
width = height
image = rotate(image, angle)
if crop_largest_rect:
image = crop_largest_rectangle(image, angle, height, width)
if size:
image = cv2.resize(image, size)
return image
def get_filenames(path, num_samples=None):
image_paths = []
# Recursively traverse the directory structure
for root, _, filenames in os.walk(path):
for filename in filenames:
image_paths.append(os.path.join(root, filename))
# Use all available images if num_samples is not provided
if num_samples is None:
train_filenames = image_paths
else:
# Randomly select num_samples images
train_filenames = random.sample(image_paths, min(num_samples, len(image_paths)))
# Shuffle the train_filenames list
random.shuffle(train_filenames)
return train_filenames
# Dataset class for RotNet data
class RotNetDataset(Dataset):
def __init__(self, filenames, num_samples, input_shape, transform=None):
self.filenames = filenames
self.num_samples = num_samples
self.input_shape = input_shape
self.transform = transform
def __len__(self):
return min(self.num_samples, len(self.filenames))
def __getitem__(self, idx):
image = cv2.imread(self.filenames[idx])
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
rotation_angle = random.randint(0, 359)
rotated_image = generate_rotated_image(
image,
rotation_angle,
size=self.input_shape,
crop_center=True,
crop_largest_rect=True
)
sample = {'image': rotated_image, 'angle': rotation_angle}
if self.transform:
sample['image'] = self.transform(sample['image'])
return sample
# Define transforms
transform = transforms.Compose([
transforms.ToPILImage(),
transforms.Resize(input_shape),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
## Run
## Run
# Model definition
num_classes = 360 # The degrees of a circle
class RotNetModel(nn.Module):
def __init__(self, num_classes):
super(RotNetModel, self).__init__()
self.resnet = resnet50(weights=True)
self.resnet.fc = nn.Linear(2048, num_classes)
def forward(self, x):
return self.resnet(x)
# Initialize the model
model = RotNetModel(num_classes=num_classes).to(device)
# Create output folder if it doesn't exist
output_folder = 'models'
Path(output_folder).mkdir(parents=True, exist_ok=True)
# Training loop
def train_model(model, dataloader, criterion, optimizer, start_epoch=0, num_epochs=50, patience=10):
model.train()
best_loss = float('inf')
epochs_without_improvement = 0 # Count how many epochs without improvement
for epoch in range(start_epoch, num_epochs):
running_loss = 0.0
for i, data in enumerate(dataloader, 0):
inputs, labels = data['image'].to(device), data['angle'].to(device)
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
running_loss += loss.item()
# Log training loss to TensorBoard
global_step = epoch * len(dataloader) + i
epoch_loss = running_loss / len(dataloader)
print(f'Epoch [{epoch + 1}/{num_epochs}] Loss: {epoch_loss:.4f}')
if epoch_loss < best_loss:
best_loss = epoch_loss
epochs_without_improvement = 0 # Reset counter
torch.save(model.state_dict(), os.path.join(output_folder, model_name + '.pth'))
else:
epochs_without_improvement += 1
if epochs_without_improvement >= patience:
print(f'Early stopping after {patience} epochs without improvement.')
break
return model # Return the trained model
# Define the objective function for Optuna
def objective(trial):
learning_rate = trial.suggest_float('learning_rate', *learning_rate_options, log=True)
weight_decay = trial.suggest_float('weight_decay', *weight_decay_options, log=True)
batch_size = trial.suggest_categorical('batch_size', batch_size_options)
num_epochs = trial.suggest_int('num_epochs', *num_epochs_options)
dropout_rate = trial.suggest_float('dropout_rate', *dropout_rate_options, log=True)
optimizer_choice = trial.suggest_categorical('optimizer', ['SGD', 'Adam', 'RMSprop'])
# Define the model
model = RotNetModel(num_classes=num_classes).to(device)
# Define the optimizer with suggested learning rate
if optimizer_choice == 'SGD':
optimizer = optim.SGD(model.parameters(), lr=learning_rate, momentum=0.9, weight_decay=weight_decay)
elif optimizer_choice == 'Adam':
optimizer = optim.Adam(model.parameters(), lr=learning_rate, weight_decay=weight_decay)
elif optimizer_choice == 'RMSprop':
optimizer = optim.RMSprop(model.parameters(), lr=learning_rate, weight_decay=weight_decay)
# Initialize data loaders
train_dataset = RotNetDataset(train_filenames, num_samples, input_shape, transform=transform)
train_dataloader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=8)
# Train the model
train_model(model, train_dataloader, criterion, optimizer, num_epochs=num_epochs)
# Calculate the angle error on the validation set
model.eval()
validation_Data = RotNetDataset(validation_filenames, num_samples, input_shape, transform=transform)
validation_dataloader = DataLoader(validation_Data, batch_size=batch_size, shuffle=False, num_workers=4)
total_angle_error = 0.0
total_samples = 0
with torch.no_grad():
for data in validation_dataloader:
inputs, labels = data['image'].to(device), data['angle'].to(device)
outputs = model(inputs)
predicted_angles = outputs.argmax(dim=1)
angle_errors = angle_error(labels, predicted_angles)
total_angle_error += angle_errors.item() * len(labels)
total_samples += len(labels)
# Calculate the mean angle error for the validation set
mean_angle_error = total_angle_error / total_samples
# Clear the output after each iteration
clear_output(wait=True)
# Return the mean angle error to Optuna (minimize it)
return mean_angle_error
if __name__ == '__main__':
# Initialize the model
model = RotNetModel(num_classes=num_classes).to(device)
# Loss function and optimizer
criterion = nn.CrossEntropyLoss()
optimizer = optim.SGD(model.parameters(), lr=0.01, momentum=0.9)
# Create output folder if it doesn't exist
output_folder = 'models'
Path(output_folder).mkdir(parents=True, exist_ok=True)
# Training loop using Optuna
study = optuna.create_study(direction='minimize')
study.optimize(objective, n_trials=n_trial)
print('Number of finished trials:', len(study.trials))
print('Best trial:')
trial = study.best_trial
print('Value:', trial.value)
print('Params:')
best_params = {}
for key, value in trial.params.items():
print(f' {key}: {value}')
best_params[key] = value # Store best hyperparameters
# Save the best hyperparameters to a file
best_params_path = os.path.join(output_folder, 'best_hyperparameters.json')
with open(best_params_path, 'w') as f:
json.dump(best_params, f)
saved_file_path = os.path.join(output_folder, model_name + '.pth')
if os.path.exists(saved_file_path):
os.remove(saved_file_path)
print(f"File {saved_file_path} deleted.")
else:
print(f"File {saved_file_path} not found.") | d80c1ed6a79b1ddf0ff650d20bdcb088 | {
"intermediate": 0.39916014671325684,
"beginner": 0.35505449771881104,
"expert": 0.24578532576560974
} |
17,379 | this is my code: import os
import math
import random
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from torchvision.models import resnet50
from torch.utils.data import Dataset, DataLoader
import json
from pathlib import Path
import cv2
import numpy as np
from tqdm import tqdm
from IPython.display import clear_output
import optuna
## Set Up
device = torch.device(‘cuda’ if torch.cuda.is_available() else ‘cpu’)
# Set a random seed for torch
seed = 13
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # If using multiple GPUs
np.random.seed(seed)
random.seed(seed)
# Additional configurations for deterministic behavior on CUDA devices
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
data_path = ‘/workspaces/local_dev/Images/Training’
validation_path = ‘/workspaces/local_dev/Images/validation_set’
model_name = ‘rotnet_resnet50v2’
# Training Parameters
num_samples = 100 # Number of samples used for training. If None then all images
num_val_samples = 25 # Number of samples used for validation. If None then all images
input_shape = (224, 224) # Tuple defining the input image shape (height, width)
# Optuna Optimization Parameters
n_trial = 100 # Number of Optuna Trials
learning_rate_options = (1e-5, 1e-1) # Learning rate for the optimizer
batch_size_options = [8, 16] # Batch size for training
num_epochs_options = (50,50) # Number of epochs to train the model for
weight_decay_options = (1e-6, 0.1)
dropout_rate_options = (0.001, 0.5)
# Define Defs
# Error Function
def angle_difference(x, y):
“”“
Calculate minimum difference between two angles.
“””
return 180 - abs(abs(x - y) - 180)
def angle_error(y_true, y_pred):
“”“
Calculate the mean difference between the true angles
and the predicted angles.
“””
diff = angle_difference(y_true, y_pred)
return torch.mean(torch.abs(diff.float()))
# Rotation Related
def rotate(image, angle):
“”“
Rotates an OpenCV 2 / NumPy image about its center by the given angle
(in degrees).
“””
center = (image.shape[1] / 2, image.shape[0] / 2)
rot_mat = cv2.getRotationMatrix2D(center, angle, 1.0)
return cv2.warpAffine(image, rot_mat, (image.shape[1], image.shape[0]), flags=cv2.INTER_LINEAR)
def largest_rotated_rect(w, h, angle):
“”“
Given a rectangle of size wxh that has been rotated by ‘angle’ (in
radians), computes the width and height of the largest possible
axis-aligned rectangle within the rotated rectangle.
Original JS code by ‘Andri’ and Magnus Hoff from Stack Overflow
Converted to Python by Aaron Snoswell
Source: http://stackoverflow.com/questions/16702966/rotate-image-and-crop-out-black-borders
“””
quadrant = int(math.floor(angle / (math.pi / 2))) & 3
sign_alpha = angle if ((quadrant & 1) == 0) else math.pi - angle
alpha = (sign_alpha % math.pi + math.pi) % math.pi
bb_w = w * math.cos(alpha) + h * math.sin(alpha)
bb_h = w * math.sin(alpha) + h * math.cos(alpha)
gamma = math.atan2(bb_w, bb_w) if (w < h) else math.atan2(bb_w, bb_w)
delta = math.pi - alpha - gamma
length = h if (w < h) else w
d = length * math.cos(alpha)
a = d * math.sin(alpha) / math.sin(delta)
y = a * math.cos(gamma)
x = y * math.tan(gamma)
return (
bb_w - 2 * x,
bb_h - 2 * y
)
def crop_around_center(image, width, height):
“”“
Given a NumPy / OpenCV 2 image, crops it to the given width and height,
around it’s centre point
Source: http://stackoverflow.com/questions/16702966/rotate-image-and-crop-out-black-borders
“””
image_size = (image.shape[1], image.shape[0])
image_center = (int(image_size[0] * 0.5), int(image_size[1] * 0.5))
if(width > image_size[0]):
width = image_size[0]
if(height > image_size[1]):
height = image_size[1]
x1 = int(image_center[0] - width * 0.5)
x2 = int(image_center[0] + width * 0.5)
y1 = int(image_center[1] - height * 0.5)
y2 = int(image_center[1] + height * 0.5)
return image[y1:y2, x1:x2]
def crop_largest_rectangle(image, angle, height, width):
“”“
Crop around the center the largest possible rectangle
found with largest_rotated_rect.
“””
return crop_around_center(
image,
*largest_rotated_rect(
width,
height,
math.radians(angle)
)
)
def generate_rotated_image(image, angle, size=None, crop_center=False,
crop_largest_rect=False):
“”“
Generate a valid rotated image for the RotNetDataGenerator. If the
image is rectangular, the crop_center option should be used to make
it square. To crop out the black borders after rotation, use the
crop_largest_rect option. To resize the final image, use the size
option.
“””
height, width = image.shape[:2]
if crop_center:
if width < height:
height = width
else:
width = height
image = rotate(image, angle)
if crop_largest_rect:
image = crop_largest_rectangle(image, angle, height, width)
if size:
image = cv2.resize(image, size)
return image
def get_filenames(path, num_samples=None):
image_paths = []
# Recursively traverse the directory structure
for root, _, filenames in os.walk(path):
for filename in filenames:
image_paths.append(os.path.join(root, filename))
# Use all available images if num_samples is not provided
if num_samples is None:
train_filenames = image_paths
else:
# Randomly select num_samples images
train_filenames = random.sample(image_paths, min(num_samples, len(image_paths)))
# Shuffle the train_filenames list
random.shuffle(train_filenames)
return train_filenames
# Dataset class for RotNet data
class RotNetDataset(Dataset):
def init(self, filenames, num_samples, input_shape, transform=None):
self.filenames = filenames
self.num_samples = num_samples
self.input_shape = input_shape
self.transform = transform
def len(self):
return min(self.num_samples, len(self.filenames))
def getitem(self, idx):
image = cv2.imread(self.filenames[idx])
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
rotation_angle = random.randint(0, 359)
rotated_image = generate_rotated_image(
image,
rotation_angle,
size=self.input_shape,
crop_center=True,
crop_largest_rect=True
)
sample = {‘image’: rotated_image, ‘angle’: rotation_angle}
if self.transform:
sample[‘image’] = self.transform(sample[‘image’])
return sample
# Define transforms
transform = transforms.Compose([
transforms.ToPILImage(),
transforms.Resize(input_shape),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
## Run
## Run
# Model definition
num_classes = 360 # The degrees of a circle
class RotNetModel(nn.Module):
def init(self, num_classes):
super(RotNetModel, self).init()
self.resnet = resnet50(weights=True)
self.resnet.fc = nn.Linear(2048, num_classes)
def forward(self, x):
return self.resnet(x)
# Initialize the model
model = RotNetModel(num_classes=num_classes).to(device)
# Create output folder if it doesn’t exist
output_folder = ‘models’
Path(output_folder).mkdir(parents=True, exist_ok=True)
# Training loop
def train_model(model, dataloader, criterion, optimizer, start_epoch=0, num_epochs=50, patience=10):
model.train()
best_loss = float(‘inf’)
epochs_without_improvement = 0 # Count how many epochs without improvement
for epoch in range(start_epoch, num_epochs):
running_loss = 0.0
for i, data in enumerate(dataloader, 0):
inputs, labels = data[‘image’].to(device), data[‘angle’].to(device)
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
running_loss += loss.item()
# Log training loss to TensorBoard
global_step = epoch * len(dataloader) + i
epoch_loss = running_loss / len(dataloader)
print(f’Epoch [{epoch + 1}/{num_epochs}] Loss: {epoch_loss:.4f}‘)
if epoch_loss < best_loss:
best_loss = epoch_loss
epochs_without_improvement = 0 # Reset counter
torch.save(model.state_dict(), os.path.join(output_folder, model_name + ‘.pth’))
else:
epochs_without_improvement += 1
if epochs_without_improvement >= patience:
print(f’Early stopping after {patience} epochs without improvement.’)
break
return model # Return the trained model
# Define the objective function for Optuna
def objective(trial):
learning_rate = trial.suggest_float(‘learning_rate’, *learning_rate_options, log=True)
weight_decay = trial.suggest_float(‘weight_decay’, *weight_decay_options, log=True)
batch_size = trial.suggest_categorical(‘batch_size’, batch_size_options)
num_epochs = trial.suggest_int(‘num_epochs’, *num_epochs_options)
dropout_rate = trial.suggest_float(‘dropout_rate’, *dropout_rate_options, log=True)
optimizer_choice = trial.suggest_categorical(‘optimizer’, [‘SGD’, ‘Adam’, ‘RMSprop’])
# Define the model
model = RotNetModel(num_classes=num_classes).to(device)
# Define the optimizer with suggested learning rate
if optimizer_choice == ‘SGD’:
optimizer = optim.SGD(model.parameters(), lr=learning_rate, momentum=0.9, weight_decay=weight_decay)
elif optimizer_choice == ‘Adam’:
optimizer = optim.Adam(model.parameters(), lr=learning_rate, weight_decay=weight_decay)
elif optimizer_choice == ‘RMSprop’:
optimizer = optim.RMSprop(model.parameters(), lr=learning_rate, weight_decay=weight_decay)
# Initialize data loaders
train_dataset = RotNetDataset(train_filenames, num_samples, input_shape, transform=transform)
train_dataloader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, num_workers=8)
# Train the model
train_model(model, train_dataloader, criterion, optimizer, num_epochs=num_epochs)
# Calculate the angle error on the validation set
model.eval()
validation_Data = RotNetDataset(validation_filenames, num_samples, input_shape, transform=transform)
validation_dataloader = DataLoader(validation_Data, batch_size=batch_size, shuffle=False, num_workers=4)
total_angle_error = 0.0
total_samples = 0
with torch.no_grad():
for data in validation_dataloader:
inputs, labels = data[‘image’].to(device), data[‘angle’].to(device)
outputs = model(inputs)
predicted_angles = outputs.argmax(dim=1)
angle_errors = angle_error(labels, predicted_angles)
total_angle_error += angle_errors.item() * len(labels)
total_samples += len(labels)
# Calculate the mean angle error for the validation set
mean_angle_error = total_angle_error / total_samples
# Clear the output after each iteration
clear_output(wait=True)
# Return the mean angle error to Optuna (minimize it)
return mean_angle_error
if name == ‘main’:
# Initialize the model
model = RotNetModel(num_classes=num_classes).to(device)
# Loss function and optimizer
criterion = nn.CrossEntropyLoss()
optimizer = optim.SGD(model.parameters(), lr=0.01, momentum=0.9)
# Create output folder if it doesn’t exist
output_folder = ‘models’
Path(output_folder).mkdir(parents=True, exist_ok=True)
# Training loop using Optuna
study = optuna.create_study(direction=‘minimize’)
study.optimize(objective, n_trials=n_trial)
print(‘Number of finished trials:’, len(study.trials))
print(‘Best trial:’)
trial = study.best_trial
print(‘Value:’, trial.value)
print(‘Params:’)
best_params = {}
for key, value in trial.params.items():
print(f’ {key}: {value}')
best_params[key] = value # Store best hyperparameters
# Save the best hyperparameters to a file
best_params_path = os.path.join(output_folder, ‘best_hyperparameters.json’)
with open(best_params_path, ‘w’) as f:
json.dump(best_params, f)
saved_file_path = os.path.join(output_folder, model_name + ‘.pth’)
if os.path.exists(saved_file_path):
os.remove(saved_file_path)
print(f"File {saved_file_path} deleted.“)
else:
print(f"File {saved_file_path} not found.”) | 4467ad9679bf9fbe0f7fae59c7876687 | {
"intermediate": 0.4911869168281555,
"beginner": 0.25153183937072754,
"expert": 0.25728127360343933
} |
17,380 | make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all vmake normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all the following: Sure! Here's an example of how you can incorporate NLP AI-generated riddles into a simple web-based game using HTML, CSS, and JavaScript:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Food Riddle Enigma</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="container">
<h1>Food Riddle Enigma</h1>
<p id="riddle"></p>
<input type="text" id="guess" placeholder="Enter your guess">
<button onclick="checkGuess()">Submit</button>
<p id="result"></p>
<button onclick="nextRiddle()">Next Riddle</button>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css):
.container {
text-align: center;
max-width: 500px;
margin: 0 auto;
}
h1 {
color: #333;
}
button {
background-color: #333;
color: #fff;
padding: 10px 20px;
border: none;
cursor: pointer;
}
input {
padding: 10px;
width: 100%;
margin-bottom: 10px;
}
#result {
font-weight: bold;
}
JavaScript (script.js):
// Place your NLP AI-generated riddles in an array
var riddles = [
"I'm round and cheesy, baked to perfection...",
"I'm wrapped up tight, a bite-sized treat...",
"I'm a culinary creation, stacked high with care..."
];
// Corresponding food names
var answers = ["Pizza", "Sushi", "Burger"];
var currentIndex = 0;
function checkGuess() {
var guess = document.getElementById("guess").value;
var result = document.getElementById("result");
if (guess.toLowerCase() === answers[currentIndex].toLowerCase()) {
result.textContent = "Correct! It's " + answers[currentIndex] + "!";
} else {
result.textContent = "Wrong! Try again.";
}
}
function nextRiddle() {
currentIndex++;
if (currentIndex >= riddles.length) {
currentIndex = 0;
}
var riddle = document.getElementById("riddle");
riddle.textContent = riddles[currentIndex];
document.getElementById("guess").value = "";
document.getElementById("result").textContent = "";
}
// Initialize the first riddle on page load
window.onload = function() {
var riddle = document.getElementById("riddle");
riddle.textContent = riddles[currentIndex];
};
This code sets up a simple web-based game where users can guess the food name based on the given riddle. The script rotates through the riddles and checks the user's input against the corresponding answer. If the guess is correct, it displays a success message, and if it's incorrect, it prompts the user to try again. The "Next Riddle" button moves to the next riddle in the array.
Remember to replace the placeholder riddles with your NLP AI-generated riddles and adjust the styling to your preference. Additionally, you can expand the game's functionality by adding more riddles, a scoring system, and additional features based on your game concept.
I hope this example helps you get started with incorporating AI-generated riddles into your game! If you need any further assistance or have any specific requirements or questions, please let me know.
you output some (in dependence of hardness in terms used) food-related emojicons in a row that should auto-fit on the entire window size and resize, like from 3 to 5. all these emojicons should be shown instantly with only one riddle beneath them in some cute container that is related to particular emojicon in food terms used. if user guess it right, it get one score added (somewhere in the corner), if no then one score got removed. the entire concept is extremely easy in overall code to perform. you can try add your suggestions or super (not complex to perform) ideas if you like or wish. nonono, you cannot use submit!11111111111111111111111!!!!!!!!!!!!11111111111 you can try add your suggestions or super (not complex to perform) ideas if you like or wish?????????????????make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all make normal pseudo-pre-prompt based on all | 16910c929a4fb548e666228aa4c8e072 | {
"intermediate": 0.3798487186431885,
"beginner": 0.4149106442928314,
"expert": 0.2052406519651413
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.