text:
Q: Servlet handling file-upload, Why bigger than the original? Servlet doPost handing file-uploads,
    InputStream in = req.getInputStream();

    File file = new File("c:/8.dat");
    OutputStream out = new FileOutputStream(file);
    byte[] buffer = new byte[1024];

    int len =0;
    while((len=in.read(buffer))!=-1){
        out.write(buffer, 0, len);
    }
    bao.close();
    out.close();
    in.close();

Dose Request's getInputStream Method take the http header information?
Why is the uploaded file bigger than the original?

A: Sending files in a HTTP request is usually done using multipart/form-data encoding. This enables the server to distinguish multiple form data parts in a single request (it would otherwise not be possible to send multiple files and/or input fields along in a single request). Each part is separated by a boundary and preceeded by form data headers. The entire request body roughly look like this (taking an example form with 3 plain <input type="text"> fields with names name1, name2 and name3 which have the values value1, value2 and value3 filled):
--SOME_BOUNDARY
content-disposition: form-data;name="name1"
content-type: text/plain;charset=UTF-8

value1
--SOME_BOUNDARY
content-disposition: form-data;name="name2"
content-type: text/plain;charset=UTF-8

value2
--SOME_BOUNDARY
content-disposition: form-data;name="name3"
content-type: text/plain;charset=UTF-8

value3
--SOME_BOUNDARY--

With a single <input type="file"> field with the name file1 the entire request body look like this:
--SOME_BOUNDARY
content-disposition: form-data;name="file1";filename="some.ext"
content-type: application/octet-stream

binary file content here
--SOME_BOUNDARY--

That's thus basically what you're reading by request.getInputStream(). You should be parsing the binary file content out of the request body. It's exactly that boundary and the form data header which makes your uploaded file to seem bigger (and actually also corrupted). If you're on servlet 3.0, you should have used request.getPart() instead to get the sole file content.
InputStream content = request.getPart("file1").getInputStream();
// ...

If you're still on servlet 2.5 or older, then you can use among others Apache Commons FileUpload to parse it.
See also:

*

*How to upload files to server using JSP/Servlet?


text:
Q: How to watch multiple properties in Vue component? I'm trying to update a Vue component property, station, when one of several other properties are updated. It wouldn't work as a computed property because computed properties are synchronous and this requires an API request.
Based on an issue reply in Vue core I found the docs on vm.$watch. This looks to be what I need, but I can't figure out how it should be implemented in the context of this component context.
I think I should be using this in place of vm in the docs, but I'm not sure about that. Then again, using this on the left side of the arrow function that's the first parameter of $watch throws errors like Invalid left-hand side in arrow function parameters.
My use of vm.$watch is toward the end of the following component code. The error I keep getting is: Failed watching path: "[object Object]" Watcher only accepts simple dot-delimited paths. For full control, use a function instead. (I thought I was...)
<template lang="html">
  <div>
    {{ station }}
  </div>
</template>

<script>
import ApiService from '@/services/ApiService';

export default {
  name: 'Chart',
  props: {
    mode: String,
    toDate: String,
    toTime: String
  },
  data() {
    return {
      stationId: 3069,
      station: {}
    };
  },
  watch: {
    station: function() {
      // Render function
    }
  },
  methods: {
    getInfo: async function(opts) {
      const stationData = await ApiService[this.mode]({
        id: opts.id,
        toTime: `${opts.toDate}T${opts.toTime}`,
        fromTime: `${opts.fromDate}T${opts.fromTime}`
      })
        .then(res => {
          return res.data.station.properties;
        })
        .catch(err => {
          console.error(err);
          return {};
        });

      return stationData;
    }
  },
  created: function() {
    // MY WATCHING STARTS HERE
    this.$watch(
      () => return {
        mode: this.mode,
        stationId: this.stationId,
        toDate: this.toDate,
        toTime: this.toTime
      },
      async function(data) {
        this.station = await this.getInfo({
          mode: data.mode,
          id: data.stationId,
          toDate: data.toDate,
          toTime: data.toTime
        }).then(res => {
          return res;
        });
      }
    );
  }
};
</script>

A: Your watcher is returning in arrow function. It should be like:
this.$watch(
  () => {
     return {
       mode: this.mode,
       stationId: this.stationId,
       toDate: this.toDate,
       toTime: this.toTime
     }
  },

This code is invalid use:
() => return {

Arrow function implicitly returns the value if no curly brace is used. So, you may also use like:
this.$watch(
  () => ({
     mode: this.mode,
     stationId: this.stationId,
     toDate: this.toDate,
     toTime: this.toTime
  }),

Notice, parentheses used for returning an object. You may also like to read this post further.

redpajama_set_name: RedPajamaStackExchange


text:
Q: excel dates in range older than 12 months I am sitting looking into a table with AJ as dates.
I need to see if there is any dates older than 12 months.
Tried
=IF(COUNTIFS('Extraction'!$E:$E;"ARVID";'Extraction'!$BU:$BU;"High";$AJ:$AJ<=TODAY()-365)>0;0;1)

but it fails.
Thinking it is due to that the date comparison has to be per cell, I fail to comply ;-)
Anyone?

A: Something like this:
=IF(COUNTIFS('Extraction'!$E:$E;"ARVID";'Extraction'!$BU:$BU;"High";$AJ:$AJ;"<="&SUM(TODAY();-365))>0;0;1)


text:
Q: web app deployed on jboss suddenly extremely slow I have a Web App deployed on JBoss App Server 7.0.2 on Windows XP
It had been running fine for the past 6 months then suddenly, it is painfully slow when launching in Internet Explorer 7
The Web App uses java, facelets, and hibernate.  Any suggestions how I can begin to locate the problem?  I don't know where I should start.

A: Start by looking at memory.
Download Visual VM 1.3.3, install all the plugins, and attach it to your JBOSS PID.  It'll show you all generations of the heap, CPU, threads, which objects consume the most memory, etc.
Information and insight are what you need.  Anything without data is merely a guess.
The other question that needs asking: what "suddenly" changed?  I'd start asking about changes on that server: software upgrades, other apps installed, patches, everything.
You should also be looking at dependencies.  What about the database server logs?


text:
Q: Npm import with Meteor, conflict between test and production I am building a Meteor app, and I am using the jStat library. I have some weird trouble with imports, using Meteor 1.3.
When I use the import { jStat } from jStat, my test are passing and jStat is correctly loaded. But it does not work in production, jStat object is undefined.
When I use the import 'jStat' syntax, that's the opposite... jStat is undefined in my test, but defined in my template.
Edit : I did install meteor-node-stubs, it did not change anything.
I also tried import * as jStat from jStat, but it only has the same effect than import jStat from jStat.
It seems to be an issue related to jStat itself, that has a weird loading behaviour (https://github.com/jstat/jstat#module-loaders).
Here are my files :
/imports/math/rates.js
import { jStat } from 'jStat';

/**
 * Confidence interval calculation on proportions
 * @return {[type]} [description]
 */
export const Rates = function(){
    var self = this;

    self.ualpha = function(alpha){
        var mean = 0;
        var std =1;
        return jStat.normal.inv(1-alpha/2,0,1);
    };
    return self;
}();

/imports/math/rates.tests.js (the test file for rates.js)
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Events } from '/collections/events.js';
import { Stubs } from '/imports/testing/stubs.js';
import { TestHelpers } from '/imports/testing/helpers.js';
import { assert } from 'chai';
import { Rates } from '/imports/math/rates.js';

describe('Rates Helpers', () => {
    beforeEach(()=>{
    });
    it("Should compute ualpha",()=>{
        var eps = 10e-7;
        assert.approximately(1.959964,Rates.ualpha(0.05),eps);
        assert.approximately(1.644854, Rates.ualpha(0.1),eps);
        assert.approximately(2.575829, Rates.ualpha(0.01),eps);
    });
});

/client/rates/ui/pages/experiment.js (the template)
import { Template } from 'meteor/templating';
import { Rates } from '/imports/math/rates.js';
import 'meteor/manuel:viewmodel';

Template.rates_experiment.viewmodel({
    alpha:0.01,
    rate: 0.5,
    precision: 0.01,
    interval:'constant',
    nIdeal : function(){
        var self = this;
        return Rates.nIdeal(self.rate, self.alpha, 'constant',self.precision);
    }
});

Did anybody have the same issue with imports ?


text:
Q: How to restrict HDFS folder access one at a time for a user? Its kind of weird use case.
For example,  user A has access to two different folders in HDFS, how to restrict the user A can access one folder at a time?
Accessing folder's can be via direct putty login or hive table or any other form of accessing those folders [Spark, BI tools etc...]


text:
Q: How to I write "å" on Ubuntu using an English (UK) keyboard? I can write æ and ø by pressing down Alt Gr + a and o, respectively.
However, trying all keys on my keyboard using Alt Gr, I've not yet found a way of writing the letter å.
I've been looking into character codes, but by pressing down Alt and entering the character code 0224 etc. nothing happens.
Can someone show me how to solve the problem (I am a danish user...)

A: Use "compose key", it is Shift + Alt Gr (Right Alt) and then in your case a will produce å. You might have to press a twice.

A: If you use the altgr-intl keyboard layout, AltGr+w produces å.


text:
Q: Edit JLabel Text in JButton OnclickListener I am fairly new to programming, and I have recently begun messing with the JFrame in java. I am creating a program where the user can scroll through a pokedex using two buttons. I have two JLabels, showing the pokedex number, and the pokedex name. I have hit a roadblock, not able to change the jlabel text, based on strings and ints, which are edited within the onclick listener. Please tell me what I am doing wrong.
package window;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

public class RunWindow extends Canvas implements Runnable{

    private static final long serialVersionUID = 1L;

    public static final int WIDTH = 800;
    public static final int HEIGHT = 600;
    public static final int SCALE = 1;
    public static final String NAME = "Pokedex";
    public int pokedexNum = 1;
    public String pokedexName = "Bulbasaur";
    private JFrame frame;
    private JPanel panel = new JPanel();
    private JButton b1;
    private JButton b2;
    private boolean update = true;

    JLabel label;
    JLabel label2;
    public boolean running = false;

    public RunWindow(){
        BufferedImage imgUP = null;
        do {
            switch(pokedexNum){
                case 1:
                    pokedexName = "Bulbasaur";
                    break;
                case 2:
                    pokedexName = "Ivysaur";
                    break;
                case 3:
                    pokedexName = "Venisaur";
                    break;

            }
            label = new JLabel("Pokemon #"+pokedexNum+"-"+pokedexName);
            label2 = new JLabel("#"+pokedexNum);
            update = false;
        }while (update);

        label = new JLabel("Pokemon #"+pokedexNum+"-"+pokedexName);
        label2 = new JLabel("#"+pokedexNum);

        label.setLocation(50, 50);
        frame = new JFrame(NAME);
        b1 = new JButton("Up");
        b2 = new JButton("Down");
        frame.setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
        frame.setPreferredSize(new Dimension(WIDTH*SCALE,HEIGHT*SCALE));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());
        frame.add(this,BorderLayout.CENTER);
        frame.setResizable(false);
        frame.add(label);
        frame.add(label2);
        frame.add(panel);
        frame.add(b1);
        frame.add(b2);
        frame.pack();
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);

        b1.setBounds(300, 400, 40, 20);
        b1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                System.out.println(pokedexNum);
                if(pokedexNum <= 3){
                pokedexNum++;
                switch(pokedexNum){
                case 1:
                pokedexName = "Bulbasaur";
                break;
                case 2:
                pokedexName = "Ivysaur";
                break;
                case 3:
                pokedexName = "Venisaur";
                break;

                }
                label = new JLabel("Pokemon #"+pokedexNum+"-"+pokedexName);
                label2 = new JLabel("#"+pokedexNum);
                update = false;
                System.out.println(pokedexName);
                label.setText("Pokemon #"+pokedexNum+"-"+pokedexName);
                label2.setText("#"+pokedexNum);
                label.setText(label.getText());

                }
                }

        } );
        b2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                pokedexNum--;
                System.out.println("Down");
                }
                } );
        b2.setBounds(300, 420, 40, 20);
        b1.setHorizontalTextPosition(JButton.CENTER);
        b1.setVerticalTextPosition(JButton.CENTER);
        label.setBounds(300, 50, 200, 24);
        label2.setBounds(340,400,80,20);
        frame.add( label, BorderLayout.NORTH );
        frame.add( panel , BorderLayout.CENTER);

    }
    public void run() {

    }
    public synchronized void start(){
        running = true;
        new Thread(this).start();

    }
    public void updatePokedex(){
        do {
            switch(pokedexNum){
                case 1:
                    pokedexName = "Bulbasaur";
                    break;
                case 2:
                    pokedexName = "Ivysaur";
                    break;
                case 3:
                    pokedexName = "Venisaur";
                    break;

            }
            label = new JLabel("Pokemon #"+pokedexNum+"-"+pokedexName);
            label2 = new JLabel("#"+pokedexNum);
            update = false;
        }while (update);
    }
    public synchronized void stop(){
        running = false;
    }
    public static void main(String[] args){
        new RunWindow().start();
    }

}

