text:
Q: Obtener checkbox seleccionado y agruparlo por nombre Tengo un formulario con varios checkbox cada uno tiene su propio valor y pertenece a un grupo por el nombre.
Grupos:

*

*Marca

*Procesador

*RAM

function evitaSubmit_filtroMarca(e) {
  console.log('Capturamos el submit');
  e.preventDefault();

  var formulario = document.getElementById('formulario');
  var checkBoxes = formulario.querySelectorAll('input[type="checkbox"]');

  recorreCheckBox(checkBoxes);

  return false;
}

function recorreCheckBox(checkBoxes) {
  let result = [];
  var nombre;
  let resultados = new Object();

  checkBoxes.forEach(item => {
    console.log(item.name)
    nombre = item.name;
    if (item.checked) {
      result.push(item.value);
    }
  })
  resultados.nombre = result;
  console.log(resultados)
  return result;
   }
<form id="formulario" onsubmit="return evitaSubmit_filtroMarca(event);">

            <input type="checkbox" class="form-check-input" value="HP" id="marca_1" name="marca">
            HP

            <input type="checkbox" class="form-check-input" value="Lenovo" id="marca_2" name="marca">
            Lenovo

            <input type="checkbox" class="form-check-input" value="Intel Core i3" id="procesador_1" name="procesador">
            Intel Core i3

            <input type="checkbox" class="form-check-input" value="Intel Core i5" id="procesador_2" name="procesador">
            Intel Core i5

            <input type="checkbox" class="form-check-input" value="8 GB" id="ram_1" name="ram">
            8 GB

        <button type="submit" class="btn btn-primary btn-sm" id="btn_filtrar">Filtrar</button>

</form>

Como puedo obtener los checkboxes seleccionados y agruparlos en un objeto por su nombre
{
  "marca": [
    "Lenovo",
    "HP"
  ],
  "procesador": [
    "Intel Core i3",
    "Intel Core i5"
  ]

}
Cualquier ayuda o referencia sirve, estuve buscando referencias sobre este punto y no encontré alguna
Posteriormente debo recorrer el objeto por su nombre para realizar otras funciones

A: Usa un FormData para extraer los datos del formulario, y luego los agrupas con un simple ciclo for. Te adjunto un ejemplo:

var formulario = document.getElementById('formulario');

function evitaSubmit_filtroMarca(e) {
  e.preventDefault();
  var formData = new FormData(formulario);

  var result = {};
  for(var pair of formData.entries()) {
   if(result.hasOwnProperty(pair[0]))
     result[pair[0]].push(pair[1])
   else
     result[pair[0]] = [pair[1]]
  }
  console.log(result);
  return false;
}
<form id="formulario" onsubmit="return evitaSubmit_filtroMarca(event);">

            <input type="checkbox" class="form-check-input" value="HP" id="marca_1" name="marca">
            HP

            <input type="checkbox" class="form-check-input" value="Lenovo" id="marca_2" name="marca">
            Lenovo

            <input type="checkbox" class="form-check-input" value="Intel Core i3" id="procesador_1" name="procesador">
            Intel Core i3

            <input type="checkbox" class="form-check-input" value="Intel Core i5" id="procesador_2" name="procesador">
            Intel Core i5

            <input type="checkbox" class="form-check-input" value="8 GB" id="ram_1" name="ram">
            8 GB

        <button type="submit" class="btn btn-primary btn-sm" id="btn_filtrar">Filtrar</button>

</form>

Otra posible solución, como sugiere @Marcos es usar keys() y getAll():

var formulario = document.getElementById('formulario');

function evitaSubmit_filtroMarca(e) {
  e.preventDefault();
  var formData = new FormData(formulario);

  var result = {};
  for(var key of formData.keys()) {
    result[key] = formData.getAll(key)
  }
  console.log(result);
  return false;
}
<form id="formulario" onsubmit="return evitaSubmit_filtroMarca(event);">

            <input type="checkbox" class="form-check-input" value="HP" id="marca_1" name="marca">
            HP

            <input type="checkbox" class="form-check-input" value="Lenovo" id="marca_2" name="marca">
            Lenovo

            <input type="checkbox" class="form-check-input" value="Intel Core i3" id="procesador_1" name="procesador">
            Intel Core i3

            <input type="checkbox" class="form-check-input" value="Intel Core i5" id="procesador_2" name="procesador">
            Intel Core i5

            <input type="checkbox" class="form-check-input" value="8 GB" id="ram_1" name="ram">
            8 GB

        <button type="submit" class="btn btn-primary btn-sm" id="btn_filtrar">Filtrar</button>

</form>


text:
Q: why "mov %crN, %eax" can be encoded when crN is not exist? Intel manual volume 3, said that there's only CR0,2,3,4 + CR8 in 32E mode, and CR1 is reserved. But when I compile instruction in title, N could be any value < 16. I disassemble the obj file and found that it's encoded just follow reference when N<8. And when 7< N <16, it's encoded same as before but a LOCK prefix is added(make it a "serializing instruction" as NOTED in MOV cr version?).
Why it's encoded without any complain and is this encoding legal? Are those CRs really exist or they are just alias for other registers?

A: I. About "LOCK" prefix: current x86 really doesn't have fixed prefix meaning. There is the set of one-byte prefixes which all have their initial meaning (LOCK, REP, CS segment, etc.) but the latter is applied only to instructions where it has direct sense. But there are other usages when an instruction doesn't have such sense. For example, F3 (REPE) before BSR/BSF converts them to LZCNT/TZCNT respectively. With ordinary memory readings, the same REPE converts to XRELEASE. Segment prefixes 2Eh and 3Eh before branch instructions are prediction hints (used in Pentium 4 line). So, don't treat basic prefix roles as thorough principle.
II. Ongoing question: why reserved CRs should not be encoded, to your mind? I don't see any principal violation in this. For analogy, why don't you require IO instructions to encode only existing ports? You'd accept CR space in the same manner as IO or MSR space, and this won't be a problem anymore. :)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Meagre sets have empty interior-A false statement. Suppose $A$ is a meagre set i.e. a set of first category.Then $A=\large\cup_{n\in \mathbb N} $$A_n$,where each $A_n$ is nowhere dense.Now $A^o=(\large \cup_n A_n)^o\subset\large \cup_n A_n^o=\phi$ as $A_n^o\subset (\bar A_n)^o=\phi$.Thus we are done.Is this proof correct?
Then we can also prove Baire Category that complete metric spaces are not meagre.By showing that if $X$ is meagre,then $X^o=\phi$,which is a contradiction,but where do we require completeness,am I making mistake?Is this not true $(\large \cup_n A_n)^o\subset\large \cup_n A_n^o$.

A: If $A_1$ is the set of all rational numbers, $A_2$ is the set of all irrational numbers, and $A_n$ is the empty set for $n>2$ the  interrior of $\cup_n A_n $ is the entire real line whereas $A_n^{0} $ is empty for each $n$.


text:
Q: How to determine how many shells deep I might be? I'm wondering whether I've called the shell recursively, is there an easy way to find out? Is any solution specific to the shell? I'm using bash.

A: One way is to use pstree:
$ pstree -h
[...]
├─sshd─┬─sshd───sshd───bash───bash───bash───bash───bash───pstree
│      └─sshd───sshd───bash───bash───bash───bash
[...]

A: echo $SHLVL

This will catch if you do something like:
[sharpestmarble@sandbox ~]$ bash

Although that won't catch something like if you SSH into localhost.
[sharpestmarble@sandbox ~]$ ssh localhost

A: echo $SHLVL

From the bash manpage:

SHLVL  Incremented by one each time an
  instance of bash is started.

A: Also useful: $BASH_SUBSHELL
$ echo $SHLVL
1
$ (echo $SHLVL)
1
$ echo $BASH_SUBSHELL
0
$ (echo $BASH_SUBSHELL)
1
$ ( (echo $BASH_SUBSHELL) )
2


text:
Q: storing a mirror of IMAP/pop3 folder/inbox in a local DB, what choices are there? I have a email inbox that will soon hit 4 million messages, I have an app that runs different policies over the inbox to associate emails with each other much like the conversation plugin for Thunderbird.
It is now becoming impossible to do so and I have been thinking about moving the emails to a DB as they come in and process them there and then, the processor needs to access the body and header. What database engine is best for this task mysql,postgre,etc?

A: You could try DBMail as local IMAP storage, and either use any of various IMAP syncing solutions or regular SMTP forwarding to get the mail in there.


text:
Q: React Native iOS: Check notifications perms memory leak, how to check notifications perms on app launch? I want to be able to check if the user has notification permissions on or off every time the user opens the app from any state ( if the app was never opened before or the app was in the background etc.) What I have now is checking permissions via PushNotificationIOS.checkPermissions in the render function. However, with that method it keeps on being called and causes a memory leak. Another method I tried was whenever the user wants to be notified (via pressing an icon) the onPress method is called to check the perms but that causes the user to press the icon twice in order for the permission state to be updated.
import {
    PushNotificationIOS,
    AsyncStorage,
    ..
  } from "react-native";

export default class Bell extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isNotifActive: null,
      isBellActive: false,
      alertBody:"",
      fireDate: null,
      LaunchStatus: "",
      ID:'',
      timeSelected: ""
    };
    this.accessKeyNotif = `${this.props.fireDate}-isNotifActive`;

  }

  componentDidMount = () =>{
    this.setState({
        set props to state....
    });
    AsyncStorage.getItem(this.accessKeyNotif).then(value => this.setState({ isNotifActive: JSON.parse(value) }));

  }

  render() {
    PushNotificationIOS.checkPermissions((permissions) => {
      if (permissions.alert) {
        AsyncStorage.setItem(this.accessKeyNotif, JSON.stringify(true)).then(() => {
          this.setState({ isNotifActive: true});

        });
      }
      else{
        AsyncStorage.setItem(this.accessKeyNotif, JSON.stringify(false)).then(() => {
          this.setState({ isNotifActive: false});

        });
      }
    });

     return (
      <Ionicons
        name={this.state.isBellActive? "md-notifications":"md-notifications-off"}
        color={"white"}
        size={30}
        style={styles.NotifIcon}
        onPress={() => {
            if(this.state.isNotifActive){
             Make a notification
            }
            else if(!this.state.isNotifActive){
               Cancel Notifications
              }
            }}
        />

    );
  }
}

The Bell component is called on multiple times (20 times) by another class in order to display the bell.

A: You shouldn't be performing that check in the render method as each setState will cause a re-render, meaning to multiple unnecessary re-renders. It would be better handling this using an AppState listener. The following code will call _handleAppStateChange whenever the app comes into the foreground, goes into the background.
You can import it from react-native like so
import { AppState } from 'react-native'

Then in your component
state = {
  appState: AppState.currentState,  // set the currentState as the appState
};

componentDidMount () {
  // Set the listener
  AppState.addEventListener('change', this._handleAppStateChange);
}

componentWillUnmount () {
  // remove the listener
  AppState.removeEventListener('change', this._handleAppStateChange);
}

