Q: How can I replace Fragment inside Dialog inside a DialogFragment? I'm trying to use https://github.com/rockerhieu/emojicon library in order to produce an EmojiKeyboard over the softkeyboard just like WhatsApp and Telegram does.
After some research, I figure that the way they do is by creating a Dialog over the soft keyboard. The library is a fragment that needs to replace some element of the layout in execution time. The replacement happens int this class:
/**
 * Class responsible for managin user's interaction with the Emoji Keyboard
 */
public class EmojiKeyboardManager {

    public static final String TAG = "EmojiKeyboardManager";

    private AppCompatActivity mActivity;

    private FrameLayout mEmojiconContainer;
    private EmojiconEditText mEditEmojicon;
    private LinearLayout mEmojiconButton;
    private ImageView mEmojiconButtonImg;

    // CONSTRUCTOR
    public EmojiKeyboardManager(AppCompatActivity activity) {
        this.mActivity = activity;
        this.implementEmojiconButton();
        this.implementInputTextListener();
        //this.initEmojiconFragment(Boolean.FALSE);
    }

    // INITIALIZATIONS
    private void implementEmojiconButton() {
        this.mEmojiconButtonImg = (ImageView) this.mActivity.findViewById(R.id.emojiButton);
        this.mEmojiconButton = (LinearLayout) this.mActivity.findViewById(R.id.emojiButtonWrapper);
        EmojiKeyboardManager.this.mEmojiconButtonImg.setSelected(Boolean.FALSE);
        this.mEmojiconButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (EmojiKeyboardManager.this.mEmojiconButtonImg.isSelected()) {
                    EmojiKeyboardManager.this.hideEmojiconKeyboard(Boolean.TRUE);
                } else {
                    EmojiKeyboardManager.this.showEmojiconKeyboard();
                }
            }
        });
    }

    public void showEmojiconKeyboard() {
        LayoutUtil.dismissSoftKeyboard(this.mEditEmojicon);
        EmojiKeyboardManager.this.mEmojiconButtonImg.setImageResource(R.drawable.ic_keyboard_black_36dp);

        DialogFragment newFragment = SampleDialogFragment.newInstance();
        newFragment.show(this.mActivity.getSupportFragmentManager(), "dialog");

        //this.mEmojiconContainer.setVisibility(FrameLayout.VISIBLE);
        EmojiKeyboardManager.this.mEmojiconButtonImg.setSelected(Boolean.TRUE);
    }

    public void hideEmojiconKeyboard(Boolean showSoftkeyboard) {
        EmojiKeyboardManager.this.mEmojiconButtonImg.setImageResource(R.drawable.input_emoji);
        LayoutUtil.dismissSoftKeyboard(EmojiKeyboardManager.this.mEditEmojicon);
        //this.mEmojiconContainer.setVisibility(FrameLayout.GONE);
        EmojiKeyboardManager.this.mEmojiconButtonImg.setSelected(Boolean.FALSE);
        if (showSoftkeyboard) {
            EmojiKeyboardManager.this.mEditEmojicon.requestFocus();
            LayoutUtil.showSoftKeyboard(EmojiKeyboardManager.this.mEditEmojicon);
        }
    }

    private void implementInputTextListener() {
        this.mEditEmojicon = (EmojiconEditText) this.mActivity.findViewById(R.id.message);
        this.mEditEmojicon.clearFocus();
    }

    // GETTERS AND SETTERS
    public EmojiconEditText getmEditEmojicon() {
        return this.mEditEmojicon;
    }

    public Boolean isEmojikeyboardAttached() {
        return EmojiKeyboardManager.this.mEmojiconButtonImg.isSelected();
    }

}

In order to achieve what I need I'm using a subclass of DialogFragment that creates a Dialog like that:
public class SampleDialogFragment extends DialogFragment {

    private Dialog dialog;

    static SampleDialogFragment newInstance() {
        SampleDialogFragment f = new SampleDialogFragment();
        return f;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        this.dialog = new Dialog(this.getActivity(), android.R.style.Theme_NoTitleBar);

        this.dialog.setContentView(R.layout.rsc_emoji_keyboard);
        this.dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        this.dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
        this.dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        this.dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

        WindowManager.LayoutParams lp = this.dialog.getWindow().getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = (int) App.context().getResources().getDimension(R.dimen.soft_keyboard_min_height);
        lp.gravity = Gravity.BOTTOM | Gravity.LEFT;
        lp.dimAmount = 0;

        return this.dialog;
    }
}

And I display the Dialog like that:
DialogFragment newFragment = SampleDialogFragment.newInstance();
.show(this.mActivity.getSupportFragmentManager(), "dialog");

The layout of the Dialog looks like that:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/emoji_keyboard"
        android:layout_width="match_parent"
        android:layout_height="@dimen/soft_keyboard_min_height"/>
</LinearLayout>

Where the FrameLayout should be replaced by the Library Fragment. I've tried to use the replace Fragment code after creating the Dialog in the Parent Activity and also overriding the show() method of the DialogFragment but I always get a view not found exception. How can I replace the framelayout in by the library fragment?
EDIT:
Follow it is the stack trace
02-13 22:47:50.613 25553-25606/br.com.instachat.demo D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-13 22:47:50.725 25553-25606/br.com.instachat.demo I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8974_LA.BF.1.1.3_RB1__release_AU (I3193f6e94a)
                                                                   OpenGL ES Shader Compiler Version: E031.28.00.02
                                                                   Build Date: 10/09/15 Fri
                                                                   Local Branch: mybranch15039904
                                                                   Remote Branch: quic/LA.BF.1.1.3_rb1.2
                                                                   Local Patches: NONE
                                                                   Reconstruct Branch: NOTHING
