text:
Q: SwiftUI - precondition failure: invalid input index: 4 on keyboard notification Tested on simulator only. I have found some code to scroll VStack when keyboard will be shown
but I get an error precondition failure: invalid input index: 4 Image attached
I've uploaded a video as well.
import SwiftUI
import Combine

struct AdaptsToKeyboard: ViewModifier {
    @State var currentHeight: CGFloat = 0

    func body(content: Content) -> some View {
        GeometryReader { geometry in
            content
                .padding(.bottom, self.currentHeight)
                .animation(.easeOut(duration: 0.16))
                .onAppear(perform: {
                    NotificationCenter.Publisher(center: NotificationCenter.default, name: UIResponder.keyboardWillShowNotification)
                        .merge(with: NotificationCenter.Publisher(center: NotificationCenter.default, name: UIResponder.keyboardWillChangeFrameNotification))
                        .compactMap { notification in
                            notification.userInfo?["UIKeyboardFrameEndUserInfoKey"] as? CGRect
                    }
                    .map { rect in
                        rect.height - geometry.safeAreaInsets.bottom
                    }
                    .subscribe(Subscribers.Assign(object: self, keyPath: \.currentHeight))

                    NotificationCenter.Publisher(center: NotificationCenter.default, name: UIResponder.keyboardWillHideNotification)
                        .compactMap { notification in
                            CGFloat.zero
                    }
                    .subscribe(Subscribers.Assign(object: self, keyPath: \.currentHeight))
                })
        }
    }
}

Here is how I use this modifier:
struct LoginView: View {

    @State private var email = ""
    @State var showWelcomeView = false
    @State var loopAnimation = false

    var body: some View {
        NavigationView {
            ZStack {
                Color.customLightGray
                if self.loopAnimation {
                    VStack {
                        LottieView(named: "19451-blue-preloader",
                                   loop: self.loopAnimation,
                                   size: 200
                        ).padding(.top, 350)
                            .padding(.leading, 110)

                    }.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading)
                } else {
                    VStack (alignment: .leading, spacing: 10) {
                        Text("Email:")
                            .font(.headline)

                        TextField("Enter your email", text: $email)
                            .padding(.all)
                            .font(Font.system(size: 18, weight: .medium, design: .rounded))
                            .overlay(RoundedRectangle(cornerRadius: 8).stroke(Color.blue, lineWidth: 1))
                            .foregroundColor(Color.blue)
                            .keyboardType(.emailAddress)
                            .autocapitalization(.none)

                        Button(action: {
                        }) {
                            Text("Forgot password?")
                                .fontWeight(.bold)
                                .font(.headline)
                                .padding(EdgeInsets(top: 20, leading: 10, bottom: 20, trailing: 0))
                                .foregroundColor(.blue)
                        }

                        HStack {
                            Button(action: {
                            }) {
                                Text("Create account")
                                    .fontWeight(.bold)
                                    .font(.subheadline)
                                    .padding()
                                    .foregroundColor(.blue)
                            }

                            Spacer()

                            Button(action: {
                                self.loopAnimation.toggle()
                                self.fetchUser(with: self.email)
                            }) {
                                Text("Next")
                                    .fontWeight(.bold)
                                    .font(.title)
                                    .padding(EdgeInsets(top: 20, leading: 40, bottom: 20, trailing: 40))
                                    .background(Color.blue)
                                    .cornerRadius(8)
                                    .foregroundColor(.white)
                            }

                            NavigationLink(destination: WelcomeView(), isActive: $showWelcomeView) { EmptyView() }
                        }

                    }.padding(.horizontal, 30)
                        .modifier(AdaptsToKeyboard())
                }

            }
            .navigationBarTitle(Text("Login"))
            .edgesIgnoringSafeArea(.all)
        }
    }

    func fetchUser(with email: String) {

        UserService().getUser(with: email) { (user) in
            self.loopAnimation = false
            self.showWelcomeView = true
        }

    }
}

struct LoginView_Previews: PreviewProvider {
    static var previews: some View {
        LoginView()
    }
}

if I remove if self.loopAnimation condition then my code works well without such SIGABRT


text:
Q: VideoPlayer freezes the app I have a subclassed VideoView:
import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.VideoView;

public class VideoPlayerView extends VideoView {
    private static final String TAG = "VideoPlayerView";

    public VideoPlayerView(Context context) {
        super(context);
    }

    public VideoPlayerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public VideoPlayerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void release() {
    }

    public void playVideo() {
        setVideoURI(Uri.parse("http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"));
        start();
    }
}

And a few XML layouts that use it in this manner:
<my.package.path.ui.common.VideoPlayerView
        android:id="@+id/video"
        android:layout_width="fill_parent"
        android:layout_height="300dp"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"/>