A: I did not look at your code in full detail, but from what I've seen, you seem to be creating JLabels a lot, and this can be the cause of the problem, because the labels you have initially created are the ones which you added to your Swing components, and which are being displayed inside the JFrame.
You should reuse these labels and simply use their setText methods, to change the text they are displaying.

A: You already have 2 Label variables and you only want to change the text, but you create new labels everytime:
label = new JLabel("Pokemon #"+pokedexNum+"-"+pokedexName);

instead you should just do:
label.setText("....");

As you do some lines later anyways. The problem is that you never add the newly created labels to the frame (you add them at the start, but when you override "label" and "label2" those are NEW labels and you'd need to also add them to your frame, resulting in 2 labels added everytime you click a button)
Just remove:
    label = new JLabel("Pokemon #"+pokedexNum+"-"+pokedexName);
    label2 = new JLabel("#"+pokedexNum);

I would also advise you to not use switch statements, you should rather use a string array and just call
setText(pokemonNames[pokedexNum]);

This way you don't need hundreds of codelines for different pokedex cases.
You can create a String[] easily like this way:
private static String[] pokeNames = new String[]{"","Bulbasaur","Ivysaur"};

I included an empty String at the start so that the index of the array is the same as the number in the pokedex (index starts at 1 so to say).


text:
Q: react-google-maps: trying to create a toggleable infowindow for each marker I know similar questions have been asked on SO before, but I've tried implementing the solutions in the answers and nothing seems to be working.
So, here's the problem I'm having: I'm using react-google-maps to generate a map. The map has multiple markers. Every time I click on a specific marker, I want an infowindow to pop up. The thing is, right now, everythime I click on a marker, the infowindows for all the markers pop up, as shown below:

Would you care to glance over my code and tell me what the problem is:
  render() {

const MapWithAMarker = compose(
  withStateHandlers(() => ({
    isOpen: false,
  }), {
    onToggleOpen: ({ isOpen }) => () => ({
      isOpen: !isOpen,
    })
  }),
  withScriptjs,
  withGoogleMap
)(props =>
  <GoogleMap
  defaultZoom={7}
  defaultCenter={{ lat: 37.468319, lng: -122.143936 }}
  containerElement={<div style={{ height: `300px`, width: `400px`, position: `absolute` }} />}
  mapElement={<div style={{ height: `300px` }} /> }
  containerElement={

 }
  loadingElement={<div style={{ height: `100%` }} />}
  googleMapURL={"https://maps.googleapis.com/maps/api/js?key=AIzaSyCk55BnGfoigxDUwDaiYiyn9tFThcJVsPA"}
  >

   {store.results.data.map( (result, index) => {
                                if(result.status.color=='success'){
                                return <Marker
                                key={ index }
                                position={{ lat: result.contract_location.lat, lng: result.contract_location.lng }}
                                icon={ '/img/darkgreen_MarkerA.png' }
                                onClick={() => props.onToggleOpen(index)}
                                >
                                   {props.isOpen && <InfoWindow onCloseClick={() => props.onToggleOpen(index)}>

hi

                                   </InfoWindow>}
                                </Marker>
                                }

                                if(result.status.color=='warning'){
                                  return <Marker
                                  key={ index }
                                  position={{ lat: result.contract_location.lat, lng: result.contract_location.lng }}
                                  icon={ '/img/yellow_MarkerA.png' }
                                  onClick={() => props.onToggleOpen(index)}
                                  >
                                    {props.isOpen && <InfoWindow onCloseClick={() => props.onToggleOpen(index)}>

hi

                                    </InfoWindow>}
                                  </Marker>
                                  }

                                if(result.status.color=='danger'){
                                  return <Marker
                                    key={ index }
                                    position={{ lat: result.contract_location.lat, lng: result.contract_location.lng }}
                                    icon={ '/img/red_MarkerA.png' }
                                    onClick={() => props.onToggleOpen(index)}
                                    >
                                       {props.isOpen && <InfoWindow onCloseClick={() => props.onToggleOpen(index)}>

hi

                                       </InfoWindow>}
                                    </Marker>
                                    }

                                 }
                                )}

  </GoogleMap>
);

A: You have mapped your InfoWindows out and conditionally render them with props.isOpen.
The onClick event for InfoWindow accepts an index argument.
However... in your onClick function, any click event will toggle isOpen to true (regardless of the index)
Since all InfoWindows depend only on the boolean isOpen, clicking one will set isOpen to true, and all of them open :)
A way around this is to store the index of the clicked marker. eg: clickedMarkerIndex = x.
Then, check {props.clickedMarkerIndex === index } and render the InfoWindow only if its' index matches the index of the clicked marker.


text:
Q: Windows Boot disc to save files? Somehow after updating my legit windows 7 OS with no pirated or mod software on my PC i was welcome to a black screen. I popped in my ghost disc and copied the files i need to an external HD. IIRC windows 7 disc can do that too. Problem with the way i did it on ghost was it excepted me to select 1 file (an HD disc image) so i couldnt select multiple folders to move. Also when i did move i had no idea if it finished or how long it would take.
My linux live cd couldnt access the HD. Anyways, is there a disc i can use to easily copy files from my laptop to my external HD? I think ghost, windows 7 and windows server all allow me but is there one that is better suited to copy files?

A: You can use WinPE and just do XCOPY or ROBOCOPY


text:
Q: rvm does not import gem path I'm running on Mac OS X Yosemite 10.10 Beta 3, I did a fresh install of rvm (removed everything I could think of and reinstalled the whole thing.
Attempting to run a scripts I had working on Mavericks.
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ gem install restclient
Successfully installed restclient-0.10.0
Parsing documentation for restclient-0.10.0
Done installing documentation for restclient after 0 seconds
1 gem installed
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ which irb
/Users/maximveksler/.rvm/rubies/ruby-2.1.2/bin/irb
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ irb
2.1.2 :001 > require 'restclient'
LoadError: cannot load such file -- restclient
    from /Users/maximveksler/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/maximveksler/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from (irb):1
    from /Users/maximveksler/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'

Path looks normal
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ env | grep GEM
GEM_HOME=/Users/maximveksler/.rvm/gems/ruby-2.1.2
GEM_PATH=/Users/maximveksler/.rvm/gems/ruby-2.1.2:/Users/maximveksler/.rvm/gems/ruby-2.1.2@global

Also the gem is installed
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ file /Users/maximveksler/.rvm/gems/ruby-2.1.2/gems/restclient-0.10.0/lib/rest_client.rb
/Users/maximveksler/.rvm/gems/ruby-2.1.2/gems/restclient-0.10.0/lib/rest_client.rb: ASCII C++ program text

So what am I missing ?

A: Looking at your link here, there is an error in your syntax. It should be require 'rest_client' rather than require 'restclient'. The reason that your version still works is as you said because there is a file called restclient.rb which is used as the source for the additional restclient binary that the gem supplies (which is against regular naming convention, you should file an issue with the github).
Now because you require this file (restclient.rb) which is used to set up an environment that already has RestClient available, it is effectively the same as requiring rest_client. It may however have unintended consequences so you should probably stick to the convention outlined in the documentation.
This is all from reading the documentation here and glancing at the files here. Does that make sense? I worried it was unclear as the two files are very similar.


text:
Q: R - Grepl vector over vector I have a vector of character strings (v1) like so:
> head(v1)
[1] "do_i_need_to_even_say_it_do_i_well_here_i_go_anyways_chris_cornell_in_chicago_tonight"
[2] "going_to_see_harry_sunday_happiness"
[3] "this_motha_fucka_stay_solid_foh_with_your_naieve_ass_mentality_your_synapsis_are_lacking_read_a_fucking_book_for_christ_sake"
[4] "why_twitter_will_soon_become_obsolete_http_www.imediaconnection.com_content_23465_asp"
[5] "like_i_said_my_back_still_fucking_hurts_and_im_going_to_complain_about_it_like_no_ones_business_http_tumblr.com_x6n25amd5"
[6] "my_picture_with_kris_karmada_is_gone_forever_its_not_in_my_comments_on_my_mysapce_or_on_my_http_tumblr.com_xzg1wy4jj"

And another vector of character strings (v2) like so:
> head(v2)
[1] "here_i_go" "going" "naieve_ass" "your_synapsis"   "my_picture_with"   "roll"

What is the quickest way that I can return a list of vectors where each list item represents each vector item in v1 and each vector item is a regular expression match where an item in v2 appeared in that v1 item, like so:
[[1]]
[1] "here_i_go"

[[2]]
[1] "going"

[[3]]
[1] "naieve_ass"      "your_synapsis"

[[4]]

[[5]]
[1] "going"

[[6]]
[1] "my_picture_with"

A: If you want speed, I'd use stringi. You don't seem to have any regex, just fixed patterns, so we can use a fixed stri_extract, and (since you don't mention what to do with multiple matches) I'll assume only extracting the first match is fine, giving us a little more speed with stri_extract_first_fixed.
It's probably not worth benchmarking on such a small example, but this should be quite fast.
library(stringi)
matches = lapply(v1, stri_extract_first_fixed, v2)
lapply(matches, function(x) x[!is.na(x)])
# [[1]]
# [1] "here_i_go"
#
# [[2]]
# [1] "going"
#
# [[3]]
# [1] "naieve_ass"    "your_synapsis"
#
# [[4]]
# character(0)
#
# [[5]]
# [1] "going"

Thanks for sharing data, but next time please share it copy/pasteably. dput is nice for that. Here's a copy/pasteable input:
v1 = c(
"do_i_need_to_even_say_it_do_i_well_here_i_go_anyways_chris_cornell_in_chicago_tonight"                                       ,
"going_to_see_harry_sunday_happiness"                                                                                ,
"this_motha_fucka_stay_solid_foh_with_your_naieve_ass_mentality_your_synapsis_are_lacking_read_a_fucking_book_for_christ_sake",
"why_twitter_will_soon_become_obsolete_http_www.imediaconnection.com_content_23465_asp"                                       ,
"like_i_said_my_back_still_fucking_hurts_and_im_going_to_complain_about_it_like_no_ones_business_http_tumblr.com_x6n25amd5"  ,
"my_picture_with_kris_karmada_is_gone_forever_its_not_in_my_comments_on_my_mysapce_or_on_my_http_tumblr.com_xzg1wy4jj")

v2 = c("here_i_go", "going", "naieve_ass", "your_synapsis",   "my_picture_with",   "roll" )

A: I'd like to leave another option with stri_extract_all_regex() in the stringi package. You can create your regular expression directly from v2 and use it in pattern.
library(stringi)

stri_extract_all_regex(str = v1, pattern = paste(v2, collapse = "|"))

[[1]]
[1] "here_i_go"

[[2]]
[1] "going"

[[3]]
[1] "naieve_ass"    "your_synapsis"

[[4]]
[1] NA

[[5]]
[1] "going"

[[6]]
[1] "my_picture_with"


text:
Q: Factor 2 in even integrand (distribution) on an even interval When I have an even function $f(x)=f(-x)$ we can write
$$ \int_{-\infty}^{\infty} f(x) = 2 \int^{\infty}_0 f(x)$$
Now if we allow $f(x)$ to be a distribution, specifically to contain delta functions, the above result no longer seems to hold.
It overcounts the contribution at 0. This normally doesn't matter for a function since it has measure zero but if $f(x)$ contains Dirac Delta function at $x=0$ the result is now different. So when I use this trick I guess I have to be careful with end points where $f(x)$ is not a function.

Should I split the integral into $\int_{-\infty}^{-\epsilon}f(x) + \int_{-\epsilon}^{\epsilon}f(x) + \int_{\epsilon}^\infty f(x)$. Then the first and last term will be equal by evenness of $f(x)$.
Does this subtlety only arise when integrating over a distribution that is not a function at the point of symmetry (and thus at the end-point when we try to split the integral)?


text:
Q: GQL query for webapp2 Unique logins I want to use GQL to find specific entries in Google App Engine Datastore.
The entities that I want locate are webapp2 unique user records. I have tried structuring the query with keys, strings, etc, without success.

EDIT:
the entities' model is webapp2_extras.appengine.auth.models.Unique
Unique entities are inserted using attributes of the webapp2_extras.appengine.auth.models.User class. It has an auth_id property that stores login information ("own" for custom logins, "google" or "yahoo" etc for google or yahoo usernames), properties that must be unique for each User and custom properties.
So, if a User's email and social security number must be unique, the corresponding entries for auth_id, email and social security number will be created in Unique (provided that the insertion doesn't result in duplicate entities). That will result in entities:
name=User.auth_id:own:someusername@example.com
name=User.social_security_number:1234567890
name=User.email:someusername@example.com

Some of my attempts include:
SELECT * FROM Unique where __key__ = KEY('name',User.auth_id:own:someusername@example.com)

or
SELECT * FROM Unique where name = 'User.auth_id:own:someusername@example.com'

or
SELECT * FROM Unique where 'name=User.auth_id:own:' = 'someusername@example.com'

These queries are either syntactically invalid or have invalid parameters. I have obviously reviewed Google's official documentation but cannot find a way to write this one.

EDIT:
There is a way to retrieve all the unique records in python using a method of Unique. What I'm looking for is a GQL query.


text:
Q: Draft version visibility I have a customer which wants their draft documents to be visible only to their authors. Moreover, the published version should be visible to everyone. However, they do not want to go through the content approval workflow. Any ideas on how this can be done?
John Doe can see his own document.doc (v0.1, v0.2 ++)
Then he clicks publish, and the document is published without content approval.
Everone can see document.doc (v1.0, v2.0 ++)

A: Since the Published and Draft documents have the format:

*

*{MajorVersionNumber}.0  for Published

*{MajorVersionNumber}.{MinorVersionNumber} for Drafts

for your scenario the View could be created with the following filters:

*

*By Published documents that corresponds to [Version] CONTAINS .0

*By Author [Created By] = [Me]

A: This should be possible from the List settings -> Versioning Settings. Under the Draft Item Security you should be able to set this to 'Only users who can edit items' for the questoin 'Who should see draft items in this document library?'.

A: That final option only becomes available if you turn on approval.  However, you do not have to use a workflow process to achieve approval.  If there is no workflow then I would recommend your approvers adding an alert to advise when something needs approving as otherwise they will get no notification.

A: It seems like this issue can be solved by adding an eventReceiver to the document library, which automates the content approval. If the status of the document is "pending" it's set to "approved". In this way, we can get the hidden draft functionality as well as the visibility of the published versions without having a separate approvers group for this job. Haven't gotten the time to test various scenarios on this solution, so if anyone can see a major flaw in this, please let me know :)