_handleAppStateChange = (nextAppState) => {
  if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
    // app has come to the foreground
    // perform checks etc here
  }
  // update the appState
  this.setState({ appState: nextAppState });
}

You can read more about it here https://facebook.github.io/react-native/docs/appstate


text:
Q: Validate in:post_fieds in laravel 5 It's posible to validate request with values from requests.
Simple example, I have FormRequest object with rules:
public function rules() {
    return [
        'id' => 'required|integer',
        'languages' => 'required|array',
        'default_language' => 'required|in:languages',
    ];
}

How to validate default_language which values must in languages ?

A: Yes you can use   in_array:anotherfield   validation like this:
 public function rules() {
return [
    'id' => 'required|integer',
    'languages' => 'required|array',
    'default_language' => 'required|in_array:languages',
];

}
https://laravel.com/docs/5.4/validation#rule-in-array


text:
Q: VSCode terminal shows incorrect python version and path, launching terminal from anaconda works perfectly I have been stuck on this one problem for hours now and believe I have tried everything outside of throwing my computer out of the window.
I have a virtual environment set up on Anaconda using python version 3.7 and Django version 2.1. If I activate this virtual environment from Anaconda everything works smoothly.
(movierecommender) bash-3.2$ python -V
Python 3.7.2
(movierecommender) bash-3.2$ python -m django --version
2.1.5

However when I try to activate the environment from a vscode terminal I get
(movierecommender) maxs-MBP:movies maxswann$ python -V
Python 2.7.10
(movierecommender) maxs-MBP:movies maxswann$ python -m django --version
/usr/bin/python: No module named django

I have Python 3.7.2 64-bit ('movierecommender':conda)
showing as my python interpreter in the bottom left of my vscode window yet still get the wrong python version
I thought this may be to do with the PYTHONPATH but have tried unsetting and resetting even though I should not have to worry about this in Anaconda as it automatically adds:
"python.pythonPath":"/Users/maxswann/anaconda3/envs/movierecommender/bin/python"
to a settings.json.vscode file
using:
python -c "import sys; print(sys.path)"

Anaconda-launched terminal
['', '/Users/maxswann/anaconda3/envs/movierecommender/lib/python37.zip', '/Users/maxswann/anaconda3/envs/movierecommender/lib/python3.7', '/Users/maxswann/anaconda3/envs/movierecommender/lib/python3.7/lib-dynload', '/Users/maxswann/anaconda3/envs/movierecommender/lib/python3.7/site-packages']

Vs Code terminal
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']

As you can see it seems to be using the default mac OS python version.
Has anybody else had this problem before? I've been tearing hair out all day trying to fix this