I call playVideo in parent activity's onCreate(). The problem is that, if I hit the back button before the video is ready, the app stops responding for about 10-20 seconds and I can see the following in LogCat:
07-31 08:30:42.049: V/MediaPlayerService(18684): [1] reset
07-31 08:30:42.049: V/ChromiumHTTPDataSource(18684): disconnect()
07-31 08:30:42.057: V/ChromiumHTTPDataSource(18684): onDisconnectComplete() mState = 0
07-31 08:30:42.065: A/(18684): frameworks/base/media/libstagefright/foundation/ABuffer.cpp:58 CHECK_LE( offset + size,mCapacity) failed: 4294967288 vs. 262824
07-31 08:30:42.065: A/libc(18684): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
07-31 08:30:42.315: I/power(179): *** release_dvfs_lock : lockType : 1
07-31 08:30:42.315: D/PowerManagerService(179): releaseDVFSLockLocked : all DVFS_MIN_LIMIT are released
07-31 08:30:42.315: W/ActivityManager(179): mDVFSLock.release()
07-31 08:30:42.573: I/DEBUG(6475): SET
07-31 08:30:42.573: I/DEBUG(6475): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-31 08:30:42.573: I/DEBUG(6475): Build fingerprint: 'samsung/espresso10wifixx/espresso10wifi:4.0.3/IML74K/P5110XXALB7:eng/test-keys'
07-31 08:30:42.573: I/DEBUG(6475): pid: 18684, tid: 18697  >>> /system/bin/mediaserver <<<
07-31 08:30:42.573: I/DEBUG(6475): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
07-31 08:30:42.573: I/DEBUG(6475):  r0 deadbaad  r1 00000001  r2 00000000  r3 00000000
07-31 08:30:42.573: I/DEBUG(6475):  r4 00000000  r5 00000027  r6 01ff81c0  r7 fffffff8
07-31 08:30:42.573: I/DEBUG(6475):  r8 00000000  r9 00000001  10 413df629  fp 0000001e
07-31 08:30:42.573: I/DEBUG(6475):  ip ffffffff  sp 42356870  lr 400f20a9  pc 400ee808  cpsr 60000030
07-31 08:30:42.573: I/DEBUG(6475):  d0  2e73762038383220  d1  6574636f2f6e6f32
07-31 08:30:42.573: I/DEBUG(6475):  d2  6f632e656c707036  d3  656e6f6870692f32
07-31 08:30:42.573: I/DEBUG(6475):  d4  73656c706d61732f  d5  2f706f627069622f
07-31 08:30:42.573: I/DEBUG(6475):  d6  69662f3172616567  d7  0000001e6553656c
07-31 08:30:42.573: I/DEBUG(6475):  d8  00000000000402a8  d9  412021a600000000
07-31 08:30:42.573: I/DEBUG(6475):  d10 416312d000000000  d11 4014000000000000
07-31 08:30:42.573: I/DEBUG(6475):  d12 0000000000000000  d13 0000000000000000
07-31 08:30:42.573: I/DEBUG(6475):  d14 0000000000000000  d15 0000000000000000
07-31 08:30:42.573: I/DEBUG(6475):  d16 4187d78400000000  d17 41f1406280400000
07-31 08:30:42.573: I/DEBUG(6475):  d18 3fe0000000000000  d19 3fe0000000000a28
07-31 08:30:42.573: I/DEBUG(6475):  d20 3f1149942ce213d7  d21 bebba8a21867784d
07-31 08:30:42.573: I/DEBUG(6475):  d22 3ff0000000000000  d23 3fe6c310da4e22ec
07-31 08:30:42.573: I/DEBUG(6475):  d24 3e66376972bea4d0  d25 0000000000000000
07-31 08:30:42.573: I/DEBUG(6475):  d26 0000000000000000  d27 0000000000000000
07-31 08:30:42.573: I/DEBUG(6475):  d28 0000000000000000  d29 0000000000000000
07-31 08:30:42.573: I/DEBUG(6475):  d30 0000000000000000  d31 0000000000000000
07-31 08:30:42.573: I/DEBUG(6475):  scr 20000010
07-31 08:30:42.651: W/PowerManagerService(179): Timer 0x7->0x3|0x3
07-31 08:30:42.651: I/PowerManagerService(179): Ulight 7->3|0
07-31 08:30:42.651: D/PowerManagerService(179): setLightBrightness : mButtonLight : 0
07-31 08:30:42.760: I/DEBUG(6475):          #00  pc 00017808  /system/lib/libc.so
07-31 08:30:42.760: I/DEBUG(6475):          #01  pc 0000144a  /system/lib/liblog.so (__android_log_assert)
07-31 08:30:42.760: I/DEBUG(6475):          #02  pc 000061ac  /system/lib/libstagefright_foundation.so (_ZN7android7ABuffer8setRangeEjj)
07-31 08:30:42.776: I/DEBUG(6475):          #03  pc 000ed0f8  /system/lib/libstagefright.so (_ZN7android11LiveSession9fetchFileEPKcPNS_2spINS_7ABufferEEEjd)
07-31 08:30:42.776: I/DEBUG(6475): code around pc:
07-31 08:30:42.776: I/DEBUG(6475): 400ee7e8 4623b15c 2c006824 e026d1fb b12368db  \.#F$h.,..&..h#.
07-31 08:30:42.776: I/DEBUG(6475): 400ee7f8 21014a17 6011447a 48124798 24002527  .J.!zD.`.G.H'%.$
07-31 08:30:42.776: I/DEBUG(6475): 400ee808 f7f47005 2106eec4 ef52f7f5 460aa901  .p.....!..R....F
07-31 08:30:42.776: I/DEBUG(6475): 400ee818 f04f2006 94015380 94029303 eb1cf7f5  . O..S..........
07-31 08:30:42.776: I/DEBUG(6475): 400ee828 4622a905 f7f52002 f7f4eb26 2106eeb0  .."F. ..&......!
07-31 08:30:42.776: I/DEBUG(6475): code around lr:
07-31 08:30:42.776: I/DEBUG(6475): 400f2088 41f0e92d 46804c0c 447c2600 68a56824  -..A.L.F.&|D$h.h
07-31 08:30:42.776: I/DEBUG(6475): 400f2098 e0076867 300cf9b5 dd022b00 47c04628  gh.....0.+..(F.G
07-31 08:30:42.776: I/DEBUG(6475): 400f20a8 35544306 37fff117 6824d5f4 d1ee2c00  .CT5...7..$h.,..
07-31 08:30:42.776: I/DEBUG(6475): 400f20b8 e8bd4630 bf0081f0 00028472 41f0e92d  0F......r...-..A
07-31 08:30:42.776: I/DEBUG(6475): 400f20c8 fb01b086 9004f602 461f4815 4615460c  .........H.F.F.F
07-31 08:30:42.776: I/DEBUG(6475): memory map around addr deadbaad:
07-31 08:30:42.776: I/DEBUG(6475): be80a000-be82b000 [stack]
07-31 08:30:42.776: I/DEBUG(6475): (no map for address)
07-31 08:30:42.776: I/DEBUG(6475): ffff0000-ffff1000 [vectors]
07-31 08:30:42.776: I/DEBUG(6475): stack:
07-31 08:30:42.776: I/DEBUG(6475):     42356830  0004c61f
07-31 08:30:42.776: I/DEBUG(6475):     42356834  00000380
07-31 08:30:42.776: I/DEBUG(6475):     42356838  ffff0208  [vectors]
07-31 08:30:42.776: I/DEBUG(6475):     4235683c  4235689c
07-31 08:30:42.776: I/DEBUG(6475):     42356840  4011a72c  /system/lib/libc.so
07-31 08:30:42.776: I/DEBUG(6475):     42356844  4011f828
07-31 08:30:42.776: I/DEBUG(6475):     42356848  00000000
07-31 08:30:42.776: I/DEBUG(6475):     4235684c  400f20a9  /system/lib/libc.so
07-31 08:30:42.776: I/DEBUG(6475):     42356850  00000000
07-31 08:30:42.776: I/DEBUG(6475):     42356854  42356884
07-31 08:30:42.776: I/DEBUG(6475):     42356858  01ff81c0  [heap]
07-31 08:30:42.776: I/DEBUG(6475):     4235685c  fffffff8
07-31 08:30:42.776: I/DEBUG(6475):     42356860  00000000
07-31 08:30:42.776: I/DEBUG(6475):     42356864  400f1215  /system/lib/libc.so
07-31 08:30:42.776: I/DEBUG(6475):     42356868  df0027ad
07-31 08:30:42.776: I/DEBUG(6475):     4235686c  00000000
07-31 08:30:42.776: I/DEBUG(6475): #00 42356870  4235686c
07-31 08:30:42.776: I/DEBUG(6475):     42356874  00000001
07-31 08:30:42.776: I/DEBUG(6475):     42356878  400d5575  /system/lib/liblog.so
07-31 08:30:42.776: I/DEBUG(6475):     4235687c  00000001
07-31 08:30:42.776: I/DEBUG(6475):     42356880  4235689c
07-31 08:30:42.776: I/DEBUG(6475):     42356884  fffffbdf
07-31 08:30:42.776: I/DEBUG(6475):     42356888  00000000
07-31 08:30:42.776: I/DEBUG(6475):     4235688c  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356890  42356cbc
07-31 08:30:42.783: I/DEBUG(6475):     42356894  400d444d  /system/lib/liblog.so
07-31 08:30:42.783: I/DEBUG(6475): #01 42356898  42356cac
07-31 08:30:42.783: I/DEBUG(6475):     4235689c  6d617266
07-31 08:30:42.783: I/DEBUG(6475):     423568a0  726f7765
07-31 08:30:42.783: I/DEBUG(6475):     423568a4  622f736b
07-31 08:30:42.783: I/DEBUG(6475):     423568a8  2f657361
07-31 08:30:42.783: I/DEBUG(6475):     423568ac  6964656d
07-31 08:30:42.783: I/DEBUG(6475):     423568b0  696c2f61
07-31 08:30:42.783: I/DEBUG(6475):     423568b4  61747362
07-31 08:30:42.783: I/DEBUG(6475):     423568b8  72666567
07-31 08:30:42.783: I/DEBUG(6475):     423568bc  74686769
07-31 08:30:42.783: I/DEBUG(6475):     423568c0  756f662f
07-31 08:30:42.783: I/DEBUG(6475):     423568c4  7461646e
07-31 08:30:42.783: I/DEBUG(6475):     423568c8  2f6e6f69
07-31 08:30:42.783: I/DEBUG(6475):     423568cc  66754241
07-31 08:30:42.783: I/DEBUG(6475):     423568d0  2e726566
07-31 08:30:42.783: I/DEBUG(6475):     423568d4  3a707063
07-31 08:30:42.783: I/DEBUG(6475):     423568d8  43203835  /dev/ashmem/AudioFlinger::Client (deleted)
07-31 08:30:42.783: I/DEBUG(6475):     423568dc  4b434548
07-31 08:30:42.783: I/DEBUG(6475):     423568e0  28454c5f
07-31 08:30:42.783: I/DEBUG(6475):     423568e4  66666f20
07-31 08:30:42.783: I/DEBUG(6475):     423568e8  20746573
07-31 08:30:42.783: I/DEBUG(6475):     423568ec  6973202b
07-31 08:30:42.783: I/DEBUG(6475):     423568f0  6d2c657a
07-31 08:30:42.783: I/DEBUG(6475):     423568f4  61706143
07-31 08:30:42.783: I/DEBUG(6475):     423568f8  79746963
07-31 08:30:42.783: I/DEBUG(6475):     423568fc  61662029
07-31 08:30:42.783: I/DEBUG(6475):     42356900  64656c69
07-31 08:30:42.783: I/DEBUG(6475):     42356904  3234203a
07-31 08:30:42.783: I/DEBUG(6475):     42356908  36393439
07-31 08:30:42.783: I/DEBUG(6475):     4235690c  38383237
07-31 08:30:42.783: I/DEBUG(6475):     42356910  2e737620
07-31 08:30:42.783: I/DEBUG(6475):     42356914  32363220
07-31 08:30:42.783: I/DEBUG(6475):     42356918  00343238
07-31 08:30:42.783: I/DEBUG(6475):     4235691c  65757165
07-31 08:30:42.783: I/DEBUG(6475):     42356920  3165636e
07-31 08:30:42.783: I/DEBUG(6475):     42356924  0073742e
07-31 08:30:42.783: I/DEBUG(6475):     42356928  42356998
07-31 08:30:42.783: I/DEBUG(6475):     4235692c  944d19e8
07-31 08:30:42.783: I/DEBUG(6475):     42356930  01fe5df4  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356934  415f4918  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356938  424bdc90
07-31 08:30:42.783: I/DEBUG(6475):     4235693c  41481069  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356940  42356998
07-31 08:30:42.783: I/DEBUG(6475):     42356944  41482719  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356948  000003ff
07-31 08:30:42.783: I/DEBUG(6475):     4235694c  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356950  00000022
07-31 08:30:42.783: I/DEBUG(6475):     42356954  00000004
07-31 08:30:42.783: I/DEBUG(6475):     42356958  0000137b
07-31 08:30:42.783: I/DEBUG(6475):     4235695c  01f48000  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356960  01fe6268  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356964  944d19e8
07-31 08:30:42.783: I/DEBUG(6475):     42356968  00000000
07-31 08:30:42.783: I/DEBUG(6475):     4235696c  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356970  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356974  41481001  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356978  423569d0
07-31 08:30:42.783: I/DEBUG(6475):     4235697c  41482719  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356980  415f4918  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356984  01fe5df0  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356988  003569a4
07-31 08:30:42.783: I/DEBUG(6475):     4235698c  00000053
07-31 08:30:42.783: I/DEBUG(6475):     42356990  423569a4
07-31 08:30:42.783: I/DEBUG(6475):     42356994  402c127c  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356998  01fe5df0  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     4235699c  00000068
07-31 08:30:42.783: I/DEBUG(6475):     423569a0  00000000
07-31 08:30:42.783: I/DEBUG(6475):     423569a4  00000000
07-31 08:30:42.783: I/DEBUG(6475):     423569a8  00000000
07-31 08:30:42.783: I/DEBUG(6475):     423569ac  00000001
07-31 08:30:42.783: I/DEBUG(6475):     423569b0  402c18f0  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     423569b4  400ed037  /system/lib/libc.so
07-31 08:30:42.783: I/DEBUG(6475):     423569b8  402c127c  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     423569bc  01ff1da0  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     423569c0  415f4918  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     423569c4  401265e8
07-31 08:30:42.783: I/DEBUG(6475):     423569c8  424bdc90
07-31 08:30:42.783: I/DEBUG(6475):     423569cc  424bdd60
07-31 08:30:42.783: I/DEBUG(6475):     423569d0  01f49068  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     423569d4  01f49068  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     423569d8  00000000
07-31 08:30:42.783: I/DEBUG(6475):     423569dc  414a5b99  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     423569e0  415f4918  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     423569e4  01fe5df0  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     423569e8  00356a58
07-31 08:30:42.783: I/DEBUG(6475):     423569ec  944d19e8
07-31 08:30:42.783: I/DEBUG(6475):     423569f0  01fe5df4  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     423569f4  415f4918  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     423569f8  424bdc90
07-31 08:30:42.783: I/DEBUG(6475):     423569fc  41481069  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a00  42356a58
07-31 08:30:42.783: I/DEBUG(6475):     42356a04  41482719  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a08  424bdc90
07-31 08:30:42.783: I/DEBUG(6475):     42356a0c  402bba2f  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a10  42356a44
07-31 08:30:42.783: I/DEBUG(6475):     42356a14  00000046
07-31 08:30:42.783: I/DEBUG(6475):     42356a18  01feaaa0  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a1c  01feaae6  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a20  01ffbee0  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a24  402bba47  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a28  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356a2c  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356a30  402c127c  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a34  01f490f8  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a38  42356a7c
07-31 08:30:42.783: I/DEBUG(6475):     42356a3c  402c1898  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a40  0000000e
07-31 08:30:42.783: I/DEBUG(6475):     42356a44  01f49068  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a48  00000000
07-31 08:30:42.783: I/DEBUG(6475):     42356a4c  402bba2f  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a50  424bdd38
07-31 08:30:42.783: I/DEBUG(6475):     42356a54  01f48c9c  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a58  42356ac0
07-31 08:30:42.783: I/DEBUG(6475):     42356a5c  00000014
07-31 08:30:42.783: I/DEBUG(6475):     42356a60  01f49068  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a64  402bba47  /system/lib/libstlport.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a68  424bdd38
07-31 08:30:42.783: I/DEBUG(6475):     42356a6c  4147d1d1  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a70  424bdd38
07-31 08:30:42.783: I/DEBUG(6475):     42356a74  4147e78f  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a78  424bdd5c
07-31 08:30:42.783: I/DEBUG(6475):     42356a7c  00000078
07-31 08:30:42.783: I/DEBUG(6475):     42356a80  01f48c88  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a84  41481791  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a88  42356af8
07-31 08:30:42.783: I/DEBUG(6475):     42356a8c  944d19e8
07-31 08:30:42.783: I/DEBUG(6475):     42356a90  01fe5df4  [heap]
07-31 08:30:42.783: I/DEBUG(6475):     42356a94  415f4918  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356a98  424bdc90
07-31 08:30:42.783: I/DEBUG(6475):     42356a9c  41481069  /system/lib/libchromium_net.so
07-31 08:30:42.783: I/DEBUG(6475):     42356aa0  42356af8
07-31 08:30:42.791: I/DEBUG(6475):     42356aa4  41482719  /system/lib/libchromium_net.so
07-31 08:30:42.791: I/DEBUG(6475):     42356aa8  424bdc90
07-31 08:30:42.791: I/DEBUG(6475):     42356aac  402bba2f  /system/lib/libstlport.so
07-31 08:30:42.791: I/DEBUG(6475):     42356ab0  42356ae4
07-31 08:30:42.791: I/DEBUG(6475):     42356ab4  00000047
07-31 08:30:42.791: I/DEBUG(6475):     42356ab8  01feaa58  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356abc  01feaa9f  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356ac0  02003ce8  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356ac4  402bba47  /system/lib/libstlport.so
07-31 08:30:42.791: I/DEBUG(6475):     42356ac8  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356acc  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356ad0  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356ad4  402c1801  /system/lib/libstlport.so
07-31 08:30:42.791: I/DEBUG(6475):     42356ad8  402c1898  /system/lib/libstlport.so
07-31 08:30:42.791: I/DEBUG(6475):     42356adc  0000000c
07-31 08:30:42.791: I/DEBUG(6475):     42356ae0  01fe6268  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356ae4  01fd7638  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356ae8  424bdc90
07-31 08:30:42.791: I/DEBUG(6475):     42356aec  402bb8b5  /system/lib/libstlport.so
07-31 08:30:42.791: I/DEBUG(6475):     42356af0  41405d8c  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356af4  42356b98
07-31 08:30:42.791: I/DEBUG(6475):     42356af8  01fe5df0  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356afc  42356b1c
07-31 08:30:42.791: I/DEBUG(6475):     42356b00  01fe6268  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356b04  402bb8c7  /system/lib/libstlport.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b08  41405d8c  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b0c  413ba783  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b10  41405d8c  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b14  413bb47b  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b18  01fd76a8  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356b1c  413f8b8c  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b20  413ead72  /system/lib/libstagefright.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b24  000001a4
07-31 08:30:42.791: I/DEBUG(6475):     42356b28  01fd76a8  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356b2c  01feaaa0  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356b30  ffffffe6
07-31 08:30:42.791: I/DEBUG(6475):     42356b34  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356b38  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356b3c  01feaa9f  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356b40  01feaa58  [heap]
07-31 08:30:42.791: I/DEBUG(6475):     42356b44  400e9401  /system/lib/libc.so
07-31 08:30:42.791: I/DEBUG(6475):     42356b48  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356b4c  00000004
07-31 08:30:42.791: I/DEBUG(6475):     42356b50  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356b54  ffffffff
07-31 08:30:42.791: I/DEBUG(6475):     42356b58  00000000
07-31 08:30:42.791: I/DEBUG(6475):     42356b5c  ffffffff
07-31 08:30:42.799: I/DEBUG(6475):     42356b60  00000007
07-31 08:30:42.799: I/DEBUG(6475):     42356b64  00000013
07-31 08:30:42.799: I/DEBUG(6475):     42356b68  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356b6c  ffffffff
07-31 08:30:42.799: I/DEBUG(6475):     42356b70  0000001a
07-31 08:30:42.799: I/DEBUG(6475):     42356b74  0000002d
07-31 08:30:42.799: I/DEBUG(6475):     42356b78  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356b7c  ffffffff
07-31 08:30:42.799: I/DEBUG(6475):     42356b80  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356b84  ffffffff
07-31 08:30:42.799: I/DEBUG(6475):     42356b88  01fd7638  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356b8c  4011f4c8
07-31 08:30:42.799: I/DEBUG(6475):     42356b90  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356b94  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356b98  01ff1e08  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356b9c  413deea1  /system/lib/libstagefright.so
07-31 08:30:42.799: I/DEBUG(6475):     42356ba0  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356ba4  400ec9e9  /system/lib/libc.so
07-31 08:30:42.799: I/DEBUG(6475):     42356ba8  01ff1de7  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356bac  01ff1da0  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356bb0  32348101
07-31 08:30:42.799: I/DEBUG(6475):     42356bb4  36323439
07-31 08:30:42.799: I/DEBUG(6475):     42356bb8  34323832
07-31 08:30:42.799: I/DEBUG(6475):     42356bbc  944d19e8
07-31 08:30:42.799: I/DEBUG(6475):     42356bc0  ffffffff
07-31 08:30:42.799: I/DEBUG(6475):     42356bc4  000402a8
07-31 08:30:42.799: I/DEBUG(6475):     42356bc8  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356bcc  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356bd0  412021a6  /system/lib/libcaps.so
07-31 08:30:42.799: I/DEBUG(6475):     42356bd4  00000000
07-31 08:30:42.799: I/DEBUG(6475):     42356bd8  42356c7c
07-31 08:30:42.799: I/DEBUG(6475):     42356bdc  42356cc8
07-31 08:30:42.799: I/DEBUG(6475):     42356be0  fffffff8
07-31 08:30:42.799: I/DEBUG(6475):     42356be4  01ff81d4  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356be8  00000001
07-31 08:30:42.799: I/DEBUG(6475):     42356bec  413df629  /system/lib/libstagefright.so
07-31 08:30:42.799: I/DEBUG(6475):     42356bf0  02027b78  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356bf4  4011f540
07-31 08:30:42.799: I/DEBUG(6475):     42356bf8  01fe6268  [heap]
07-31 08:30:42.799: I/DEBUG(6475):     42356bfc  01fe62e8  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c00  00000000
07-31 08:30:42.807: I/DEBUG(6475):     42356c04  4011f4b8
07-31 08:30:42.807: I/DEBUG(6475):     42356c08  00000000
07-31 08:30:42.807: I/DEBUG(6475):     42356c0c  400ebb85  /system/lib/libc.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c10  01ff1370  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c14  4011f4c8
07-31 08:30:42.807: I/DEBUG(6475):     42356c18  00000010
07-31 08:30:42.807: I/DEBUG(6475):     42356c1c  4011f494
07-31 08:30:42.807: I/DEBUG(6475):     42356c20  01ff1378  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c24  00000001
07-31 08:30:42.807: I/DEBUG(6475):     42356c28  00000000
07-31 08:30:42.807: I/DEBUG(6475):     42356c2c  400ec9e9  /system/lib/libc.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c30  01ff1378  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c34  00000080
07-31 08:30:42.807: I/DEBUG(6475):     42356c38  00000010
07-31 08:30:42.807: I/DEBUG(6475):     42356c3c  01fe6268  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c40  00000000
07-31 08:30:42.807: I/DEBUG(6475):     42356c44  00000001
07-31 08:30:42.807: I/DEBUG(6475):     42356c48  00000000
07-31 08:30:42.807: I/DEBUG(6475):     42356c4c  400ecf3d  /system/lib/libc.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c50  42356cbc
07-31 08:30:42.807: I/DEBUG(6475):     42356c54  0000006a
07-31 08:30:42.807: I/DEBUG(6475):     42356c58  01fe6268  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c5c  0000006a
07-31 08:30:42.807: I/DEBUG(6475):     42356c60  40893e60  /system/lib/libstagefright_foundation.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c64  fffffff8
07-31 08:30:42.807: I/DEBUG(6475):     42356c68  00000000
07-31 08:30:42.807: I/DEBUG(6475):     42356c6c  40110951  /system/lib/libc.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c70  42356cbc
07-31 08:30:42.807: I/DEBUG(6475):     42356c74  40893195  /system/lib/libstagefright_foundation.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c78  42356cbc
07-31 08:30:42.807: I/DEBUG(6475):     42356c7c  0000006a
07-31 08:30:42.807: I/DEBUG(6475):     42356c80  01fe62d2  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c84  40110959  /system/lib/libc.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c88  42356cbc
07-31 08:30:42.807: I/DEBUG(6475):     42356c8c  40893195  /system/lib/libstagefright_foundation.so
07-31 08:30:42.807: I/DEBUG(6475):     42356c90  42356cbc
07-31 08:30:42.807: I/DEBUG(6475):     42356c94  42356cc8
07-31 08:30:42.807: I/DEBUG(6475):     42356c98  02006510  [heap]
07-31 08:30:42.807: I/DEBUG(6475):     42356c9c  944d19e8
07-31 08:30:42.815: I/DEBUG(6475):     42356ca0  42356cc8
07-31 08:30:42.815: I/DEBUG(6475):     42356ca4  408911af  /system/lib/libstagefright_foundation.so
07-31 08:30:42.815: I/DEBUG(6475):     42356ca8  40893d3e  /system/lib/libstagefright_foundation.so
07-31 08:30:42.815: I/DEBUG(6475):     42356cac  01fe6268  [heap]
07-31 08:30:45.198: D/AudioHardwareTinyALSA(18684): Entering AudioStreamOutALSA standby mode
07-31 08:30:45.198: I/AudioHardwareTinyALSA(18684): Close
07-31 08:30:45.619: I/DEBUG(6475): EET
07-31 08:30:45.619: I/DEBUG(6475): !@dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_native -m 18684
07-31 08:30:45.619: I/BootReceiver(179): Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)
07-31 08:30:45.619: I/dumpstate(18714): begin
07-31 08:30:45.737: D/dalvikvm(179): GC_CONCURRENT freed 1199K, 21% free 14383K/18183K, paused 1ms+25ms
07-31 08:30:51.315: W/ActivityManager(179): Launch timeout has expired, giving up wake lock!
07-31 08:30:51.330: W/ActivityManager(179): Activity idle timeout for ActivityRecord{419e84a0 com.missiondata.tcu/.ui.course.CourseActivity}
07-31 08:30:54.041: D/VoldCmdListener(87): asec list
07-31 08:30:54.041: D/VoldCmdListener(87): CommandListener::AsecCmd::runCommand -> --
07-31 08:30:57.041: I/dumpstate(18714): done
07-31 08:30:57.112: W/AudioSystem(179): AudioPolicyService server died!
07-31 08:30:57.112: V/MediaPlayer-JNI(18600): release
07-31 08:30:57.112: V/MediaPlayer(18600): setListener
07-31 08:30:57.112: V/MediaPlayer(18600): disconnect
07-31 08:30:57.119: W/AudioSystem(179): AudioFlinger server died!
07-31 08:30:57.119: I/ServiceManager(86): service 'media.audio_policy' died
07-31 08:30:57.119: W/IMediaDeathNotifier(18600): media server died
07-31 08:30:57.119: V/MediaPlayer(18600): died
07-31 08:30:57.119: V/MediaPlayer(18600): message received msg=100, ext1=100, ext2=0
07-31 08:30:57.119: E/MediaPlayer(18600): error (100, 0)
07-31 08:30:57.119: V/MediaPlayer(18600): destructor
07-31 08:30:57.119: V/MediaPlayer(18600): disconnect
07-31 08:30:57.119: W/AudioSystem(18600): AudioFlinger server died!
07-31 08:30:57.119: I/ServiceManager(86): service 'media.audio_flinger' died
07-31 08:30:57.119: I/ServiceManager(86): service 'media.player' died
07-31 08:30:57.119: I/ServiceManager(86): service 'media.camera' died
07-31 08:30:57.127: D/OpenGLRenderer(18600): Flushing caches (mode 0)

This is very consistent and predictable. I don't believe it is related to the stream as I was able to reproduce the problem with other LIVE HTTP sources too. Do you see anything wrong with my code?

A: My options:
1,Don't extend VideoView class.Use VideoView directly.
2,When your app be paused,let videoview pause.When your app resume,let  videoview resume.My mean is that u should sync app state with video view state.
Hope my options help you.Good luck.^-^

redpajama_set_name: RedPajamaStackExchange


text:
Q: Key.toUrlSafe() - how to get entity by urlSafeKey?
com.google.cloud.datastore.Key

has a toUrlSafe method()
how do I recreate the key from this url safe string? Key has only methods like getParent, getId, getName...
I tried with

com.google.cloud.datastore.Datastore

key factory, but I haven't found any methods that create key from url safe string.

A: It looks like you are using Java.  In Java, the Key class has a static method fromUrlSafe (https://googleapis.dev/java/google-cloud-clients/latest/com/google/cloud/datastore/Key.html#fromUrlSafe-java.lang.String-).


text:
Q: Carrinho de compras Java Tenho dúvidas quanto a criação de um carrinho de compras, consegui até aqui: Informar o nome do produto,
Preço do produto
Quantidade; aí existe a soma e a pergunta se que realizar outra compra, se for "N" ele finaliza, caso contrário ele reinicia.
Depois tem que ser informado um ciclo e depois somar todos os valores dividindo em dinheiro ou cartão.
package problema01;

import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author VAGNER.MATOS
 */
public class Problema01 {

    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */

      public static void main(String[] args) throws IOException{
        Scanner ent = new Scanner(System.in);
        Scanner ler = new Scanner(System.in);

        double num, preço;
        String nome;
        String nome2;
        char resposta;

            System.out.println("Informe o Produto:");// Usuario digita o nome do produto
            nome = ler.nextLine();
            System.out.println("Digite o preço do Produto");// usuario digita o preço
            preço = ent.nextDouble();
            System.out.println("Digite a quantidade do Produto"); // usuario digita a quantidade do produto
            num = ent.nextDouble();

            System.out.println("A Quantidade de produtos é "+num+"\nTotal a pagar é R$"+num*preço+"\n\nObrigado por comprar "+nome); // Resumo

            //Nova Compra
            System.out.println("\nRealzar outra compra? (S/N): "); //entrada de dados (lendo um caractere)
            resposta = (char)System.in.read();
                if ((resposta == 'S') || (resposta == 's'));
{
                System.out.println("\n\"Nova compra\"\n");
                System.out.println("Favor iniciar com as informações\n");
                System.out.println("Informe o Produto:");
                nome2 = ler.nextLine();//Novo produto
                System.out.println("Digite o preço do Produto");
                preço = ent.nextDouble(); // usuario digita o preço
                System.out.println("Digite a quantidade do Produto");
                num = ent.nextDouble(); // usuario digita a quantidade do produto
                System.out.println("A Quantidade de produtos é " + num + "\nTotal a pagar é R$"+ num*preço +"\n\nObrigado por comprar " + nome2);
}               System.out.println("\n\n\"Volte sempre!\"\n\n");

    }
}

A: Não faz sentido criar dois Scanner's que lêem do mesmo lugar (no caso, do System.in). Use um só.
Outro detalhe é esse ponto-e-vírgula depois do if:
if ((resposta == 'S') || (resposta == 's'));
                                           ^ esse aqui

Quando você faz isso, está dizendo que dentro do if tem um bloco vazio. Ou seja, se a resposta for S ou s, você não faz nada. E todo o trecho que vem depois não faz parte do if e é executado sempre. Retire esse ; daí.
Não entendi porque a quantidade deve ser um double. Existe a possibilidade de alguém comprar algo como "2,6 produtos"? Se não existir, mude o tipo da variável para int.
E se está usando um Scanner, não há motivo para misturar as leituras com System.in.read.
Outro detalhe é que se você quer repetir várias vezes a mesma coisa, tem que usar um loop (neste caso eu usaria um while, por exemplo).
Enfim, uma alternativa seria:
Scanner ent = new Scanner(System.in);
while (true) {
    System.out.println("Informe o Produto:");// Usuario digita o nome do produto
    String nome = ent.nextLine();
    System.out.println("Digite o preço do Produto");// usuario digita o preço
    double preço = ent.nextDouble();
    System.out.println("Digite a quantidade do Produto"); // usuario digita a quantidade do produto
    int num = ent.nextInt();
    ent.nextLine(); // consumir o ENTER, para não atrapalhar a próxima leitura: https://pt.stackoverflow.com/q/262976/112052

    System.out.println("A Quantidade de produtos é " + num + "\nTotal a pagar é R$" + num * preço + "\n\nObrigado por comprar " + nome); // Resumo

    // Nova Compra
    System.out.println("\nRealzar outra compra? (S/N): "); // entrada de dados (lendo um caractere)
    String resposta = ent.nextLine();
    if ("n".equalsIgnoreCase(resposta))
        break; // sai do while(true)

    System.out.println("\n\"Nova compra\"\n");
    System.out.println("Favor iniciar com as informações\n");
}
System.out.println("\n\n\"Volte sempre!\"\n\n");

Claro que dá para melhorar mais. Se não for digitado um número, nextDouble e nextInt dão erro. Além disso, esses métodos não consomem a quebra de linha, e na próxima vez que você chamar nextLine, o resultado será inesperado (por isso há a chamada extra de nextLine para consumir a quebra de linha, conforme explicado em detalhes aqui).
Em vez de System.in.read eu usei o Scanner, e fiz a comparação case insensitive para decidir se saio ou não do while. Mas eu só verifico se foi digitado "n", então se for digitado qualquer outra coisa, ele prossegue.
Enfim, uma alternativa um pouco melhor é criar métodos específicos para validar cada um desses casos:
double lerPreco(Scanner sc, String mensagem) {
    while (true) {
        System.out.println(mensagem);
        try {
            return Double.parseDouble(sc.nextLine());
        } catch (NumberFormatException e) {
            System.out.println("Número inválido");
        }
    }
}

int lerQuantidade(Scanner sc, String mensagem) {
    while (true) {
        System.out.println(mensagem);
        try {
            return Integer.parseInt(sc.nextLine());
        } catch (NumberFormatException e) {
            System.out.println("Número inválido");
        }
    }
}

String lerOpcao(Scanner sc, String mensagem) {
    while (true) {
        System.out.println(mensagem);
        String opcao = sc.nextLine().toLowerCase();
        if ("s".equals(opcao) || "n".equals(opcao))
            return opcao;
        else
            System.out.println("A opção deve ser S ou N");
    }
}

Aí é só usar esses métodos no loop principal. E como você disse que quer calcular o total de todas as compras, basta criar uma variável nova para isso e ir somando dentro do loop:
Scanner ent = new Scanner(System.in);
double total = 0;
while (true) {
    System.out.println("Informe o Produto:");// Usuario digita o nome do produto
    String nome = ent.nextLine();
    double preço = lerPreco(ent, "Digite o preço do Produto");
    int num = lerQuantidade(ent, "Digite a quantidade do Produto");
    double valor = num * preço;

    System.out.printf("A Quantidade de produtos é %d\nTotal a pagar é R$%.2f\n\nObrigado por comprar %s\n", num, valor, nome);
    total += valor;

    // Nova Compra
    String resposta = lerOpcao(ent, "\nRealzar outra compra? (S/N): ");
    if ("n".equalsIgnoreCase(resposta))
        break; // sai do while(true)

    System.out.println("\n\"Nova compra\"\n");
    System.out.println("Favor iniciar com as informações\n");
}
System.out.printf("Total das compras: R$%.2f\n", total);
System.out.println("\n\n\"Volte sempre!\"\n\n");

Também usei printf para formatar o valor sempre com duas casas decimais. Se bem que, se for trabalhar com valores monetários, é melhor não usar double.

A: Então, sua pergunta está um pouco complicada de entender, mas pelo que eu li, você quer trabalhar com uma quantidade dinâmica de informações, ou seja, o usuário vai continuar entrando com os dados, até ele decidir parar, que seria a entrada 'N'.
Para esses tipos de situações uma forma de resolver é utilizando uma estrutura de repetição como o while, ou seja:
Scanner sc = new Scanner(System.in);
String nome;
double preco;
double num;

char resposta = 'S';

while (resposta=='S'){
  #Entradas do usuário aqui
}

Perceba que só houve a necessidade de um único Scanner para trabalhar com as entradas, além disso, eu já inicializei a variável resposta pra poder entrar no loop que irá continuar até resposta == 'N'.
Espero ter ajudado!


text:
Q: Tree View in SQL Is there a simple way of doing a expanded tree view within SQL Select statement using the Output to Text in SQL Server Management Studio?
Input Table
GRP NAME ITEM1 ITEM2
--- ---- ----- -----
 1   AB   100   200
 1   AC   150   200
 1   AD   175   200
 2   BC   200   220
 2   BD   NULL  NULL

Desired output
GRP 1
+-- AB
+    +-- ITEM1: 100
+    +-- ITEM2: 200
+-- AC
+    +-- ITEM1: 150
+    +-- ITEM2: 200
+-- AD
+    +-- ITEM1: 175
+    +-- ITEM2: 200

GRP 2
+-- BC
+    +-- ITEM1: 200
+    +-- ITEM2: 220
+-- BD

Thanks
jlimited

A: This will do (you will need to ignore columns 2,3,4 in the output, they are there for ordering):
select DISTINCT 'GRP ' + convert(varchar(10), GRP), convert(int, GRP), ' ', 0 from table1
UNION ALL
select '+-- ' + [NAME], convert(int, GRP), [name], 1 from table1
UNION ALL
select '+    +-- ITEM 1: ' + [ITEM1], convert(int, GRP), [name], 2 from table1 where ITEM1 IS NOT NULL
UNION ALL
select '+    +-- ITEM 2: ' + [ITEM2], convert(int, GRP), [name], 3 from table1 where ITEM2 IS NOT NULL
ORDER BY 2,3,4

SQL Fiddle


text:
Q: finding Element causing chrome driver instance to crash First the Environment:

*

*Node JS 16.15.0

*Web Driver io v7 (wdio)

*wdio/cucumber framework

*end to end testing of a website
-obviously using cucumber and feature files

*using a test configuration file similar to wdio's

*using wdio-chromedriver-service v7.2.6 and npm chromedriver package version ^107 to produce a browser to hit

*

*my browser : chrome v107.0.5304.62

The Question:
an element cannot be found by webDriver as I expect, but the command causes the instance to crash
I am searching for an element that no longer appears on the page (it is a spinner element that shows the page is loading)
I call
if(await this.spinner.isDisplayed())

and then the test run hangs, the debugger tells me the command
INFO webdriver: COMMAND findElement("css selector", "i.fa-spinner")
is running and then nothing else, finally the renderer times out
WARN chromedriver: [SEVERE]: Timed out receiving message from renderer: 600.000
DEBUG webdriver: request failed due to response error: timeout
and the chrome instance crashes shortly later
I am unsure why this behavior is happening, is something wrong with my wdio configuration? or with my chrome driver?
What I have tried
I understand that
browser.setTimeout exists but
I am sure it is not set in my config anywhere.
I have done a global search (using vscode for all development) for browser.setTimeout (no results).
I have manually set browser.setTimeout({ 'implicit': 0 }) (no success).
I have also tried directly hitting a chrome driver instance by manually downloading a chrome driver exe that matched my browser version v107.0.5304.62 and removing the 'services: ['chromedriver']'
from my test config file
when this happens something very interesting occurs, I can keep running after searching for the element that broke the run before, but we dont get very far and the command still causes issues. Chrome driver is throwing errors like
error: 'no such element',
[0-0]   message: 'no such element: Unable to locate element: {"method":"css selector","selector":"i.fa-spinner"}\n' +
[0-0]     '  (Session info: chrome=107.0.5304.87)'
The browser closes shortly afterwards without progressing through the rest of the tests.
I find it interesting that the version that chrome driver says it is running is 107.0.5304.87 since the version of chromedriver I downloaded clearly says it is v107.0.5304.62 and my chrome version clearly states it is also v107.0.5304.62 .
though theoretically using v107.0.5304.87 shouldnt be an issue according to this
since the 107.0.5304 part matches across the board
I could use some assistance.

A: We had the same issue this days, seems there is a bug introduced in Chrome 106; try to change config or downgrade Chrome on the machine to use Chrome 105 as with this version is working.


text:
Q: What is the max size of AF_UNIX datagram message in Linux? Currently I'm hitting a hard limit of 130688 bytes. If I try and send anything larger in one message I get a ENOBUFS error.
I have checked the net.core.rmem_default, net.core.wmem_default, net.core.rmem_max, net.core.wmem_max, and net.unix.max_dgram_qlen sysctl options and increased them all but they have no effect because these deal with the total buffer size not the message size.
I have also set the SO_SNDBUF and SO_RCVBUF socket options, but this has the same issue as above. The default socket buffer size are set based on the default socket options anyways.
I've looked at the kernel source where ENOBUFS is returned in the socket stack, but it wasn't clear to me where it was coming from. The only places that seem to return this error have to do with not being able to allocate memory.
Is the max size actually 130688? If not can this be changed without recompiling the kernel?

A: AF_UNIX SOCK_DATAGRAM/SOCK_SEQPACKET datagrams need contiguous memory. Contiguous physical memory is hard to find, and the allocation fails, logging something similar to this on the kernel log:
udgc: page allocation failure. order:7, mode:0x44d0
[...snip...]
DMA: 185*4kB 69*8kB 34*16kB 27*32kB 11*64kB 1*128kB 1*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 3788kB
Normal: 13*4kB 6*8kB 100*16kB 62*32kB 24*64kB 10*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 7012kB
[...snip...]

unix_dgram_sendmsg() calls sock_alloc_send_skb() lxr1, which calls sock_alloc_send_pskb() with data_len = 0 and header_len = size of datagram lxr2. sock_alloc_send_pskb() allocates header_len from "normal" skbuff buffer space, and data_len from scatter/gather pages lxr3. So, it looks like AF_UNIX sockets don't support scatter/gather on current Linux.


text:
Q: Django ORM error: FieldError: Cannot resolve keyword XXX into field When I typing
comds = Purchased.objects.filter(category_id = '1'),
it thrown a error like this
FieldError: Cannot resolve keyword 'category_id' into field. Choices are: comd_expire, comd_img_type, comd_name, id, player, player_id, purchase_time, status,
and my table's fields are:

my models is:

I don't know why there has no category and category_id

A: Try this:
comds = Purchased.objects.filter(category__id =1)


text:
Q: Issue with NSTreeController moveNode:toIndexPath:? I'm using an NSTreeController set in entity mode, to manage a hierarchy of folders (a core data entity I call Folder). The "Children" key path is set to an NSArray readwrite property of Folder, which I call subfoldersArray. (I use NSArray because NSOrderedSet doesn't work with a tree controller).
When the user moves a folder to another folder (via an NSOutlineView) or at a different position of the same parent folder, the app calls  moveNode:toIndexPath: on the tree controller. I use this method as it preserves the selection (while changing the underlying model tends to deselect the selected folder, even though the controller has preserveSelection set to YES.
Problem: every Folder instance that is moved by moveNode:toIndexPath: is placed at the end of the subfoldersArray, regardless of the index path specified.
This happens only when the NSTreeController controls an NSManagedObject subclass (in either class or entity mode).
The exact same moveNode:toIndexPath: instruction on the same NSTreeController controlling an equivalent NSObject subclass (with an identical subfoldersArray property) works as expected.
I'd like a solution that doesn't involve setting the underlying model myself, as this tends to deselect the selected folder (which may not be the one that is moved).


text:
Q: In Java, how can I play a sound for a given period? My target is to play a given sound or music for a given second, but the music file is actually longer than the given seconds.
i.e. the file is 2 min 32 seconds long but only required to play 16 seconds.
My design of player part is:
public class MusicClip {
    private Clip clip;
    private Long pos;

    private String status;
    private String pathKeeper;

    private AudioInputStream AIS = null;

    public MusicClip(String path) throws LineUnavailableException, UnsupportedAudioFileException, IOException {
        AIS = AudioSystem.getAudioInputStream(new File(path));
        pathKeeper = path;
        clip = AudioSystem.getClip();
        clip.open(AIS);
        status = "waiting";
    }

    public void play()
    {
        if (status.equals("play"))
        {
            System.out.println("audio is already playing");
            return;
        }
        //start the clip
        clip.start();
        status = "play";
    }

    public void stop() {
        pos = 0L;
        clip.stop();
        clip.close();
        status = "waiting";
    }

    //restart the clip in case to replay
    public void resetAudioStream() {
        try {
            AIS = AudioSystem.getAudioInputStream(new File(pathKeeper));
            clip.open(AIS);
        } catch (Exception e) {
            //This shouldn't happen!
            System.err.println("OOPS!");
        }
        status = "waiting";
    }

The first thing that comes to my mind is timer but I don't understand how it is implemented.
Are there any approaches or solutions with timer or other ways?

A: Theoretically, if I understand the question right, you can just call stop() after x seconds when you call play()
new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            stop();
        }
    }, TimeUnit.SECONDS.toMillis(3));


text:
Q: Kubernetes Nginx container unable to access php-fpm container I've created 2 Kubernetes deployments for nginx and a php-fpm laravel container. But for some reason, traffic from nginx seems unable to successfully get to the php-fpm containers generating the following error
172.18.0.1 - - [18/Jul/2022:16:51:10 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"

This is my deployment file
apiVersion: v1
kind: ConfigMap
metadata:
  name: web-server-config
  namespace: dev-api
data:
  nginx.conf: |
    server {
        listen 80;
        index index.php index.html;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /var/www/html/public;

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;

            fastcgi_pass api-web-svc:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }

        location / {
            try_files $uri $uri/ /index.php?$query_string;
                gzip_static on;
        }
    }
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: php-config
  namespace: dev-api
data:
  laravel.ini: |
    upload_max_filesize: 80M
    post_max_size: 80M
---
apiVersion: v1
kind: Secret
metadata:
  name: api-web-secret
  namespace: dev-api
type: Opaque
data:
 ...
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-web
  namespace: dev-api
spec:
  selector:
    matchLabels:
      app: api-web
  replicas: 1
  template:
    metadata:
      labels:
        app: api-web
    spec:
      containers:
      - name: api-web
        image: XXX.dkr.ecr.us-east-1.amazonaws.com/api-web:0.9.4-alpha
        volumeMounts:
         - name: php-config
           mountPath: /usr/local/etc/php/conf.d/laravel.ini
         - name: env-config
           mountPath: /var/www/html/.env
        ports:
        - containerPort: 9000
      volumes:
        - name: php-config
          configMap:
            name: php-config
        - name: env-config
          secret:
            secretName: api-web-secret
      imagePullSecrets:
      - name: regcred
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: dev-api
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:alpine
        volumeMounts:
         - name: web-server-config
           mountPath: /etc/nginx/conf.d/
        ports:
        - containerPort: 80
      volumes:
        - name: web-server-config
          configMap:
            name: web-server-config
---
apiVersion: v1
kind: Service
metadata:
  name:  web-server-svc
  namespace: dev-api
spec:
  type: NodePort
  selector:
    app:  nginx
  ports:
  - protocol: TCP
    port:  80
    targetPort:  80
    nodePort: 32420
---
apiVersion: v1
kind: Service
metadata:
  name:  api-web-svc
  namespace: dev-api
  labels:
    app: api-web
spec:
  type: ClusterIP
  selector:
    app:  api-web
  ports:
  - protocol: TCP
    port:  9000

The namespace is declared separately. The two containers in each of the deployments run successfully.
k logs deployment/nginx-deployment  -n dev-api
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/07/18 16:18:50 [notice] 1#1: using the "epoll" event method
2022/07/18 16:18:50 [notice] 1#1: nginx/1.21.6
2022/07/18 16:18:50 [notice] 1#1: built by gcc 10.3.1 20211027 (Alpine 10.3.1_git20211027)
2022/07/18 16:18:50 [notice] 1#1: OS: Linux 5.4.0-109-generic
2022/07/18 16:18:50 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2022/07/18 16:18:50 [notice] 1#1: start worker processes
2022/07/18 16:18:50 [notice] 1#1: start worker process 21
2022/07/18 16:18:50 [notice] 1#1: start worker process 22
2022/07/18 16:18:50 [notice] 1#1: start worker process 23
2022/07/18 16:18:50 [notice] 1#1: start worker process 24
2022/07/18 16:18:50 [notice] 1#1: start worker process 25
2022/07/18 16:18:50 [notice] 1#1: start worker process 26
2022/07/18 16:18:50 [notice] 1#1: start worker process 27
2022/07/18 16:18:50 [notice] 1#1: start worker process 28

 k logs deployment/api-web -n dev-api
[18-Jul-2022 16:18:51] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[18-Jul-2022 16:18:51] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[18-Jul-2022 16:18:51] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[18-Jul-2022 16:18:51] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[18-Jul-2022 16:18:51] NOTICE: fpm is running, pid 1
[18-Jul-2022 16:18:51] NOTICE: ready to handle connections

And the Dockerfile used to generate the image api-web:0.9.4-alpha in the api-web deployment is as shown below
FROM php:7.2-fpm

# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/html/

# Set working directory
WORKDIR /var/www/html

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl \
    nodejs \
    npm

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www

# Copy existing application directory contents
COPY . /var/www/html/

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html/

# Change current user to www
USER www

## Run composer dependencies
RUN composer update
RUN composer install

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

This Dockerfile runs fine too, with no issues. A docker-compose file using this image also works with no issues.
Any ideas why traffic from the nginx-deployment container fails to reach the api-web php-fpm container with the error
172.18.0.1 - - [18/Jul/2022:16:51:10 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"

A: As far as I know both pods or at least the containers need the same source files. If the nginx doesn't know that this php files exists, it can not forward the request to the php-fpm container.
I'm saying container, while i wouldn't recommend to split the nginx and php-fpm into separate pods. More likely i would start those containers as one unit with the same source in one pod. Except you have some sort of Cron jobs or batch jobs.

A: i would suggest maintaining both containers in a single POD if using the php-fpm however if already using the Nginx ingress controller or any other proxy support php-fpm in the existing setup there is no need to run the Nginx as sidecar or another deployment
apiVersion: extensions/v1
kind: Deployment
metadata:
  labels:
    app: wordpress-site
  name: wordpress-site
  namespace: development
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: wordpress-site
      tier: frontend
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: wordpress-site
        tier: frontend
    spec:
      volumes:
      - configMap:
          defaultMode: 256
          name: nginxthroughpass
          optional: false
        name: nginxconf
      - name: shared-files
        emptyDir: {}
      containers:
        - name: app
          image: <REPLACE WITH DOCKER PHP-FPM IMAGE URL>
          imagePullPolicy : IfNotPresent
          volumeMounts:
            - name: shared-files
              mountPath: /var/www/html
          envFrom:
            - configMapRef:
                name: wordpress-configmap
        - name: nginx
          image: nginx
          imagePullPolicy : IfNotPresent
          volumeMounts:
          - name: shared-files
            mountPath: /var/www/html
          - mountPath: /etc/nginx/conf.d
            name: nginxconf
            readOnly: true

Repo for ref : https://github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx
Or else
If you don't want to run Nginx container you can also use the Nginx ingress to forward the traffic to php-fpm container
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
    nginx.ingress.kubernetes.io/fastcgi_send_timeout: "1800"
    nginx.ingress.kubernetes.io/fastcgi_read_timeout: "1800"
    nginx.ingress.kubernetes.io/backend-protocol: "FCGI"
    nginx.ingress.kubernetes.io/fastcgi-index: "index.php"
    nginx.ingress.kubernetes.io/fastcgi-params-configmap: "development/word-cm"
    nginx.ingress.kubernetes.io/server-snippets: |
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass wordpress-site:9000;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
        }
  name: wordpress-dev
spec:
  rules:
  - host: dev.example.io
    http:
      paths:
      - backend:
          serviceName: php-fpm-service
          servicePort: 80

You can also use this ingress as ref : https://github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx/blob/master/ingress.yaml


text:
Q: Генерация docx средствами php Стоит следующая задача:
Существует шаблон док-та в формате docx, в котором есть маркеры (например,{{dl.name.no-mod.req}} ). Необходимо вместо маркеров подставить рассчитанные параметры.
После того, как я разархивирую docx, в исходном xml часть подобных маркеров разбивается различными тегами:
<w:p>
        <w:pPr>
            <w:pStyle w:val="Normal"/>
            <w:rPr></w:rPr>
        </w:pPr>
        <w:r>
            <w:rPr></w:rPr>
            <w:t>«{{dl.name.</w:t>
        </w:r>
        <w:r>
            <w:rPr>
                <w:lang w:val="en-US"/>
            </w:rPr>
            <w:t>no</w:t>
        </w:r>
        <w:r>
            <w:rPr></w:rPr>
            <w:t>-</w:t>
        </w:r>
        <w:r>
            <w:rPr>
                <w:lang w:val="en-US"/>
            </w:rPr>
            <w:t>mod</w:t>
        </w:r>
        <w:r>
            <w:rPr></w:rPr>
            <w:t>.</w:t>
        </w:r>
        <w:r>
            <w:rPr>
                <w:lang w:val="en-US"/>
            </w:rPr>
            <w:t>req</w:t>
        </w:r>
        <w:r>
            <w:rPr></w:rPr>
            <w:t xml:space="preserve">}}»</w:t>
        </w:r>
    </w:p>

Соответственно, моё регулярное выражение их не находит.
Из-за чего происходит разбиение в исходном шаблоне?
Есть ли способ избежать подобного? Возможно, стоит, изменить формат маркеров?
Или же нужно как-то по иначе работать с данными (сейчас, работаю с исходным xml, как с обычной строкой - ищу все вхождения подобных маркеров, рассчитываю их значения, после запаковываю обратно в docx архив)?


text:
Q: Retrieve last logon user and login time of remote computer I have the following code. I don't see any property of Win-Event that holds the name of the user that logged in except for the "Account Name" in the "Message" property. How can I extract only the "Account Name" part of the "Message" property?
Get-WinEvent -Computer $computer -FilterHashtable @{Logname='Security';ID=4672} -MaxEvents 1 | Select-Object -Property Message

EDIT: I've also tried the following but got an empty string back
Get-WinEvent -Computer $computer -FilterHashtable @{Logname='Security';ID=4672} -MaxEvents 3 | Select @{Name = "Username";Expression = {$_.ReplacementStrings[1]}}

A: this seems rather roundabout, but it works. there is a Data= option in FilterHashTable, but i can't figure out how to use it. [blush]
in any case, this searches the .Message property for Account Name and puts the result in the named match property .AccountName.
$ComputerName = $env:COMPUTERNAME

$GWE_Params = @{
    Computer = $ComputerName
    FilterHashtable = @{
        Logname = 'Security'
        ID = '4672'
        }
    MaxEvents = 3
    }

$EventInfo = @(Get-WinEvent @GWE_Params)

[void]($EventInfo[0].Message -match 'Account Name:\s{1,}(?<AccountName>.+)')

$Matches.AccountName

output ...
SYSTEM

i presume you will want to filter out accounts like system - that is easily done. [grin]


text:
Q: how to select by index from a bigr.frame? In standard r, I can select by index using something like the following:
newdf <- df[1:4,]

However, if I try the above on a bigr.frame, I get:
Error: BigR[bigr.frame.[]]: The given filtering condition must be a logical bigr.vector.

The documentation for [ {bigr} is as follows:

Description
Filter rows and project columns of a dataset
Usage
"["(x, i, j, ..., drop = TRUE)
Arguments
x (bigr.frame or bigr.matrix) the object being operated on. If x is a
  bigr.frame or bigr.csv.matrix, both filtering and projection are
  supported. If x is a bigr.binary.matrix, only projections are
  supported.
i (bigr.vector) a logical operation that represents the filtering
  condition (only for bigr.frame and bigr.matrix objects)
j (character or integer) a vector representing columns to be
  projected. These could be column ids (i.e., integers) or column names
  (i.e., characters)
drop in the case of projecting one single column, parameter drop determines
  whether the result should be a bigr.vector (drop=TRUE) or a bigr.frame
  (drop=FALSE). Default value is drop=TRUE.
Value
the derived bigr.frame, bigr.matrix, or bigr.vector
See Also
bigr.frame bigr.matrix
Examples
air[air$UniqueCarrier %in% c("UA", "HA"), c(1,2,3,5:9)]
air[, c("Origin", "Dest")]
air[air$Dest == "SFO", 17]
class(air[, 17, drop=FALSE])
class(air[, 17, drop=TRUE])

It isn't clear to me if I can select by index.  Is this possible? How?

A: The first parameter expects the logical condition and second argument represent the columns.
The same functionality you are looking can be done by head(frame, no#OfRows)
airfile <- system.file("extdata", "airline.zip", package="bigr")
airfile <- unzip(airfile, exdir = tempdir())
airR <- read.csv(airfile, stringsAsFactors=F)
air <- as.bigr.frame(airR)
head(air, 4)

Refer: https://www.ibm.com/support/knowledgecenter/SSPT3X_4.0.0/com.ibm.swg.im.infosphere.biginsights.tut.doc/doc/tut_Less_BigR_Stat2.html

A: You can use as.data.frame function.
Refer: https://www.ibm.com/support/knowledgecenter/SSPT3X_4.0.0/com.ibm.swg.im.infosphere.biginsights.bigr.doc/doc/frame_as.data.frame.html?lang=en
airfile <- system.file("extdata", "airline.zip", package="bigr")
airfile <- unzip(airfile, exdir = tempdir())
airR <- read.csv(airfile, stringsAsFactors=F)
air <- as.bigr.frame(airR)
airdf <- as.data.frame(air)
newdf <- airdf[1:4,]
newdf


text:
Q: How to SELECT partial entity, and then use the entity update the entity in the database? I have an entity class with about 70 columns. The table may have around 200,000 rows. I want to update just one of the columns for all the 200,000 records.
Normally I would retrieve all the entities, and for each one, update the entity with the new value for the field, and save it.
The HQL would look something like this: select p from Person p. This allows us to write Java code such as: entity.PhoneNumber = new_value; session.flush();. The problem is that the SELECT will retrieve ALL 70 columns, when only 2 are required (the primary key and the field to be changed).
We could write HQL like this: select p.Id, p.PhoneNumber from Person p. Unfortunately now we're not getting entities anymore, so now rather than programming in an object-oriented way, we're now stuck with writing HQL: update Person set p.PhoneNumber = ? where Id = ?.
Is there a way to load a PARTIAL entity (load an entity with only some of the fields filled, and then use that object to make a change and then save it?

A: According to this
1) For the first part of your question answer is positive. You can declare an entity constructor like the following
@Entity
public class Person
{
   public Person(){} // The jpa required default constructor

   public Person(Long id, String phone){
      this.id = id;
      this.phoneNumber = phone;
   }
   ...
}

and then use it in the following way:
select new com.entity.Person(p.Id, p.PhoneNumber)
from Person p

2) But according to the same link:

The projection class must be fully qualified in the entity query, and it must define a matching constructor. The class here need not be mapped. It can be a DTO class. If it does represent an entity, the resulting instances are returned in the NEW state (not managed!).

You can not expect synchronization with database after updating of this instance of entity. So, answer for the second part of your question is negative.


text:
Q: Hashtable insertion order I am doing an assignment and it requires use of a hashtable. We need to store numbers in a hashtable, and then return the index of the location of 2 numbers that sum to a given target. So if the target is 8, and theres a 3 and a 5 in there, i need to return the indicies. I have written it with array no problem, but I dont understand the location of where numbers go when being inserted in the hashtable.
Hashtable<String, Integer> numbers = new Hashtable<String, Integer>();
    numbers.put("one", 1);
    numbers.put("two", 2);
    numbers.put("three", 3);
    numbers.put("four", 4);
    numbers.put("five", 5);
    numbers.put("six", 6);

This, in debugging mode, shows that the insertion all said and done is:
{five = 5, six = 6, two = 2, one = 1, three = 3, four = 4}
Why is it like this? We learned that hastables store data as the following:
1%11 (where 11 is the size of the hashtable which is default in this case) = 1 and store it at position 1.
2%11 would give position at index 2.
and so on...
14%11 would give position 3 (index 3) and if there is a collision to do linear probing or quadratic probing. Im confused on how the built in hashtable function stores my data. Thanks!!
EDIT:
Lets say i do Hashtable Integer, Integer instead


text:
Q: Using preg_replace()? I'm trying to understand the function preg_replace(), but it looks rather cryptic to me. From looking at the documentation on the function here. I understand that it consists of three things - the subject, the pattern for matching, and what to replace it with.
I'm currently trying to 'sanitize' numerical input by replacing anything that isn't a number. So far I know I would need to allow the numbers 0-9, but remove anything that isn't a number and replace it with: "".
Instead of escaping every character I need to, is there some way to simply not allow any other character than the numbers 0-9? Also if anyone could shed light on how the 'pattern for matching' part works...

A: If you want to sanitize a string to replace anything that isn't a number, you would write a regular expression that matches characters not in list.
The pattern [0-9] would match all numerals. Placing a caret (^) at the beginning of the set matches everything that isn't in the set: [^0-9]
$result = preg_replace('/[^0-9]/', '', $input);

Note that this will also filter out periods/decimal points and other mathematical marks. You could include periods/decimal points (allowing floats) by making the period allowed:
$result = preg_replace('/[^0-9.]/', '', $input);

Note that the period (.) is the wildcard character in regular expressions. It doesn't need to be escaped in a bracket expression, but it would elsewhere in the pattern.

A: preg_replace() is easier than you think:
$p = "/[A-Z a-z]/";
$r = "";
$s = "12345t7890";

echo preg_replace($p, $r, $s);

Will output "123457890" - note no '6'

A: is_numeric(); isn't resolve your problem ?


text:
Q: Is my model underfitting, tensorflow? My loss first decreased for few epochs but then started increasing and then increased up to a certain point and then stopped moving. I think now it has converged. Now, can we say that my model is underfitting? Because my interpretation is that (slide 93 link) if my loss is going down and then increasing it means that I have a high learning rate and which after every 2 epochs I'm decaying so after few epochs loss stopped increasing because learning rate is low now, because I'm still decaying my learning rate, now loss should start decreasing again, according to slide 93 because learning rate is low, but it doesn't. Can we say that loss is not decreasing further because my model is underfitting?

A: So, to summarize, the loss on the training data:

*

*first went down

*then it went up again

*then it remains at the same level

*then the learning rate is decayed

*and the loss doesn't go back down again (still stays the same with decayed learning rate)

To me it sounds like the learning rate was too high initially, and it got stuck in a local minimum afterwards. Decaying the learning rate at that point, once it's already stuck in a local minimum, is not going to help it escape that minimum. Setting the initial learning rate at a lower value is more likely to be beneficial, so that you don't end up in the ''bad'' local minimum to begin with.
It is possible that your model is now underfitting, and that making the model more complex (more nodes in hidden layers, for instance) would help. This is not necessarily the case though.
Are you using any techniques to avoid overfitting? For example, regularization and/or dropout? If so, it is also possible that your model was initially overfitting (when the loss was going down, before it went back up again). To get a better idea of what's going on, it would be beneficial to plot not only your loss on the training data, but also loss on a validation set. If the loss on your training data drops significantly below the loss on the validation data, you know it's overfitting.


text:
Q: Access insert into values I created a table in Access and the connection works, but my loop through my dataframe using iterrows() is throwing a syntax error.
I have tried removing spaces and altering the syntax.
for index, row in futures_table.iterrows():
    cursor.execute('''
                    INSERT INTO cme_oil_futures (MONTH,SETTLE,DATE,REPORT_TYPE)
                    VALUES (?,?,?,?)
                ''',(row['MONTH'],row['SETTLE'],row['DATE'],row['REPORT_TYPE']))
    conn.commit()

Expected result is to insert the values for each row in the "MONTH", "SETTLE", "DATE", and "REPORT_TYPE" columns from my dataframe.
The error I get is "

Exception has occurred: pyodbc.ProgrammingError
  ('42000', '[42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (-3502) (SQLExecDirectW)')
    File "E:\Python\DDWebsraping\cme_oil.py", line 83, in
      ''',(row['MONTH'],row['SETTLE'],row['DATE'],row['REPORT_TYPE']))

A: Try the following code. I think you just needed brackets around the fields. MS Access is a strange and mysterious beast.
for index, row in futures_table.iterrows():
    cursor.execute('''
                    INSERT INTO cme_oil_futures ([MONTH],[SETTLE],[DATE],[REPORT_TYPE])
                    VALUES (?,?,?,?)
                ''',(row['MONTH'],row['SETTLE'],row['DATE'],row['REPORT_TYPE']))
    conn.commit()


text:
Q: HTML call a JS function to disable radio buttons On my webpage I want to disable certain radio buttons if a certain selection is made from a dropdown list.
Below is my head section:

This is my body section:
<select name="time" form="bookingForm" id="time" onchange="return myRadio()">
  <option value="19.00">19.00</option>
  <option value="19.30">19.30</option>
  <option value="20.00">20.00</option>
  <option value="20.30">20.30</option>
</select>
Duration:

<input type="radio" name="duration" id="duration_30" value="30">30 mins
<input type="radio" name="duration" id="duration_60" value="60">60 mins
<input type="radio" name="duration" id="duration_90" value="90">90 mins
<input type="radio" name="duration" id="duration_120" value="120">120 mins

So what i want to do is if a time of 19.30 is selected then i want to disable (grey out) the 120 mins radio button. And if 20.30 is selceted then i want to disable the 60, 90 & 120 mins radio buttons.
There is also more selection options before 19.00 that I wish all the radio buttons to be enabled for.
The function that I am currently trying is not working so any help on how to do this is appreciated.
Hope this makes sense.

A:

disableDurationTimeMap = {
  '19.30': [120],
  '20.30': [60, 90, 120]
};

function disableDurationsForTime(timeValue) {
  var disableDurations = disableDurationTimeMap[timeValue];
  if (disableDurations === undefined) { return; }
  disableDurations.forEach(function(duration) {
    document.querySelector('input[name="duration"][value="' + duration.toString() + '"]').disabled = true;
  });
}

function enableAllDurations() {
  var durations = document.querySelectorAll('input[name="duration"]');
  Array.prototype.forEach.call(durations, function(input) {
    input.disabled = false;
  });
}
var timeSelect = document.getElementById('time');
timeSelect.addEventListener('change', function() {
  enableAllDurations();
  var selectedTime = timeSelect.options[timeSelect.selectedIndex].value;
  disableDurationsForTime(selectedTime);
});
<select name="time" form="bookingForm" id="time">
  <option value="19.00">19.00</option>
  <option value="19.30">19.30</option>
  <option value="20.00">20.00</option>
  <option value="20.30">20.30</option>
</select>
Duration:

<input type="radio" name="duration" id="duration_30" value="30">30 mins
<input type="radio" name="duration" id="duration_60" value="60">60 mins
<input type="radio" name="duration" id="duration_90" value="90">90 mins
<input type="radio" name="duration" id="duration_120" value="120">120 mins

A: Using pure javascript, i think this is what you want...
function myRadio() {

//Enable all (the 'each' way, with no jquery)
document.getElementById('duration_120').disabled = false;
document.getElementById('duration_90').disabled = false;
document.getElementById('duration_60').disabled = false;
document.getElementById('duration_30').disabled = false;

//switch for undefined options and durations
switch(document.getElementById('time').value) {

  // 1 case for each option
  case '19.30':
  document.getElementById('duration_120').disabled = true;
  break;

  case '20.30':
  document.getElementById('duration_120').disabled = true;
  document.getElementById('duration_90').disabled = true;
  document.getElementById('duration_60').disabled = true;
  break;

 }

}


text:
Q: Fingerprint option is not shown in lenovo thinkpad e14 i have this hardware in my system
Bus 001 Device 003: ID 27c6:55a4 Shenzhen Goodix Technology Co.,Ltd. Goodix FingerPrint Device
please anyone tell me how to enable fingerprint in my lenovo thinkpad e14
my ubuntu version is 20.10

A: It is not compatible yet, but good folks are working on it. There is long thread about it https://gitlab.freedesktop.org/libfprint/libfprint/-/issues/376
And there is discord server with all the news on all devices: https://discord.gg/K4rFkXqg


text:
Q: Calculating time spent in a given level when that level changes This is what my dataframe looks like.The rightmost column("TimeForLevelChange") is my desired column. When a level changes for a given Name, I want to take the minimum date from the prior level and take the date from the row where the level change happens and calculate the difference. So on third row, John's level changed from 1 to 2 and he spent 16 days(2016-01-17 - 2016-01-01) in level 1 before changing to level 2.
  library(data.table)
         dt <- fread('
            Name      Level     Date         RecentLevelChange TimeForLevelChange
            John       1       2016-01-01       NA                 NA
            John       1       2016-01-10       NA                 NA
            John       2       2016-01-17       1->2               16
            John       2       2016-01-18       NA                 NA
            John       3       2016-01-22       2->3               5
            John       4       2016-01-26       3->4               4
            John       4       2016-01-27       NA                 NA
            John       7       2016-01-29       4->7               3
            Tom        1       2016-01-10       NA                NA
            Tom        2       2016-01-17       1->2              7
            Tom        2       2016-01-18       NA                NA
            Tom        3       2016-01-22       2->3              5
            Tom        4       2016-01-26       3->4              4
            Tom        4       2016-01-27       NA                NA
            Tom        7       2016-01-29       4->7              3
      ')
dt[, Date := as.IDate(Date)]

I can use shift function in data.table but I dont know how to define the minimum date from the prior level for a given name.

A: I might do
spell = dt[,{.(
    w    = .I[1L],
    Date = Date[1L]
)}, by=.(Name, rleid(Level))][, .(
  w = tail(w,-1),
  d = diff(Date)
), by=Name]

dt[spell$w, dur_lastspell := spell$d]

which gives
    Name Level       Date RecentLevelChange TimeForLevelChange dur_lastspell
 1: John     1 2016-01-01                NA                 NA       NA days
 2: John     1 2016-01-10                NA                 NA       NA days
 3: John     2 2016-01-17              1->2                 16       16 days
 4: John     2 2016-01-18                NA                 NA       NA days
 5: John     3 2016-01-22              2->3                  5        5 days
 6: John     4 2016-01-26              3->4                  4        4 days
 7: John     4 2016-01-27                NA                 NA       NA days
 8: John     7 2016-01-29              4->7                  3        3 days
 9:  Tom     1 2016-01-10                NA                 NA       NA days
10:  Tom     2 2016-01-17              1->2                  7        7 days
11:  Tom     2 2016-01-18                NA                 NA       NA days
12:  Tom     3 2016-01-22              2->3                  5        5 days
13:  Tom     4 2016-01-26              3->4                  4        4 days
14:  Tom     4 2016-01-27                NA                 NA       NA days
15:  Tom     7 2016-01-29              4->7                  3        3 days

I use {.()} instead of .() because the latter gives an error. I'll report it as a bug.


text:
Q: jQuery UI datepiker not attached to input I added a jQuery UI datepiker here. You could see it on the left side of the page under Date Available.
I can't make it fixed on the input textbox. If you scroll or re-size, the calendar window is floating around the screen. I need it remain on the default open position when scrolling and resizing. I tried all the possible fixes but no chance. How do I fix this problem?
I call it like:
$( "#datepicker" ).datepicker({
    numberOfMonths: 2,
    showButtonPanel: true
});

A: If you are repositioning the datepicker container on window scroll event then consider the document scroll position also. I think that is what creating this issue.


text:
Q: Do 10k users get to read deleted comments? Do 10k (and moderator) users have the ability to read deleted comments (are comments deleted forever, or never really deleted like questions and answers)?

A: No, we (10k+ users) don't have that ability. They are as good as deleted forever (at least to non-moderators—those diamond folk can still see them).

A: No, 10k+ users cannot read deleted comments, so a deleted comment is as good as gone.
The comments do, however, still exist in the database and ♦ moderators can read them and see who deleted them should an issue arise.


text:
Q: Where did dedicated.abac.net. come from in my rDNS and PTR records? So I followed this guide to the letter: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/RdnsForBind
I did so for 3 domains.
When I "test" the records and enter: host 64.150.176.81 on my linux machine, it shows me 81.172.150.64.in-addr.arpa domain name pointer 64-150-172-81.dedicated.abac.net.
when it should be showing me 81.176.150.64.in-addr.arpa domain name pointer 64-150-172-81.example.com.
Has anybody encountered a similar problem?
I am hosting with codero, not abac.net btw.

A: To set the PTR record for your IP address, you also need to have the DNS server for that range delegated to your nameserver.
Currently, abac.net hold the ownership of your IP address, so you will need to contact them to ask them to configure the nameserver for your IP address to point to your nameserver, or, ask them to change the PTR record to 64-150-172-81.example.com. Most providers will do one of these for their business customers.


text:
Q: pycharm - windows - "alt gr + {" opening project-structur instead inserting "{" i updated pycharm to 4.0.3 and i cannot insert { by alt gr + {. it keeps opening Structure Panel (screenshot) instead of inserting {. anyone any idea?

A: On which keyboard layout are you? I'm on the German one, and there it works with alt gr + {

A: (if restarting Pycharm.exe doesn't work, like in my case, the following applies:)
I have Pycharm 2019.1, and I had the same problem with the Alt+Gr+any_key not working in Pycharm (but elswhere working fine).
-Win 10
-error occured in whole Pycharm interface, while coding in python 3.7.0
-Europe
To fix this (at least in my case), just go to the following in Pycharm, and check the following box:
=>Help>Find Action...>registry> actionSystem.fix.alt.gr check
(: good luck :)


text:
Q: How to scroll focused TextBox with large text I've got a grid containing a header, a textbox and a footer. The header and the footer occupy as much space as needed, the remainder should be filled by the textbox entirely. This is what I've got so far:
<Grid x:Name="LayoutRoot" Background="Transparent">
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>

  <Grid  x:Name="TitlePanel"  Grid.Row="0">
    <TextBlock Text="Title" />
  </Grid>

  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0">
    <ScrollViewer Margin="0">
      <TextBox x:Name="NoteText"
                InputScope="Text"
                AcceptsReturn="True"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                TextAlignment="Left"
                TextWrapping="Wrap"
                FontSize="24"
                BorderThickness="0">
      </TextBox>
    </ScrollViewer>
  </Grid>

  <Grid x:Name="Footer" Grid.Row="2">
    <TextBlock Text="Footer"/>
  </Grid>
</Grid>

This set up gives me the lay-out I want. The problem, however, is that when the Textbox contains large amounts of text scrolling does not work the way I want.
Suppose the textbox contains twice as much text than can be displayed. As long as the textbox doesn't have the focus, scrolling works just fine. When I set focus on the textbox and put the caret at the first position, I cannot scroll to the end of the textbox. When I put the caret at the last position, I cannot scroll to the top of the textbox.
How can I solve this?

A: There is a very simple solution already built into the TextBoxcontrol, it's called verticalscrollbarvisibility.
It adds, as the name suggests, a vertical scrollbar to the TextBox.
This eliminates the need for the ScrollViewer that you have in your markup.
Edit
I've made a very simple test to show that it works:
<TextBox Width="100"
         Height="100"
         VerticalScrollBarVisibility="Auto"
         TextWrapping="Wrap"
         Text="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" />

If you copy & paste that control to a new project and run it, you'll see that the option works.
In your specific case, there must be another option conflicting to cause it not to work.

A: I had same problem. I created a Style for textbox and that work for me, may this will also help you. No need to use ScrollViewer.
<phone:PhoneApplicationPage.Resources>
        <ControlTemplate x:Key="PhoneDisabledTextBoxTemplate" TargetType="TextBox">
            <ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="Stretch"/>
        </ControlTemplate>

        <Style x:Key="AppVerticalTextBoxStyle" TargetType="TextBox">
            <Setter Property="FontFamily" Value="Cambria"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="FontSize" Value="26"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TextBox">
                        <Grid Background="Transparent" >
                            <Grid>
                                <ScrollViewer x:Name="EnabledBorder" BorderBrush="Silver" BorderThickness="1" Background="{TemplateBinding Background}" Margin="{StaticResource PhoneTouchTargetOverhang}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" >
                                    <ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Left" Padding="{TemplateBinding Padding}" VerticalContentAlignment="Top"  />
                                </ScrollViewer>
                                <Border x:Name="DisabledOrReadonlyBorder" BorderThickness="{TemplateBinding BorderThickness}" Background="#FF71B68D" Margin="{StaticResource PhoneTouchTargetOverhang}" Visibility="Collapsed">
                                    <Border.BorderBrush>
                                        <SolidColorBrush Color="{StaticResource PhoneDisabledColor}"/>
                                    </Border.BorderBrush>
                                    <TextBox x:Name="DisabledOrReadonlyContent" Background="Transparent" Foreground="{StaticResource PhoneDisabledBrush}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" IsReadOnly="True" SelectionForeground="{TemplateBinding SelectionForeground}" SelectionBackground="{TemplateBinding SelectionBackground}" TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="{TemplateBinding TextWrapping}" Text="{TemplateBinding Text}" Template="{StaticResource PhoneDisabledTextBoxTemplate}"/>
                                </Border>
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

//Remove ScrollViewer from your code.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="0">

      <TextBox x:Name="NoteText"
                InputScope="Text"
                AcceptsReturn="True"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                TextAlignment="Left"
                TextWrapping="Wrap"
                FontSize="24"
                BorderThickness="0"
                Style="{StaticResource AppVerticalTextBoxStyle}" TextWrapping="Wrap">
      </TextBox>
  </Grid>


text:
Q: react-hook-form + materialUI + yup: How to make file is required I have
  const validationSchema = Yup.object().shape({
    photo: Yup.mixed().required("File is required"),
  });
  const {
    control,
    handleSubmit,
    formState: { errors },
    reset,
    setError,
  } = useForm({
    resolver: yupResolver(validationSchema),
  });

and the code for the file input using material UI
    {/********************************************************
    PHOTO
    *********************************************************/}
    <Controller
      type="file"
      name="photo"
      control={control}
      render={({ field }) => (
        <TextField
          inputRef={field.ref}
          fullWidth
          label="photo"
          margin="dense"
          accept="image/*"
          type="file"
          onChange={(e) => {
            field.onChange(e.target.files);
            handleChange(e);
          }}
          InputLabelProps={{
            shrink: true,
          }}
          error={errors.photo ? true : false}
        />
      )}
    />
    <Typography variant="inherit" color="textSecondary">
      {errors.photo?.message}
    </Typography>


text:
Q: Nginx Rewrite to remove php filename Hej
It is possible to write a Rewrite Rule in Nginx for Removing a filename?
I have it like this:
domain.tld/post.php?p=1
and want somthing like this:
domain.tld/?p=1
Is there a way for it? And if is, how?
thanks

A: Yes, absolutely.
It's a fairly common practice to redirect all requests to your index.php file, and then for that to route the requests within your application logic - this way your PHP code can define your URL structures entirely.
If you wanted to do so, here's an example Nginx rewrite configuration you can use to rewrite all requests to index.php:
#
# Redirect all to index.php
#
RewriteEngine On

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} (/[^.]*|\.)$ [NC]
RewriteRule .* index.php [L]


text:
Q: Azure Mobile Service Filter - Removed? I've been reading about custom auth methods using Azure, and stumbled upon 12 Days of ZUMO. It's an excellent write up, but I can't seem to find anything related to IServiceFilter in the current .Net Client SDK for Azure.
I'm developing a Xamarin app in C#.
Has this functionality been removed or relocated? I have all Azure namespaces referenced and intellisense can't find IServiceFilter or anything else related to service filters.
Thanks for reading.

A: I currently develop an app for Android on Java (I don't think that library for C# is very different).
And I can access ServiceFilter. But I don't see IServiceFilter.
Namespace - com.microsoft.windowsazure.mobileservices.http.ServiceFilter
Library version - 2.0.2-beta2

A: In Xamarin you need to use a DelegateHandler instead.  This is the standard .net way to filter http traffic.
public class MyLogFilter : DelegatingHandler
{
    protected override async Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request, CancellationToken cancellationToken)
    {
        // Do any pre-request requirements here
        Log.Warning("http request", request.RequestUri.ToString() );

        // Request happens here
        var response = await base.SendAsync(request, cancellationToken);

        // Do any post-request requirements here
        Log.Warning("http response", response.StatusCode + "  " + response.Content.ReadAsStringAsync().Result);

        return response;
    }
}

Once you've done that, you just chain the handler when initializing your MobileServiceClient, changing this:
Client = new MobileServiceClient (API_URL, new MyExistingHandler());

to:
Client = new MobileServiceClient (API_URL, new MyLogFilter(), new MyExistingHandler());


text:
Q: ComboBox with two columns in C#
Possible Duplicate:
WinForms combobox with multiple columns (C#)?

I this procedure
ALTER proc [dbo].[VCNAE]
as
select cnae_id,cnae_descricao, cnae_classe    from tbl_CNAE order by cnae_descricao
I use for populate this dataset
        SqlCommand llena4 = new SqlCommand("vcnae", abre);
        llena4.CommandType = CommandType.StoredProcedure;
        da2.SelectCommand = llena4;
        da2.Fill(carga1, "cnae");//4

Then i populate  combobox
         BindingSource srd = new BindingSource();
         srd.DataSource = llenar.Tables["cnae"];
         CmbCnaePrin.DataSource = srd;
         CmbCnaePrin.DisplayMember = "cnae_descricao" ;
         CmbCnaePrin.ValueMember = "cnae_id";
         CmbCnaePrin.SelectedValue = 259;

I want to show in display member this :
cnae_descricao, cnae_classe
                     displaymember = "cnae_descricao"+"cnae_classe"; but this code not work how can  i solve this::????

Thanks


text:
Q: How does one disable the suggested terms in Magento 1.9.3.3 I have tried disabling the Magento suggested terms for their search function by first turning of autocomplete in the backend, but this doesn't seem to work. Now I'm looking for another way to make this happen or to make sure that search terms entered by customers do not get added with use suggested terms by default.
Any help not involving editing the core code would be greatly appreciated.

A: You can try this find the catalog search phtml in
<yourmagentodir>/app/design/frontend/package/theme/template/catalogsearch/form.mini.phtml

You can comment the script which does the trick
<script type="text/javascript">
//<![CDATA[
    var searchForm = new Varien.searchForm('search_mini_form', 'search', '');
    searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>


text:
Q: Convert object of any type to JObject with Json.NET I often need to extend my Domain model with additional info before returning it to the client with WebAPI. To avoid creation of ViewModel I thought I could return JObject with additional properties. I could not however find direct way to convert object of any type to JObject with single call to Newtonsoft JSON library. I came up with something like this:

*

*first SerializeObject

*then Parse

*and extend JObject

Eg.:
var cycles = cycleSource.AllCycles();

var settings = new JsonSerializerSettings
{
    ContractResolver = new CamelCasePropertyNamesContractResolver()
};

var vm = new JArray();

foreach (var cycle in cycles)
{
    var cycleJson = JObject.Parse(JsonConvert.SerializeObject(cycle, settings));
    // extend cycleJson ......
    vm.Add(cycleJson);
}

return vm;

I this correct way ?

A: If you have an object and wish to become JObject you can use:
JObject o = (JObject)JToken.FromObject(miObjetoEspecial);

like this :
Pocion pocionDeVida = new Pocion{
tipo = "vida",
duracion = 32,
};

JObject o = (JObject)JToken.FromObject(pocionDeVida);
Console.WriteLine(o.ToString());
// {"tipo": "vida", "duracion": 32,}

A: This will work:
var cycles = cycleSource.AllCycles();

var settings = new JsonSerializerSettings
{
    ContractResolver = new CamelCasePropertyNamesContractResolver()
};

var vm = new JArray();

foreach (var cycle in cycles)
{
    var cycleJson = JObject.FromObject(cycle);
    // extend cycleJson ......
    vm.Add(cycleJson);
}

return vm;

A: JObject implements IDictionary, so you can use it that way. For ex,
var cycleJson  = JObject.Parse(@"{""name"":""john""}");

//add surname
cycleJson["surname"] = "doe";

//add a complex object
cycleJson["complexObj"] = JObject.FromObject(new { id = 1, name = "test" });

So the final json will be
{
  "name": "john",
  "surname": "doe",
  "complexObj": {
    "id": 1,
    "name": "test"
  }
}

You can also use dynamic keyword
dynamic cycleJson  = JObject.Parse(@"{""name"":""john""}");
cycleJson.surname = "doe";
cycleJson.complexObj = JObject.FromObject(new { id = 1, name = "test" });

A: JObject.FromObject(obj);

Documentation here