A: You can set Draft Visibility of document library when you create it programmatically. Here is the code :
#region Create Document Library

SPListTemplate listTemplate = web.ListTemplates["Document Library"];

SPDocTemplate docTemplate = (from SPDocTemplate dt in web.DocTemplates where dt.Type == 100 select dt).FirstOrDefault();

Guid guid = web.Lists.Add("Document Library Name", "Description", listTemplate, docTemplate);

SPDocumentLibrary library = web.Lists[guid] as SPDocumentLibrary;

library.DraftVersionVisibility = DraftVisibilityType.Author;     // <<<<< DRAFT VISIBILITY

 #endregion


text:
Q: Moving view controller based on pan gesture in scrollview Right now I have a scrollView that takes up the entire view controller. The code below is able to move the scrollView around but I want to move the whole view controller around. How would I do that?
override func viewDidLoad() {
        pan = UIPanGestureRecognizer(target: self, action: "handlePan:")
        self.scrollview.addGestureRecognizer(pan)
}

func handlePan(recognizer:UIPanGestureRecognizer!) {

    switch recognizer.state {
    case .Changed:
        handlePanChanged(recognizer); break
    case .Ended:
        handlePanTerminated(recognizer); break
    case .Cancelled:
        handlePanTerminated(recognizer); break
    case .Failed:
        handlePanTerminated(recognizer); break
    default: break
    }
}

func handlePanChanged(recognizer:UIPanGestureRecognizer!) {
    if let view = recognizer.view {
        var translation = recognizer.translationInView(self.view)
        println("moving")
        view.center = CGPointMake(view.center.x, view.center.y + translation.y);
        recognizer.setTranslation(CGPointZero, inView: self.view)
    }
}

I've tried different variations of "self.view.center ...." "UIApplication.sharedApplication.rootViewController.view.center.." etc.

A: I infer from your other question that you want to a gesture to dismiss this view controller. Rather than manipulating the view yourself in the gesture, I'd suggest you use custom transition with a UIPercentDrivenInteractiveTransition interaction controller, and have the gesture just manipulate the interaction controller. This achieves the same UX, but in a manner consistent with Apple's custom transitions paradigm.
The interesting question here is how do you want to delineate between the custom dismiss transition gesture and the scroll view gesture. What you want is some gesture that is constrained in some fashion. There are tons of options here:

*

*If the scroll view is left-right only, have a custom pan gesture subclass that fails if you use it horizontally;

*If the scroll view is up-down, too, then have a top "screen edge gesture recognizer" or add some visual element that is a "grab bar" to which you tie a pan gesture
But however you design this gesture to work, have the scroll view's gestures require that your own gesture fails before they trigger.
For example, if you wanted a screen edge gesture recognizer, that would look like:
class SecondViewController: UIViewController, UIViewControllerTransitioningDelegate {

    @IBOutlet weak var scrollView: UIScrollView!

    var interactionController: UIPercentDrivenInteractiveTransition?

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        modalPresentationStyle = .Custom
        transitioningDelegate = self
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // ...

        let edge = UIScreenEdgePanGestureRecognizer(target: self, action: "handleScreenEdgeGesture:")
        edge.edges = UIRectEdge.Top
        view.addGestureRecognizer(edge)
        for gesture in scrollView.gestureRecognizers! {
            gesture.requireGestureRecognizerToFail(edge)
        }
    }

    // because we're using top edge gesture, hide status bar

    override func prefersStatusBarHidden() -> Bool {
        return true
    }

    func handleScreenEdgeGesture(gesture: UIScreenEdgePanGestureRecognizer) {
        switch gesture.state {
        case .Began:
            interactionController = UIPercentDrivenInteractiveTransition()
            dismissViewControllerAnimated(true, completion: nil)
        case .Changed:
            let percent = gesture.translationInView(gesture.view).y / gesture.view!.frame.size.height
            interactionController?.updateInteractiveTransition(percent)
        case .Cancelled:
            fallthrough
        case .Ended:
            if gesture.velocityInView(gesture.view).y < 0 || gesture.state == .Cancelled || (gesture.velocityInView(gesture.view).y == 0 && gesture.translationInView(gesture.view).y < view.frame.size.height / 2.0) {
                interactionController?.cancelInteractiveTransition()
            } else {
                interactionController?.finishInteractiveTransition()
            }
            interactionController = nil
        default: ()
        }
    }

    @IBAction func didTapDismissButton(sender: UIButton) {
        dismissViewControllerAnimated(true, completion: nil)
    }

    // MARK: UIViewControllerTransitioningDelegate

    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return DismissAnimation()
    }

    func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        return interactionController
    }

}

class DismissAnimation: NSObject, UIViewControllerAnimatedTransitioning {

    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.25
    }

    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        let from = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
        let container = transitionContext.containerView()!

        let height = container.bounds.size.height

        UIView.animateWithDuration(transitionDuration(transitionContext), animations:
            {
                from.view.transform = CGAffineTransformMakeTranslation(0, height)
            }, completion: { finished in
                transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
            }
        )
    }

}