A: I have been facing the exact same problem. Finally found a workaround from a forum (https://github.com/Microsoft/vscode-python/issues/4434#issuecomment-466600591)
As long as you ADD some stuff to configuration, terminal.integrated.env.osx, the content will be appended to PATH after shell initialization(source bash_profile or zshrc). In my Mojave, I simply add following empty entry to my user configuration:
"terminal.integrated.env.osx": {
        "PATH": ""
}

Then the $PATH will be the same as the external terminal.

A: The officially accepted answer by @Samuel was the correct answer at the time.
But VS Code has now provided a better way to handle it.
In short, open up your user settings and add this line of code:
    "terminal.integrated.inheritEnv": false,

This prevents stomping over whatever Python environment manager you are using (eg, venv, conda, etc).

A: For Windows users:
First if you haven't done already, set VS code (the editor, not its terminal) to the desired Python environment, using Ctrl+Shift+P --> Python: Select interpreter.
Then, Change VS code's default terminal from Powershell to CMD. This is what worked for me at least.

A: I just ran into the same problem. Try switching out of the powershell terminal to the windows terminal. Then restart. It should restart with the anaconda terminal. If that does not work you could:
First change the default terminal from within Visual Code to the CMD terminal instead of Powershell. Add the following code to a batch file.
call "c:\path\to\anaconda3\Scripts\activate"

Then I named the batch file and saved it to my root directory. In my case snake.bat. Now when I launch my CMD terminal I just type c:\snake.bat and the CMD prompt changes into an Anaconda prompt.

A: Windows Solution:
If anyone in the future ends up scratching their heads over this particular problem, I've found another culprit, which blocked me for this problem on Windows:

Terminal>Integrated>Env: Enable Persistent Sessions
I suspect what happens is that after you update system paths, VScode caches the old path in the terminal and persists it. In this case it persists the old python path rather than the new conda one.
Toggling this option off and restarting VSCode clears that cache, and the new path is loaded in. You can also toggle the option back on after you're done.

A: I ran this script. Now python3 is running from virtual env. [Windows 10]
pip3 install virtualenv
virtualenv env
call ".\env\Scripts\activate.bat"
set requirements="./Requirements.txt"
pip3 install -r %requirements%
python


text:
Q: rpart Classification Tree interpretation I have created the following classification tree using rpart and I'm trying to interpret what the numbers below the labels mean. Taking the left most leaf its labelled "Success" with 0.04 below it. What is the 0.04? It looks as if it means 4% chance of success but 44/46 were success for small so it shouldn't it be 0.96? Is the number below the proportion for the opposite result? So for the one labelled failure with 0.62 below does that mean 62% chance of success? Thank you
d


text:
Q: Slight modification of a well known limit
Possible Duplicate:
$ \lim\limits_{n \to{+}\infty}{\sqrt[n]{n!}}$ is infinite

We have
$$\lim_{n \to \infty} n^{1/n} = 1$$
But in my prep for a Real Analysis exam, I came across the following modification:
$$\lim_{n \to \infty} (n!)^{1/n} = ? $$
and got stumped because the usual method of taking natural logarithms does not seem to work. (Or perhaps it requires some amendment that I'm not seeing?)
Any help would be appreciated. Thanks.

A: Here is a simple proof of $\lim (n!)^{\frac{1}{n}}=+\infty.$
Observe that $(n!)^{\frac{1}{n}}\geq (2\cdot2\cdots2)^{\frac{1}{n}}=(2^{n-1})^{\frac{1}{n}}=2^{1-\frac{1}{n}} \to 2$.
In general $\forall k \in \mathbb{N}$ and $n \geq k$ we have $(n!)^{\frac{1}{n}}\geq (k\cdot k\cdots k)^{\frac{1}{n}}=(k^{n-(k-1)})^{\frac{1}{n}}=k^{1-\frac{k-1}{n}} \to k$.
Therefore $\forall k \in \mathbb{N}, \ \exists n_0 \in \mathbb{N}: \forall n \geq n_0 \ \  (n!)^{\frac{1}{n}} \geq k-1$ (choose $n_0$ s.t. $\forall n \geq n_0 \ \ k^{1-\frac{k-1}{n}} \geq k-1$ ).
Hence $\lim_{n \to \infty} (n!)^{\frac{1}{n}} = \infty .$

A: Note that
$$ \frac{\log n!}{n} = \log n + \sum_{k=1}^{n} \log\left( \frac{k}{n} \right)\frac{1}{n} $$
and also
$$ \int_{0}^{1} \log x \, dx \leq \sum_{k=1}^{n} \log\left( \frac{k}{n} \right)\frac{1}{n} \leq \int_{1/n}^{1} \log x \, dx $$
by comparing the area as we can see from below:

This shows that
$$ \frac{\log n!}{n} = \log n - 1 + o(1)$$
and hence
$$(n!)^{1/n} = \exp\left(\frac{\log n!}{n}\right) = \frac{n}{e}(1+o(1)). $$
In particular, the limit diverges. (If we are only interested in the convergence, we may argue by some much simpler arguments.)

A: We have (Stirling formula)
$$n!\approx n^n e^{-n}\sqrt{2\pi n},$$
hence $\sqrt[n]{n!}\approx \frac ne$ for large $n$.


text:
Q: nginx 1.6 alias + php5-fpm = 404 on Debian 8 I have a ploblem with nginx shipped with Debian 8 jessie (version 1.6) and php5-fpm. This is a example of my working configuration on nginx 1.2 shipped with Debian 7 wheezy, however, it doesn't work on 1.6.
server {
    listen 80;
    server_name localhost;

    location / {
        try_files $uri $uri/ /error.html;
        include php.fast.conf;
    }

    location /phpmyadmin {
        alias /usr/share/phpmyadmin;
        include php.fast.conf;
    }
}

and this is my php.fast.conf
location ~ \.php$ {
    fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

Things changed a lot on Debian 8, I modified the stock configuration to get PHP running, a php script showing phpinfo works if it is located in /var/www/html.
server {
    listen 80;
    root /var/www/html;
    index index.html index.htm index.php index.nginx-debian.html;
    server_name localhost;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    location /phpmyadmin {
        alias /usr/share/phpmyadmin;
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
    }
}

However http://localhost/phpmyadmin doesn't work (404), tried lots of options only get 404 / blank page / input file not specified. I think it is a fastcgi_param problem, but don't know how to fix it.
Also, a working config will not work after upgrade, what is the reason of making changes to all of these?

A: i worked code
    location /phpmyadmin {
            root /usr/share/;
            index index.php index.html index.htm;

            location ~ ^/phpmyadmin/(.+\.php)$ {
                    include snippets/fastcgi-php.conf;
                    root /usr/share/;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_intercept_errors on;
            }

            location ~* ^/phpmyadmin/(.+\.(jpeg|jpg|png|css|gif|ico|js|html|xml|txt))$ {
                    root /usr/share/;
            }
    }

    location /phpMyAdmin {
            rewrite ^/* /phpmyadmin last;
    }


text:
Q: Object with one key's value dependent on another key's value What would be the best way of achieving this effect (note: this is not valid syntax - consider it a pseudocode):
type Config = {
  [key: string]: <T> {
    params: T,
    doSth: (params: T) => void,
  },
}

I.e. the generic T type is different for every key's value (which is an object itself), but at the same time it's being reused within that value (object) under different fields. Also, T is derived from the params field. With that I could do:
const config: Config = {
  a: {
    params: { x: 123 },
    doSth: params => {}, // Type of "params" is "{ x: 123 }"
  },
  b: {
    params: { y: 'asd' },
    doSth: params => {}, // Type of "params" is "{ y: 'asd' }"
  },
}

To my surprise, googling this doesn't yield matching results, even though it seems relatively useful pattern - there's a lot of similar problems but not really the same. Some solutions to those, that I tried to apply - all failed.

A: There are some things you can't do in TypeScript with types alone, sometimes you need a function to help even if the function doesn't actually do anything at runtime. I think this is one of those times. Here's an example of a function that gets close to what you're describing:
type ConfigEntry<T extends object> = {
    params: T;
    doSth: (params: T) => void;
};

function makeConfigEntry<T extends object>(obj: ConfigEntry<T>): ConfigEntry<T> {
    return obj;
}

Notice how ConfigEntry lets us relate the two places we'll be using that type. You'd use that function when defining the values of the properties:
const config = {
    a: makeConfigEntry({
        params: { x: 123 },
        doSth: params => {}, // Type of `params` is `{ x: number; }`
        //     ^?
    }),
    b: makeConfigEntry({
        params: { y: "asd" },
        doSth: params => {}, // Type of `params` is `{ y: string; }`
        //     ^?
    }),
};

Note there's no Config type annotation on that. TypeScript will infer it from the object initializer.
But notice the types on params aren't quite what you wanted. TypeScript won't infer the types { x: 123; } and { y: "asd"; } from your objects. It will either infer { x: number; } and { y: string; }, or if you define the objects as const, it'll infer { readonly x: 123; } and { readonly y: "asd"; }:
const config = {
    a: makeConfigEntry({
        params: { x: 123 } as const,
        doSth: params => {}, // Type of `params` is `{ readonly x: 123; }`
        //     ^?
    }),
    b: makeConfigEntry({
        params: { y: "asd" } as const,
        doSth: params => {}, // Type of `params` is `{ readonly y: "asd"; }`
        //     ^?
    }),
};

This is likely not quite what you wanted, but I think it's close, probably one of several approaches that are as close to what you want as you can get with today's TypeScript.
Playground example of the above


text:
Q: How to get percentage values based on matrix value when column and row name match I have a matrix as follows
    structure(c(4407, 0, 53, 46, 50, 0, 4407, 0, 0, 0, 53, 0, 742,
408, 411, 46, 0, 408, 688, 464, 50, 0, 411, 464, 672, 40, 0,
447, 359, 382, 72, 0, 439, 342, 356, 35, 0, 350, 321, 344, 45,
0, 365, 341, 364, 42, 0, 498, 372, 376, 102, 0, 304, 333, 340,
52, 0, 396, 354, 343, 52, 0, 377, 371, 374, 80, 0, 458, 374,
385, 54, 0, 509, 367, 365, 52, 0, 416, 322, 352, 47, 0, 505,
368, 384, 85, 0, 338, 358, 374, 45, 0, 396, 328, 330, 45, 0,
351, 381, 358, 53, 0, 362, 293, 301, 52, 0, 396, 340, 346, 55,
0, 385, 343, 340, 52, 0, 493, 406, 406, 49, 0, 516, 384, 416,
29, 0, 344, 330, 335, 32, 0, 326, 299, 314, 50, 0, 520, 372,
376, 33, 0, 348, 336, 340, 33, 0, 380, 329, 358, 31, 0, 354,
337, 349, 33, 0, 320, 301, 336, 33, 0, 341, 316, 347, 52, 0,
340, 316, 329, 48, 0, 522, 388, 389, 56, 0, 300, 362, 334, 57,
0, 303, 327, 301, 44, 0, 487, 401, 400, 51, 0, 439, 362, 373,
38, 0, 361, 336, 353, 38, 0, 328, 315, 337, 52, 0, 561, 403,
402, 44, 0, 459, 386, 393, 37, 0, 381, 340, 337, 37, 0, 405,
344, 343, 27, 0, 335, 346, 347, 31, 0, 370, 370, 385, 31, 0,
369, 340, 348, 54, 0, 326, 305, 335, 39, 0, 368, 343, 357, 38,
0, 379, 347, 367, 42, 0, 527, 389, 393, 56, 0, 382, 504, 471,
56, 0, 382, 504, 471, 51, 0, 459, 379, 394, 41, 0, 507, 393,
381, 68, 0, 475, 396, 398, 30, 0, 386, 362, 371, 34, 0, 378,
363, 379, 24, 0, 341, 317, 350, 35, 0, 378, 348, 364, 34, 0,
334, 327, 345, 28, 0, 323, 311, 322, 47, 0, 486, 365, 378, 52,
0, 479, 395, 414, 40, 0, 391, 327, 350, 49, 0, 363, 344, 370,
22, 0, 342, 329, 338, 51, 0, 381, 463, 440, 46, 0, 389, 460,
476, 46, 0, 487, 371, 385, 35, 0, 331, 307, 330, 47, 0, 522,
388, 405, 39, 0, 359, 352, 365, 42, 0, 369, 342, 356, 27, 0,
364, 352, 364, 38, 0, 377, 327, 342, 29, 0, 369, 346, 380, 37,
0, 382, 330, 355, 29, 0, 291, 245, 275, 30, 0, 354, 332, 358,
31, 0, 338, 310, 326, 37, 0, 347, 325, 356, 46, 0, 505, 385,
377, 44, 0, 504, 411, 430, 34, 0, 315, 310, 333, 37, 0, 392,
367, 373, 60, 0, 339, 324, 352, 48, 0, 475, 385, 402, 48, 0,
376, 342, 314, 1, 0, 0, 0, 0), .Dim = c(5L, 91L), .Dimnames = list(
    c("chr", "leftPos", "OC_AH_026C.res", "OC_AH_026C.1.res",
    "OC_AH_026C.2.res"), c("chr", "leftPos", "OC_AH_026C.res",
    "OC_AH_026C.1.res", "OC_AH_026C.2.res", "OC_AH_026T.res",
    "OC_AH_058T.res", "OC_AH_084C.res", "OC_AH_084T.res", "OC_AH_086C.res",
    "OC_AH_086C.1.res", "OC_AH_086C.2.res", "OC_AH_086C.3.res",
    "OC_AH_086T.res", "OC_AH_088C.res", "OC_AH_088T.res", "OC_AH_094C.res",
    "OC_AH_094C.1.res", "OC_AH_094C.2.res", "OC_AH_094C.3.res",
    "OC_AH_094C.4.res", "OC_AH_094C.5.res", "OC_AH_094C.6.res",
    "OC_AH_094C.7.res", "OC_AH_094T.res", "OC_AH_096C.res", "OC_AH_096T.res",
    "OC_AH_100C.res", "OC_AH_100C.1.res", "OC_AH_100T.res", "OC_AH_127C.res",
    "OC_AH_127T.res", "OC_AH_133C.res", "OC_AH_133T.res", "OC_ED_008C.res",
    "OC_ED_008C.1.res", "OC_ED_008C.2.res", "OC_ED_008C.3.res",
    "OC_ED_008T.res", "OC_ED_016C.res", "OC_ED_016T.res", "OC_ED_031C.res",
    "OC_ED_031T.res", "OC_ED_036C.res", "OC_ED_036T.res", "OC_GS_001C.res",
    "OC_GS_001T.res", "OC_QE_062C.res", "OC_QE_062T.res", "OC_RS_010C.res",
    "OC_RS_010T.res", "OC_RS_027C.res", "OC_RS_027C.1.res", "OC_RS_027C.2.res",
    "OC_RS_027T.res", "OC_SH_051C.res", "OC_SH_051T.res", "OC_ST_014C.res",
    "OC_ST_014C.1.res", "OC_ST_014T.res", "OC_ST_016T.res", "OC_ST_020C.res",
    "OC_ST_020T.res", "OC_ST_024C.res", "OC_ST_024T.res", "OC_ST_033C.res",
    "OC_ST_033T.res", "OC_ST_034C.res", "OC_ST_034C.1.res", "OC_ST_034C.2.res",
    "OC_ST_034T.res", "OC_ST_035C.res", "OC_ST_035T.res", "OC_ST_036C.res",
    "OC_ST_036T.res", "OC_ST_037T.res", "OC_ST_040C.res", "OC_ST_040T.res",
    "OC_WG_001T.res", "OC_WG_002C.res", "OC_WG_002T.res", "OC_WG_005C.res",
    "OC_WG_005T.res", "OC_WG_006C.res", "OC_WG_006T.res", "OC_WG_009T.res",
    "OC_WG_019C.res", "OC_WG_019T.res", "Means.res", "sd.res",
    "count")))

I want to get the value from each column when the rowname and columnname match and use this value as the denominator when calculating column-wise percentage
so far I have this:
 NewMatrix <- t(sapply(row.names(res_matrix),
                        function(x) substr(x, 1, 6) == substr(colnames(res_matrix), 1, 6)))

which gives me a true or false for matching, but then how do I take the true value and use it to do percentages for the other values in that column?

A: Do you want something like this:
library(dplyr)
library(tidyr)

long_data =
  data %>%
  as.data.frame %>%
  mutate(rowname = rownames(.) ) %>%
  gather(variable, value, OC_AH_026C.res:OC_WG_019T.res)

matches =
  long_data %>%
  filter(rowname == variable) %>%
  select(rowname, control_value = value)

long_result =
  long_data %>%
  left_join(matches) %>%
  mutate(ratio = value / control_value)

wide_result =
  long_result %>%
  select(-value, -control_value) %>%
  spread(variable, ratio)


text:
Q: Make a Custom template for a specific category in wordpress I am having issue with a custom category template. I want to create a new template for my specific category "VIDEOS" so that all posts under this category show in new style. Basically, i want to show posts with videos in a new way as 3 posts in one row with featured images and a featured slider on top of that page showing 4 new posts of that category ?
But i am confused... Can i do this in wordpress ? Because my home page also has a featured slider. Can i create a new slider for that page template but one thing is sure. I need to work with only one category for that custom template i.e. videos.........

A: Yes, certainly possible with WordPress.
Find the slug or the category id. Your slug for the category may be videos. So create a custom template named category-videos.php. This template will be used for the category archive VIDEOS.
If you know the category id, you can create template named category-<category_id>.php.

A: For other people landing on this page and wondering what to do when they go to their theme's folder and don't find a file called "category.php", what you need is to find the next file in the hierarchy, copy it, and rename it category-[slug or id].php (this should be archive.php, followed by index.php).
For a listing of the category hierarchy, see the official documentation: http://codex.wordpress.org/Category_Templates

A: Just create category-[id].php & you will be ready to use that. Wordpress will automatically load that file for that ID of category.
You can also do same task via slug like category-files.php etc as well


text:
Q: Create dynamic link to embedded documents in Excel WITHOUT VBA Firstly, I realise this problem could be solved with VBA, but I am looking to keep this workbook macro-free.
What I am trying to do is have several Excel workbooks embedded into my workbook (each embedded workbook is specific to a factory). I want to create a cell that acts as a dynamic hyperlink, which changes depending on which factory is filtered (I don't have any issues creating this dynamic hyperlink myself). The part I don't know how to do, is create a hyperlink that opens a document that is embedded within the workbook. I can make a hyperlink that opens a file saved in a directory, but I need to be able to share this workbook with multiple users, therefore I am embedding the documents.
Hopefully this makes sense - to summarise; I need to create a button/hyperlink that opens an embedded document WITHOUT VBA.
Many thanks

A: You have an EXCEL function HYPERLINK that receives a string (i.e. URL) as the first parameter. You can of course set BUILD the URL with a formula or a reference to other cell.
For instance, if you set in a cell the value:
=HYPERLINK("http://www.google.com")

and link on it, Google's page will be open on your browser. If you set the link to point to a file (any file) it will open it with the suitable application (e.g. Excel).
Is this what you were looking for?


text:
Q: Deadlocks due to foreign keys (MySQL) We are in the process of creating a web application using mysql as a data source.
We are using spring with hibernate as an ORM framework.
We have hundreds of entities with relations (manyToMany \ manyToOne etc..).
In the dev envioronment we currently use the hbm2dll in order to create the schemas from time to time. (after huge changes).
last week we encountered a deadlock happening (note that we do not use any explicit locking on our project). on a simple usage of the application.
removing the foreign keys from the table actually solved the issue.
So a couple of questions:
1) are foreign keys "evil"? if removing them from the DB did not affect the application logic and solved the issue - whats the point?
2) should we get rid of all of them?


text:
Q: Getting permission denied when using a URI despite FLAG_GRANT_READ_URI_PERMISSION being set I have two android apps A and B.  I am passing a file from app A to app B and I am seeing that app B is getting the URI.  I am setting the FLAG_GRANT_READ_URI_PERMISSION flag in app A and I am seeing that that mFlags is a 1, which is the value of FLAG_GRANT_READ_URI_PERMISSION, from within app B.  This is all good, but when I try to create a FileInputStream from the URI, I get a FileNotFoundException (Permission denied) exception.  What am I doing wrong?
Here are the pertinent code snippets:
In app A:
public void openTest Intent(String filePath) {
    Intent testIntent = new Intent("com.example.appB.TEST");
    testIntent.addCategory(Intent.CATEGORY_DEFAULT);
    testIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    testIntent.setDataAndType(Uri.parse("file://"+filePath),"text/plain");
    try {
        startActivityForResult(testIntent, OPEN_NEW_TERM);
    } catch (ActivityNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

In app B:
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.getAction().equals("com.example.appB.TEST")) {
        Uri fileUri = intent.getData();
        File srcFile = new File(fileUri.getPath());
        File destFolder = getFilesDir();
        File destFile = new File(destFolder.getAbsolutePath()+srcFile.getName());
        try {
            copyFile(srcFile,destFile);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

public void copyFile(File src, File dst) throws IOException {
    InputStream in = new FileInputStream(src);  //**this is where it dies**
    OutputStream out = new FileOutputStream(dst);

    // Transfer bytes from in to out
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }
    in.close();
    out.close();
}

It is when I am creating in that it gets the exception.  Any thoughts on why?

A:
What am I doing wrong?

You are trying to use FLAG_GRANT_READ_URI_PERMISSION for a file. That only works for content:// Uri values, pointing to a stream served by a ContentProvider.
Use FileProvider to serve up your files via such a ContentProvider. This is also covered in a training guide, and here is a sample project demonstrating its use.


text:
Q: Primefaces no está definido - error javaScript Buenas,
Estoy usando Primefaces versión 5.3 junto con bootsfaces para mi capa web. El problema que tengo es que me sale el error "Primefaces is not defined" en un facelet donde hago uso del componente poll deste esta forma:
<b:row id="results">
   <c:if test="${not empty twitterSearch.text or not empty twitterSearch.result }">
       <b:panel  title="Tweets for #{twitterSearch.text}" collapsible="false" look="info" col-md="6">
         <h:form>
            <p:poll interval="3" update="sentimentChart"  />
            <p:chart id="sentimentChart" type="pie" model="#{liveSentimentChartBean.liveCharts.get(twitterSearch.text)}" style="width:400px;height:300px"/>
         </h:form>
       </b:panel>
   </c:if>
</b:row>

Este facelet llamado analysis.xhtml es un facelet client de la template app_template.xhtml y por tanto su elemento raíz es el siguiente:
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:b="http://bootsfaces.net/ui"
                template="/WEB-INF/templates/app_template.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
                xmlns:p="http://primefaces.org/ui">

Sé que el problema se suele deber a que falta la etiqueta head en el facelet, pero esta está definida en el template de esta forma:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:b="http://bootsfaces.net/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <h:head>
        <meta charset="utf-8" />
        <title>#{i18n['page.title']}</title>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta name="revisit-after" content="7 days" />
        <meta name="DISTRIBUTION" content="GLOBAL" />
        <meta http-equiv="PRAGMA" content="NO-CACHE" />
    </h:head>

    <h:body>
        <c:set var="root" value="#{request.contextPath}/" />
        <ui:insert name="navbar">
            <ui:include src="/WEB-INF/content/navbar.xhtml"/>
        </ui:insert>
        <b:container>
            <ui:insert name="content" />
        </b:container>
        <ui:insert name="footer">
            <ui:remove>
                <ui:include src="/WEB-INF/content/footer.xhtml"/>
            </ui:remove>
        </ui:insert>
    </h:body>
</html>

¿Alguien sabe a que puede deberse el problema?
Gracias por adelantado :)

A: En tu archivo análisis pon también
xmlns:p="http://primefaces.org/ui"
o
< h:outputScript library="primefaces" name="primefaces.js" />


text:
Q: How should a blog be structured to easily extract its data? I'm currently using Wordpress to run my website.  However, with each new release I become more concerned with software bloat and the convoluted table structures used to store my data.  Maybe this is a fruitless pursuit.  Features are always added to blogging software until it claims to be a CMS--and at that point your data is probably stuck.

A: You do have the option of sticking with the 2.0 branch. This will be maintained with just bug fixes until 2010. Take a look at http://wordpress.org/download/legacy/

A: I also sometimes worry about the large changes WordPress undergoes.
However, since all the important data (the posts themselves and the comments) are stored in a database, it does not seem difficult to extract them in case of need (moving to a different system, or just backup). Even if the table structure gets more complex, the MySQL DB WordPress uses is easy to access and extract data from.
I'm sure that it is easy to find such extractors freely floating in the web.

A: Wordpress has an 'export' feature. It downloads most of the data such as posts, pages and comments in an XML file. These XML files can be imported into other Wordpress installations.
You can also create a simple importer to import that data else where.

A: None of the previous answers have really addressed the title of this question.
How should the tables be constructed for a blog? That entirely depends on what you want to do with it, honestly.
One approach could be to have a posts table and a comments table. The posts table could have the title, content, date, and a post id. The comments table could have a post id, comment id, commenter note, and content.
But that's really only relevant if you're building it yourself. None of the blogging tools I have ever seen are very inefficient in terms of space usage, and all of them provide import tools from "standard" formats (from blogger, wordpress, moveabletype, etc to any where else). And don't forget that they will all publish posts and comments via RSS, which makes them eminently portable.
WordPress in particular is still only 1.2 MB as a tar.gz. If that's big enough to be concerned about bloat, I'd strongly suggest building one yourself, or moving to a hosted blogging platform :)


text:
Q: Apache reached MaxRequestWorkers, but nothing in access_log This is in Apache error_log:
[Thu Nov 17 17:08:22.935022 2016] [mpm_event:error] [pid 27241:tid 139681776355296] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
And in access_log there is nothing between 16:41 and 17:21.
Also, Server Density shows at 17:08 (same time as Apache error_log)- Load Average: 34- php-cgi (nobody) Processes: 87- php-cgi (nobody) CPU: 140%
How is it possible that apache says reached MaxRequestWorkers and there is nothing in its access_log around that time?
Notes:

*

*I run some crons but they show up as a user (so not as "nobody") and they run in php cli (so not via apache)

*In htop, "nobody" usually has /usr/sbin/httpd

*Centos 6, WHM cPanel, Apache 2.4

A: It's an expected behavior. All your httpd processes/threads were doing some long-running php tasks to serve multiple user sessions. Once the limit MaxRequestWorkers was reached, no more requests were served. An entry appears in the access_log after the request completes with some status, such as normal (200) or timeout (502). Hence if no new request is completed, there are no lines in the access_log, even if many browsers were trying to connect all the time.


text:
Q: Validating form using jquery I was reading a tutorial on form validation and I followed it. The form is still not validated. Please help me out. Thanks
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="stylesheet.css" type="text/css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script>
$(document).ready(function(){
    $("#registerForm").validate();
  });
</script>

<title>9am Resource Agency</title>
</head>

Here is the form,
 <form id="form1" class="registerForm" method="post" action="mailsent.php">
                      <input name="name" class="required" type="text" minlength="3"  id="name"  style="font-family: Verdana; color:#FFFFFF; ; font-size: 13px; background-color: #0E0E0F;border: 1px solid #740086; margin-bottom:10px;  width:385px;" size="32" value="Name" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>
                      <input name="email" class="required" type="text" id="email" minlength="5"  style=" font-family: Verdana;  font-size: 13px;  color:#FFFFFF; background-color: #0E0E0F; border: 1px solid #740086;  margin-bottom:10px;   width:385px;" size="38" value="Email" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />
                      <input name="phone"  type="text" id="phone" minlength="7" style=" font-family: Verdana; color:#FFFFFF; font-size: 13px;background-color: #0E0E0F; border: 1px solid #740086; width:385px;  margin-bottom:10px;" size="385" value="Phone #" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>
                     <textarea
                     minlength="10"
                     class="required"
    name="message"
    cols="37"
    rows="12"
    id="message"
    style="font-family:Verdana; color:#FFFFFF; font-size:13px; background-color:#0E0E0F; border:1px solid #740086; width:385px;margin-bottom:10px;overflow:hidden;"
    onFocus="if(this.value==this.defaultValue)this.value='';"
    onBlur="if(this.value=='')this.value=this.defaultValue;">
Message
</textarea>

                      <input style="margin-left:303px; margin-top:20px;" type="image" src="logonbutton.png" name="Submit" value="Submit" />
   </form>

A: You're using $("#registerForm").validate(); but your form id is form1.
Change to:
$("#form1").validate();

A: working demo http://jsfiddle.net/dMTCq/
Good link: http://docs.jquery.com/Plugins/Validation/validate
Also something extra for you from one of my previous demo: http://jsfiddle.net/CRfuZ/
This should help :)
code
jQuery(function($) {
    $("#form1").validate();
});

*and in case you want to use for class use * . like this.
jQuery(function($) {
    $(".registerForm").validate();
});

A: There is no need to include two jquery-core file in the head.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>

A: I'm curious as to why you have 2 versions of jQuery in your script tags. Version 1.6.1 and version  1.3.2
You also are not including jQuery unobtrusive validation which is needed if you want to perform jQuery validation.
I suggest removing the version 1.3.2 line, because it is conflicting with 1.6.1 and then adding the necessary scripts for validation. In this order:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

If you want to the most current version of jQuery I suggest instead of using the 1.6.1 script use this.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

These 4 lines can be placed in your _Layout view in the head section so that they are available to all views. Then you don't have to place these in your individual Views at all


text:
Q: Hyperledger Fabric and NodeJS - How to convert buffer I'm using Hyperledeger Fabric v1.1 and I'm developing a backend in NodeJs.
Using the Fabric NodeJS SDK I can successfully query the blockchain and retrieve the information of the current block.
However, I can't properly convert the hash of the block from the Buffer type.
Below the snippet of the json that I retrieve from the blockchain.
currentBlockHash:{
  "buffer": {
    "type": "Buffer",
    "data": [8,38,18,32,150,172,137,248,232,203,159,23,44,4,75,29,169,171,120,165,83,22,158,45,93,3,37,120,100,164,229,211,49,194,208,181,26,32,119,47,159,196,237,190,29,24,139,56,212,190,59,126,77,80,76,228,28,171,108,134,241,97,162,190,84,39,240,25,115,135]
  }
}

How can I convert this to a normal string in utf-8 in NodeJS?

A: You can use arraybuffer-to-string npm package.
var str = arrayBufferToString(buffer, encoding='utf8')


text:
Q: Statical and dynamical column in QML TableView I would like to show in one column static data like data titles and on second column show dynamically populated data from c++ part of program. I want to send dynamical data from qt c++ part as QStringList. Data comes from sql database and i only need static titles on first column and data on second. Any ideas ?
[EDIT]
I have QStringList passed from c++ with dynamically populated data and Listmodel in QML with names describing each value form QStringList. I want to show both lists in one QML TableView. I wanted to merge them in ListModel like
ListElement {
         title: "Part material"
         data: handlecombo.stringmodel4x.at(1).toString}
ListElement {
         title: "Part dimension"
         data: handlecombo.stringmodel4x.at(2).toString}

But i can't use scripts in listmodel


text:
Q: Issue compiling a piece of open source software written in C++ on MacOS Sierra I am trying to install a piece of open source software (AB3P) on MacOS Sierra. When I issue the command make I get this error: ld: library not found for -lops. The make command issued before the error is thrown is: g++ -g -o make_wordSet make_wordSet.o -L./Library -lops -D_POSIX_C_SOURCE=199506L -lpthread

I have the latest version of MacOS Sierra and Xcode + the Xcode command line developer tools (as of this writing). In addition gcc is installed, the command gcc --version returns:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I am not sure how to approach the problem, any suggestions?

A: Get into Library folder, and make it first.

cd Library
make

There it will find the libops.a
On the updated version of the Ab3P as @ridoro1 mentioned, you need to make first NCBITextLib and edit the both Makefiles under Ab3P and also under Library.
First get into Library and make it. Then make Ab3P.

A: You need to download this library and compile it, then edit Makefile in the folder of this library and the Makefile in the lib folder inside it to point to NCBITextLib-master folder on your disk, after that You can compile the ABP3 library.


text:
Q: Add "Zoomability" function to a d3.js map processing data from dc.js/crossfilter I'm working with this map.
Here is the file used to render it.
I want add the click-to-zoom via transform functionality demonstrated in that mbostock example.
In the map I'm using, this is the code that draws the map:
        //This is the data for the Map
    d3.json("data/europe5.json", function (error, eu) {

        console.log('map', eu)
        usChart.width(590)
                .height(500)
                .dimension(countries)
                .group(countriesJobsdSum)
                .projection(d3.geo.mercator()
                    .scale((1200 + 1) / 2 )
                    .translate([660 / 4, 3360 / 4])
                    .precision(.1)
                    )
                .colors(d3.scale.quantize().range(["#E2F2FF", "#C4E4FF", "#9ED2FF", "#81C5FF", "#6BBAFF", "#51AEFF"]))
                .colorDomain([0, 200])
                .colorCalculator(function (d) { return d ? usChart.colors()(d) : '#ccc'; })
                .overlayGeoJson(eu.features, "countries", function (d) {
                    return d.properties.name;
                    //return d.properties.Country;
                })
                .transitionDuration(0)
                .title(function (d) {
                    return "Country: " + d.key + "\nNumber of Jobs: " + numberFormat(d.value ? d.value : 0) ;
                });

but it's inside of a larger function. The zoom feature is also a function, I'm not sure how these two functions could interoperate or how I might re-factor them to interact harmoniously together.
How to do that?
I would appreciate any and all insights or reference materials.
EDIT, added elsewhere: "I was trying to do it with this "renderlet" http://plnkr.co/edit/OWLStxfPMtDuZeHHvvH1?p=preview, but... doesn't seem that is the right direction."


text:
Q: Convert a collection of typed dependencies into a tree I am struggling with a problem for a while. Suppose you have a collection of typed dependencies (from edu.stanford.nlp.trees.TypedDependency) and you want to convert them to a tree (from edu.stanford.nlp.trees.Tree).
For instance:
// Suppose you get the typed dependencies from a grammatical structure object
Collection<TypedDependency> atd = gs.allTypedDependencies();
Tree t = null;

Now, how could I transform the object atd into a tree (which could be stored in t)?

A: These are not equivalent types. Typed Dependencies define a dependency tree (SemanticGraph), whereas the Tree class represents a constituency tree. While there is actually code to produce a dependency tree from a constituency tree, there is nothing in CoreNLP that would do the reverse. As far as I know, this is actually a nontrivial task.
My recommendation is to run the parse annotator rather than the depparse annotator, and get a Tree that way (see TreeCoreAnnotations.TreeAnnotation).


text:
Q: Unable to download Spring Boot 2.1.7.RELEASE I'm not familiar with Spring eco and  to run gradle to install required modules.
I just cloned this spring boot repo and tried to run it

git@github.com:didinj/springboot-mongodb-security.git

Plugin [id: 'org.springframework.boot', version: '2.1.7.RELEASE'] was not found in any of the following sources:

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.springframework.boot', version: '2.1.7.RELEASE'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.7.RELEASE')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    at .....

How come? Does this mean the 'org.springframework.boot', version: '2.1.7.RELEASE' is not in this world anymore? If so, the package management system is holly crap.
What should I do? I cloned bunch of git repos from the github and try to run gradle and always have this problem.
Java ecosystem is too broken. Unlike NPM or ruby gem which is so stable and no-brain to use.
Is there related to my gradle setting, java version, or anything else?

A: Use JDK 8. Change or config MongoDB at https://github.com/didinj/springboot-mongodb-security/blob/master/src/main/resources/application.properties
git clone https://github.com/didinj/springboot-mongodb-security.git
cd springboot-mongodb-security
gradlew bootRun

A: There is no 2.1.7.RELEASE version of this plugin available at Maven Central Repository (which is used in your build.gradle script), since this version is outdated. But it's still accessible at Gradle Plugin Repository (https://mvnrepository.com/artifact/org.springframework.boot/org.springframework.boot.gradle.plugin/2.1.17.RELEASE).
So you should either use least available plugin version from Central repository (2.2.0.RELEASE) or add Gradle Plugin Repository to the repositories section of  your build.gradle
repositories {
  mavenCentral()

  maven { url "https://plugins.gradle.org/m2/" }
}


text:
Q: Angular2 Observables - Creating my own - subscriber undefined I can't quite tell if this is a scoping issue or an issue with how I've set up my observables, but maybe you can help.
Firstly, my logic. My overall aim is to be able to check if some data is held locally before sending off a http.get request for it. What I'd like to do is return the locally held data back if it exists, and I thought that I could make this return an observable so that I could subscribe to the output of this function regardless of if it returned local data or remote data. Any thoughts on this logic would be appreciated!
I am following this blog post by Cory Rylan to implement my own observable. I am running into a problem where I cannot get my Observer to be defined in my getData function.
Here is Cory's working demo
Here is my not-working demo - You can see in the log that this._dataObserver in the service is undefined, whereas in Cory's it is. This is what is causing me issues.
Here are snippets from the code:
App.ts
@Component({
  selector: 'my-app',
  template: `
    <landing-page></landing-page>
  `,
  providers: [DataService],
  directives: [LandingPageComponent]
})
export class App {
  constructor() { }
}

bootstrap(App, [HTTP_BINDINGS])
  .catch(err => console.error(err));

LandingPageComponent.ts
@Component({
  selector: 'landing-page',
  template : `
    hello
  `,
})
export class LandingPageComponent implements OnInit{
  data : Observable<any[]>;
  constructor(
    private _dataService : DataService
  ) { }

  ngOnInit() {
    this.data = this._dataService.data$;
    this._dataService.getData();
  }
}

DataService
@Injectable()
export class DataService {

   data$ : Observable<any[]>; // data stream
   private _baseUrl: string;
   private _dataObserver : Observer<any[]>;
   private _dataStore : {
    data : any[]
   };

  constructor (
    private _http: Http
  ) {
    this._baseUrl  = 'http://56e05c3213da80110013eba3.mockapi.io/api';
    this.data$ =  new Observable(observer => this._todosObserver = observer).share();
    this._dataStore = { data: [] };
  }

  /** **************
  * Public functions
  *****************/

  getData () {
    this._http.get(`${this._baseUrl}/todos`)
      .map(data => data.json())
      .subscribe( data => {
      this._dataStore.data = data;
      console.log(this._dataObserver);   //<------ This is undefined for me!
      this._dataObserver.next(this.data);
    },
    error => {
      console.log('couldn\'t load data! ' + error );
    });

  }

}

Thank you for any thoughts

A: _dataObserver is null because you don't subscribe on the associated observable. Don't forget that observables are lazy...
You could try the following:
ngOnInit() {
  this.data = this._dataService.data$.subscribe(data => { // <-----
    console.log(data);
  });
  this._dataService.getData();
}

Edit
In addition, there is a typo in your code:
this.data$ =  new Observable(observer => this._todosObserver = observer).share();

You should use _dataObserver instead of _todosObserver:
this.data$ =  new Observable(observer => this._dataObserver = observer).share();


text:
Q: Sudo apt-get update in raspberry pi is not working after raspbian updates & folder structure change in http://raspbian.raspberrypi.org/raspbian/ Since recently i am facing an issue with sudo apt-get update and sudo apt-get upgrade, There is an official updates from http://raspbian.raspberrypi.org/raspbian/
Issue is listed below
santhosh@raspberrypi:/ $ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
libgnutls30 libjavascriptcoregtk-4.0-18 libnss3 libsox-fmt-alsa libsox-fmt-base libsox3 libwebkit2gtk-4.0-37 sox
Err:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libgnutls30 armhf 3.7.1-5+deb11u3
Connection failed [IP: 103.195.68.3 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
I tried by editing the /ect/apt/source.list file by replacing
from
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
To
http://raspbian.raspberrypi.org/raspbian/dists/
deb http://raspbian.raspberrypi.org/raspbian/dists/bullseye main contrib non-free rpi
It updates few packages but again it start to through the error's like
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/dists/bullseye/dists/main/contrib/binary-armhf/Packages
looking for solution to resolve this issue
Regards
Santhosh

A: --change file permission of sources.list file in /etc/apt using chmod 777.
--put ## in front of present repository in /etc/apt/sources.list.
--add  deb http://ftp.crifo.org/raspbian/raspbian/ bullseye main contrib non-free rpi   to sources.list.
-- save sources.list .


text:
Q: How to display custom attribute name after login into site in magento? I want to display custom attribute name after welcome message when login in to site. I have added custom attribute in "full_name" in customer account so i need to display this full name after welcome message in header after login in to site.
My Header.php file is
class Mage_Page_Block_Html_Header extends Mage_Core_Block_Template
{
    public function _construct()
    {
        $this->setTemplate('page/html/header.phtml');
    }

    public function getIsHomePage()
    {
        return $this->getUrl('') == $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
    }

    public function setLogo($logo_src, $logo_alt)
    {
        $this->setLogoSrc($logo_src);
        $this->setLogoAlt($logo_alt);
        return $this;
    }

    public function getLogoSrc()
    {
        if (empty($this->_data['logo_src'])) {
            $this->_data['logo_src'] = Mage::getStoreConfig('design/header/logo_src');
        }
        return $this->getSkinUrl($this->_data['logo_src']);
    }

    public function getLogoSrcSmall()
    {
        if (empty($this->_data['logo_src_small'])) {
            $this->_data['logo_src_small'] = Mage::getStoreConfig('design/header/logo_src_small');
        }
        return $this->getSkinUrl($this->_data['logo_src_small']);
    }

    public function getLogoAlt()
    {
        if (empty($this->_data['logo_alt'])) {
            $this->_data['logo_alt'] = Mage::getStoreConfig('design/header/logo_alt');
        }
        return $this->_data['logo_alt'];
    }

    public function getWelcome()
    {
        if (empty($this->_data['welcome'])) {
            if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
                $this->_data['welcome'] = $this->__('Welcome, %s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()));
            } else {
                $this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');
            }
        }

        return $this->_data['welcome'];
    }
}

Anybody knows answer please share. I am new in Magento.


text:
Q: SSL Certification for telegram api webhook I've set self-signed SSL certificate on my local virtual host, setup redirect in router from MyGlobalIP:8443 to MyLocalIP:443
It works fine for browser, but if I check my hook with telegram api method getWebhookInfo I get a error message
"SSL error {336134278, error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed"
I cant find any solution how to fix this. I cant even find kind of problem, bad certificate or bad apache settings or something else.
php 7.1
apache 2.4
mac os x sierra


text:
Q: Laravel - How to convert time in seconds to human readable In my Laravel-8, I have this in my view blade:
{{$duration['time_spent'] ?? '' }}

time_spent is in seconds.  How do I convert it to hours in human readable
For instance, 4 Hours 20 Minutes
time_spent is something like:   124323.4
When I did
{{$duration['time_spent']->diffForHumans() ?? '' }}

I got this error:

Call to a member function diffForHumans() on float

How do I resolve it?
Thanks

A: Usually you can use Carbon for all actions with date in laravel (https://carbon.nesbot.com/)
For your task:
CarbonInterval::seconds($duration['time_spent'])->cascade()->forHumans();

UPD:
blade file
\Carbon\CarbonInterval::seconds($duration['time_spent'])->cascade()->forHumans();

A: You can try this
{{gmdate("H:i:s", $duration['time_spent'])?? ''}};

A: I'm sure Carbon has a dedicated method for this operation, but just for fun, I tried to create a function to do the job.
I tested my code with small and large numbers. I know it works with small ones, and it seems OK with large numbers, but I didn't verify.
public function convertTime($sec)
{
    $timeParts = [];
    foreach ($this->durations() as $tf => $duration) {
        extract($this->createTimeString($sec, $tf, $duration));
        array_push($timeParts, $timeString);
    }
    return implode(' ', array_filter($timeParts, function ($item) {
        return $item != '';
    }));
}

private function durations()
{
    return array_reverse([
        'second' => 1,
        'minute' => $minute = 60,
        'hour' => $hour = $minute * 60,
        'day' => $day = $hour * 24,
        'week' => $day * 7,
        'month' => $day * 30,
        'year' => $day * 365
     ]);
}

private function createTimeString($sec, $tf, $duration)
{
    $howManyLeft = floor($sec / $duration);
    return [
        'sec' => !$howManyLeft ? $sec : $sec - $howManyLeft * $duration,
        'timeString' => !$howManyLeft ? '' : $howManyLeft . " $tf" . ($howManyLeft > 1 ? 's' : '')
    ];
}

// convertTime(3684615) returns 1 month 1 week 5 days 15 hours 30 minutes 15 seconds


text:
Q: Python RandomForest - Unknown label Error I have trouble using RandomForest fit function
This is my training set
         P1      Tp1           IrrPOA     Gz          Drz2
0        0.0     7.7           0.0       -1.4        -0.3
1        0.0     7.7           0.0       -1.4        -0.3
2        ...     ...           ...        ...         ...
3        49.4    7.5           0.0       -1.4        -0.3
4        47.4    7.5           0.0       -1.4        -0.3
... (10k rows)

I want to predict P1 thanks to all the other variables using sklearn.ensemble RandomForest
colsRes = ['P1']
X_train = train.drop(colsRes, axis = 1)
Y_train = pd.DataFrame(train[colsRes])
rf = RandomForestClassifier(n_estimators=100)
rf.fit(X_train, Y_train)

Here is the error I get:
ValueError: Unknown label type: array([[  0. ],
       [  0. ],
       [  0. ],
       ...,
       [ 49.4],
       [ 47.4],

I did not find anything about this label error, I use Python 3.5.
Any advice would be a great help !

A:
According to this SO post, Classifiers need integer or string labels.

You could consider switching to a regression model instead (that might better suit your data, as each datum appears to be a float), like so:
X_train = train.drop('P1', axis=1)
Y_train = train['P1']
rf = RandomForestRegressor(n_estimators=100)
rf.fit(X_train.as_matrix(), Y_train.as_matrix())

A: When you are passing label (y) data to  rf.fit(X,y), it expects y to be 1D list. Slicing the Panda frame always result in a 2D list. So, conflict raised in your use-case. You need to convert the 2D list provided by pandas DataFrame to a 1D list as expected by fit function.
Try using 1D list first:
Y_train = list(train.P1.values)

If this does not solve the problem, you can try with solution mentioned in MultinomialNB error: "Unknown Label Type":
Y_train = np.asarray(train['P1'], dtype="|S6")

So your code becomes,
colsRes = ['P1']
X_train = train.drop(colsRes, axis = 1)
Y_train = np.asarray(train['P1'], dtype="|S6")
rf = RandomForestClassifier(n_estimators=100)
rf.fit(X_train, Y_train)

A: may be a tad late to the party but I just got this error and solved it by making sure my y variable was type(int) using
 y = df['y_variable'].astype(int)

before doing a train test split, also like others have said you problem seems better fit with a RFReg rather then RF


text:
Q: Unable to change brightness using keys after recent 13.10 update I have been using Ubuntu 13.10 for months now without too many hassles. But a couple of days back, my system offered to install this major update and of the many things that have gone wrong, the most prominent one is I am unable to change the brightness of my laptop (Dell Inspiron 15R) using my brightness hotkeys and as far as my knowledge goes, you can't do this graphically using Ubuntu's settings (please correct me if I am mistaken).
How can I rectify this? Please help my poor eyes!

A: Are you running nvidia drivers per chance? This seems to be a common issue. Try installing the xbacklight package as a workaround. It won't fix your function keys but at least you can look for an answer without melting your retina's.
$ Sudo apt-get install xbacklight

You can then adjust the settings from a terminal using commands found here.
To increase brightness by 20%:
$ sudo xbacklight -inc 20

Alternatively to decrease:
$ sudo xbacklight -dec 20

Or use the -set parameter to define the exact level:
$ sudo xbacklight -set 50

If this works for you may want to add a new startup entry so it runs on boot. Open "Startup Applications" and add the following details:
Name: Brightness
Command: xbacklight -set 60
Click add and you are done! Hope this helps.

A: I have Dell Inspiron 15 and in a fresh ubuntu installation I always do the following to fix the brightness
Edit the grub configuration file by running in terminal :
gksu gedit /etc/default/grub

Change this line:
GRUB_CMDLINE_LINUX=""
To:
GRUB_CMDLINE_LINUX="acpi_osi=\"!Windows 2012\""

Save the file And Update Grub:
sudo update-grub

Reboot and test.


text:
Q: Limpiar controles masivo en VB.NET Tengo el siguiente código para limpiar los controles de un formulario, éstos estaban agrupados por GroupBox y antes me funcionaba perfecto, ahora tuve que añadir un panel para controlar mejor mi formulario y este código ya no me hace la tarea que requiero, alguna sugerencia?
Public Sub limpiarControles()
    Dim ctrl As Control
    Dim ctrlHijo As Control

    For Each ctrl In Me.Controls
        If TypeOf ctrl Is TextBox Then
            ctrl.Text = ""
        ElseIf ctrl.HasChildren Then
            For Each ctrlHijo In ctrl.Controls
                If TypeOf ctrlHijo Is TextBox Then
                     ctrlHijo.Text = ""
                End If
            Next
        End If
    Next

A: Prueba esto para hacer una repasada para que así no falle hasta no dejar ni un texto...

Public Function existenControles() As Boolean
    existenControles = false
    On Error Resume Next
    Dim ctrl As Control
    Dim ctrlHijo As Control

    For Each ctrl In Me.Controls
        If TypeOf ctrl Is TextBox Then
           existenControles = true
           Exit Function
        Else
            If ctrl.HasChildren Then
             For Each ctrlHijo In ctrl.Controls
                If TypeOf ctrlHijo Is TextBox Then
                     existenControles = true
                     Exit Function
                End If
             Next
            End If
        End If
    Next
End Function

Public Sub limpiarControles()
  On Error Resume Next
  Dim ctrl As Control
  Dim ctrlHijo As Control

  Do Until (existenControles = True)
    For Each ctrl In Me.Controls
        If TypeOf ctrl Is TextBox Then
            ctrl.Text = ""
        Else
            If ctrl.HasChildren Then
             For Each ctrlHijo In ctrl.Controls
                If TypeOf ctrlHijo Is TextBox Then
                     ctrlHijo.Text = ""
                End If
             Next
            End If
        End If
    Next
  Loop
End Sub


text:
Q: Winforms taskbar hide/overlay I m trying to solve problem in my fullscreen application. When I start the app it is fullscreen. That is handled by this code
    public MainForm()
    {
        //this.TopMost = true;
        InitializeComponent();
        this.FormBorderStyle = FormBorderStyle.None;
    }

    private void Hlavni_Load (object sender, EventArgs e)
    {
        this.WindowState = FormWindowState.Maximized;
        //this.Bounds = Screen.PrimaryScreen.Bounds;
    }

When opening another fullscreen Form, everything works fine. Taskbar is cover with and doesn't show up. The problem occurs when I want to open 3rd form. This one is not meant to be fullscreen and serves for purpose similar to MessageBox.
While is this form open, taskbar is also visible untill the form is closed again. I tried somehow to update/change bounds of that form but it only led to making this form fullscreen.
Any idea how to show desired form and keep taskbar hidden?
Thanks in advance
EDIT
Adding the code for 3rd form
 public RadForm3()
    {
        InitializeComponent();
        //this.TopMost = true;
        this.FormBorderStyle = FormBorderStyle.None;
        this.ShowInTaskbar = false;
    }

    private void RadForm3_Load(object sender, EventArgs e)
    {
        //this.Bounds = Screen.PrimaryScreen.Bounds;
        this.CenterToScreen();
        ...
    }


text:
Q: getting previous and next record in MySQL when ordering by date and allowing duplicate dates I've tried looking up other help for this problem but I'm just not getting it. Suppose I have a table that looks like the one below.
+----+--------------+------------+
| id | date_col     | label      |
+----+--------------+------------+
| 1  | 2010-09-07   | Record 1   |
| 2  | 2010-09-03   | Record 2   |
| 3  | 2010-08-23   | Record 3   |
| 4  | 2010-08-23   | Record 4   |
| 5  | 2010-08-23   | Record 5   |
| 6  | 2010-08-12   | Record 6   |
| 7  | 2010-08-06   | Record 7   |
| 8  | 2010-08-06   | Record 8   |
| 9  | 2010-08-02   | Record 9   |
| 10 | 2010-08-01   | Record 10  |
+----+--------------+------------+

When queried, I order these records according to date_col and use id (or really any other arbitrary column) to help ordering with duplicate dates.
mysql_query("SELECT * FROM table ORDER BY date_col DESC, id DESC");

However, when I query only one of these records at a time, I want to have a previous and a next button to navigate to the next or previous record. My problem is that date_col allows duplicate values and so, for example, the query below does not work for me when determining the next record in sequence. (assume that this_date is the date_col value and this_id is the id value for the current record we are looking at)
mysql_query("SELECT id FROM table WHERE date_col > this_date ORDER BY date_col DESC, id DESC LIMIT 1");

Even this wouldn't work for me:
mysql_query("SELECT id FROM table WHERE date_col > this_date AND NOT id=this_id ORDER BY date_col DESC, id DESC LIMIT 1");

So what I'm going for is something like this - If I'm looking at the record with id #4, since its being ordered by date_col DESC id DESC, the previous record should be id #5 and the next record should be id #3, but I'm not getting these results at all.
Can someone explain how to make this work properly? Any help is much appreciated.

A: If you're going to have workable PREV and NEXT buttons in your view, you're going to need a solid conceptual foundation for record ordering in your data model.  As you have noticed, your date_col doesn't do the trick because it permits duplicates.
It seems like your concept of NEXT(id) means "the row with the smallest ID number whose ID number is greater than the current id number and whose date is greater than the current row's date."  That's OK, but it has a flaw:  PREV(NEXT(id)) isn't necessarily equal to id in all cases.  This may drive your users around the bend, and may drive your program logic into some real kludges to get things to work.
Why not simply use the serial number?
To get the "next" row, either do
SELECT id FROM table WHERE id = current_id +1

or, if your ID numbers are not guaranteed to be contiguous, do
SELECT min(id) AS id FROM table WHERE id > current_id

If you must show the next date instead of the next row with your next button, then do
SELECT id, date_col
  FROM table
 WHERE id = (
  SELECT min(id) AS id
    FROM table
   WHERE date_col > this_date
)

But if you do that be sure to create an index for date_col.  There are equivalent versions of all these queries to use for your PREV button.

A: If you can handle the initial data hit (recordset isn't huge) a very simple workout would be to query ALL into an array, order as necessary via array functions, then grab data based on the array key which is also your ordering.  Again, the limitation on this example is that if you're going to be dealing with tons of data, it's probably not the best option.

A: One way might be to have the conditional split up a bit more, to treat the greater-than and equal-to dates differently. Something like this:
    SELECT `id` FROM `table`
      WHERE
        -- Date is greater
        `date_col` > :this_date
        -- Or date is the same, but ID is greater
        OR (`date_col` = :this_date AND `id` > :this_id)
      ORDER BY `date_col` DESC, `id` DESC
      LIMIT 1


text:
Q: PostgreSQL sequence with specific formula for next value I have a column(bigint) in my table and I want every next value of it automatically be twice of previous (starting from one). How can I do it with sequences?

A: You can't do this with a SEQUENCE. You must, to generate each value:
 BEGIN;
 LOCK TABLE mytable IN EXCLUSIVE MODE;
 INSERT INTO mytable (id, blah) VALUES ( (SELECT max(id) * 2 FROM mytable), 'blah' );
 COMMIT;

The LOCK and transaction block are important, otherwise two concurrent transactions can get the same value.
This is a variant of the "gapless sequence" problem (see Google). Like there, my general advice is: don't do it. Instead, use an ordinary sequence to generate IDs if you don't have a natural key, then calculate the value on demand. In this case, double-the-previous-row is the same as saying "two to the power of the row number", so you can write:
SELECT
  id,
  2 ^ row_number() OVER (ORDER BY id) AS generated_id
FROM mytable;


text:
Q: how to config pip on osx when installed by brew? I install python using brew on mac and add a config file in ~/.pip/pip.conf
[global]
index-url=http://mirrors.aliyun.com/pypi/simple

[install]
trusted-host=http://mirrors.aliyun.com

But it doesn't work. When hit the command pip install PIL, it complains:
Collecting PIL
  The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host mirrors.aliyun.com'.
  Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL

Please advice.

A: All you need to do is mark the repository as trusted for this run of pip:
pip install PIL --trusted-host mirrors.aliyun.com


text:
Q: Indentation issue with python3 and vim A sample of my python file is
def __init__(self, csvFile, chunksize=10000):
        self.newName = csvFile[:-4]
        import ipdb; ipdb.set_trace()
        self.csvFile=csvFile
        self.chunksize=int(chunksize)
        self.headers_without_timestamp = header_without_timestamp

        self.total_rows = 0
        self.username=username
        self.password=password
        self.dbname="data"

and it is well written.
I have the little error, but I can't fix it. When I ran the command python3 Final_Fast_Version_Waqar.py ~/home/Data/DCIX_OB.csv 1000 7, I got
  File "Final_Fast_Version_Waqar.py", line 37
    import ipdb; ipdb.set_trace()
                                ^
TabError: inconsistent use of tabs and spaces in indentation

It is a problem related to the vim editor I guess because I set up an Ubuntu server and installed vim very recently. How can I fix the indentation error?

A: Since Python is sensitive to indentation, it is desirable to configure your editor to use spaces instead of tabs. For vim, you can add this to your .vimrc
set tabstop=4

Every  time you type tab, vim will use 4 spaces instead.
Also, to fix the indentation of your current file, type:
:retab

A: It might be helpful to turn on white-space characters in vim to see what is happening.
:set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:·

What you'll probably see is a mix where some lines use tabs (>·) and others use spaces (··), something that's not allowed in python.
I'd recommend setting up your vim config so that it automatically switches tabs to spaces in python. Maybe something like?
autocmd Filetype python setlocal ts=4 sw=4 sts=0 expandtab


text:
Q: I am getting empty cookie in laravel 5 I am setting cookie in such request as the following:
$cookie1 = Cookie::make('payment_method_id', 1, 60);
$cookie2 = Cookie::make('payment_value', 2, 60);

and in another page I want to read that cookie as the following:
    $val1 = Cookie::get('payment_method_id');
    $val2 = Cookie::get('payment_value');

but I got the empty, what am I missing?

A: You are only making a cookie but not attaching it with response so you should attach the cookie using something like this:
Response::withCookie(Cookie::make('payment_method_id', 1, 60));

Check the documentation for more information.

A: I hope you are setting cookie as below
$response = new Illuminate\Http\Response('Hello World');
$response->withCookie(cookie('name', 'value', $minutes))

And in next request you can get it as below,
$value = Request::cookie('name');

you can also queue cookie as below, so it will be passed on with next response automatically,
Cookie::queue('name', 'value');

Read More


text:
Q: Prove n-th root is different each other.
*

*I already know FTA and I have a question about solving $z^n = re^{ix}$. The candidates for the roots of this equation are $z=r^{\frac{1}{n}}e^{i\frac{2k\pi+x}{n}}$. The number of roots should be below $n$ by FTA, but to verify these candidates are all roots and nothing else can't be, the $z$'s which are depending on $k$ are different each other. I don't know how to prove $z$'s are distinct.

*Let $n$ is odd and $\zeta_n = e^{i\frac{2\pi}{n}}$. Surely, $\zeta_n^n$. I wonder $\zeta_n$ cannot be 1 before the power of $n$. That is $\zeta_n^2, \ldots \zeta_n^{n-1}$ cannot be 1. Is it right?. How can we prove it?

A: Hints:

*

*$\;z^n=a \iff p(z)=z^n - a = 0\,$, and if $\,p(z)$ had a multiple root, then that root would have to be a common root with its derivative $p'(x)=n\,z^{n-1}\,$.

* Consider for example the case $\,n=4\,$ with $\,z^4=1\,$, where $\pm 1$ are also roots of $z^2=1$.

[ EDIT ]  I misread OP's point 2. as "if $\zeta_n$ is any $n^{th}$ root of unity, then is it possible that $\zeta_n^k = 1$ for some power $1 \le k \le n-1$ ?", and the second hint (now crossed out) pointed out that the answer is "yes" in general.

However, the question actually being asked was whether this can happen for the particular root $\zeta_n = e^{i\frac{2\pi}{n}}$. The answer to that is "no", which follows from the more general statement that the primitive roots of unity are those $e^{i \frac{2k\pi}{n}}$ with $\gcd(k,n)=1\,$. Since $\zeta_n$ corresponds to $k=1$ and $\gcd(1,n)=1\,$, $\zeta_n$ is always a primitive root of unity i.e. the lowest power with ${\zeta_n}^m = 1$ is $m=n$.

A: You can actually derive (1) from (2), if (2) is proven for all n.
Namely, if $z_k=r^{\frac {1}{n}}e^{i\frac {2k\pi+x}{n}}$ then $\frac {z_k}{z_l}=e^{(k-l)\frac {2i\pi}{n}}=\zeta_n^{k-l} $ for $0\le l\le k\lt n $. Thus, it suffices to show that $\zeta_n^k=1$ (where $0\le k\lt n $) only for $k=0$.
To prove (2), note that $\zeta_n^k=\cos\frac {2k\pi}{n}+i\sin\frac {2k\pi}{n} $. The real part must be $1$, and $ \cos\alpha=1$ only for $\alpha=2m\pi $ for some  integer $m $, so it follows that $\frac {k}{n} $ is an integer. This is possible only for $k=0$.


text:
Q: Programmatically check a custom treeview checkbox I'm trying to programatically check a custom checkbox in a treeview. What I mean by custom, is that I call the below code to enable these checkboxes:
SetWindowLong(TreeView1.Handle, GWL_STYLE, GetWindowLong(TreeView1.Handle, GWL_STYLE) or TVS_CHECKBOXES)

I tried the below code to check it, but it did not work.
  Node := TreeView1.Selected;
  TVItem.mask := TVIF_STATE;
  TVItem.hItem := Node.ItemId;
  TreeView_GetItem(Node.TreeView.Handle, TVItem);
  TVItem.stateMask := TVIS_CHECKED;
  TVItem.mask := TVIS_CHECKED;

Thanks in advance

A: You have your state mask wrong, there's no TVIS_CHECKED state mask (in fact there is no TVIS_CHECKED, more on that later). Check boxes are managed through an image list, this is explained in the documentation.
Additionally, of course, you have to call TreeView_SetItem:
const
  TVIS_CHECKED = 2 shl 12;
var
  Node: TTreeNode;
  TVItem: TTVItem;
begin
  Node := TreeView1.Selected;
  if Assigned(Node) then begin
    TVItem.mask := TVIF_STATE;
    TVItem.hItem := Node.ItemId;
    TreeView_GetItem(Node.TreeView.Handle, TVItem);

    TVItem.stateMask := TVIS_STATEIMAGEMASK;
    TVItem.state := TVIS_CHECKED;
    TreeView_SetItem(Node.TreeView.Handle, TVItem);
  end;
end;

Normally I'd advise to call TreeView_SetCheckState but the VCL has got a weird error in the translation of the macro.

This is the macro in the header:
#define TreeView_SetCheckState(hwndTV, hti, fCheck) \
  TreeView_SetItemState(hwndTV, hti, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), TVIS_STATEIMAGEMASK)

where
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)

This is why the made-up TVIS_CHECKED is $2000, the define shifts 2 12 bits left when fCheck is true (2 is the index of the checked image, 1 is unchecked).
This is VCL's translation:
function TreeView_SetCheckState(hwndTV: HWND; hti: HTreeItem; fCheck: BOOL): UINT;
var
  LState: UINT;
begin
  if IndexToStateImageMask(Integer(fCheck)) = 0 then
    LState := 1
  else
    LState := 2;
  Result := TreeView_SetItemState(hwndTV, hti, LState, TVIS_STATEIMAGEMASK);

where IndexToStateImageMask is
Result := I shl 12;

Strangely, the VCL shifts fCheck 12 bits and then calls TreeView_SetItemState with a state that makes no sense for a state image mask (TVIS_FOCUSED (1), TVIS_SELECTED (2)).
This is XE2, I suggest to test the macro first if you are working with a later version.

A: What do you have TVIS_CHECKED defined as? It should be:
const
  TVIS_CHECKED = $2000;

Then, assuming Value is a Boolean of whether or not the item is checked:
FillChar(TVItem, SizeOf(TVItem), 0);
TVItem.hItem := Node.ItemId;
TVItem.mask := TVIF_STATE;
TVItem.stateMask := TVIS_STATEIMAGEMASK;
if Value then
  TVItem.state := TVIS_CHECKED
else
  TVItem.state := TVIS_CHECKED shr 1;
TreeView_SetItem(Node.Handle, TVItem);


text:
Q: UILabel Swift/Storyboard returns nil I created a navigation controller with a view controller inside, containing a label. This label should be changed, when the view controller is loaded on tapping a button.
class ViewController: UIViewController {
    @IBOutlet weak var btnEmergency: UIButton!

    override func viewWillAppear(animated: Bool) {
        self.btnEmergency.backgroundColor = UIColor.redColor();
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func btnEmergencyTapped(sender: AnyObject) {
        let emergencyViewController = storyboard?.instantiateViewControllerWithIdentifier("EmergencyViewController") as! EmergencyViewController
        emergencyViewController.emergencyLabel?.text = "Notruf"
        navigationController?.pushViewController(emergencyViewController, animated: true)
    }
}

But the label text does not change when loaded. I am relatively new to SWIFT so I try to learn my ropes at the moment using optionals. So I guess the reason is, that the label is not yet instantiated when the view is being loaded on pressing the button. Therefore the default text is being shown and not the text I want to have appear on screen.
I am a little bit stuck at the moment, how to correctly change the label text, when this is an optional. So I guess I cannot expect the label to be there, when I call it. But how do I handle this correctly?

A: Instead of this, the correct way is to set a property of your emergencyViewController.
In your emergencyViewController viewDidLoad set your label text according to the property set previously.
Anything that you do between initialize of a viewController to viewDidLoad will not take effect.


text:
Q: One Button but 2 onClick actions I'm working through a general tutorial for making a fact app and when I click the 'next fact' button it works fine and moves onto the next fact. But I would also like to add a source to each fact but it would mean that I would need to have 2 Onclick actions but on 1 button and I'm really not sure how to do this.
I've looked around and I can only find ones for multiple buttons.
Facts.java:
package com.example.me.myapplication;

public class Facts {
String Facts [] = {
        "Fact 1",
        "Fact 2",

};

int i = 0;

public String nextFact()
{
    i++;
    return Facts[i];
}

}

source.java:
package com.example.me.myapplication;

public class source {
String source [] = {
        "source 1",
        "source 2",
};

int i = 0;

public String nextsource()
{
    i++;
    return source[i];
}
}

activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F44336"
tools:context="com.example.me.myapplication.MainActivity">

<TextView
android:id="@+id/factTextBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:fontFamily="@font/gothamblack"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:text="fact"
android:textAllCaps="true"
android:textColor="#fff"
android:textSize="25sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="60dp"
    android:onClick="genFact"
    android:text="Next Fact" />

<TextView
    android:id="@+id/sourceTextBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/factTextBox"
    android:layout_centerHorizontal="true"
    android:text="TextView" />

 </RelativeLayout>

MainActivity.java:
package com.example.me.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

TextView factBox;
Facts factHolder = new Facts();

TextView sourceBox;
source sourceHolder = new source();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    factBox = (TextView) findViewById(R.id.factTextBox);
    sourceBox = (TextView) findViewById(R.id.sourceTextBox);
}

public void genFact(View view)
{
    factBox.setText(factHolder.nextFact());
}

public void gensource(View view)
{
    sourceBox.setText(sourceHolder.nextsource());
}
}

A: Instead of declaring your on click function in the layout (the .xml file) use the function setOnClickListener and write your own function.
factBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                genFact(factBox); // or whatever you want
        });

A: You can use longClickListner to view the source link and onClickListner to go on next source.
You just need to return true in the longClickListner to make both of them work simultaneously.

A: you can simply use onClick inside a XML, and call onClickListener inside you code.
factBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            genFact(factBox); // or whatever you want
    });

And a second one to be called from XML
public void genFact(View view) {

factBox.setText(factHolder.nextFact()); }


text:
Q: Compile parameters for MIPS based codesourcery toolchain? I installed codesourcery cross compile toolchain for mips32 architecture on my WIN 7 machince. I want to first compile a simple 'factorial' binary for my router which is based on MIPS32. From little search on the internet, I found it is based on MIPS32 big-endian.
#cat /proc/cpuinfo
system type             : 96338W2
processor               : 0
cpu model               : BCM6338 V1.0
BogoMIPS                : 239.20
wait instruction        : no
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : no
unaligned access        : 1269919
VCED exceptions         : not available
VCEI exceptions         : not available

# cat /proc/version
Linux version 2.6.8.1 (root@WangHaiTao) (gcc version 3.4.2) #1 Wed Sep 2 10:13:53 CST 2009

The router's LIB dir contains:

ld-uClibc.so.0 libc.so.0 libcrypt.so.0 libcrypto.so.0.9.7 libdl.so.0 libm.so.0 libnvram.so libpsi.so libpsixml.so libresolv.so.0 libssl.so.0.9.7 libutil.so.0 libwlbcmcrypto.so libwlbcmshared.so libwlctl.so modules

Toolchain info: (on the host WIN 7 system)
C:\code>mips-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=mips-linux-gnu-gcc
COLLECT_LTO_WRAPPER=f:/program files/codesourcery/sourcery_codebench_lite_for_mi
ps_gnu_linux/bin/../libexec/gcc/mips-linux-gnu/4.6.3/lto-wrapper.exe
Target: mips-linux-gnu
Configured with: /scratch/cmoore/2012.03-63-linux-lite/src/gcc-4.6-2012.03/confi
gure --build=i686-pc-linux-gnu --host=i686-mingw32 --target=mips-linux-gnu --ena
ble-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with
-arch-32=mips32r2 --with-arch-64=mips64r2 --with-float=hard --with-mips-plt --en
able-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-t
emps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2012 -D__CS_SOURCERYGXX_MIN__=3 -D
__CS_SOURCERYGXX_REV__=63 %{O2:%{!fno-remove-local-statics: -fremove-local-stati
cs}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}
}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu -
-enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2012.03-63' --wi
th-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=
/opt/codesourcery --with-sysroot=/opt/codesourcery/mips-linux-gnu/libc --with-bu
ild-sysroot=/scratch/cmoore/2012.03-63-linux-lite/install/host-i686-mingw32/mips
-linux-gnu/libc --with-libiconv-prefix=/scratch/cmoore/2012.03-63-linux-lite/obj
/host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr --with-gmp=/scratch/cmoore
/2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr
--with-mpfr=/scratch/cmoore/2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-
linux-gnu-i686-mingw32/usr --with-mpc=/scratch/cmoore/2012.03-63-linux-lite/obj/
host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr --with-ppl=/scratch/cmoore/
2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr -
-with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with
-cloog=/scratch/cmoore/2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-linux
-gnu-i686-mingw32/usr --with-libelf=/scratch/cmoore/2012.03-63-linux-lite/obj/ho
st-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr --disable-libgomp --enable-po
ison-system-directories --with-build-time-tools=/scratch/cmoore/2012.03-63-linux
-lite/obj/tools-i686-pc-linux-gnu-2012.03-63-mips-linux-gnu-i686-mingw32/mips-li
nux-gnu/bin --with-build-time-tools=/scratch/cmoore/2012.03-63-linux-lite/obj/to
ols-i686-pc-linux-gnu-2012.03-63-mips-linux-gnu-i686-mingw32/mips-linux-gnu/bin
Thread model: posix
gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-63)