02-13 22:47:50.727 25553-25606/br.com.instachat.demo I/OpenGLRenderer: Initialized EGL, version 1.4
02-13 22:47:50.757 25553-25553/br.com.instachat.demo E/RecyclerView: No adapter attached; skipping layout
02-13 22:47:50.791 25553-25623/br.com.instachat.demo I/RegIntentService: br.com.instachat.demo:string/token_received_successfully
02-13 22:47:50.796 25553-25553/br.com.instachat.demo E/RecyclerView: No adapter attached; skipping layout
02-13 22:47:51.395 25553-25553/br.com.instachat.demo I/RegIntentService: br.com.instachat.demo:string/token_sent_to_app_server_successfully
02-13 22:47:51.410 25553-25553/br.com.instachat.demo I/FragmentContacts: br.com.instachat.demo:string/contact_sync_success
02-13 22:47:53.010 25553-25553/br.com.instachat.demo I/FragmentContacts: br.com.instachat.demo:string/get_chatroomid_success
02-13 22:47:53.011 25553-25553/br.com.instachat.demo I/FragmentContacts:  chatroom retrieved (via request) has title: Hall 9000
02-13 22:47:53.066 25553-25553/br.com.instachat.demo I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
02-13 22:47:53.440 25553-25606/br.com.instachat.demo D/OpenGLRenderer: endAllActiveAnimators on 0xb82bf2a0 (LinearLayout) with handle 0xb83b6700
02-13 22:47:53.952 25553-25553/br.com.instachat.demo E/FragmentManager: No view found for id 0x7f0d00e3 (br.com.instachat.demo:id/emoji_keyboard) for fragment EmojiconsFragment{d8f31ba #1 id=0x7f0d00e3}
02-13 22:47:53.952 25553-25553/br.com.instachat.demo E/FragmentManager: Activity state:
02-13 22:47:53.953 25553-25553/br.com.instachat.demo D/FragmentManager:   Local FragmentActivity a698ff2 State:
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:     mCreated=truemResumed=true mStopped=false mReallyStopped=false
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:     mLoadersStarted=true
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:   Active Fragments in 6fb086b:
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:     #0: SampleDialogFragment{3355fc8 #0 dialog}
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:       mFragmentId=#0 mContainerId=#0 mTag=dialog
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:       mState=5 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:       mAdded=true mRemoving=false mResumed=true mFromLayout=false mInLayout=false
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:       mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:       mRetainInstance=false mRetaining=false mUserVisibleHint=true
02-13 22:47:53.957 25553-25553/br.com.instachat.demo D/FragmentManager:       mFragmentManager=FragmentManager{6fb086b in HostCallbacks{d98e861}}
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mHost=android.support.v4.app.FragmentActivity$HostCallbacks@d98e861
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:     #1: EmojiconsFragment{d8f31ba #1 id=0x7f0d00e3}
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mFragmentId=#7f0d00e3 mContainerId=#7f0d00e3 mTag=null
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mState=0 mIndex=1 mWho=android:fragment:1 mBackStackNesting=0
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mAdded=true mRemoving=false mResumed=false mFromLayout=false mInLayout=false
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mRetainInstance=false mRetaining=false mUserVisibleHint=true
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mFragmentManager=FragmentManager{6fb086b in HostCallbacks{d98e861}}
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mHost=android.support.v4.app.FragmentActivity$HostCallbacks@d98e861
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:       mArguments=Bundle[{useSystemDefaults=false}]
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:   Added Fragments:
02-13 22:47:53.958 25553-25553/br.com.instachat.demo D/FragmentManager:     #0: SampleDialogFragment{3355fc8 #0 dialog}
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:     #1: EmojiconsFragment{d8f31ba #1 id=0x7f0d00e3}
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:   FragmentManager misc state:
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:     mHost=android.support.v4.app.FragmentActivity$HostCallbacks@d98e861
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:     mContainer=android.support.v4.app.FragmentActivity$HostCallbacks@d98e861
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:     mCurState=5 mStateSaved=false mDestroyed=false
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:   View Hierarchy:
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:     com.android.internal.policy.PhoneWindow$DecorView{f889320 V.ED.... ... 0,0-1080,1920}
02-13 22:47:53.959 25553-25553/br.com.instachat.demo D/FragmentManager:       android.widget.LinearLayout{5a1ae9e V.E..... ... 0,0-1080,1776}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:         android.view.ViewStub{ceeaf86 G.E..... ... 0,0-0,0 #10203ab android:id/action_mode_bar_stub}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:         android.widget.FrameLayout{3b1ca13 V.E..... ... 0,72-1080,1776}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:           android.support.v7.widget.FitWindowsLinearLayout{bf70450 V.E..... ... 0,0-1080,1704 #7f0d0080 app:id/action_bar_root}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:             android.support.v7.widget.ViewStubCompat{2bfc047 G.E..... ... 0,0-0,0 #7f0d0081 app:id/action_mode_bar_stub}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:             android.support.v7.widget.ContentFrameLayout{15d6649 V.E..... ... 0,0-1080,1704 #1020002 android:id/content}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:               android.widget.RelativeLayout{f64fb4e V.E..... ... 0,0-1080,1704 #7f0d0094 app:id/activity_canvas}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:                 android.support.design.widget.AppBarLayout{ee4f46f V.E..... ... 0,0-1080,168 #7f0d0095 app:id/toolbar_wrapper}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:                   android.support.v7.widget.Toolbar{6d0157c V.E..... ... 0,0-1080,168 #7f0d0096 app:id/toolbar}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:                     android.widget.RelativeLayout{c997e5a V.E..... ... 168,0-528,168}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:                       com.mikhaellopez.circularimageview.CircularImageView{d196b08 V.ED.... ... 0,15-135,152 #7f0d0097 app:id/thumbnail}
02-13 22:47:53.962 25553-25553/br.com.instachat.demo D/FragmentManager:                       android.widget.LinearLayout{576688b V.E..... ... 150,27-360,141}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                         android.support.v7.widget.AppCompatTextView{dc70d68 V.ED.... ... 0,0-210,65 #7f0d0098 app:id/name}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                         android.support.v7.widget.AppCompatTextView{a469581 V.ED.... ... 0,65-99,114 #7f0d0099 app:id/status}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                     android.widget.ImageButton{70d1e05 VFED..C. ... 0,0-168,168}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                     android.support.v7.widget.ActionMenuView{48ca098 V.E..... ... 816,0-1080,168}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                       android.support.v7.view.menu.ActionMenuItemView{e995357 VFED..CL ... 0,12-144,156 #7f0d00f2 app:id/action_attach_media}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                       android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton{41af862 VFED..C. ... 144,12-264,156}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                 android.support.v7.widget.RecyclerView{4612626 VFE..... F.. 0,168-1080,1506 #7f0d009a app:id/messages}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                 android.widget.LinearLayout{e610267 V.E..... ... 0,1506-1080,1704 #7f0d009b app:id/bottomLayoutWrapper}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                   android.widget.LinearLayout{b39814 V.E..... ... 24,24-1056,174}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                     android.widget.LinearLayout{84608bd V.E..... ... 0,0-882,150}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                       android.widget.LinearLayout{ba97eb2 V.E...C. ... 1,0-145,150 #7f0d00da app:id/emojiButtonWrapper}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                         android.support.v7.widget.AppCompatImageView{b715e03 V.ED.... .S. 36,39-108,111 #7f0d00db app:id/emojiButton}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                       com.rockerhieu.emojicon.EmojiconEditText{33c2180 VFED..CL ... 145,0-822,150 #7f0d00b7 app:id/message}
02-13 22:47:53.963 25553-25553/br.com.instachat.demo D/FragmentManager:                       android.widget.LinearLayout{bcf73b9 V.E..... ... 822,38-822,111}
02-13 22:47:53.964 25553-25553/br.com.instachat.demo D/FragmentManager:                         android.widget.LinearLayout{624b074 VFE..... ... 0,0-0,0}
02-13 22:47:53.964 25553-25553/br.com.instachat.demo D/FragmentManager:                         android.support.v7.widget.AppCompatAutoCompleteTextView{6acd3fe VFED..CL ... 0,0-0,73 #7f0d00ec app:id/autotext}
02-13 22:47:53.964 25553-25553/br.com.instachat.demo D/FragmentManager:                     android.support.v7.widget.AppCompatImageButton{4a1d75f VFED..C. ... 882,0-1032,150 #7f0d00dc app:id/send}
02-13 22:47:53.964 25553-25553/br.com.instachat.demo D/FragmentManager:       android.view.View{e881223 V.ED.... ... 0,1776-1080,1920 #1020030 android:id/navigationBarBackground}
02-13 22:47:53.964 25553-25553/br.com.instachat.demo D/FragmentManager:       android.view.View{4ba94d9 V.ED.... ... 0,0-1080,72 #102002f android:id/statusBarBackground}
02-13 22:47:53.964 25553-25553/br.com.instachat.demo D/AndroidRuntime: Shutting down VM
02-13 22:47:53.968 25553-25553/br.com.instachat.demo E/AndroidRuntime: FATAL EXCEPTION: main
                                                                       Process: br.com.instachat.demo, PID: 25553
                                                                       java.lang.IllegalArgumentException: No view found for id 0x7f0d00e3 (br.com.instachat.demo:id/emoji_keyboard) for fragment EmojiconsFragment{d8f31ba #1 id=0x7f0d00e3}
                                                                           at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)
                                                                           at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
                                                                           at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
                                                                           at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
                                                                           at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
                                                                           at android.os.Handler.handleCallback(Handler.java:746)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                           at android.os.Looper.loop(Looper.java:148)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5443)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

SOLVED

I was able to manage the issue by using the code below:
public class SampleDialogFragment extends DialogFragment {

    static SampleDialogFragment newInstance() {
        SampleDialogFragment f = new SampleDialogFragment();
        return f;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_NoTitleBar);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.rsc_emoji_keyboard, container, false);

        this.getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        this.getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
        this.getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        this.getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

        WindowManager.LayoutParams lp = this.getDialog().getWindow().getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = (int) App.context().getResources().getDimension(R.dimen.soft_keyboard_min_height);
        lp.gravity = Gravity.BOTTOM | Gravity.LEFT;
        lp.dimAmount = 0;

        getChildFragmentManager()
                .beginTransaction()
                .replace(R.id.emoji_keyboard, EmojiconsFragment.newInstance(false))
                .commit();

        return v;
    }
}


Q: convert hex to decimal with awk incorrect (with --non-decimal-data or strtonum) awk hex to decimal result is incorrect, not equal with bash/python
echo 0x06375FDFAE88312A |awk --non-decimal-data '{printf "%d\n",$1}'

or
echo 0x06375FDFAE88312A |awk '{printf "%d\n",strtonum($1)}'

the result is 447932102257160448， but with python the result is 447932102257160490
python -c "print int('0x06375FDFAE88312A', 16)"

A: You need to use --bignum option, as this answer suggests. (Supported in gawk since version 4.1).
echo 0x06375FDFAE88312A |awk --bignum '{printf "%d\n",strtonum($1)}'

echo 0x06375FDFAE88312A |awk --bignum --non-decimal-data '{printf "%d\n",$1}'

The problem is that AWK typically uses double floating point number to represent numbers by default, so there is a limit on how many exact digits can be stored that way.


Q: TSQL getting record count and records in single query I got this tasks table that has TODO items. We are retrieving the todo items and the count of Finished, Pending tasks using separate query in single stored procedure even though it is querying from same table. Here is the query,
select
TaskName 'Task/TaskName',
CASE IsDone WHEN '1' THEN 'True' ELSE 'False' END 'Task/IsDone',
(
 SELECT COUNT(*) FROM Tasks WHERE IsDone = '1'
) 'CompletedCount'
FROM Tasks FOR XML PATH('Tasks')

here is the output
'<Tasks>
    <Task>
        <TaskName>Write a email to Mayor<TaskName>
        <IsDone>True</IsDone>
        <CompletedCount>2<CompletedCount>
    </Task>
</Tasks>'

CompletedCount is present in each Task which is unnecessary  also is there anyway i can query the count too without explicitly writing this      SELECT COUNT(*) FROM Tasks WHERE IsDone = '1'
How do i get a output as below
'<Tasks>
    <CompletedCount>2<CompletedCount>
    <Task>
        <TaskName>Write a email to Mayor<TaskName>
        <IsDone>True</IsDone>
    </Task>
    <Task>
        <TaskName>Organize Campaign for website<TaskName>
        <IsDone>False</IsDone>
    </Task>
</Tasks>'

A: select (
          select count(*)
          from Tasks
          where IsDone = 1
          for xml path('CompletedCount'), type
       ),
       (
          select TaskName,
                 case IsDone
                   when 1 then 'True'
                   else 'False'
                 end as IsDone
          from Tasks
          for xml path('Task'), type
       )
for xml path('Tasks')

Update:
You can do it with a singe select if you first build your task list and then query the XML for the completed count. I doubt this will be any faster than using two select statements.
;with C(Tasks) as
(
  select TaskName,
         case IsDone
           when 1 then 'True'
           else 'False'
         end as IsDone
  from Tasks
  for xml path('Task'), type
)
select C.Tasks.value('count(/Task[IsDone = "True"])', 'int') as CompletedCount,
       C.Tasks
from C
for xml path('Tasks')

A: You can use type to calculate part of the XML in a subquery:
declare @todo table (TaskName varchar(50), IsDone bit)
insert @todo values ('Buy milk',1)
insert @todo values ('Send thank you note',1)

select  sum(case when isdone = 1 then 1 end) as 'CompletedCount'
,       (
        select  TaskName 'TaskName'
        ,       case when isdone = 1 then 'True' else 'False' end 'IsDone'
        from    @todo
        for xml path('Task'), type
        ) as 'TaskList'
from    @todo
for xml path('Tasks')

This prints:
<Tasks>
    <CompletedCount>2</CompletedCount>
    <TaskList>
        <Task>
            <TaskName>Buy milk</TaskName>
            <IsDone>True</IsDone>
        </Task>
        <Task>
            <TaskName>Send thank you note</TaskName>
            <IsDone>True</IsDone>
        </Task>
    </TaskList>
</Tasks>


Q: HID reports/scan codes for iPhone's/iPad's home button I'm creating a very simple Arduino BT keyboard for iOS using a RN-42-HID Bluetooth module. I've been able to connect to an iPad and send it a few HID reports.
So far, I can make the cursor go left, right, up and down, as well as select a certain app. Yay! I do this using the HID raw reports as detailed by Roving Network's HID manual.
I've been trying to figure out how to make my iPad go to the home screen, or change the page. When I connect with a regular BT keyboard, with VoiceOver enabled, the BT keyboard combination of "ctrl + alt + H" makes the iPad return to the home page.
When I send the corresponding HID raw report, the iPad doesn't return home.
const byte HOME1[] = { //equivalent to keyboard ctrl + opt/alt + h
  0xFD,0x09,0x01,0x05,0x00,0x0B,0x00,0x00,0x00,0x00,0x00};

It sees the "H", and prints "H" when I have a text field open, but it just doesn't return to the home page.
I've also tried sending the modifier keys just as a combination of 3 scan codes at the same time, but that didn't work on the iPad, either.
const byte HOME2[] = { //equivalent to keyboard ctrl + opt/alt + h
  0xFD,0x09,0x01,0x00,0x00,0xE0,0xE2,0x0B,0x00,0x00,0x00};

Am I sending the report in the right format? Am I sending the right scan codes?
Even if you don't have the actual scan code, it would be nice if there was a way to figure out what code activates the home page. Does anyone know how I can find the scan code for the home button (and for page turn, which also involves the alt button)?

A: I had a similar issue but with a different combination of keys. I found that i had to split the action into 3 steps: Ctrl+alt+ "letter", then Ctrl+alt, then all buttons released. So just looking at your code, maybe try sending this sequence:
0xFD,0x09,0x01,0x05,0x00,0x0B,0x00,0x00,0x00,0x00,0x00 //ctrl + alt + h
0xFD,0x09,0x01,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //ctrl + alt
0xFD,0x09,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //all released.

A: I'm not sure of a raw report, but I did manage it with [0xFD,0x03,0x03,0x01,0x00] (down), and [0xFD,0x03,0x03,0x00,0x00] (up)


Q: Use the same object animator property (translationx) twice on one object at the same time I have spent the entire day trying to figure this out. I have tried a plethora of code combinations but none of them want to work. Well technically they do work but not the way I'm wanting it to. If I add translationY property it works. I'm basically wanting run 2 animations, both translationx, on a single object at the same time. The object should go from left to right for the entire width of the screen and be moving back and forth a short distance at the same time. So the main question is, is it possible to achieve this or is it not possible to use the same property with an AnimatorSet at the same time?
here is the current code I'm working with:
private void _ballLevel20Animation () {
    move1.cancel();
    int center = (board.getMeasuredWidth() / 2);
    int lr = board.getMeasuredWidth();
    final float left = Float.valueOf(100 - center);
    final float right = Float.valueOf(center - 100);
    int center1 = (board.getMeasuredWidth() / 6);
    final float left1 = Float.valueOf(100 - center);
    final float right1 = Float.valueOf(center - 100);
    move1.setTarget(ball);
    move1.setPropertyName("translationX");
    move1.setFloatValues(left, right);
    move1.setRepeatCount(ObjectAnimator.INFINITE);
    move1.setDuration((int)(ball_duration_increa));
    move1.setRepeatMode(ValueAnimator.REVERSE);
    bounce_ani.setTarget(ball);
    bounce_ani.setPropertyName("translationX");
    bounce_ani.setFloatValues((float)(SketchwareUtil.getDip(getApplicationContext(), (int)(-20))), (float)(SketchwareUtil.getDip(getApplicationContext(), (int)(20))));
    bounce_ani.setRepeatCount(ObjectAnimator.INFINITE);
    bounce_ani.setDuration((int)(ball_duration_increa / 6));
    bounce_ani.setRepeatMode(ValueAnimator.REVERSE);
    AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(bounce_ani).with(move1);

    animatorSet.start();
    /*bounce_ani.setFloatValues(right1, left1);*/
}

A: You could try adding an animation listener to the animation. In the listener, there is onAnimationEnd() which gets called when the animation is done. Here, you may call succeeding animations such that they appear that they are chained.
Android Guide on Animation - Animation Listeners


Q: CSS Transitions on tab load - bug I am creating a home screen and I have 3 tabs that you can go between on the home screen. When you click one all the li's within the tab transition in to the page but if you click between the tabs quickly then they don't always load. This only seems to effect Chrome on pc and mac and sometimes safari on mac. Fine on firefox on pc and mac.
http://codepen.io/2ne/pen/1f7dbb81f464fb5b0e1a4f5bacc30a56
Tab JS
$(document).ready(function() {
  $('nav li').click(function(){
    $('nav li').removeClass('active');
    $(this).addClass('active');
    $('.tab').removeClass('active');
    $('#' + $(this).attr('data-tab')).addClass('active');
  });
});

Portion of css
.tab-content .tab li {
  opacity: 0;
  transform: translatey(-50px) scale(0);
}
.tab-content .tab.active li {
  transition: all 500ms ease;
  transform-origin: top center;
  transform: translatey(0) scale(1);
  opacity: 1;
}
@for $i from 1 through 50 {
  .tab-content .tab.active li:nth-child(#{$i}) {
    transition-delay: (#{$i * 0.1}s);
  }
}

A: You need to add vendor specific values for transform and transition properties. Below is the modified CSS:
  $headerColour: #456878; $headerHeight: 58px; $headerLineHeight: $headerHeight - 2px; @import url(http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900); .cf:after {
            clear: both;
            content: " ";
            display: table;
        }

        body {
            background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/12596/bg.png");
            background-attachment: fixed;
            -ms-background-size: contain;
            background-size: contain;
            color: #fff;
            font-family: "Lato";
            font-size: 18px;
            font-weight: 300;
            overflow-y: scroll;
        }

        header {
            background: $headerColour;
            height: $headerHeight;
            position: relative;
        }

            header li {
                position: absolute;
                top: 0;
                line-height: $headerLineHeight;
            }

                header li.logo {
                    left: 20px;
                }

                header li.user {
                    right: 20px;
                }

        .wrapper {
            position: absolute;
            top: 120px;
            left: 0;
            right: 0;
            margin: auto;
            width: 80%;
        }

        nav {
            margin-bottom: 50px;
            margin-left: 20px;
        }

            nav li {
                color: rgba(255, 255, 255, 0.75);
                cursor: pointer;
                float: left;
                font-size: 20px;
                margin-right: 60px;
                -webkit-transition: color 500ms ease 0s;
                -moz-transition: color 500ms ease 0s;
                -ms-transition: color 500ms ease 0s;
                -o-transition: color 500ms ease 0s;
                transition: color 500ms ease 0s;
                width: 100px;
            }

                nav li:not(.active):hover,
                nav li.active {
                    color: rgba(255, 255, 255, 1);
                }

                nav li.active {
                    font-size: 22px;
                    font-weight: 400;
                }

        .tab-content .tab {
            position: absolute;
            margin-bottom: 100px;
            visibility: hidden;
        }

            .tab-content .tab.active {
                visibility: visible;
            }

            .tab-content .tab > ul {
                margin-bottom: 100px;
            }

            .tab-content .tab li {
                background: #fff;
                height: 200px;
                width: 200px;
                float: left;
                background: #fff;
                margin: 20px;
                -ms-border-radius: 30px;
                border-radius: 30px;
                -ms-opacity: 0;
                opacity: 0;
                -webkit-transform: translatey(-50px) scale(0);
                -moz-transform: translatey(-50px) scale(0);
                -ms-transform: translatey(-50px) scale(0);
                -o-transform: translatey(-50px) scale(0);
                transform: translatey(-50px) scale(0);
            }

            .tab-content .tab.active li {
                -webkit-transition: all 500ms ease;
                -moz-transition: all 500ms ease;
                -ms-transition: all 500ms ease;
                -o-transition: all 500ms ease;
                transition: all 500ms ease;
                -webkit-transform-origin: top center;
                -moz-transform-origin: top center;
                -ms-transform-origin: top center;
                -o-transform-origin: top center;
                transform-origin: top center;
                -webkit-transform: translatey(0) scale(1);
                -moz-transform: translatey(0) scale(1);
                -ms-transform: translatey(0) scale(1);
                -o-transform: translatey(0) scale(1);
                transform: translatey(0) scale(1);
                -ms-opacity: 1;
                opacity: 1;
            }

        @for $i from 1 through 50 {
            .tab-content .tab.active li:nth-child(#{$i}) {
                transition-delay: (#{$i * 0.1}s);
            }
        }

Code Pen: http://codepen.io/anon/pen/gIDsv


Q: Flutter & Firestore - problem about "startAfter" pagination I am able to use "startAfter" and "limit" to do pagination but it have bug.
For example, in Firestore DB I have 7 records:
{"title": "item1", "create_datetime": "2018-11-11 11:11:11"}
{"title": "item2", "create_datetime": "2018-11-11 11:11:11"}
{"title": "item3", "create_datetime": "2018-11-11 11:11:11"}
{"title": "item4", "create_datetime": "2018-11-11 11:11:11"}
{"title": "item5", "create_datetime": "2018-11-11 11:11:11"}
{"title": "item6", "create_datetime": "2018-11-11 11:11:11"}
{"title": "item7", "create_datetime": "2018-12-22 22:22:22"}

When the page size is 5, first page is ok because I used:
.orderBy('create_datetime').limit(5)

It gives me item 1-5.
When it load second page, I used:
.orderBy('create_datetime').startAfter(['2018-11-11 11:11:11']).limit(5)

The problem is that the second page result had item7 only, item6 was disappeared.
"startAt" have the same problem too.
I really hope it has "offset" function. Does anyone have solution?

A: Your query will always return 'item7' because you always starting after 2018-11-11 11:11:11 so it will ignore all the other items and go to the last 2018-11-11 11:11:11 and skip from there. You need to get the last item returned and keep a reference to it, then on your startAfter use the document reference to start after. Usually, flutter's startAfter requires a list to keep a reference to it.
Look at Firebase query cursors

A: Currently flutter don't support startAfter(lastDocFetched) or startAt(anyDoc).
This is required as you said it starts with the string matching values, not at a particular document.


Q: query nutch 2 table result from cassandra 2 dose not look right I am using Nutch 2.2.1 and Cassandra 2 to craw pages. for a test i just inject one url to Cassandra and explore the database.
Using CQL i can query the table in the webpage keyspace
cqlsh:simplex> select * from webpage.f;
 key                                  | column1 | value
--------------------------------------+---------+--------------------
 0x6564752e6373752e7777773a687474702f |  0x6669 |         0x00278d00
 0x6564752e6373752e7777773a687474702f |    0x73 |         0x3f800000
 0x6564752e6373752e7777773a687474702f |  0x7473 | 0x00000145a266703e

which is fine if i convert those hex bytes to string. the key will be the reverted url.
then i write java code to read the table f using datastax java driver 2 (http://www.datastax.com/documentation/developer/java-driver/2.0/java-driver/whatsNew2.html)
i followed the sample code
Cluster cluster = Cluster.builder().addContactPoint("10.20.104.181").build();
Session session = cluster.connect();
ResultSet results = session.execute("SELECT * FROM webpage.f");
for (Row row : results) {

            System.out.println("Key");
        System.out.println(toStrFromByteBuffer(row.getBytes("key")));
        System.out.println("column1");
        System.out.println(toStrFromByteBuffer(row.getBytes("column1")));
        System.out.println("value");
        System.out.println(toStrFromByteBuffer(row.getBytes("value")));

}
cluster.close();

public static String toStrFromByteBuffer(ByteBuffer buffer)
    {
        byte[] ar=buffer.array();
        System.out.println(ar.length);
        return new String(ar,Charset.forName("UTF-8"));
    }

the result is below. You can see row.getBytes("key") returns a whole row data not a specific column value.
Could some master help on this?

A: Nutch stores its data in the f column family as BytesType. The column names are stored as UTF8Type.
If you want to get the data as a String you have to convert it first. A row is completely stored in the ByteBuffer. In your example you convert the whole byte buffer to String what gives you the whole row. When you select one row, you get the current position an limit of that row. So you have to read from begin:buffer current pointer position to buffer limit. For example to get the websites content in the "cnt" field:
// This is the byte buffer you get from selecting column "cnt"
ByteBuffer buffer;
int length = buffer.limit() - buffer.position();

byte[] cellValue = new byte[length];

buffer.get(cellValue, 0, length);

return new String(cellValue, Charset.forName("UTF-8"));


Q: Need help on choosing locks for thread synchronization I have several modifying threads and some reading threads, which all access the global variable X. I want to make my synchronization policy like this:
When a thread try to modify X, it will require a lock first, and several modifying threads can have several locks required.
When a thread try to read X, it must wait until all the modifying threads drop their locks.
Is there any solution to this situation in linux pthread library? Many thanks

A: You are looking for a read/write lock (or reader-writer lock).  I believe there is one in pthreads (pthread_rwlock_*).


Q: Accessing a class method from within an Active Record scope? I am having issues with the scope in this model and I'm at a loss at how best to fix it. I would like to call the distinct_mechanics_sql from within the scope to keep things cleaner, but when I run this I get an "undefined local variable or method" error. Here is the model:
class Mechanics < ActiveRecord::Base
  scope :with_moz, -> { joins("JOIN (#{distinct_mechanics_sql}) mh ON mh.mechanic_id = mechanics.id") }

  def distinct_mechanics_sql
    """
    SELECT DISTINCT ON (mechanic_id) *
    FROM checkups
    ORDER BY mechanic_id, updated_at DESC
    """
  end

end

Any help would be greatly appreciated!

A: Scopes are same as class methods, so within the scope you are implicitly call another class methods. And your distinct_mechanics_sql is an instance method, to use it inside a scope declare it as:
def self.distinct_mechanics_sql

or
def Mechanics.distinct_mechanics_sql

or
class << self
  def distinct_mechanics_sql
    ...
  end
end


Q: How to correctly send a matplotlib.figure.Figure to a private telegram channel on Python3 via Telegram API? Say I have the following df called df_trading_pair_date_time_index which contains the following data:
                         Open      High       Low     Close                End Date
Start Date
2022-08-12 00:25:00  23834.13  23909.27  23830.00  23877.62 2022-08-12 00:29:59.999
2022-08-12 00:30:00  23877.62  23968.52  23877.62  23936.89 2022-08-12 00:34:59.999
2022-08-12 00:35:00  23936.89  23989.95  23915.92  23962.50 2022-08-12 00:39:59.999
2022-08-12 00:40:00  23960.64  23985.03  23935.60  23966.71 2022-08-12 00:44:59.999
2022-08-12 00:45:00  23966.71  23996.94  23958.00  23983.68 2022-08-12 00:49:59.999
2022-08-12 00:50:00  23982.53  24009.67  23958.89  23996.59 2022-08-12 00:54:59.999
2022-08-12 00:55:00  23995.49  24005.30  23963.92  23964.37 2022-08-12 00:59:59.999
2022-08-12 01:00:00  23965.31  24000.00  23940.61  23975.64 2022-08-12 01:04:59.999
2022-08-12 01:05:00  23977.04  23996.85  23928.95  23943.09 2022-08-12 01:09:59.999
2022-08-12 01:10:00  23944.05  23972.86  23885.00  23905.23 2022-08-12 01:14:59.999
2022-08-12 01:15:00  23905.23  23944.66  23901.74  23925.72 2022-08-12 01:19:59.999
2022-08-12 01:20:00  23925.72  23951.21  23917.84  23945.03 2022-08-12 01:24:59.999
2022-08-12 01:25:00  23945.03  23961.78  23935.12  23945.60 2022-08-12 01:29:59.999
2022-08-12 01:30:00  23945.60  23949.86  23919.90  23934.50 2022-08-12 01:34:59.999
2022-08-12 01:35:00  23934.49  23934.50  23853.65  23895.44 2022-08-12 01:39:59.999
2022-08-12 01:40:00  23895.44  23932.11  23894.67  23906.00 2022-08-12 01:44:59.999
2022-08-12 01:45:00  23905.42  23927.26  23878.57  23902.75 2022-08-12 01:49:59.999
2022-08-12 01:50:00  23902.76  23915.00  23888.08  23889.19 2022-08-12 01:54:59.999

When running df_trading_pair_date_time_index.dtypes the following output is presented:
Open               float64
High               float64
Low                float64
Close              float64
End Date    datetime64[ns]
dtype: object

And when running df_trading_pair_date_time_index.index the following output is returned:
DatetimeIndex(['2022-08-12 00:25:00', '2022-08-12 00:30:00', '2022-08-12 00:35:00', '2022-08-12 00:40:00', '2022-08-12 00:45:00', '2022-08-12 00:50:00', '2022-08-12 00:55:00', '2022-08-12 01:00:00',
               '2022-08-12 01:05:00', '2022-08-12 01:10:00', '2022-08-12 01:15:00', '2022-08-12 01:20:00', '2022-08-12 01:25:00', '2022-08-12 01:30:00', '2022-08-12 01:35:00', '2022-08-12 01:40:00',
               '2022-08-12 01:45:00', '2022-08-12 01:50:00'],
              dtype='datetime64[ns]', name='Start Date', freq=None)

In order to plot the data above, I used the following code:
import requests
import mplfinance as mpf
import matplotlib.pyplot as plt
import pandas as pd

# Plotting
# Create my own `marketcolors` style:
mc = mpf.make_marketcolors(up='#2fc71e',down='#ed2f1a',inherit=True)
# Create my own `MatPlotFinance` style:
s  = mpf.make_mpf_style(base_mpl_style=['bmh', 'dark_background'],marketcolors=mc, y_on_right=True)

# Plot it
btc_plot, axlist = mpf.plot(df_trading_pair_date_time_index,
                            figratio=(10, 6),
                            type="candle",
                            style=s,
                            tight_layout=True,
                            datetime_format = '%H:%M',
                            ylabel = "Precio ($)",
                            returnfig=True)
# Add Title
axlist[0].set_title("BTC/USDT - 5m", fontsize=25, style='italic', fontfamily='fantasy' )

After running btc_plot in the console, the following chart is returned:

And finally when running type(btc_plot) the following output is returned:
matplotlib.figure.Figure

The problem:
I am having a hard time dealing with a "simple" thing, I want to send such plotted trading chart to a private telegram channel through the Telegram API with Python3, so according to this section of the Telegram API Documentation, the following line should work:
requests.post(f'https://api.telegram.org/bot{bot_str}/sendPhoto',
                          data = {'chat_id':f'-100{channel_id_str}', 'photo': btc_plot, 'caption':'Fue detectada una señal bajista en el par BTC/USDT!'})

However, after running that statement, all I got was a <Response [400]> without any explanation nor exception from the console.
So, I do think that it may be happening because I'm trying to send a matplotlib.figure.Figure object, but I mistakenly thought that btc_plot had stored a png object just because an image was returned after running btc_plot in the console, so I am lost.
Ironically, the following sentence works as expected with a <Response [200]> as output:
requests.post(f'https://api.telegram.org/bot{bot_str}/sendMessage',
                              data = {'chat_id':f'-100{channel_id_str}', 'text': 'Fue detectada una señal bajista en el par BTC/USDT!'})

May I get here some alternative solution or an improvement to my current one?

A: Found an alternative, which I think it actually always was the right way to do it.
import telegram

btc_plot.savefig('signal.png',dpi=300, bbox_inches = "tight")
telegram.Bot(token= token_str).send_photo(chat_id= chat_id_str,
                                          photo=open("signal.png", 'rb'),
                                          caption="Fue detectada una señal bajista en el par BTC/USDT!")

Output:


Q: question about SQLAlchemy's choice of join targets I'm going through the SQLAlchemy ORM tutorial (https://docs.sqlalchemy.org/en/latest/orm/tutorial.html#querying-with-joins) and there's a part that confused me more than it helped me:

What does Query select from if there’s multiple entities?
The Query.join() method will typically join from the leftmost item in
  the list of entities, when the ON clause is omitted, or if the ON
  clause is a plain SQL expression. To control the first entity in the
  list of JOINs, use the Query.select_from() method:
query = session.query(User, Address).select_from(Address).join(User)

Is the "list of entities" the list within query()?
More to the point, when would the ON clause not be omitted?
By ON clause does it mean a relationship like User.addresses (previously defined for example as User.addresses = relationship(Address)) used like join(User.addresses)? Is that the type of "ON clause" that would prevent us from needing select_from() since the join() parameter itself would contain the necessary information for determining which table we intend to join with?
Surely there must be some way to specify join targets without having them always defaulting to the first table in query() since otherwise it wouldn't be possible to build certain complex queries.

A: Let's start from the beginning. When you pass items to query(), it will build a SELECT statement from these items. If they are models, then it will enumerate all the fields of such models. The query will automatically add the tables to select FROM.
Unless you tell it to, the query will not perform joins automatically, so you must add assume what tables to look up your values from. Additional clauses like join() tell the query how the JOIN operation should be performed.
Additional arguments to join() will be used as the ON clause, otherwise the query will infer the clause based on mapper-defined relationships.
So to summarize, the ON clause is omitted whenever you do not specify additional arguments to join(). In the following expression, the ON clause is omitted: query(User, Address).join(Address) This does not mean that the SQL emitted will not have an ON clause; it will do the right thing by inferring the proper ON clause using the relationships defined on the model.
When there are multiple possibilities, you need to specify the clause yourself: query(Person).join(Person.parent1).join(Person.parent2) should result in a query that returns a person and both of their parents. In this case, the ON clause was not omitted.


Q: Using SVG, hover on X, Y or Z to make X and Z rotate I have an element (logo) on my webpage which contains three other elements, I want to make it so when the logo as a whole is hovered, two of the elements within the logo (two of the letters) will rotate around their centre indefinitely.
I have achieved rotating elements with CSS animations, but only to get an element to rotate when itself is hovered. I cannot figure out how to get multiple elements to rotate when any of the three elements are hovered using CSS.
I have the three elements in their own svg tags as data URI, all within a single g, which itself is in an a href that links to the home page.
<header><a id="logoLink" href="">

<g class="logoSvg">

<svg id="c" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34.68 37.2"><defs><style>.cls-1{fill:#e94a4a;}</style></defs><title>logo</title><path class="cls-1" d="...
</svg>
<svg id="hri" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 76.88 79.53"><defs><style>.cls-1{fill:#e94a4a;}</style></defs><title>logo copy</title><path class="cls-1" d="M
</svg>
<svg id="s" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31.19 37.2"><defs><style>.cls-1{fill:#e94a4a;}</style></defs><title>logo copy 2</title><path class="cls-1" d="M
</svg>

</g>

</a>

In the html doc I also have a script source with SnapSVG content, as well as linking to the SnapSVG source code:
<script src="js/logoAni.js"></script>

The SnapSVG js is as follows:
var logo = $("#logoSvg");
var c = $("#c");
var hri = $("#hri");
var s = $("#s");

function rollover(){
    c.transform('r0,100,100');
    c.animate({transform: "r360,100,100"},1000,mina.linear,anim);
    s.transform('r0,100,100');
    s.animate({transform: "r360,100,100"},1000,mina.linear,anim);
}

logo.hover(rollover);

I'm assuming that the snap code is wrong. Perhaps I don't need to use snap at all?
Update:
Here's a recent jfiddle https://jsfiddle.net/Lc12bvyn/

A: You could use @keyframes animation and nested styles in SCSS to achieve something like this without javascript. Not sure if you're wanting to go this route, but it seems the most straightforward to me.
Particularly you're looking to set the animation-iteration-count to infinite on the elements that you want to rotate.
The below code is just some rough concept stuff, not sure the animation you're looking to set, or the full context of your elements, etc.
.logoSvg {

  &:hover {

    &:first-child {
      animation-name: someAnimation;
      animation-iteration-count: infinite;
    }

    &:last-child {
      animation-name: someAnimation;
      animation-iteration-count: infinite;
    }
  }
}

@keyframes someAnimation {
  0%: {transform: some transformation};
  100%: {transform: some transformation};
}

I hope this is helpful Chris, or at least gets you going in the right direction.

A: The rollover code itself looks ok (assuming missing code is, if you still get stuck I would put up a jsfiddle or jsbin), it's just applying to the wrong type of elements.
I'm guessing you are using jquery for the selections? If so, I'm not sure that will work..rather than doing..
var logo = $("#logoSvg");

try
var logo = Snap("#logoSvg");

That way you will get the Snap element (which links to the DOM element) to operate on, not a DOM or jquery object.
You can't transform the 'svg' element itself typically (as it doesn't technically support the transform attribute as far as I'm aware).
So, I would put the two svgs you want to transform inside a g/group element and transform that g element. You could look into css, but css transforms on svg don't always play nice regarding browser support, so whilst Davids answer may be good for normal elements, I'm not sure it would play nice for svg elements (especially rotations), do test different browsers very early if you do try that method.


Q: json post request size limit (now a verified php-mysqli bug) I'm sending a request to my PHP application through a JSON-encoded ajax request (form process).  A post-request with character length of 4174 is successfully processed and the result is received correctly.  Adding one additional character to the request causes my application to loop infinitely until Apache2 seg-faults.  There are only 2 fields, one for a 3-digit id, and the rest is text from a text area.
I'm using the Zend Framework to drive my application, Apache2.2.3, PHP 5.2.8, JSON plugin version 1.2.1, MySQL 5.0.77
Anyone have any ideas...
here is another update::
    tracked this issue to NOT a json request problem, but an issue with the query i am running.  I'm performing an INSERT ON DUPLICATE KEY UPDATE query that inflates the text size of the query.  I can run this query find from the command line, however from PHP it's failing.  Currently investigating the issue.  Anyone interested could see the query here..
** this is a bug with the mysqli plugins for php, for some reason the db handler doesn't like this code.  If/when I have time to properly test, you'll see my results.**
INSERT INTO element_attribute_values (ElementAttributeId,ElementId,value) VALUES  (1,'553','444st text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this itext this itext this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test tex this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is sotext this ime test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test tex tesxthis is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is fsome test texttext this i this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is sometext this i test text this is some test text this is some test text this is sothis is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text thisf iffffffff4444') ON DUPLICATE KEY UPDATE value='444st text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this itext this itext this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test tex this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is sotext this ime test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test tex tesxthis is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is fsome test texttext this i this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is sometext this i test text this is some test text this is some test text this is sothis is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text this is some test text thisf iffffffff4444'

A: I don't know if this is related or not but I was using jQuery recently using the $.ajax() method to submit POST data from a text field to a php script. The php script would then parse the data (XML) for the bits of information that I needed. I noticed an error on my firephp output that it was unable to parse the XML from the POSTed form. I then had it output the strlen() and the data and noticed it was cutting it from around 7k bytes down to 268 (or 256 or something I forget the exact amount). This made it an incomplete and not valid XML pile of data. I fixed this by using the $.post() method instead. Worked perfectly.

A: You could simply check the length of your string, and if it's over the limit, split it up. Run the first portion in the insert, then do a += update on the field with the second portion. It's a bit crude, but it gets around the bug.


Q: nodejs proxy local api calls to external rest api service (no express.js) I'm running the demo app of angularjs (angular-seed) using nodejs with the default project file /scripts/web-server.js (see below)
I would like node js to proxy/redirect all the local calls to /api to the external Rest api endpoint http://www.mywebsite.com/api in order to avoid the cross domain origin policy.
How should I edit the web-server.js below to achieve the proxy redirect?
All the example I found do use express.js. I'm using node.js only as development environment so I've no interest in using express.js.
Default web-server.js nodejs script:
#!/usr/bin/env node

var util = require('util'),
    http = require('http'),
    fs = require('fs'),
    url = require('url'),
    events = require('events'),
    request = require('request');
    ;

var DEFAULT_PORT = 8000;

function main(argv) {
  new HttpServer({
    'GET': createServlet(StaticServlet),
    'HEAD': createServlet(StaticServlet)
  }).start(Number(argv[2]) || DEFAULT_PORT);
}

function escapeHtml(value) {
  return value.toString().
    replace('', '>').
    replace('"', '"');
}

function createServlet(Class) {
  var servlet = new Class();
  return servlet.handleRequest.bind(servlet);
}

/**
 * An Http server implementation that uses a map of methods to decide
 * action routing.
 *
 * @param {Object} Map of method => Handler function
 */
function HttpServer(handlers) {
  this.handlers = handlers;
  this.server = http.createServer(this.handleRequest_.bind(this));
}

HttpServer.prototype.start = function(port) {
  this.port = port;
  this.server.listen(port);
  util.puts('Http Server running at http://localhost:' + port + '/');
};

HttpServer.prototype.parseUrl_ = function(urlString) {
  var parsed = url.parse(urlString);
  parsed.pathname = url.resolve('/', parsed.pathname);
  return url.parse(url.format(parsed), true);
};

HttpServer.prototype.handleRequest_ = function(req, res) {
  var logEntry = req.method + ' ' + req.url;
  if (req.headers['user-agent']) {
    logEntry += ' ' + req.headers['user-agent'];
  }
  util.puts(logEntry);
  req.url = this.parseUrl_(req.url);
  var handler = this.handlers[req.method];
  if (!handler) {
    res.writeHead(501);
    res.end();
  } else {
    handler.call(this, req, res);
  }
};

/**
 * Handles static content.
 */
function StaticServlet() {}

StaticServlet.MimeMap = {
  'txt': 'text/plain',
  'html': 'text/html',
  'css': 'text/css',
  'xml': 'application/xml',
  'json': 'application/json',
  'js': 'application/javascript',
  'jpg': 'image/jpeg',
  'jpeg': 'image/jpeg',
  'gif': 'image/gif',
  'png': 'image/png',
  'svg': 'image/svg+xml'
};

StaticServlet.prototype.handleRequest = function(req, res) {
  var self = this;
  var path = ('./' + req.url.pathname).replace('//','/').replace(/%(..)/g, function(match, hex){
    return String.fromCharCode(parseInt(hex, 16));
  });
  var parts = path.split('/');
  if (parts[parts.length-1].charAt(0) === '.')
    return self.sendForbidden_(req, res, path);
  fs.stat(path, function(err, stat) {
    if (err)
      return self.sendMissing_(req, res, path);
    if (stat.isDirectory())
      return self.sendDirectory_(req, res, path);
    return self.sendFile_(req, res, path);
  });
}

StaticServlet.prototype.sendError_ = function(req, res, error) {
  res.writeHead(500, {
      'Content-Type': 'text/html'
  });
  res.write('\n');
  res.write('Internal Server Error\n');
  res.write('Internal Server Error');
  res.write('' + escapeHtml(util.inspect(error)) + '');
  util.puts('500 Internal Server Error');
  util.puts(util.inspect(error));
};

StaticServlet.prototype.sendMissing_ = function(req, res, path) {
  path = path.substring(1);
  res.writeHead(404, {
      'Content-Type': 'text/html'
  });
  res.write('\n');
  res.write('404 Not Found\n');
  res.write('Not Found');
  res.write(
    'The requested URL ' +
    escapeHtml(path) +
    ' was not found on this server.'
  );
  res.end();
  util.puts('404 Not Found: ' + path);
};

StaticServlet.prototype.sendForbidden_ = function(req, res, path) {
  path = path.substring(1);
  res.writeHead(403, {
      'Content-Type': 'text/html'
  });
  res.write('\n');
  res.write('403 Forbidden\n');
  res.write('Forbidden');
  res.write(
    'You do not have permission to access ' +
    escapeHtml(path) + ' on this server.'
  );
  res.end();
  util.puts('403 Forbidden: ' + path);
};

StaticServlet.prototype.sendRedirect_ = function(req, res, redirectUrl) {
  res.writeHead(301, {
      'Content-Type': 'text/html',
      'Location': redirectUrl
  });
  res.write('\n');
  res.write('301 Moved Permanently\n');
  res.write('Moved Permanently');
  res.write(
    'The document has moved here.'
  );
  res.end();
  util.puts('301 Moved Permanently: ' + redirectUrl);
};

StaticServlet.prototype.sendFile_ = function(req, res, path) {
  var self = this;
  var file = fs.createReadStream(path);
  res.writeHead(200, {
    'Content-Type': StaticServlet.
      MimeMap[path.split('.').pop()] || 'text/plain'
  });
  if (req.method === 'HEAD') {
    res.end();
  } else {
    file.on('data', res.write.bind(res));
    file.on('close', function() {
      res.end();
    });
    file.on('error', function(error) {
      self.sendError_(req, res, error);
    });
  }
};

StaticServlet.prototype.sendDirectory_ = function(req, res, path) {
  var self = this;
  if (path.match(/[^\/]$/)) {
    req.url.pathname += '/';
    var redirectUrl = url.format(url.parse(url.format(req.url)));
    return self.sendRedirect_(req, res, redirectUrl);
  }
  fs.readdir(path, function(err, files) {
    if (err)
      return self.sendError_(req, res, error);

    if (!files.length)
      return self.writeDirectoryIndex_(req, res, path, []);

    var remaining = files.length;
    files.forEach(function(fileName, index) {
      fs.stat(path + '/' + fileName, function(err, stat) {
        if (err)
          return self.sendError_(req, res, err);
        if (stat.isDirectory()) {
          files[index] = fileName + '/';
        }
        if (!(--remaining))
          return self.writeDirectoryIndex_(req, res, path, files);
      });
    });
  });
};

StaticServlet.prototype.writeDirectoryIndex_ = function(req, res, path, files) {
  path = path.substring(1);
  res.writeHead(200, {
    'Content-Type': 'text/html'
  });
  if (req.method === 'HEAD') {
    res.end();
    return;
  }
  res.write('\n');
  res.write('' + escapeHtml(path) + '\n');
  res.write('\n');
  res.write('  ol { list-style-type: none; font-size: 1.2em; }\n');
  res.write('\n');
  res.write('Directory: ' + escapeHtml(path) + '');
  res.write('
*');
  files.forEach(function(fileName) {
    if (fileName.charAt(0) !== '.') {
      res.write('
*' +
        escapeHtml(fileName) + '');
    }
  });
  res.write('');
  res.end();
};

// Must be last,
main(process.argv);


Q: java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling I am trying to remove an item from listview which is not starting a specific text "Dev". But the application is crashing when I remove an item and refresh the recycler list via notifydatasetChanged(). This question has been already asked and I have seen all the solutions but I can't find a proper solution to this.
EvelistAdapter.java
     public class EvelistAdater extends RecyclerView.Adapter<EvelistAdater.ViewHolder> {
    Context cxt;
    ArrayList<Dbbean> adapterlist;
    int row_index;
    public EvelistAdater(Context cxt, ArrayList<Dbbean> list) {
        adapterlist=list;
        this.cxt=cxt;
        Log.d("LIst count",""+adapterlist.size());
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.scanlistadp, viewGroup, false);
        return  new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {

        if(adapterlist.get(position).blename.startsWith("Dev")) {
            holder.tv_country.setText(adapterlist.get(position).blename);

        }else{
            removeAt(position);
        }
    }

    @Override
    public int getItemCount() {
        return adapterlist.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView tv_country;
        RelativeLayout layout;
        ImageView setting;
        public ViewHolder(View view) {
            super(view);
            tv_country = (TextView)view.findViewById(R.id.tshirtname);
            setting = (ImageView) view.findViewById(R.id.setting);
            layout = (RelativeLayout)view.findViewById(R.id.layout);
        }
    }
    public void removeAt(int position) {
        adapterlist.remove(position);
        notifyDataSetChanged();
    }
}

LOGCAT
E/UncaughtException: java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
                                                                        at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2586)
                                                                        at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeChanged(RecyclerView.java:4951)
                                                                        at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView.java:11371)
                                                                        at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView.java:11362)
                                                                        at android.support.v7.widget.RecyclerView$Adapter.notifyItemChanged(RecyclerView.java:6650)
                                                                        at com.scanner.com.eve.EvelistAdater.removeAt(EvelistAdater.java:94)
                                                                        at com.scanner.com.eve.EvelistAdater.onBindViewHolder(EvelistAdater.java:44)
                                                                        at com.scanner.com.eve.EvelistAdater.onBindViewHolder(EvelistAdater.java:19)
                                                                        at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6354)
                                                                        at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6387)
                                                                        at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5343)
                                                                        at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5606)
                                                                        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5448)
                                                                        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5444)
                                                                        at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
                                                                        at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1551)
                                                                        at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
                                                                        at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
                                                                        at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3600)
                                                                        at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3329)
                                                                        at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3867)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:636)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                        at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2895)
                                                                        at android.view.View.layout(View.java:16655)
                                                                        at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
                                                                        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
                                                                        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                                        at android.view.ViewR