Personally, I find the notion of having top and bottom screen edge gestures to be a bad UX, so I'd personally change this modal presentation to slide in from the right, and then swiping from left edge to the right feels logical, and doesn't interfere with the built in top pull down (for iOS notifications). Or if the scroll view only scrolls horizontally, then you can just have your own vertical pan gesture that fails if it's not a vertical pan.
Or, if the scroll view only scrolls left and right, you can add your own pan gesture that is only recognized when you pull down by (a) using UIGestureRecognizerDelegate to recognize downward pans only; and (b) again setting the scroll view gestures to only recognize gestures if our pull-down gesture fails:
override func viewDidLoad() {
    super.viewDidLoad()

    // ...

    let pan = UIPanGestureRecognizer(target: self, action: "handlePan:")
    pan.delegate = self
    view.addGestureRecognizer(pan)

    for gesture in scrollView.gestureRecognizers! {
        gesture.requireGestureRecognizerToFail(pan)
    }
}

func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
    if let gesture = gestureRecognizer as? UIPanGestureRecognizer {
        let translation = gesture.translationInView(gesture.view)
        let angle = atan2(translation.x, translation.y)
        return abs(angle) < CGFloat(M_PI_4 / 2.0)
    }
    return true
}

func handlePan(gesture: UIPanGestureRecognizer) {
    // the same as the `handleScreenEdgeGesture` above
}

Like I said, tons of options here. But you haven't shared enough of your design for us to advise you further on that.
But the above illustrates the basic idea, that you shouldn't be moving the view around yourself, but rather use custom transition with your own animators and your own interactive controller.
For more information, see WWDC 2013 Custom Transitions Using View Controllers (and also WWDC 2014 A Look Inside Presentation Controllers, if you want a little more information on the evolution of custom transitions).


text:
Q: is it possible to overlay two graphs (line and bar) in kibana I am creating few graphs in Kibana to show statistics about the process. I have graph which takes how much time process took each time we ran the program. I show that using bar charts, however it would be nice to have a line graph on top of this bar graph to show average and standard deviation, which would help more to understand if duration it took is good or not.
if it's not possible in kibana, is there any third party utility for showing graphs, I mean something which fetches the data from Kibana and I can configured graph and create dashboard. I know this could be achievable using my own web application (sping or django) but that would be too much an effort. I need something like plug and play solution.


text:
Q: Bash script to pythonscript Convertion BASH CODE:
source /proj/common/tools/repo/etc/profile.d/repo.sh
repo project init $branch
repo project sync
source poky/fnc-init-build-env build
bitbake -g $image

I converted this bash code into python(version 2.7). While executing my python code, I am getting repo command not found  message.
PYTHON CODE:
os.system("source /proj/common/tools/repo/etc/profile.d/repo.sh")
os.system("repo project init " + branch)
os.system("repo project sync")
os.system("source poky/fnc-init-build-env build")
os.chdir("poky/build")
os.system("bitbake -g " + image)

ERROR MESSAGE:
sh: repo: command not found
sh: repo: command not found

I tried with subprocess.call(), I am getting the same error message.

A: The problem is in this call:
os.system("source /proj/common/tools/repo/etc/profile.d/repo.sh")

The problem is that it runs source in a separate subshell and when the subshell exits all changes to the environment (cd commands if there are any and environment variables, most notable PATH) are gone.
My advice is to continue using the shell script you've used — just call it from Python with one os.system() call. Inside the shell script you can use source.

A: You could at least use the full path for the repo command.
That would avoid the subshell to have to know where the repo command is (meaning have the right PATH set on each os.system call).


text:
Q: Python and pywinauto while automate with software I am facing problem.
Currently, I have install window on my MacBook Air 64bit. By right, it supposed to be 64bit window but it turned out to be 32bit window instead. As the System directory showed c:/windows/system32.
With that, I install python 32bit, pywin32 and pywinauto. However, I want to automate a software that is 64bit and it currently working on my window 32bit.
My question: is it okay for me to use python 32bit and pywin32 and pywinauto to automate a 64bit software?
or should I change my python to 64bit,pywin32-amd64 and pywinauto to automate a 64bit software when my window is at 32bit but my processor is 64bit.
I have try to change window to 64bit but it just couldn't work as I reformate the whole laptop and reinstall macOS and reinstall window to 64bit. it just change out to be 32 bit.


text:
Q: Imputing Missing Value I am looking to filter the talentpool_subset dataframe to capture only the city and state from the location column (it currently contains strings like this, "Software Developer in London, United Kingdom"). I've tried replacing NaN values with 0, and confirmed that I've done this by subsetting the dataframe to return only NaN values, which returned an empty data frame as expected. But every time I run the final statement, I get this error: "ValueError: cannot mask with array containing NA / NaN values"
Why is this happening?
talentpool_subset = talentpool_df[['name', 'profile', 'location','skills']]
talentpool_subset

talentpool_subset['location'].fillna(0, inplace=True)
location = talentpool_subset['location'].isna()
talentpool_subset[location]

talentpool_subset[talentpool_subset['location'].str.contains(r'(?<=in).*')]

    name    profile     url     source  github  location    skills  tags_strong     tags_expert     is_available    description
0   Hugo L. Samayoa     DevOps Developer    https://www.toptal.com/resume/hugo-l-samayoa    toptal  NaN     DevOps Developer in Long Beach, CA, United States   {"Paradigms":["Agile Software Development","Sc...   NaN     ["Linux System Administration","VMware ESXi","...   available   "DevOps before DevOps" is a term mostly associ...
1   Stepan Yakovenko    Software Developer  https://www.toptal.com/resume/stepan-yakovenko  toptal  stiv-yakovenko  Software Developer in Novosibirsk, Novosibirsk...   {"Platforms":["Debian Linux","Windows","Linux"...   ["Linux","C++","AngularJS"]     ["Java","HTML5","CSS","JavaScript","MySQL","Hi...   available   Stepan is an experienced software developer wi...
2   Slobodan Gajic  Software Developer  https://www.toptal.com/resume/slobodan-gajic    toptal  bobangajicsm    Software Developer in Sremska Mitrovica, Vojvo...   {"Platforms":["Firebase","XAMPP"],"Storage":["...   ["Firebase","Karma"]    ["jQuery","HTML5","CSS3","Git","JavaScript","S...   available   Slobodan is a front-end developer with a Bache...
4   Jennifer Aquino     Query Optimization Developer    https://www.toptal.com/resume/jennifer-aquino   toptal  BlueCamelArt    Query Optimization Developer in West Ryde, New...   {"Paradigms":["Automation","ETL Implementation...   ["Data Warehouse","Unix","Oracle 10g","Automat...   ["SQL","SQL Server Integration Services (SSIS)...   available   Jennifer has five years of professional experi...

A: Assuming here that the objective is to get location and it is not required to use a mask for location. Code below uses .extract() to keep only city, state in the location column.
For example: Long Beach, CA, United States from DevOps Developer in Long Beach, CA, United States.
# Import libraries
import pandas as pd
import numpy as np

# Create list using text from question
name = ['Hugo L. Samayoa','Stepan Yakovenko','Slobodan Gajic','Bruno Furtado Montes Oliveira','Jennifer Aquino']
profile = ['DevOps Developer','Software Developer','Software Developer','Visual Studio Team Services (VSTS) Developer','Query Optimization Developer']
url = ['https://www.toptal.com/resume/hugo-l-samayoa','https://www.toptal.com/resume/stepan-yakovenko','https://www.toptal.com/resume/slobodan-gajic','https://www.toptal.com/resume/bruno-furtado-mo...','https://www.toptal.com/resume/jennifer-aquino']
source = ['toptal','toptal','toptal','toptal','toptal']
github = [np.nan, 'stiv-yakovenko','bobangajicsm','brunofurmon','BlueCamelArt']
location = ['DevOps Developer in Long Beach, CA, United States', 'Software Developer in Novosibirsk, Novosibirsk','Software Developer in Sremska Mitrovica, Vojvo','Visual Studio Team Services (VSTS) Developer in New York','Query Optimization Developer in West Ryde, New York']
skills = ['{"Paradigms":["Agile Software Development","Sc...', '{"Platforms":["Debian Linux","Windows","Linux"...','{"Platforms":["Firebase","XAMPP"],"Storage":["...','{"Paradigms":["Agile","CQRS","Azure DevOps"],"...','{"Paradigms":["Automation","ETL Implementation...']

# Create DataFrame using list above
talentpool_df = pd.DataFrame({
    'name':name,
    'profile':profile,
    'url':url,
    'source':source,
    'github':github,
    'location':location,
    'skills':skills
})

# Add NaN row to DataFrame
talentpool_df.loc[6,:] = np.nan

# Subset DataFrame to get columns of interest
talentpool_subset = talentpool_df[['name', 'profile', 'location','skills']]

# Use .extract() to keep only text after 'in' in the 'location' column
talentpool_subset['location'] = talentpool_subset['location'].str.extract(r'((?<=in).*)')

Output
talentpool_subset


text:
Q: Help understanding this proof of contradiction (integer sequence) I'm following a proof for this problem:

Define a 3-chain to be a (not necessarily contiguous) subsequence of three integers, which is either monotonically increasing or monotonically decreasing. We will show here that any sequence of five distinct integers will contain a 3-chain. Write the sequence as $a_1, a_2, a_3, a_4, a_5$. Note that a monotonically increasing sequences is one in which each term is greater than or equal to the previous term. Similarly, a monotonically decreasing sequence is one in which each term is less than or equal to the previous term. Lastly, a subsequence is a sequence derived from the original sequence by deleting some elements without changing the location of the remaining elements.
(a) [4 pts] Assume that $a_1 < a_2$. Show that if there is no 3-chain in our sequence, then $a_3$ must be less than $a_1$. (Hint: consider a4!)

The answer I linked to reads:

Now we assume $a_1 < a_2$.
So, the 5 numbers would be $ a_1 < a_2 ; a_3 ; a_4 ; a_5$.
Proof by contradiction -
For propositon, lets assume, there is no 3-chain, but $a_3 > a_1$. There arise possibilities, which are:
$1 )\quad a_1 < a_2 < a_3$
$2) \quad  a_1 < a_3 < a_2$
The first case cannot be taken(It forms the 3 chain)

Ok that makes sense, the first case forms the chain $a_1 < a_2 < a_3$. The second case is not a chain? Maybe my English is not good enough, but why is this not a chain as defined in the problem?
The proof further goes on:

In the second case, when we introduce $a_4$, there are 4 possibilities,as -
$ 1)\quad  a_4 < a_1 < a_3 < a_2$
$2)\quad a_1 < a_4 < a_3 < a_2 $
$3)\quad a_1 < a_3 < a_4 < a_2 $
$4)\quad  a_1 < a_3 < a_2 < a_4$