I tried the following compile parameters:

*

*mips-linux-gnu-gcc -mips32 -muclibc -o factorial factorial.c
When I ran the output binary on the MIPS box, it just printed "can't load library 'libgcc_s.so.1' ".

*

*mips-linux-gnu-gcc -muclibc -mips32 -static-libgcc -s -o factorial factorial.c
When I run its output, it prints 'sigsegv'.
What is wrong here? What compiler parameter should I enter? Please help me.

A: Do you have libgcc_s.so.1 on teh file system? If not, the toolchain will have a folder to copy onto the file system. Do that.
If you do, ensure LD_LIBRARY_PATH is correctly set.
EDIT: Generic issue resolution
When you create a executable, you link to libraries. Those libraries must also be present in the environment where you run the executable. Hence in general in a embedded system 3 things must match

*

*The kernel headers

*The toolchain

*The file system

Here is how they are related
Your kernel headers are used as #include in your program in some form finally. So what headers the toolchain uses must match the actual one running and will be present in the file system.
The toolchain will consist of libraries to link to, so that the executable can be created [think libc and others]. These must be the same present in your runtime environment which is your filesystem
The toolchain must create a format agreable to your kernel. Executable format.
So in general if you don't have a file in your filesystem while trying to execute it should come from some sdk or your toolchain.
If you have it in the filesystem then you can instruct your toolchain to use it from there.
One way to get around the problem if you do not have the libraries in the filesystem for some reason is to build static executables. But you must be sure you know what you are doing.
EDIT: Specific issue you are facing
If you filesystem is readonly then either you already have everything on it and a sdk is provided to develop against. If you dont have that you can still develop by getting your toolchain to use libraries from your filesystem [think -I, -L].
EDIT 2:
Your file system seems to be a ucLibc one. Your toolchain seems to be built against a libc. There is your mismatch.
Now you seem to have a read only file system with no development sdk. So I am not sure the following will work.
Your toolchain has to be configured to use only the files from your filesystem and configured for ucLibc. If the router guys have made sure all files needed for development is available in the rilesystem its good enough. Else you need their sdk. See above edit for explanation.

A: I have successfully compiled this
#include <iostream>
using namespace std;

int main() {
  cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
  return 0;
}

mips-linux-gnu-g++ -muclibc -mips32  main.cpp -o main