A: Filter the data in list before passing to Adapter
 ArrayList<Dbbean> list = yourlist;

Create a filtered list
  ArrayList<Dbbean> filteredList = new ArrayList<>();
  for(Dbbean dbean : list){
    if(dbean.blename.startsWith("Dev")
     filteredList.add(dbean);
  }

Pass filtered list to Adapter
EvelistAdapter adapter = new EvelistAdaptr(this,filteredList);
yourRecyclerView.setAdapter(adapter);

A: Do not call removeItem inside onBindViewHolder directly. If you want to remove item then just do it before setting adapter.
Provide the filtered ArrayList<Dbbean> list to adpater in first place .Later you can remove item from adapter on any specified action.
 Do not use notifyDataSetChanged() until you are not sure which dataset is changed. Use :
notifyItemRemoved() for a particular item removed for position .

A: this is causing the problem you are just forcefully making changes to the onBindViewHolder which is drawing something right now again to redraw.
@Override
public void onBindViewHolder(ViewHolder holder, final int position) {

    if(adapterlist.get(position).blename.startsWith("Dev")) {
        holder.tv_country.setText(adapterlist.get(position).blename);

    }else{
        removeAt(position);
    }
}

public void removeAt(int position) {
    adapterlist.remove(position);
    notifyDataSetChanged();
}

suggestion better check this condition and remove the items when you are about to notify the adapter from fragment or activity.


Q: persistent vs immutable data structure Is there any difference in a persistent and immutable data structure? Wikipedia refers to immutable data structure when discussing persistence but I have a feeling there might be a subtle difference between the two.

A: Immutability is an implementation technique. Among other things, it provides persistence, which is an interface. The persistence API is something like:

*

*version update(operation o, version v) performs operation o on version v, returning a new version. If the data structure is immutable, the new version is a new structure (that may share immutable parts of the old structure). If the data structure isn't immutable, the returned version might just be a version number. The version v remains a valid version, and it shouldn't change in any observe-able way because of this update - the update is only visible in the returned version, not in v.

*data observe(query q, version v) observes a data structure at version v without changing it or creating a new version.

For more about these differences, see:

*

*The chapter "Persistent data structures" by Haim Kaplan in Handbook on Data Structures and Applications

*"Making Data Structures Persistent" by Driscoll et al.

*The first lecture of the Spring 2012 incarnation of MIT's 6.851: Advanced Data Structures

A: Yes, there is a difference.  An immutable data structure cannot be modified in any way after its creation. The only way to effective modify it would be to make a mutable copy or something similar (e.g. slightly modifying the parameters you pass to the constructor of the new one). A persistent data structure, on the other hand, is mutable in the sense that the exposed API appears to allow changes to the data structure. In truth, though, any changes will retain a pointer to the existing data structure (and therefore every preceding structure); they only seem to mutate the data structure because the exposed API returns a new pointer that may include pointers to a subset of the previous data structure (in trees, e.g., we will point at the node whose subtree hasn't changed as a result of the operation).


Q: Action Script: Drawing on video I was wondering how to draw over a video like this.
http://www.bannerblog.com.au/2009/06/burger_king_sharpie.php

A: I'm not sure that in the example is drawing process over video. As for me It's a 3d model with video background. And you could sync prerecorded states with 3d object transformations (position, rotation, mesh transformations), or create well textured object.
Here for your tutorial how to draw over the 3D objects

A: Easy! Use Adobe After Effects (or any number of other compositing programs).


Q: SQL 'belong to' logic So, I have been trying to write a query in SQL but facing an issue. I am trying to write a 'belongs to' kind of condition. What I want to do is if the values being fetched belongs to a column in another table then populate one thing otherwise populate null.
for ex.
NAME table
ID    NAMES
1      A
2      B
3      C
4      D
5      E

XYZ table
ID
2
4
5

I wrote the query something like this
(CASE WHEN NAME.ID IN (SELECT ID FROM XYZ) THEN NAME.NAMES ELSE NULL END ) AS 'ABC'

This query does run but it has been running for 14 hours (OBVIOUSLY FOR A VERY HUGE AMOUNT OF DATA) and still there is no result.  Is there some flaw in this logic or is there some better way it could be done?
I expect a result like this:
ABC
NULL
B
NULL
D
E

A: You just need a plain left join here:
SELECT
    CASE WHEN t2.ID IS NOT NULL THEN t1.NAMES END AS ABC
FROM NAME t1
LEFT JOIN XYZ t2
    ON t1.ID = t2.ID;

Demo
Note that a CASE expressions else condition, if not explicitly specified, defaults to NULL.  This behavior works here because you want to render NULL if a given record in the NAME table does not match to any record in the XYZ table.

A: The problem isn't your logic.  It is simply how the code is optimized.  The subquery is probably being run for each row in the outer query.
I would recommend switching to exists:
(case when exists (select 1 from xyz where xyz.id = name.id) then name.names
 end) as abc

This maintains the semantics of your original query.  In particular, there is no danger that duplicates in xyz would return multiple rows (as would happen with a left join).
For performance for this -- or for the left join -- you want an index on xyz(id).


Q: Angular2: Too many calls on Observable So currently I created a service in order to path data from one component to another. Let's say I have a select component and a component factory. In order to pass a selected value from a select component to factory I designed this service.
Here is how the service looks like:
import { Injectable } from '@angular/core';
import {Subject} from "rxjs/Subject";

@Injectable()
export class ObservableService {
    private dataSource = new Subject();
    data = [];
    data$ = this.dataSource.asObservable();

    updateFilter(value) {
        this.data.push(value);
        console.log('Changes transfer');
        this.dataSource.next(this.data)
    }
}

So, as I said I have to path data from my html select input that belongs to select component to factory, and here is the select component html
<select (change)="onChange($event)">
    <option value="">Options</option>
    <option *ngFor="let option of options" [value]="option.value">{{ option.name }}</option>
</select>

And here is the way I sending selected value from select component to observable service:
private onChange(option) {
    console.log('Changes sent');
    this._observable.updateFilter(option);

}
Here is how I'm catching data in factory component
ngOnInit() {
    this._observable.data$.subscribe(
        data => console.log('Changes detected');
    )
}

You may notice console commands that I put on each stage of data transfer. And in fact I got this:
Changes sent
Changes transfer
(13) Changes detected

So in fact the observable subscriber detected 13 changes! Please, help me to understand where this strange behavior goes from?


Q: Issues with https:// non-www re-directing to https://www I have a website which has recently moved from http:// to https://
The site is built with MVC hosted on IIS7, and I know I should have 4 bindings in place for this.
the main one:
https://www.example.com (port:443 - ip address: *)
and 3 others all to 301 re-direct to the above.
    http://www.example.com - (port:80 - ip address: * -re-direct works)
    http://example.com - (port:80 - ip address: * -re-direct works)
    https://example.com - (port:443 - ip address: * -re-direct does not work)

Trying to troubleshoot why the bottom one is failing with Site could not be reached. server DNS address could not be found.
Below is the code I am using to re-direct http to https
            // The base only redirects GET, but we added HEAD as well. This avoids exceptions for bots crawling using HEAD.
            // The other requests will throw an exception to ensure the correct verbs are used.
            // We fall back to the base method as the mvc exceptions are marked as internal.

            if (!String.Equals(filterContext.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)
                && !String.Equals(filterContext.HttpContext.Request.HttpMethod, "HEAD", StringComparison.OrdinalIgnoreCase))
            {
                base.HandleNonHttpsRequest(filterContext);
            }

            // Redirect to HTTPS version of page
            // We updated this to redirect using 301 (permanent) instead of 302 (temporary).
            string url = "https://" + filterContext.HttpContext.Request.Url.Host + filterContext.HttpContext.Request.RawUrl;

            filterContext.Result = new RedirectResult(url, true);

Any ideas what is going wrong here with the bottom binding? Trying to set up 4th property on Google Webmaster Search Console and obviously can't due to failing DNS.
Any help at all is greatly appreciated. Cheers

A: It's better do this kind of thing on web-server level rather than in app code.
For IIS, you need to change file Web.config by adding a rewrite rules.
I was not able to test it, but you should add something like that:
<rewrite>
  <rules>
    <rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
      <match url="*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="example.com" />
      </conditions>
      <action type="Redirect" url="http://www.example.com/{R:0}" />
    </rule>

    <rule name="HTTP Redirect to HTTPS" enabled="true" stopProcessing="true">
      <match url="(.*)" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="off" />
      </conditions>
      <action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>

A: The issue was with the DNS on our domain provider.


Q: Illegal mix of collations for operation ' IN ', While using LINQ Lambda with contains clause I am having Linq query that fetch city names as keyValue pair, Refer below code
 public List<KeyValuePair<string, int>> GetCityKeyValuesByNames(List<string> cityNames)
        {

                var cityList = _cityRepo
                    .GetConditionalQuery(x => cityNames.Contains(x.Name))
                    .Select(x => new { Key = x.Name, Value = x.Id })
                    .AsEnumerable()
                    .Select(x => new KeyValuePair<string, int>(x.Key, x.Value))
                    .ToList();

                return cityList;
        }

However we getting Eception MySql.Data.MySqlClient.MySqlException: Illegal mix of collations for operation ' IN ', How I can control the collation in EF Linq query?


Q: iOS framework to get audio in from dock connector How would I go abouts playing an 'audio in' through the dock connector in an iOS app? I'm making an app just for myself and have no plans of putting it into the apple store. I have the 30pin breakout board, and on it there are pins for L/R audio in, but I can not find any info on how to use them?
Thanks

A: As far as I'm aware, your only officially supported option for any accessory using the dock connector would be to use the External Accessory Framework, which requires enrollment in the Made for iPod Program (overkill for your purposes). However, the iPhone and iPod both support line-in via the headphone jack, and there are plenty of apps that make use of audio input. At least it provides some possibilities.

A: Have you looked at the pinouts for the dock connector floating about? It appears that certain resistances connected to pin 21 indicate to the iDevice what is connected.
68kΩ seems to be the magic number for audio in/out.


Q: Firebase Web Version 9 updateProfile not updating the authorized user I'm using Firebase Web version 9 in a react app. I have a sign-up form with first name, email, and password inputs. When the form is submitted, I need to create an authorized user with Firebase and immediately update that new user's first name and profile picture.
I'm using two Firebase auth functions - createUserWithEmailAndPassword() and updateProfile(). A new user is always created when the form is submitted, but the profile updates only happen once in a while. I haven't been able to pinpoint the cases when the profile update is successful.
Any ideas on what I'm missing? Would love some feedback and guidance. Thank you!
Here's the code for the sign-up page.
import { useState, useEffect } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import {
  StyledHeader,
  StyledFooter,
  StyledDropdown,
  StyledForm,
} from '../styles';
import {
  getAuth,
  createUserWithEmailAndPassword,
  updateProfile,
} from 'firebase/auth';
import { ShortFooter, LanguageSelect, Form } from '../components';
import { logo, p1, p2, p3, p4, p5 } from '../assets';

const SignUp = ({ children }) => {
  const [firstName, setfirstName] = useState('');
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [isFirstNameEmpty, setIsFirstNameEmpty] = useState(true);
  const [isEmailEmpty, setIsEmailEmpty] = useState(true);
  const [isPasswordEmpty, setIsPasswordEmpty] = useState(true);
  const [error, setError] = useState('');
  const [checked, setChecked] = useState(true);
  const [isShown, setIsShown] = useState(true);
  const isInvalid = firstName === '' || email === '' || password === '';
  const navigate = useNavigate();
  const userProfileImgs = [p1, p2, p3, p4, p5];

  useEffect(() => {
    setTimeout(() => {
      //  scroll to top on page load
      window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
    }, 100);
  }, []);

  const handlefirstNameChange = (firstName) => {
    if (firstName.length !== 0) {
      setIsFirstNameEmpty(false);
    } else {
      setIsFirstNameEmpty(true);
    }
  };

  const handleEmailChange = (email) => {
    if (email.length !== 0) {
      setIsEmailEmpty(false);
    } else {
      setIsEmailEmpty(true);
    }
  };

  const handlePasswordChange = (password) => {
    if (password.length !== 0) {
      setIsPasswordEmpty(false);
    } else {
      setIsPasswordEmpty(true);
    }
  };

  const handleCheckbox = () => {
    setChecked((checked) => !checked);
  };

  const handleLearnMore = (e) => {
    e.preventDefault();
    setIsShown((isShown) => !isShown);
  };

  const handleSignUp = async (e) => {
    e.preventDefault();

    try {
      // firebase work!
      const auth = getAuth();
      let { user } = await createUserWithEmailAndPassword(
        auth,
        email,
        password
      );
      console.debug(`User ${user.uid} created`);

      // updating the user's profile with their first name and a random profile image
      await updateProfile(user, {
        displayName: firstName,
        photoURL:
          userProfileImgs[Math.floor(Math.random() * userProfileImgs.length)],
      });
      console.debug(`User profile updated`);

      // navigate to the profile page
      navigate('/profile');
    } catch (e) {
      if (e.message === 'Firebase: Error (auth/email-already-in-use).') {
        setError('That email is already in use, please try again.');
      }
    }
  };

  return (
    <>

          </form>

                </ShortFooter>
              </StyledFooter>

        {children}
      </StyledHeader>
    </>
  );
};

export default SignUp;

This is the error I'm getting in the console.
Error

A: Based on how my app was set up I ultimately decided to remove the photoURL property altogether since it could be defined elsewhere in the app. After testing, only one of my images worked. This is why I experienced the full profile updates working out sometimes since random images were selected each time a new user signs up. I ended up sticking wth this image as the default image.
As @adsy mentioned, my profile updates weren't happening consistently because certain profile images I had exceeded the allowed input body length for this property. The example in the Docs shows a link with 43 characters but no other information. The path to the profile images in the question are much shorter than this so I still need some understanding.
After researching a bit, I didn't come across the maximum limit set. It's now something to contact Google Developer's support team about. If anyone has the information for the allowed input body length for this property, feel free to share it on this post.
Thanks!
 const handleSignUp = async (e) => {
    e.preventDefault();

    try {
      // firebase work!
      const auth = getAuth();
      let { user } = await createUserWithEmailAndPassword(
        auth,
        email,
        password
      );
      console.debug(`User ${user.uid} created`);

      // updating the user's profile with their first name
      await updateProfile(user, {
        displayName: firstName,
      });
      console.debug(`User profile updated`);

      // navigate to the profile page
      navigate('/profile');
    } catch (e) {
      if (e.message === 'Firebase: Error (auth/email-already-in-use).') {
        setError('That email is already in use, please try again.');
      }
    }
  };


Q: How to search in string for  inside of  and unwrap it with PHP What is the best way to reformat the HTML with PHP. Put span tag outside of a tag?
This:

    Text Link

To:

    Text Link

A: You can make a good use of preg_match function:
$str = '

            Text Link

';

if(preg_match('/^(\
).*(\).*(\)([0-9a-zA-Z ]*).*$/is', $str, $regs))
{
    // $regs = [
    //    0 => ... (original string)
    //    1 => '
',
    //    2 => '',
    //    3 => '',
    //    4 => 'Text Link']
    $newStr = $regs[1].$regs[3].$regs[2].$regs[4].'
';
}

You may have to change the [0-9a-zA-Z ]* in regular expression to match your links format.
If input HTML is multiple line text then you have to use s modifier after the regular exception, I also used i as case insensitive just to be sure noone mixed
 and
 tag together and so on...
Note that this if fairly specific solution and for more general solution you should use something like loading HTML into DOM and working with nodes, but this is pretty simple and quick solution for this particular case.