So, these are now chains, but $a_1 < a_3 < a_2$ is not? Can someone help me understand the reasoning here?

A: The second case, $a_1<a_3<a_2$ is not a chain because a chain is a subsequence, which means the order must remain the same. So $(a_1,a_2,a_3)$ is a subsequence, but it is not a chain because it is not increasing and it is not decreasing (it goes up from $a_1$ to $a_2$, but then down from $a_2$ to $a_3$). For example, it could be that $a_1=1, a_2=5$ and $a_3=2$.
Then, $(1,5,2)$ is clearly not a chain, but $a_1<a_3<a_2$ (i.e., $1<2<5$) is clearly true

In the last part of the proof:

*

*If $a_4<a_1<a_3<a_2$, then $(a_2,a_3,a_4)$ is a decreasing chain.

*If $a_1<a_4<a_3<a_2$, then again, $(a_2,a_3,a_4)$ is a decreasing chain.

*If $a_1<a_3<a_4<a_2$, then $(a_1, a_3, a_4)$ is an increasing chain

*If $a_1<a_3<a_2<a_4$, then $(a_1, a_3, a_4)$ is an increasing chain

A: A $3-$ chain is an ordered triple. This means that the order, given by the indices, cannot be changed, and, if $a_1<a_3<a_2$ the triple $(a_1,a_2,a_3)$ is not a chain.


text:
Q: How to call a webmethod from jQuery ajax? I am using visual studio 2015 and my project is ASP.NET Web Application. using Web Form template.
I can't call a webmethod from the jQuery ajax
Here is my webform aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="EquipmentSubmitter.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function ShowCurrentTime() {
            $.ajax({
                type: "POST",
                url: "WebForm2.aspx/GetCurrentTime",
                data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function (response) {
                    alert(response.d);
                }
            });
        }
        function OnSuccess(response) {
            alert(response.d);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            Your Name :
            <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
            <input id="btnGetTime" type="button" value="Show Current Time"
                onclick="ShowCurrentTime()" />
        </div>
    </form>
</body>
</html>

And here is my webform aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EquipmentSubmitter
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [System.Web.Services.WebMethod]
        public static string GetCurrentTime(string name)
        {
            return "Hello " + name + Environment.NewLine + "The Current Time is: "
                + DateTime.Now.ToString();
        }
    }
}

The breakpoint inside the webmethod is never reached.
Is there anything should be changed in the BundleConfig.cs or anywhere else?

A: Your web method is a GET and you're sending data - data is for POST methods. Change your URL to:
url: "WebForm2.aspx/GetCurrentTime?name=" + $("#<%=txtUserName.ClientID%>")[0].value

A: I found the answer to the question.
in the file RouteConfig.cs I changed this line
settings.AutoRedirectMode = RedirectMode.Permenant;

To this
settings.AutoRedirectMode = RedirectMode.Off;


text:
Q: redefine uint type c++ In c++ when I try to compile the following code I get a conflicting declaration error:
#include <iostream>
using namespace std;

typedef uint_least64_t uint;

int main() {
    uint i = -1;
    cout << i << endl;
}

error:
main.cpp:5:24: error: conflicting declaration 'typedef uint_least64_t uint'
 typedef uint_least64_t uint;
                        ^~~~
In file included from /usr/include/stdlib.h:275:0,
                 from /usr/include/c++/6/cstdlib:75,
                 from /usr/include/c++/6/ext/string_conversions.h:41,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/sys/types.h:152:22: note: previous declaration as 'typedef unsigned int uint'
 typedef unsigned int uint;
                      ^~~~

I assume that conflicting declaration error is because a type declaration for uint already exists somewhere in the language, and I believe that the type is uint_least32_t because:
#include <iostream>
using namespace std;

int main() {
    uint i = -1;
    cout << i << endl;
}

returns an integer value that is (2^32)-1. Therefore is it possible in c++ to redefine uint as uint_least64_t.

A: As you can see from the error message, on your platform <iostream> pulls in <string>, which pulls in <cstdlib>, which pulls in <stdlib.h>, which pulls in <sys/types.h>.
Looking at the source code, we can see that <sys/types.h> does this:
#ifdef __USE_MISC
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
#endif

The #ifdef __USE_MISC guard is part of the feature_test_macros system. __USE_MISC is set internally if you request _DEFAULT_SOURCE (which is also set if you request nothing else).
Thus you should be able to bypass the problem by compiling with -ansi or one of the -std=... options (e.g. -std=c++11).

A: uint is not part of standard C++.
It's quite possible that something in your codebase is introducing it, or perhaps even the C++ standard library that ships with your compiler. You might be lucky and the library has introduced std::uint and you're introducing that into the global namespace when you write that polluting statement using namespace std;.
Sadly, you can't un-typedef a type or hide a class once it's been introduced.
So you'll just have to use a different symbol.

A: You can not redefine the typedef symbol and will have to use different(unused) symbol.
If you want to use the same symbol you can wrap it in namespace as mentioned in this post: Using a typedef'd uint causes error, while "unsigned int" does not...?


text:
Q: Delaying the display message in jQuery I have a button, which shows a message through jQuery on click. Now, the message disappears immediately, and the button comes back again. I want to show the message for some time before displaying the button again. I am new to jQuery, and I tried with some options like delay() and setTimeout(), but have been unable to get the exact script to make it happen.
Here is my existing code:
$('#id1').click(function() {
  $('#id2').html('
A code has been sent to your email
');
});

The .ftl is as below:
    <#if !(obj)?has_content>

      Send Token

   </#if>

Can you please advise me on the code I need to make this happen?

A: $('#div1').click(function() {
    setTimeout(function() {
        $('#div2').html('
A code has been sent to your email
');
    }, 1000);
});

A: Have you tried putting it inside a setTimeout() function? Referring to w3schools,

$('#div1').click(function() {
  setTimeout(function() {
   $('#div2').html('
A code has been sent to your email
');
  }, 3000 // 3000 is equivalent to 3 seconds. It's in MS.
 );
});

A: This will hide the div2 after 3 seconds
cm hx box
$('#div1').click(function() {
    $('#div2').html('
A code has been sent to your email
');

i
        setTimeout(function() {
            $('#div2').html();
zv
        }, 3000);
    });

A: check if it is work for you.

$(function() {
$('#div1').click(function() {
$('#div2').show();
$("#div1").hide();
setTimeout(
function() { $("#div2").fadeOut(1500); $("#div1").show(); }, 5000)
})
})
.content
{
border: 2px solid Red;
color: #008000;
padding: 10px;
width: 400px;
font-family:Calibri;
font-size:16pt
}

<input type="button" id="div1" value="Show DIV" />

Hi, Welcome  Raj
It will disappear in 4 seconds!

A: I'm assuming that you want to hide the button after clicking and show it after the message is gone.
$('#id1').click(function(event) {
    var $btn = $(this);
    var $msg = $('#id2');

    $msg
        .html('
A code has been sent to your email
')
        .show(); // or you could use .fadeIn()

    // Remove this line if you don't want to hide the button.
    $btn.hide();

    setTimeout(function() {
       $msg.hide().html(''); // or you could use .fadeOut()

       // Remove this line if you did't hide the button above.
       $btn.show();
    }, 3000);

    event.preventDefault();
    return false;
});

If you want an effect when showing and hiding, you can just replace .show() and .hide() with .fadeIn() and .fadeOut().
setTimeout(function() {
   // Send a callback function, which will be called after the 'fadeOut' animation.
   $msg.fadeOut(400, function() {
       $msg.html('');

       // Remove this line if you did't hide the button above.
       $btn.show();
   }).html('');
}, 3000);

Update
If your html is like this...

  Send Token

then you will not be able to hide #id1, because it will hide #id2 also.
Try something like this...
Send Token

Update 2
If your page breaks when trying to implement the above Update, then try this...

  Send Token

Update 3 (Prevent Page refresh on click)
See above in the click event I have updated in the last few lines...
$('#id1').click(function(event) {
    ... above code bla bla..

    event.preventDefault();
    return false;
});

Try this to prevent page refresh. But then you'll have to call your email service manually using ajax inside the click event.
var emailText = "someones@email.com";

$.ajax({
    url: ("/link?email=" + emailText),
    type: "GET",
    success: function(data) {
        console.log("Email request sent.");
    },
    error: function() {
        console.log("Some error occurred");
    }
});

A: You can redirect your link in Javascript using window.location.href and invoke it after 3 sec. Check out this jsfiddle. Let me know if you got expected behavior.


text:
Q: sudo to other user doesn't preserve DISPLAY variable I've got an /etc/sudoers file that works just fine in all versions of Fedora prior to F18, but we've noticed that when upgrading to F18 (and installing FreeIPA, though the cases I'll show here were run with sudo processing done using this file to minimize variables), sudo is not preserving the DISPLAY variable as requested by sudo:
# sudo -V
:
Environment variables to preserve:
        PYTHONPATH
        :
        HOSTNAME
        DISPLAY
        COLORS
:
# exit
[user2]$ echo $DISPLAY
:1
[user2]$ sudo su - user1
[user1]$ echo $DISPLAY
DISPLAY: Undefined variable.
[user1]$

Usually, we use ssh -Y to pipe displays back and forth, but this is preventing us from doing so. I've been troubleshooting this for several days without success. Has anyone else experienced this, or have any ideas?
Update: Further testing revealed this may not be a sudo problem, but may be related to su itself:
[user2]$ sudo -u user1 echo $DISPLAY
:1
[user2]$

Does this change things? Why would "su" start stripping away (parts of) the environment?

A: While sudo preserves the variables, your use of su wipes them again. Don't use su, it's entirely unnecessary. If you want a shell, use sudo -i


text:
Q: order of operations for environment variables I want to understand how environment variables are set and reset (overridden). I'm running Apache/2.2.24 (Unix) PHP/5.4.14 on a mac . My theory is this:
Environment vars can be set in bash, then they can be overwritten with httpd.conf preceding a VirtualHost directive that precedes php.ini, which can then be overwritten by .htaccess (if allowable) and finally by PHP
I tried the following:

*

*setting environment variable in bash: I added export ENVIRONMENT='local' to my ~/.bashrc file, restarted apache and did not get any output from print_r($_ENV); (in a simple index.php file at the root of my webserver). I also tried putting ENVIRONMENT='local' into /etc/environment, and restarting apache, nothing, as well as /etc/bashrc, restart apache. still nothing.

*setting environment variable in httpd.conf: I added SetEnv ENVIRONMENT 'local-httpd to the end of my /etc/apache2/httpd.conf file (but before I load other conf files, such as virtual host [Include /private/etc/apache2/other/*.conf]). I now see the variable in the array print_r($_SERVER); but not print_r($_ENV);.

*setting environment variable in httpd-vhosts.conf: I added SetEnv ENVIRONMENT 'local-vhost to my /etc/apache2/extra/httpd-vhosts.conf file in my generic directive that points to my default document root. I now see the variable has been overwritten (to local-vhost from local-httpd, so I know where the variable is getting set).

*setting environment variable in php.ini: while searching for a proper place to put my environment variable, I noticed that variables_order = "GPCS" was set to the production value rather than EGPCS. I changed it, restarted my server and found that I was now getting output for print_r($_ENV); but not my expected custom variable. It also appears that I am not able to set a custom variable in this file. Please tell me if I am wrong

*setting environment variable in .htaccess: I added SetEnv ENVIRONMENT 'local-htaccess'. This worked as expected, overwriting all other values that were set.

*setting / overwriting environment variable in PHP:

    if (...) {
     putenv('ENVIRONMENT=local');
    }

I'm asking this question because I have a lot of local and remote testing servers, some of which may or may not allow me access to modify httpd, httpd-vhost, php.ini or environment variables. I want to understand what is best for those difference scenarios (shared hosting, heroku, local servers, etc)
I obviously don't know how to properly set the environment variable in bash in a way that php can use it, I'd like to know how to do that (as I think Heroku does something similar with heroku config set...)

A: normally Apache uses the user www-data, which means, that you don't have to modify ~/.bashrc but /var/www/.bashrc.
Because:

$ ~www-data
-bash: /var/www: Is a directory


text:
Q: Redis for PHP Sessions - why so many sessions on web server but only one locally? I've installed Redis to handle PHP sessions (and caching purposes). When I load the homepage of my website, the following happens.
On localhost
One session ID is generated.
$ redis-cli
127.0.0.1:6379> keys *
1) "PHPREDIS_SESSION:3g8sdqkj51btah10v88vapkr57"

On web server
10+ session IDs are generated.
$ redis-cli
127.0.0.1:6379> keys *
1) "PHPREDIS_SESSION:sgp4gop68st6iqmgnrti76tqn4"
2) "PHPREDIS_SESSION:2sstonql09hreokd14gba5csr2"
3) "PHPREDIS_SESSION:kv7cjhpgq8o2dkuglcg3rqj955"
4) "PHPREDIS_SESSION:2m07rtut3qt0k0ujuvftp0g3g3"

(... and about 10 more session keys)
The other thing is that for every refresh of the homepage, the redis server on the web host seems to instantiate around 2-10 new PHP sessions, while on localhost it just stays at one session all the time.
There's probably a good reason for this, and I'm hoping that anyone could explain this to me.
Could it have anything to do with the web page on the web server actually loading many external resources, which get their own session? Or could it be that I have configured something incorrectly? Both pages are identical in PHP code.
I'm not sure what more information I can provide for helping answer this question better, but please ask for anything.

A: This is not a redis problem. The most probable reason is difference in session management settings in your local vs webserver php, do check the ini configuration primarily for session settings.
Your webservers is creating new sessions on all requests, while localhost is respecting the existing session.


text:
Q: value for serialVersionUID does it matter? I am using the serialized classes in java and in those classes I need to specify the serialVersionUID with some long number to be initialized.
As a default it takes as
    private static final long serialVersionUID = 1L;

Or else I can initialize the same with some other long number too, like as bellow:
    private static final long serialVersionUID = 5561040348988016571L;

some very big number.
My question is: Does it really matter which value we initialize to serialVersionUID or not?

A:
My question is does this really matters which value we initialize to serialVersionUID or it doesn't matter.

No, it doesn't matter, unless you already have existing serializations (e.g. files) that were made before you added this member. In that case you must use the value output by the serialver utility when run on the .class file as it was when those serializations were made.

A: If your object state is not going to serialized, then it doesn't matter else you will have to generate serialVersionUID everytime class structure changes (u can use eclipse default UID generation policy).


text:
Q: BIND returns serverfail when querying for its authoriative domain Hi there Serverfault folks!
First of all: sorry about the title, I had some problem coming up with the proper title.
I have a little home server set up, for internet sharing, samba, basic http, dlna mediaserver and what not, and I happend to have a domain at hand, so I thought why not direct it to this computer?
I have a BIND 9.8.0 installed, and - afaik - configured it properly.
For a few days, the public view did not worked, and I really did not cared, since the local view worked.
But now suddenly, even the local view fails.
If I try to query the nameserver for anything in my domain, it returns the following error:
$ nslookup andromeda.dafaces.com
;; Got SERVFAIL reply from ::1, trying next server
;; Got SERVFAIL reply from ::1, trying next server
Server:         127.0.0.1
Address:        127.0.0.1#53

** server can't find andromeda.dafaces.com.dafaces.com: SERVFAIL

Also, the public view points to the old ip address of the domain, probably because of the same error.
Some information about the system:
$ uname -a
Linux tressis 2.6.37-ARCH #1 SMP PREEMPT Tue Mar 15 09:21:17 CET 2011 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5000+ AuthenticAMD GNU/Linux

$ named -v
BIND 9.8.0

And the named.conf file:
# cat /etc/named.conf
//
// /etc/named.conf
//

include "/etc/rndc.key";

#controls {
#       inet 127.0.0.1 allow {localhost; } keys { "dnskulcs"; };
#};

options {
        directory "/var/named";
        pid-file "/var/run/named/named.pid";
        auth-nxdomain yes;
        datasize default;
// Uncomment these to enable IPv6 connections support
// IPv4 will still work:
        listen-on-v6 { any; };
        listen-on { any; };
// Add this for no IPv4:
//      listen-on { none; };

// Default security settings.
//      allow-recursion { 127.0.0.1; ::1; 192.168.1.0/24; };
//      allow-recursion { any; };
        allow-query { any; };
        allow-transfer { 127.0.0.1; ::1; 92.243.14.172; 87.98.164.164; 88.191.64.64; };
        allow-update { key "dnskulcs"; };
        version none;
        hostname none;
        server-id none;
        zone-statistics yes;

        forwarders { 213.46.246.53; 213.26.246.54; 8.8.8.8; 8.8.4.4; 192.188.242.65; 193.227.196.3; 2001:470:20::2; };
};

view "local" {

        match-clients { 192.168.1.0/24; 127.0.0.1; ::1; fec0:0:0:ffff::/64; };
        recursion yes;

        zone "localhost" IN {
                type master;
                file "localhost.zone";
                allow-transfer { any; };
        };

        zone "0.0.127.in-addr.arpa" IN {
                type master;
                file "127.0.0.zone";
                allow-transfer { any; };
        };

        zone "." IN {
                type hint;
                file "root.hint";
        };

        zone "dafaces.com" IN {
                type master;
                file "internal/dafaces.com.fw";
                allow-update { key "dnskulcs"; };
        };

        zone "1.168.192.in-addr.arpa" IN {
                type master;
                file "internal/dafaces.com.rev";
                allow-update { key "dnskulcs"; };
        };
};

view "public" {
        match-clients { any;};
        recursion no;

        zone "dafaces.com" IN {
                type master;
                file "external/dafaces.com.fw";
                allow-transfer {
                        87.98.164.164; 195.234.42.1; 88.191.64.64;
                };
        };
};

//zone "example.org" IN {
//      type slave;
//      file "example.zone";
//      masters {
//              192.168.1.100;
//      };
//      allow-query { any; };
//      allow-transfer { any; };
//};

logging {
        channel xfer-log {
                file "/var/log/named.log";
                print-category yes;
                print-severity yes;
                print-time yes;
                severity info;
        };
        category xfer-in { xfer-log; };
        category xfer-out { xfer-log; };
        category notify { xfer-log; };
};

All help would be highly appreciated!
EDIT: Zone files:
# cat /var/named/internal/dafaces.com.fw
$ORIGIN .
$TTL 3600       ; 1 hour
dafaces.com             IN SOA  tressis.dafaces.com. postmaster.dafaces.com. (
                                2011032201 ; serial
                                28800      ; refresh (8 hours)
                                7200       ; retry (2 hours)
                                2419200    ; expire (4 weeks)
                                3600       ; minimum (1 hour)
                                )
                        NS      tressis.dafaces.com.
                        A       192.168.1.1
                        MX      10 mail.dafaces.com.
$ORIGIN _tcp.dafaces.com.
_http                   SRV     0 5 80 www.dafaces.com.
_ssh                    SRV     0 5 22 tressis.dafaces.com.
$ORIGIN dafaces.com.
acrisius                A       192.168.1.230
andromeda               A       192.168.1.7
andromeda-win7          CNAME   andromeda
aspasia                 A       192.168.1.233
athena                  A       192.168.1.232
callisto                A       192.168.1.102
db                      A       192.168.1.1
management              A       192.168.1.1 ; web management for the router functions
haley                   A       192.168.1.5
hoth                    A       192.168.1.101
mail                    A       192.168.1.1
satelite                A       192.168.1.20
sony-player             A       192.168.1.103
                        TXT     "310f16de2d2712dfc4ae6e5c54f60f828e"
torrent                 A       192.168.1.1
tracker                 A       192.168.1.1
tressis                 A       192.168.1.1
www                     A       192.168.1.1
zeus                    A       192.168.1.231

and
# cat /var/named/external/dafaces.com.fw
$ORIGIN .
$TTL 3600
dafaces.com             IN SOA  ns.dafaces.com. postmaster.dafaces.com. (
                                        2011032405; serial
                                        28800; refresh
                                        7200; retry
                                        2419200; expire
                                        3600; minimum
                                        )

                        NS      ns.dafaces.com.
                        NS      ns0.xname.org.
                        NS      ns1.xname.org.
                        NS      ns2.xname.org.

                        A       89.135.129.37
                        MX      10 mail.dafaces.com.

$ORIGIN dafaces.com.
;Szolgaltatasok
_ssh._tcp               SRV     0 5 22 tressis
_http._tcp              SRV     0 5 80 www

ns                      A       89.135.129.37
hoth                    A       89.135.129.37
www                     A       89.135.129.37
mail                    A       89.135.129.37
db                      A       89.135.129.37

torrent                 A       89.135.129.37
tracker                 A       89.135.129.37

Edit:
Ohh, hell I almost forgot. Since the node is connected to the internet via a residential connection, there is a possibility, that the public ipv4 address will change(but thank god, it is a very rare case), so I daily update the external IP address in the zone file with a shellscript:
# cat /etc/cron.daily/dnsupdate
#!/bin/sh

FILE="/var/named/external/dafaces.com.fw"
SERIAL=$(date +%Y%m%d05)
PUBLIC_IP=$(ifconfig internet |sed -n "/inet addr:.*255.255.255.255/{s/.*inet addr://; s/ .*//; p}")

cat $FILE | sed --posix 's/^.* serial$/\t\t\t\t\t'$SERIAL'; serial/' | sed --posix 's/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/'$PUBLIC_IP'/'  > /tmp/ujzona
mv /tmp/ujzona $FILE
/etc/rc.d/named reload

A: Try changing the lines:
dafaces.com             IN SOA  tressis.dafaces.com. postmaster.dafaces.com. (

To
dafaces.com.               IN SOA  tressis.dafaces.com. postmaster.dafaces.com. (

A: The usual mantra: "what's changed?" By any chance have you fiddled with /etc/resolv.conf, maybe trying to tighten down the timeout a little? (Or is it possible the machine that's running BIND is quite a bit more heavily loaded and significantly slower than it was at first?)
Only a network trace (wireshark?) would tell for sure, but it looks to me like the first request for foo.bar.baz isn't being returned fast enough, so the resolver is timing out and then trying foo.bar.baz.bar.baz (append "domain" to whatever  ...even if it's a silly duplication). That second query probably never did work right even before (possibly because of the missing trailing dot mentioned in another response), but it didn't matter during your initial testing because the query never got sent anyway.
Now the query is being sent, and tickling the incorrect behavior that was latent in your BIND configuration all along. Try turning the option timeout:N in /etc/resolv.conf way up and see if it stops happening. (Or turn the option way down so it tickles the problem all the time, then fix the root problem, then turn the option back up to a reasonable value.)


text:
Q: Add class attribute with decorator I try to use a decorator to add some method or property to an annotated class.
This is my decorator :
export default function Component(params) {
    return function decorator(target) {
        target.template = params.template;
        console.log(target, params.template);
    }
}

I used it this way :
@Component({
    template: template
})
export default class App {}

But when I use this class :
app.template // undefined;

Any idea?

A: You are modifying class object itself, i.e.
App.template // your template is here

and you just defined a static property for App class in this case.
In order to set template for class instances you should use:
target.prototype.template = params.template;

(Good example that classes are actually just syntactical sugar over constructor functions and prototype-based inheritance).
Also, I think this article about combining mixins and decorators might be helpful.


text:
Q: prolog arguments are not sufficently instantiated I am trying to find max,mid and min number from 3 given number. The code is:
t_max(X,Y,Z):-
    A is max(max(X,Y),max(Y,Z)),
    C is min(min(X,Y),min(Y,Z)),
    (X>=A,X=<C)->B is X;
    (Y>=A,Y=<C)->B is Y;
    (Z>=A,Z=<C)->B is Z;
    format('~w      ~w      ~w',[A,B,C]).

When i try to run  the method with any three numbers, I get this error
ERROR: >=/2: Arguments are not sufficiently instantiated

Why I'm getting this error?

A: The problem is that the ; binds with lower priority than the , so what you have written is equivalent to:
t_max(X, Y, Z) :-
    (   A is max(max(X, Y), max(Y, Z)),
        C is min(min(X, Y), min(Y, Z)),
        X>=A,
        X=<C
    ->  B is X
    ;   Y>=A,
        Y=<C
    ->  B is Y
    ;   Z>=A,
        Z=<C
    ->  B is Z
    ;   format('~w      ~w      ~w', [A, B, C])
    ).

What does this mean: Prolog evaluates:
A is max(max(X,Y),max(Y,Z)),
C is min(min(X,Y),min(Y,Z)),

first and then checks the condition:
X>=A,X=<C

if that fails however, the program backtracks entirely to the beginning of the clause. So now A and C are again uninstantiated and Prolog performs a new attempt by checking:
Y>=A,Y=<C

but now A and C are not grounded.
You can resolve the problem by adding brackets:
t_max(X,Y,Z):-
    A is max(max(X,Y),max(Y,Z)),
    C is min(min(X,Y),min(Y,Z)),
    ((X>=C,X=<A)
     -> B is X
     ; ((Y>=C,Y=<A)
        ->B is Y
        ; ((Z>=C,Z=<A)
           -> B is Z;
           true
          )
       )
    ),
    format('~w      ~w      ~w',[A,B,C]).

If I understand your problem correctly. If you however want to sort them from large to small, a compact way to do this for three numbers is:
t_max(X,Y,Z) :-
    Max is max(X,max(Y,Z)),
    Min is min(X,min(Y,Z)),
    Mid is X+Y+Z-Max-Min,
    format('~w      ~w      ~w',[Max,Mid,Min]).


text:
Q: Windows 7 keeps changing my language(keyboard) settings I am using Windows 7 Ultimate on a Windows network. My default settings is Danish locale, Danish keyboardlayout, but English system language. I only have Danish keyboard layout installed (in Text Services and Input Languages).
However, at the login screen I can choose Danish and English, but whatever I choose Windows 7 changes system language (and keyboard layout!) to English (United States). Since this is a per-App setting I must change the language setting (language bar in the taskbar)
Where can this be changed system wide and permament?

A: Open the Region and Languages in the Control Panel and do this:
Click the Keyboards and Languages tab and click Change keyboards...

From here you can either change the Default input language to Danish.

Or you can completely remove the US Keyboard.

Doing either one of these should result in you being able to use only the Danish keyboard instead of having to change it per-app as it makes it the default system-wide.

A: The best solution (assuming you want to have access to more than one keyboard, which I did) is to go into the Control Panel, Keyboards and Languages/advanced settings.
And change the keyboard shortcut for switching keyboards from Ctrl/Shift to none!
All along, I, too thought it was changing from Eng to Fr on a "random" basis. But it wasn't random at all: I always use keyboard shortcuts, and one of my favorites is Ctrl+Shift+Tab for moving to the previous tab in Chrome.
Stumbled on the shortcut conflict when checking out someone else's suggestion of going into Control Panel. That's when I saw the problem. Once I turned off the keyboard shortcut for changing languages (no biggy) I've never again had the problem. Random or otherwise! Mystery solved!

A: Go into Control Panel>Region and Languages>Keyboards and Languages tab>Change Keyboards, and remove the ones you don't want.

A: I had the same issue of it changing regions on me.
I right clicked the keyboard icon in the lower right taskbar and unchecked "auto adjust".
French screenshot:

A: This is a the most annoying bug and it still happens to a genuine brand new HP computer with Windows 7 Buisness OEM but my issue is also related to 'MS Word 2003' not changing keyboard layout (could not Apostrophe properly )
I use 2 keyboard layouts: US-International and French
I found these solutions that worked for me and some that seems like your issue:

METHOD 1

In MS WORD 2003 ["] and apostrophes ['] would not display until another key was pressed.
Then this key and the quote or apostrophe would appear on the screen.
Checking in the keyboard settings the system was set to United States-International and French for it's keyboard layout.
Change your keyboard layout to another US layout and removed the United States-International keyboard layout.
After pressing OK, I tested it on a Word Document and the issue still remained.
But after rebooting the system it went back to normal and I could use apostrophes and quotation marks as usual.
Suggestions (if it fails): Try to change your Windows local language Unicode just to see how it behave. Another suggestion related to application language switching issues is to change the hotkey combination that switch the keyboard layout.
Also in Word turn off when configuring Microsoft Word 'Smart Quotes' option.

METHOD 2

Before changing registry values I recommend making a restore point or a registry backup.
Use it at your own risk
To change the keyboard layout manually you need to change the keyboard layouts\preload\ Registry key in the Registry:
Press Start> type Regedit.exe
In the registry locate this key:
HKEY_CURRENT_USER\ Keyboard Layout\Preload\1

You will need to edit the Registry Key , change the string key "1" value setting to the "ID Language code" number listed below next to the keyboard layout name you want.
Close Regedit.exe
Restart Computer
Note: Preload\2 is used if you want to be able to switch between two keyboard layouts.
Find the ID language code here below:
00000402="bg"
00000404="ch"
00000405="cz"
00000406="dk"
00000407="gr"
00000408="gk"
00000409="us"
0000040A="sp"
0000040B="su"
0000040C="fr"
0000040E="hu"
0000040F="is"
00000410="it"
00000411="jp"
00000412="ko"
00000413="nl"
00000414="no"
00000415="pl"
00000416="br"
00000418="ro"
00000419="ru"
0000041A="yu"
0000041B="sl"
0000041C="us"
0000041D="sv"
0000041F="tr"
00000422="us"
00000423="us"
00000424="yu"
00000425="et"
00000426="us"
00000427="us"
00000804="ch"
00000807="sg"
00000809="uk"
0000080A="la"
0000080C="be"
00000813="be"
00000816="po"
00000C0C="cf"
00000C1A="us"
00001009="us"
0000100C="sf"
00001809="us"
00010402="us"
00010405="cz"
00010407="gr"
00010408="gk"
00010409="dv"
0001040A="sp"
0001040E="hu"
00010410="it"
00010415="pl"
00010419="ru"
0001041B="sl"
0001041F="tr"
00010426="us"
00010C0C="cf"
00010C1A="us"
00020408="gk"
00020409="us"
00030409="usl"
00040409="usr"
00050408="gk"

For more informations about adding keyboard layout manualy check this link:
Adding and removing keyboard languages with PowerShell

A: I had the same problem: My KB kept switching between US and UK keyboards even though I didn't have a UK KB installed. I manged to solve this by adding a UK keyboard, then removing it. The language bar disappeared and my input KB now stays as US.

A: Use AHK. Finally, after all my attempts it solved my issue with Russian and English auto-swithing in Windows 7. You will define, which language you want to see for all threads / windows, and will be able to change it by keyboard shortcut.
Code:
#SingleInstance, Force ;
LangCode_First := 67699721          ; langcode of first language in decimal ( i made it by 0x0409 --> 0x04090409 --->  https://www.rapidtables.com/convert/number/hex-to-decimal.html
LangCode_HEX_First := 0x0409        ; langcode of first language in HEX (get it here https://docs.microsoft.com/en-us/windows/win32/menurc/varfileinfo-block)
LangCode_Second := 68748313         ; langcode of second language
LangCode_HEX_Second := 0x0419       ; langcode of second language in HEX

; English (USA) 0x0419 0x4190419 68748313 (HEX to Dec)
; Russian 0x0409 0x4090409 67699721 (HEX to Dec)

;function that set keyboard language
    SetDefaultKeyboard(LocaleID){
        Static SPI_SETDEFAULTINPUTLANG := 0x005A, SPIF_SENDWININICHANGE := 2

        Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
        VarSetCapacity(binaryLocaleID, 4, 0)
        NumPut(LocaleID, binaryLocaleID)
        DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &binaryLocaleID, "UInt", SPIF_SENDWININICHANGE)

        WinGet, windows, List
        Loop % windows {
            PostMessage 0x50, 0, % Lan, , % "ahk_id " windows%A_Index%
        }
    }

;your shortcut for swithing language

!LShift::SetKey()

;function that detect current language and change it, if it is needed
SetKey(){

    if ("" DllCall("GetKeyboardLayout", Int,DllCall("GetWindowThreadProcessId", int,WinActive("A"), Int,0)) = 67699721)  ;change value here to your lang code
    {
        SetDefaultKeyboard(0x0419) ;change value here to your lang code
    }
    else if ("" DllCall("GetKeyboardLayout", Int,DllCall("GetWindowThreadProcessId", int,WinActive("A"), Int,0)) = 68748313) ;change value here to your lang code
    {
        SetDefaultKeyboard(0x0409) ;change value here to your lang code
    }
}

In the beginning you can see language codes, that required. You can extract them from here and convert additional parameters here (HEX to DEC)
Please change also variables in ending of code, I marked where you need to do it.
It is also better to delete default language-swiching shortcut
in advanced key settings menu, by changing both options in Change Key Sequence to Not Assigned

A: I found a solution that worked for me. The problem was that I only had Dvorak installed under Installed Services, and since the computer's locale was set to US, it kept defaulting to that. Once I added US to Installed Services and set Dvorak as the "Default input language", it started behaving.
In your case, changing the system locale to Danish may remedy your issue. In the Region and Language window (first pictured by Thiago), click the Administrative tab, then click "Change system locale" and choose the appropriate selection from the list.
I don't know if this is a desirable fix for you, but there you go. I really wish this wasn't so complicated; I don't have this problem on my Mac... ;-)


text:
Q: Call a variable based on a second variable in a batch file The process of the program i am trying to right is to take a text file with a number of words in, and set each one to a variable, then echo a random variable form the list set. So far my code looks as follows:
@Echo Off
Set _InputFile=config.txt
//Sets the Input file
For /F "tokens=1,2* delims=:" %%A IN (%_InputFile%) DO Set _Data%%A=%%B
//Sets each Word to a vairable from _data1 to _datax
set n=(random number code)
//Set's N to be a rational random number depending on the variables available
Echo _data%%n
//This is where i get stuck, i need to be able to echo _data(whatever number n is)
pause>nul

So basically my main problem is getting the file to echo a random variable based on the value of another variable. An alternate method would also be appreciated if it is better/more appropriate than what i am trying.
Secondly (a smaller issue) is there any way to determine the number of words (or lines as it will be the same thing) in config.txt and then assign that number to a variable?

A: 1) Use CALL to get 2 expansion phases - one before the call, and one after. This is slow, and visually confusing. Also it is the least reliable because many characters have the ability to corrupt the results.
call echo %%_Data%n%%%

2) Delayed Expansion - Much faster, easier to follow method that always works. However, delayed expansion will corrupt FOR variable expansion if the FOR variable contains the ! character. Delayed expansion must be enabled before it can be used.
setlocal enableDelayedExpansion
::Above line must be executed sometime before the following
echo !_Data%n%!

2a) If the n variable is being set within the same parenthesised block of code that is trying to echo the value, then %n% will not work. This problem often arises with FOR loops and IF statements. It fails because %n% is expanded when the entire block is parsed, before the value of n has been set. The trick is to transfer the value of !n! to a FOR variable.
setlocal enableDelayedExpansion
for .... (
  set n = ....
  for %%N in (!n!) do echo !_Data%%N!
)

Here is a convenient method to get a pseudo random number between 1 and x. It relies on the predefined dynamic variable: RANDOM.
set /a n=%random% %% x + 1

If computing the value in a loop, then you probably want delayed expansion so that you get a different number with each iteration.
set /a n=!random! %% x + 1

A: To answer your second question first, there are several methods for getting the number of lines in a file quickly.
Using  the FIND.EXE method:
for /f %%x in ('type %FileName% ^| find /v /c ""') do set Lines=%%x

The advantage of using find.exe is that find zipps though any text file like mad, and that it will count even blank lines.
Using the for method:
for /f %%x in (%FileName%) do set /a count=count+1

The drawback for the second method is that for loops automatically skip blank lines. The advantage to this method is that the file need only be accessed once.
Since we are going to read in each line of the file and manipulate it, it will be more efficient to count each line when you read it in.

Before we go on I should point out that // is not a comment mark in Batch and will cause errors. Either use REM, the REMark command, or a pair of double-colons :: to denote comments.
Notice the setlocal enabledelayedexpansion and endlocal lines. SETLOCAL makes all variables temporary so exist only during the execution of the script, eliminating the need to clear every variable at the end of the script. enableDelayedExpansion enables the use of ! notation, allowing variables to be accessed like so: !Variable!. Lastly endLocal specifies WHERE in the script all the temporary variables die or revert to their pre-setlocal values. If you eliminate the endLocal line there will be an implied endlocal when the batch file ends.
@Echo Off
setlocal enabledelayedexpansion
Set _InputFile=CONFIG.TXT
set count=

:: Sets each line to a vairable from _data1 to _data##
For /F "tokens=1* delims=:" %%A IN (%_InputFile%) DO (
    set /a count=!count!+1
    Set "_Data!count!=%%A"
)

:: Create a random number between 1 and %count% using the MOD function in 'set /a'
:: Equivalent to: SET /A n = aRandomNumber - ( theSameRandomNumber / %Count% ) + 1
:: See http://en.wikipedia.org/wiki/Mod_function
set /a n=%random% %% %count% +1

:: Echo # of lines, a random # from 1 to %count%, and a random line from the file:
echo.
echo =================================================
echo File is %count% lines deep
echo Random #: %n%

:: Print a random line of data
:: We are taking advantage of Delayed Expansion and ! notation:
Echo Random Line: "!_data%n%!"
echo.

:: Use SET to echo every line of data read in
echo Whole Set of _data[#] data:
set _data
echo.

endlocal

One thing to keep in mind is that CMD.EXE brings some of the limitations that were inherent in old MS-DOS. In this case there are two important limitations:
1) There is a severe limits on the amount of memory available for use.
2) Setting Environmental Variables uses a lot of the memory available to a CMD.EXE session.
What this means for you is that you will be limited to creating about 100 _data variables, so no data past that point can be saved to a variable.
In older versions of Windows you could create a .PIF file (at the command line type copy nul BatchName.PIF then right-clicking it in Windows Explorer and selecting Properties) for your batch file and change the amount of memory that would be allocated for it when it ran.  I think you could even do that under XP, but I know that in Windows 7 you cannot. Though it may be possible to download an existing .PIF file and connecting it to your batch file, but I don't know.


text:
Q: fieldset in firefox page zoom i have a fieldset in a form. when i use firefox and i ctrl+middle mouse button to zoom with mouse pointer inside the fieldset, nothing is happening. it works in IE/chrome. replacing fieldset with div works in firefox.
am i using fieldset wrong? or is my firefox broken?
    <form name="test">
        <fieldset>
            test
            <input />
            test
            <input />
        </fieldset>

            test
            <input />
            test
            <input />

    </form>

A: Did some digging and found the bug report that describes exactly what you are experiencing. It's 9 years old, so I wouldn't hold your breath for it being fixed anytime soon.


text:
Q: How to split residuals into groups for the Brown-Forsythe test I have the following data
id: 1 2 3 4 5 6 7 8 9 10 11 12
num. responses(predictor): 16 14 22 10 14 17 10 13 19 12 18 11
cost(response): 77 70 85 50 62 70 55 63 88 57 81 51
I fitted the linear regression model and I got the following residuals:
5.22478992, 4.76260504, -6.38865546, -2.16176471, -3.23739496, -5.04411765, 2.83823529, 1.03151261, 6.41806723, -1.69957983, 2.68697479, -4.43067227
I want to preform the Brown-Forsythe test and I am suppose to split the residuals into two groups using the following method "Begin by letting group 1 consist of the residuals associated with the n1 lowest values of the predictor. Then, let group 2 consists of the residuals associated with the n2 highest values of the predictor (so n1+n2 = n)." I can't understand how I should apply the method above to split the data can someone explain it to me.


text:
Q: CSS: Responsive font-size doesn't look responsive on Safari browser I'm building a responsive personal website and I've encountered a weird problem. I created a menu for my website. Since its homepage and content pages have different CSS files, I put the same menu code into both CSSs. It works and looks same on my pc browsers (Firefox and Chrome) but when it comes to mobile browser the font-size changes even if they are same in the code.
This is what the homepage menu looks like on pc browser:

And this is the inner menu, also on pc. They are identical:

This is what the homepage menu looks like on mobile. (iPhone Safari) This is the expected result:

However my content pages' menu looks like this and it's not user friendly:

As far as I tested I believe the problem occurs on Safari. I also tried Mobile Firefox Browser and it looked decent. I don't have a clue about Android browsers though.
By the way this is the menu list styling code part of my two CSS files. Entire code is in vw or %
.menu-pane li {
   padding-top: 1.8vw;
   padding-bottom: 0.1vw;
   margin-left: 1vw;
   font-size: 80%;
   font-family: 'Josefin Sans', sans-serif;
}

A: Use this code on your CSS file
html{
   -webkit-text-size-adjust: 100%;
}


text:
Q: How to change local notification icon? I made the local notification icon with png file. However, in android, the icon looks transparent. It looks good in ios app. How can I show the original icon image as a notification icon?
ios notification icon

android notification icon

Notification code
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
// import 'package:timezone/data/latest_all.dart' as tz;
// import 'package:timezone/timezone.dart' as tz;

final notifications = FlutterLocalNotificationsPlugin();

initNotification() async {

  var androidSetting = const AndroidInitializationSettings('ic_launcher');

  var iosSetting = const IOSInitializationSettings(
    requestAlertPermission: true,
    requestBadgePermission: true,
    requestSoundPermission: true,
  );

  var initializationSettings = InitializationSettings(
      android: androidSetting,
      iOS: iosSetting
  );
  await notifications.initialize(
    initializationSettings,
  );
}

showNotification() async {

  var androidDetails = const AndroidNotificationDetails(
    'ID',
    'notification',
    priority: Priority.high,
    importance: Importance.max,
    // color: Color.fromARGB(255, 255, 0, 0),
  );

  var iosDetails = const IOSNotificationDetails(
    presentAlert: true,
    presentBadge: true,
    presentSound: true,
  );

  notifications.show(
      1,
      'title1',
      'content1',
      NotificationDetails(android: androidDetails, iOS: iosDetails)
  );
}

A: I have the same problem today. For android, you need to change the icon,
android -> app -> main -> res -> drawable and that name put inside
var androidSetting = const AndroidInitializationSettings('ic_launcher');
inside but for iOS I don't know where to change

A: You can try this for android icon
https://medium.com/nonstopio/change-the-firebase-notification-icon-in-a-flutter-245b7f7dc546

A: Yes, you can use png image color, and it will show color icon on notification.
ex :
image file ic_launcher.png
create new file in your drawable folder
launcher_notification.xml
    <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap android:gravity="fill" android:src="@drawable/ic_launcher"/>
    </item>
    <item>
        <bitmap android:gravity="center" android:src="@drawable/ic_launcher"/>
    </item>
</layer-list>

and put "launcher_notification" in
var androidSetting = const AndroidInitializationSettings('launcher_notification');

if it show grey icon on emulator, try it on your phone. It's same if you want to use it for firebase notification icon

A: If it helps, I just change the icon in the @mipmap files and keep the same name as ic_launcher. The code does the rest. It's a lazy approach but prevents you from an big headache

A: If your notification Icon is displaying a grey or white color, check if the image you are using is transparent.