qid
int64
1
74.6M
question
stringlengths
45
24.2k
date
stringlengths
10
10
metadata
stringlengths
101
178
response_j
stringlengths
32
23.2k
response_k
stringlengths
21
13.2k
42,297,695
I have a numpy binary array like this: ``` np_bin_array = [0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] ``` It was 8-bit string characters of a word originally, starting from the left, with 0's padding it out. I need to convert this back into strings to form the word again and strip the 0's and the output for the above should be 'Hello'. Thanks for your help!
2017/02/17
['https://Stackoverflow.com/questions/42297695', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7580607/']
You can firstly interpret the bits into an array, using [`numpy.packbits()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.packbits.html), then convert it to an array of bytes by applying [`bytearray()`](https://docs.python.org/3.6/library/functions.html#bytearray), then `decode()` it to be a normal string. The following code ``` import numpy np_bin_array = [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] print(bytearray(numpy.packbits(np_bin_array)).decode().strip("\x00")) ``` gives ``` Hello ```
``` import numpy as np np_bin_array = np.array([0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) bhello = ''.join(map(str, np_bin_array)) xhello = hex(int(bhello, 2)).strip("0x") ''.join(chr(int(xhello[i:i+2], 16)) for i in range(0, len(xhello), 2)) ```
42,297,695
I have a numpy binary array like this: ``` np_bin_array = [0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] ``` It was 8-bit string characters of a word originally, starting from the left, with 0's padding it out. I need to convert this back into strings to form the word again and strip the 0's and the output for the above should be 'Hello'. Thanks for your help!
2017/02/17
['https://Stackoverflow.com/questions/42297695', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7580607/']
You can firstly interpret the bits into an array, using [`numpy.packbits()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.packbits.html), then convert it to an array of bytes by applying [`bytearray()`](https://docs.python.org/3.6/library/functions.html#bytearray), then `decode()` it to be a normal string. The following code ``` import numpy np_bin_array = [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] print(bytearray(numpy.packbits(np_bin_array)).decode().strip("\x00")) ``` gives ``` Hello ```
I got it working with this: ``` np_bin_array = [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] yy=[] yy_word="" yy=np.packbits(np_bin_array) for i in yy: if i: j = chr(i) yy_word += str(j) print(yy_word) ```
26,911,620
After looking for a long time on the internet I could not find a real solution for my "problem". --- **What I want to do:** Compare 2 images (created with the Raspberry Pi camera in a Python script) in C. I have tried this in Python but it is too slow (+/- 1 minute per 2 images). So I would like to try it in C. I call a C function with ctypes from my Python script. The C function expect to get 2 strings containing the paths of the 2 images. The C function must return a double variable (percentage of difference) back to the Python script. --- **What I tried:** I store the images as .JPG, so I searched for a c-library that can handle the jpg-format. I found a post here on stackoverflow advising CImg. I could not get that to work on my Raspberry Pi. Said it could not find the imports. ``` #include <stdio.h> #include <stdlib.h> #include <math.h> #include "cimg/CImg.h" using namespace cimg_library; double compare_pictures(const char* path1, const char* path2); // Compares two Pictures and returns the difference value double compare_pictures(const char* path1, const char* path2) { CImg<unsigned char> image1(path1); CImg<unsigned char> image2(path2); double totalDiff = 0.0; unsigned int x, y; if (image1 == NULL || image2 == NULL) { fprintf(stderr, "One of the images does not exist\n"); return -1; } if ((image1.width() != image2.width()) || (image1.height() != image2.height())) { fprintf(stderr, "width/height of the images must match!\n"); return -1; } else { for (y = 0; y < image1.height; y++) { for (x = 0; x < image1.width; x++) { totalDiff += fabs((int)image1(x, y, 0, 0) - (int)image2(x, y, 0, 0)) / 255.0; totalDiff += fabs((int)image1(x, y, 0, 1) - (int)image2(x, y, 0, 1)) / 255.0; totalDiff += fabs((int)image1(x, y, 0, 2) - (int)image2(x, y, 0, 2)) / 255.0; } } totalDiff = 100.0 * totalDiff / (double)(image1.width() * image1.height() * 3); printf("%lf\n", totalDiff); return totalDiff; } } ``` > > CImg.h:73:18: fatal error: cstdio: No such file or directory. > compilation terminated. > > > After some tries I gave up and went back to the internet to find another library. I found libjpeg8-dev which is suitable for the Raspberry Pi and C. Nonetheless this did not help me much either, because I couldn't really find good tutorials/documentation how to use it for my purposes. --- I just want to be able to compare images created by the Raspberry Pi camera and calculate a difference percentage in a fast way (best would be in less than a second)
2014/11/13
['https://Stackoverflow.com/questions/26911620', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2289964/']
To use Coveralls with Gradle and Travis, I'm using the Coverall's Gradle plugin ([com.github.kt3k.coveralls](https://github.com/kt3k/coveralls-gradle-plugin)) and a command after success in Travis. The plugin's readme explains its usage pretty well. But if you want to check an example, you can refer to the project in which I'm using it: [Sabina Java](https://github.com/jamming/sabina) The relevant files are: `.travis.yml` and `build.gradle` Just a hint: you can enable logging in Travis adding the `--info` flag in the commands to help you spot the bugs. I hope this would be of any use after such a long time.
I also got this error (*Couldn't find a repository matching this job.*) when I specified a repo token. The Coveralls documentation suggested to specify a repo token, but didn't make it clear enough to me that you *must not* specify a repo token if you're using public repos. In other words, if your stuff is public on GitHub and on Coveralls, don't specify a repo token, or you'll get this error.
34,092,276
**EDIT**: Ive recreated the problem here <http://plnkr.co/edit/w6yJ8KUvD3cgOrr56zH3?p=preview> I'm new to angularjs and I'm trying to create a popupmodal with some data.. I can't understand why it is empty the first time I open it, but the second (and so on) its good. By good I mean that the header is there. So every time the page is reloaded it's empty the first time. Can you see what I am missing? ModalController.js: ``` angular.module("Modal") .controller("ModalController", [ "$scope", "$uibModal", "$log", "ModalService", "AuthenticationService", function($scope, $uibModal, $log, ModalService, AuthenticationService) { AuthenticationService.GetCurrentWindowsUser(function(username) { $scope.username = username; }); $scope.openModal = function () { AuthenticationService.GetItems($scope.username, function(items) { $scope.items = items; }); $scope.animationsEnabled = true; $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'modals/items.html', controller: 'ModalInstanceController', size: 'lg', resolve: { funds: function() { return $scope.items; } } }); }; } ]) .controller('ModalInstanceController', function($scope, $uibModalInstance, items) { $scope.items = items; $scope.ok = function() { $uibModalInstance.close(); }; }); ``` items.html: ``` <div class="container" ng-controller="ModalController"> <script type="text/ng-template" id="modals/items.html"> <div class="modal-header"> <h3 class="text-centered">items</h3> </div> <div class="modal-footer"> <button class="btn btn-primary" type="button" ng-click="ok()">SELECT</button> </div> </script> </div> ``` Home.html: ``` <div class="container" ng-controller="ModalController"> <button type="button" class="btn btn-default" ng-click="openModal()">Large modal</button> </div> ```
2015/12/04
['https://Stackoverflow.com/questions/34092276', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1789325/']
I managed to solve this by removing the script tag in my modal which I wanted to display ``` <div class="modal-header"> <h3 class="modal-title">I'm a modal!</h3> </div> <div class="modal-body"> <ul> <li ng-repeat="item in items"> <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a> </li> </ul> Selected: <b>{{ selected.item }}</b> </div> <div class="modal-footer"> <button class="btn btn-primary" type="button" ng-click="ok()">OK</button> <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button> </div> ``` <http://plnkr.co/edit/D4B6puSS2Z9j4DPPBTWx?p=preview>
Try the following ``` angular.module("Modal") .controller("ModalController", [ "$scope", "$uibModal", "$log", "ModalService", "AuthenticationService", function($scope, $uibModal, $log, ModalService, AuthenticationService) { AuthenticationService.GetCurrentWindowsUser(function(username) { $scope.username = username; }); $scope.openModal = function () { AuthenticationService.GetItems($scope.username, function(items) { $scope.items = items; $scope.animationsEnabled = true; $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'modals/items.html', controller: 'ModalInstanceController', size: 'lg', resolve: { items: function() { return $scope.items; } } }); }); }; } ]) .controller('ModalInstanceController', function($scope, $uibModalInstance, items) { $scope.items = items; $scope.ok = function() { $uibModalInstance.close(); }; }); ``` Could it be thet your resolve was called funds and not items as being passed into your `modalInstanceController`
34,092,276
**EDIT**: Ive recreated the problem here <http://plnkr.co/edit/w6yJ8KUvD3cgOrr56zH3?p=preview> I'm new to angularjs and I'm trying to create a popupmodal with some data.. I can't understand why it is empty the first time I open it, but the second (and so on) its good. By good I mean that the header is there. So every time the page is reloaded it's empty the first time. Can you see what I am missing? ModalController.js: ``` angular.module("Modal") .controller("ModalController", [ "$scope", "$uibModal", "$log", "ModalService", "AuthenticationService", function($scope, $uibModal, $log, ModalService, AuthenticationService) { AuthenticationService.GetCurrentWindowsUser(function(username) { $scope.username = username; }); $scope.openModal = function () { AuthenticationService.GetItems($scope.username, function(items) { $scope.items = items; }); $scope.animationsEnabled = true; $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'modals/items.html', controller: 'ModalInstanceController', size: 'lg', resolve: { funds: function() { return $scope.items; } } }); }; } ]) .controller('ModalInstanceController', function($scope, $uibModalInstance, items) { $scope.items = items; $scope.ok = function() { $uibModalInstance.close(); }; }); ``` items.html: ``` <div class="container" ng-controller="ModalController"> <script type="text/ng-template" id="modals/items.html"> <div class="modal-header"> <h3 class="text-centered">items</h3> </div> <div class="modal-footer"> <button class="btn btn-primary" type="button" ng-click="ok()">SELECT</button> </div> </script> </div> ``` Home.html: ``` <div class="container" ng-controller="ModalController"> <button type="button" class="btn btn-default" ng-click="openModal()">Large modal</button> </div> ```
2015/12/04
['https://Stackoverflow.com/questions/34092276', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1789325/']
I managed to solve this by removing the script tag in my modal which I wanted to display ``` <div class="modal-header"> <h3 class="modal-title">I'm a modal!</h3> </div> <div class="modal-body"> <ul> <li ng-repeat="item in items"> <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a> </li> </ul> Selected: <b>{{ selected.item }}</b> </div> <div class="modal-footer"> <button class="btn btn-primary" type="button" ng-click="ok()">OK</button> <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button> </div> ``` <http://plnkr.co/edit/D4B6puSS2Z9j4DPPBTWx?p=preview>
``` angular.module("Modal") .controller("ModalController", [ "$scope", "$uibModal", "$log", "ModalService", "AuthenticationService", function($scope, $uibModal, $log, ModalService, AuthenticationService) { AuthenticationService.GetCurrentWindowsUser(function(username) { $scope.username = username; }); $scope.openModal = function () { AuthenticationService .GetItems($scope.username, function(items) { $scope.items = items; $scope.animationsEnabled = true; showModal(); }); }; function showModal(){ $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'modals/items.html', controller: 'ModalInstanceController', size: 'lg', resolve: { funds: $scope.items } }); } } ]) .controller('ModalInstanceController', function($scope, $uibModalInstance, items) { $scope.items = items; $scope.ok = function() { $uibModalInstance.close(); }; }); ``` Refactored it a bit. Would hazard a guess that the first time you call the modal $scope.items is empty as the service has not finished. See if my example works. The problem will other stuff running before the async call is finished. The second time round it works as it is using the previous $scope.items data. You should try and use some form of promises. Also what dose your service look like?
2,574,504
How can I prove that polynomial ring $\mathbb{Z}[x]$ is not an integral domain ? I was thinking that $\mathbb{Z}[x]$ is not a field so it is will not form integral domain as every finite integral domain is a field but here $\mathbb{Z}[x]$ contain infinitely many element so ,it will not form field ..... Is my thinking is correct or not please tell and verify me ?
2017/12/20
['https://math.stackexchange.com/questions/2574504', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
$\Bbb Z[X]$ is actually an integral domain: --- Let $f,g \in \Bbb Z[X]$ with $fg=0$. Convince yourself (prove via induction) that if the leading coefficient of $f$ is $m$ and that of $g$ is $n$, then that of $fg$ is $mn$. However, since the leading coefficients of both sides must be equal, we must have $mn = 0$. However, $m$ and $n$ are integers, so $mn=0$ implies $m=0$ or $n=0$. The leading coefficient of a polynomial, by definition, is $0$ only when the polynomial itself is $0$, so we conclude $f=0$ or $g=0$. To conclude, for any $f,g \in \Bbb Z[X]$, $fg=0$ implies $f=0$ or $g=0$, so $\Bbb Z[X]$ is an integral domain.
$\mathbb Z [x] $ can be considered a subring of $\mathbb Q [x] $. $\mathbb Q $ is a field, so $\mathbb Q [x] $ is an integral domain, and so $\mathbb Z [x] $ must be too (as any zero divisors in $\mathbb Z [x] $ will also be zero divisors in $\mathbb Q [x] $).
2,574,504
How can I prove that polynomial ring $\mathbb{Z}[x]$ is not an integral domain ? I was thinking that $\mathbb{Z}[x]$ is not a field so it is will not form integral domain as every finite integral domain is a field but here $\mathbb{Z}[x]$ contain infinitely many element so ,it will not form field ..... Is my thinking is correct or not please tell and verify me ?
2017/12/20
['https://math.stackexchange.com/questions/2574504', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
$\Bbb Z[X]$ is actually an integral domain: --- Let $f,g \in \Bbb Z[X]$ with $fg=0$. Convince yourself (prove via induction) that if the leading coefficient of $f$ is $m$ and that of $g$ is $n$, then that of $fg$ is $mn$. However, since the leading coefficients of both sides must be equal, we must have $mn = 0$. However, $m$ and $n$ are integers, so $mn=0$ implies $m=0$ or $n=0$. The leading coefficient of a polynomial, by definition, is $0$ only when the polynomial itself is $0$, so we conclude $f=0$ or $g=0$. To conclude, for any $f,g \in \Bbb Z[X]$, $fg=0$ implies $f=0$ or $g=0$, so $\Bbb Z[X]$ is an integral domain.
A material implication $P\to Q$ is a statement like "If $P$, then $Q$". For example, "If a ring $R$ is finite and integral domain, then it is a field". To every material implication $P\to Q$, we can consider the converse $Q\to P$, the inverse $\neg P\to\neg Q$, and the contrapositive $\neg Q\to\neg P.$ If an implication is true, then so is its contrapositive; they are tautologically equivalent. However the converse and inverse are not equivalent and may fail to be true. Consider that "All men are mortal" is true, but "all mortals are men" is not. Assuming the converse of a true implication is also true is a variation of a logical fallacy sometimes known as affirming the consequent. Assuming the truth of the inverse implication is known as "denying the antecedent". So if $P$ is the statement "$R$ is a finite integral domain", and $Q$ is the statement "$R$ is a field", the converse $Q\to P$ is the statement "All fields are finite integral domains", the inverse $\neg P\to\neg Q$ is the statement "if a ring is not a finite integral domain, it is not a field", and the contrapositive $\neg Q\to \neg P$ is the statement "if a ring is not a field, then it is not a finite integral domain." So in our case, if it is true that all finite integral domains are fields, it is also true that any ring which is not a field is not a finite integral domain. What is *not* true is that any ring not a finite integral domain is therefore a field. It is also not the case that any ring that is not finite must not be an integral domain. To the point, $\mathbb{Z}[x]$ is certainly an integral domain. See if you can prove that for $R$ an integral domain, $R[x]$ is also an integral domain.
2,574,504
How can I prove that polynomial ring $\mathbb{Z}[x]$ is not an integral domain ? I was thinking that $\mathbb{Z}[x]$ is not a field so it is will not form integral domain as every finite integral domain is a field but here $\mathbb{Z}[x]$ contain infinitely many element so ,it will not form field ..... Is my thinking is correct or not please tell and verify me ?
2017/12/20
['https://math.stackexchange.com/questions/2574504', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
$\Bbb Z[X]$ is actually an integral domain: --- Let $f,g \in \Bbb Z[X]$ with $fg=0$. Convince yourself (prove via induction) that if the leading coefficient of $f$ is $m$ and that of $g$ is $n$, then that of $fg$ is $mn$. However, since the leading coefficients of both sides must be equal, we must have $mn = 0$. However, $m$ and $n$ are integers, so $mn=0$ implies $m=0$ or $n=0$. The leading coefficient of a polynomial, by definition, is $0$ only when the polynomial itself is $0$, so we conclude $f=0$ or $g=0$. To conclude, for any $f,g \in \Bbb Z[X]$, $fg=0$ implies $f=0$ or $g=0$, so $\Bbb Z[X]$ is an integral domain.
You don't explicitly say what $x$ is. If, as others seem to assume, $x$ is an indeterminate (an unknown variable), then of course $\mathbb{Z}[x]$ is an integral domain (no "zero divisors"). On the other hand one can construct a simple overring of the integers $\mathbb{Z}[x]$ in which there are zero-divisors. For example one might take $\mathbb{Z}[x] \simeq \mathbb{Z}[X]/\langle X^2 \rangle$, in which case $x^2 = 0$ is a nilpotent element of the overring.
2,574,504
How can I prove that polynomial ring $\mathbb{Z}[x]$ is not an integral domain ? I was thinking that $\mathbb{Z}[x]$ is not a field so it is will not form integral domain as every finite integral domain is a field but here $\mathbb{Z}[x]$ contain infinitely many element so ,it will not form field ..... Is my thinking is correct or not please tell and verify me ?
2017/12/20
['https://math.stackexchange.com/questions/2574504', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
$\mathbb Z [x] $ can be considered a subring of $\mathbb Q [x] $. $\mathbb Q $ is a field, so $\mathbb Q [x] $ is an integral domain, and so $\mathbb Z [x] $ must be too (as any zero divisors in $\mathbb Z [x] $ will also be zero divisors in $\mathbb Q [x] $).
A material implication $P\to Q$ is a statement like "If $P$, then $Q$". For example, "If a ring $R$ is finite and integral domain, then it is a field". To every material implication $P\to Q$, we can consider the converse $Q\to P$, the inverse $\neg P\to\neg Q$, and the contrapositive $\neg Q\to\neg P.$ If an implication is true, then so is its contrapositive; they are tautologically equivalent. However the converse and inverse are not equivalent and may fail to be true. Consider that "All men are mortal" is true, but "all mortals are men" is not. Assuming the converse of a true implication is also true is a variation of a logical fallacy sometimes known as affirming the consequent. Assuming the truth of the inverse implication is known as "denying the antecedent". So if $P$ is the statement "$R$ is a finite integral domain", and $Q$ is the statement "$R$ is a field", the converse $Q\to P$ is the statement "All fields are finite integral domains", the inverse $\neg P\to\neg Q$ is the statement "if a ring is not a finite integral domain, it is not a field", and the contrapositive $\neg Q\to \neg P$ is the statement "if a ring is not a field, then it is not a finite integral domain." So in our case, if it is true that all finite integral domains are fields, it is also true that any ring which is not a field is not a finite integral domain. What is *not* true is that any ring not a finite integral domain is therefore a field. It is also not the case that any ring that is not finite must not be an integral domain. To the point, $\mathbb{Z}[x]$ is certainly an integral domain. See if you can prove that for $R$ an integral domain, $R[x]$ is also an integral domain.
2,574,504
How can I prove that polynomial ring $\mathbb{Z}[x]$ is not an integral domain ? I was thinking that $\mathbb{Z}[x]$ is not a field so it is will not form integral domain as every finite integral domain is a field but here $\mathbb{Z}[x]$ contain infinitely many element so ,it will not form field ..... Is my thinking is correct or not please tell and verify me ?
2017/12/20
['https://math.stackexchange.com/questions/2574504', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
$\mathbb Z [x] $ can be considered a subring of $\mathbb Q [x] $. $\mathbb Q $ is a field, so $\mathbb Q [x] $ is an integral domain, and so $\mathbb Z [x] $ must be too (as any zero divisors in $\mathbb Z [x] $ will also be zero divisors in $\mathbb Q [x] $).
You don't explicitly say what $x$ is. If, as others seem to assume, $x$ is an indeterminate (an unknown variable), then of course $\mathbb{Z}[x]$ is an integral domain (no "zero divisors"). On the other hand one can construct a simple overring of the integers $\mathbb{Z}[x]$ in which there are zero-divisors. For example one might take $\mathbb{Z}[x] \simeq \mathbb{Z}[X]/\langle X^2 \rangle$, in which case $x^2 = 0$ is a nilpotent element of the overring.
2,574,504
How can I prove that polynomial ring $\mathbb{Z}[x]$ is not an integral domain ? I was thinking that $\mathbb{Z}[x]$ is not a field so it is will not form integral domain as every finite integral domain is a field but here $\mathbb{Z}[x]$ contain infinitely many element so ,it will not form field ..... Is my thinking is correct or not please tell and verify me ?
2017/12/20
['https://math.stackexchange.com/questions/2574504', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
You don't explicitly say what $x$ is. If, as others seem to assume, $x$ is an indeterminate (an unknown variable), then of course $\mathbb{Z}[x]$ is an integral domain (no "zero divisors"). On the other hand one can construct a simple overring of the integers $\mathbb{Z}[x]$ in which there are zero-divisors. For example one might take $\mathbb{Z}[x] \simeq \mathbb{Z}[X]/\langle X^2 \rangle$, in which case $x^2 = 0$ is a nilpotent element of the overring.
A material implication $P\to Q$ is a statement like "If $P$, then $Q$". For example, "If a ring $R$ is finite and integral domain, then it is a field". To every material implication $P\to Q$, we can consider the converse $Q\to P$, the inverse $\neg P\to\neg Q$, and the contrapositive $\neg Q\to\neg P.$ If an implication is true, then so is its contrapositive; they are tautologically equivalent. However the converse and inverse are not equivalent and may fail to be true. Consider that "All men are mortal" is true, but "all mortals are men" is not. Assuming the converse of a true implication is also true is a variation of a logical fallacy sometimes known as affirming the consequent. Assuming the truth of the inverse implication is known as "denying the antecedent". So if $P$ is the statement "$R$ is a finite integral domain", and $Q$ is the statement "$R$ is a field", the converse $Q\to P$ is the statement "All fields are finite integral domains", the inverse $\neg P\to\neg Q$ is the statement "if a ring is not a finite integral domain, it is not a field", and the contrapositive $\neg Q\to \neg P$ is the statement "if a ring is not a field, then it is not a finite integral domain." So in our case, if it is true that all finite integral domains are fields, it is also true that any ring which is not a field is not a finite integral domain. What is *not* true is that any ring not a finite integral domain is therefore a field. It is also not the case that any ring that is not finite must not be an integral domain. To the point, $\mathbb{Z}[x]$ is certainly an integral domain. See if you can prove that for $R$ an integral domain, $R[x]$ is also an integral domain.
2,016,967
I am using Ubuntu ARM as testing platform on a QEMU emulator. The emulator has 256MB of RAM, but I'm wondering: what are the minimum requirements for running Ubuntu ARM? (CLI only)
2010/01/06
['https://Stackoverflow.com/questions/2016967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/62802/']
Most of the time, it's because your code is mis-aligned and compiler assumes that your "do" block ended prematurely (or has extra code that dont really belong there)
Your last line isn't something like `someVar <- putStrLn "hello"`, by any chance, is it? You'll get that error if you try to do a variable binding on the last line, because it's equivalent to `putStrLn "Hello" >>= \someVar ->` — it expects there to be an expression at the end.
2,016,967
I am using Ubuntu ARM as testing platform on a QEMU emulator. The emulator has 256MB of RAM, but I'm wondering: what are the minimum requirements for running Ubuntu ARM? (CLI only)
2010/01/06
['https://Stackoverflow.com/questions/2016967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/62802/']
Your last line isn't something like `someVar <- putStrLn "hello"`, by any chance, is it? You'll get that error if you try to do a variable binding on the last line, because it's equivalent to `putStrLn "Hello" >>= \someVar ->` — it expects there to be an expression at the end.
Incorrect indentation can lead to this error. Also, is good not to use tabs, only spaces.
2,016,967
I am using Ubuntu ARM as testing platform on a QEMU emulator. The emulator has 256MB of RAM, but I'm wondering: what are the minimum requirements for running Ubuntu ARM? (CLI only)
2010/01/06
['https://Stackoverflow.com/questions/2016967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/62802/']
Most of the time, it's because your code is mis-aligned and compiler assumes that your "do" block ended prematurely (or has extra code that dont really belong there)
Incorrect indentation can lead to this error. Also, is good not to use tabs, only spaces.
39,741,293
I have seen similar questions on this issue but non of the answers worked for me. I have a boolean value that change whenever an async task has been completed, but it's strange that ngonchages does not fire anytime it changes. Below is my code: ``` import { Component, OnChanges, SimpleChange } from '@angular/core'; export class HomePage implements OnChanges { isLoaded: boolean; constructor() { this.isLoaded = false; this.loadData(); } loadData() { setTimeout(() => { this.isLoaded = true; console.log(this.isLoaded); }, 3000); } ngOnChanges(changes) { console.log("There has been a change ", changes); //this is not firing } } ```
2016/09/28
['https://Stackoverflow.com/questions/39741293', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/944258/']
`ngOnChanges` is a lifecycle callback of Angulars change detection mechanism and it is called when an `@Input()` is changed by Angulars data binding When you have ``` @Input() isLoaded: boolean; ``` and ``` <home-page [isLoaded]="someValue"> ``` and `someValue` in the parent component is changed, then change detection updates `isLoaded` and calls `ngOnChanges()`. For your case the simplest solution is probably using a getter instead of a property: ``` _isLoaded: boolean; set isLoaded(value:bool) { this._isLoaded = value; this.doSomething(value) } get isLoaded() { return this._isLoaded; } ```
Property treated as input (part of checking changes) should be marked with @Input ``` @Input() isLoaded: boolean; ```
69,591,239
There is Hive table with ~ 500,000 rows. It has the single column which keeps the JSON string. JSON stores the measurements from 15 devices organized like this: ``` company_id=… device_1: array of measurements every single measurements has 2 attributes: value= date= device_2: … device_3 … device_15 ... ``` There are 15 devices in json where every device has the nested array of measurements inside. The size of measurements array is not fixed. The goal is to get from the measurements only the one with max(date) per device. The output of SELECT should have the following columns: ``` company_id device_1_value device_1_date ... device_15_value device_15_date ``` I tried to use the LATERAL VIEW to explode the measurements array: ``` SELECT get_json_object(json_string,'$.company_id), d1.value, d1.date, ... d15.value, d15.date FROM T LATERAL VIEW explode(device_1.measurements) as d1 LATERAL VIEW explode(device_2.measurements) as d2 … LATERAL VIEW explode(device_15.measurements) as d15 ``` I can use the result of this SQL as an input for another SQL which will extract the records with max(date) per device. My approach does not scale well: with 15 devices and 2 measurements per device the single row in input table will generate 2^15 = 32,768 rows using my SQL above. There are 500,000 rows in input table.
2021/10/15
['https://Stackoverflow.com/questions/69591239', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3440012/']
You need to combine the recursive result with testing the current index. ``` def firstNCharsSame(string, string2, n): if n == 0: # base case return True if n > len(string) or n > len(string2): return False return string[n - 1] == string2[n - 1] and firstNCharsSame(string, string2, n-1) ```
Maybe something like this: ``` def firstNCharsSameRec(string, string2, current, n): if current >= n: return True if string[current] != string2[current]: return False return firstNCharsSameRec(string, string2, current + 1, n) ``` And calling it like this: ``` print(firstNCharsSameRec("apple", "appll", 0, 5)) print(firstNCharsSameRec("apple", "appll", 0, 3)) ```
69,591,239
There is Hive table with ~ 500,000 rows. It has the single column which keeps the JSON string. JSON stores the measurements from 15 devices organized like this: ``` company_id=… device_1: array of measurements every single measurements has 2 attributes: value= date= device_2: … device_3 … device_15 ... ``` There are 15 devices in json where every device has the nested array of measurements inside. The size of measurements array is not fixed. The goal is to get from the measurements only the one with max(date) per device. The output of SELECT should have the following columns: ``` company_id device_1_value device_1_date ... device_15_value device_15_date ``` I tried to use the LATERAL VIEW to explode the measurements array: ``` SELECT get_json_object(json_string,'$.company_id), d1.value, d1.date, ... d15.value, d15.date FROM T LATERAL VIEW explode(device_1.measurements) as d1 LATERAL VIEW explode(device_2.measurements) as d2 … LATERAL VIEW explode(device_15.measurements) as d15 ``` I can use the result of this SQL as an input for another SQL which will extract the records with max(date) per device. My approach does not scale well: with 15 devices and 2 measurements per device the single row in input table will generate 2^15 = 32,768 rows using my SQL above. There are 500,000 rows in input table.
2021/10/15
['https://Stackoverflow.com/questions/69591239', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3440012/']
You need to combine the recursive result with testing the current index. ``` def firstNCharsSame(string, string2, n): if n == 0: # base case return True if n > len(string) or n > len(string2): return False return string[n - 1] == string2[n - 1] and firstNCharsSame(string, string2, n-1) ```
You can use the base case as 0, and implement like so: ``` def firstNCharsSame(string, string2, n): if n == 0: return True if n > min(len(string), len(string2)): return False return string[n - 1] == string2[n - 1] and firstNCharsSame(string, string2, n-1) ```
69,591,239
There is Hive table with ~ 500,000 rows. It has the single column which keeps the JSON string. JSON stores the measurements from 15 devices organized like this: ``` company_id=… device_1: array of measurements every single measurements has 2 attributes: value= date= device_2: … device_3 … device_15 ... ``` There are 15 devices in json where every device has the nested array of measurements inside. The size of measurements array is not fixed. The goal is to get from the measurements only the one with max(date) per device. The output of SELECT should have the following columns: ``` company_id device_1_value device_1_date ... device_15_value device_15_date ``` I tried to use the LATERAL VIEW to explode the measurements array: ``` SELECT get_json_object(json_string,'$.company_id), d1.value, d1.date, ... d15.value, d15.date FROM T LATERAL VIEW explode(device_1.measurements) as d1 LATERAL VIEW explode(device_2.measurements) as d2 … LATERAL VIEW explode(device_15.measurements) as d15 ``` I can use the result of this SQL as an input for another SQL which will extract the records with max(date) per device. My approach does not scale well: with 15 devices and 2 measurements per device the single row in input table will generate 2^15 = 32,768 rows using my SQL above. There are 500,000 rows in input table.
2021/10/15
['https://Stackoverflow.com/questions/69591239', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3440012/']
You need to combine the recursive result with testing the current index. ``` def firstNCharsSame(string, string2, n): if n == 0: # base case return True if n > len(string) or n > len(string2): return False return string[n - 1] == string2[n - 1] and firstNCharsSame(string, string2, n-1) ```
You only need to use the last parameter as a decreasing counter. Just compare the first characters and recurse for the rest: ``` def firstNCharsSame(a, b, n): return not n or a and b and a[0]==b[0] and firstNCharsSame(a[1:],b[1:],n-1) ```
69,591,239
There is Hive table with ~ 500,000 rows. It has the single column which keeps the JSON string. JSON stores the measurements from 15 devices organized like this: ``` company_id=… device_1: array of measurements every single measurements has 2 attributes: value= date= device_2: … device_3 … device_15 ... ``` There are 15 devices in json where every device has the nested array of measurements inside. The size of measurements array is not fixed. The goal is to get from the measurements only the one with max(date) per device. The output of SELECT should have the following columns: ``` company_id device_1_value device_1_date ... device_15_value device_15_date ``` I tried to use the LATERAL VIEW to explode the measurements array: ``` SELECT get_json_object(json_string,'$.company_id), d1.value, d1.date, ... d15.value, d15.date FROM T LATERAL VIEW explode(device_1.measurements) as d1 LATERAL VIEW explode(device_2.measurements) as d2 … LATERAL VIEW explode(device_15.measurements) as d15 ``` I can use the result of this SQL as an input for another SQL which will extract the records with max(date) per device. My approach does not scale well: with 15 devices and 2 measurements per device the single row in input table will generate 2^15 = 32,768 rows using my SQL above. There are 500,000 rows in input table.
2021/10/15
['https://Stackoverflow.com/questions/69591239', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3440012/']
You can use the base case as 0, and implement like so: ``` def firstNCharsSame(string, string2, n): if n == 0: return True if n > min(len(string), len(string2)): return False return string[n - 1] == string2[n - 1] and firstNCharsSame(string, string2, n-1) ```
Maybe something like this: ``` def firstNCharsSameRec(string, string2, current, n): if current >= n: return True if string[current] != string2[current]: return False return firstNCharsSameRec(string, string2, current + 1, n) ``` And calling it like this: ``` print(firstNCharsSameRec("apple", "appll", 0, 5)) print(firstNCharsSameRec("apple", "appll", 0, 3)) ```
69,591,239
There is Hive table with ~ 500,000 rows. It has the single column which keeps the JSON string. JSON stores the measurements from 15 devices organized like this: ``` company_id=… device_1: array of measurements every single measurements has 2 attributes: value= date= device_2: … device_3 … device_15 ... ``` There are 15 devices in json where every device has the nested array of measurements inside. The size of measurements array is not fixed. The goal is to get from the measurements only the one with max(date) per device. The output of SELECT should have the following columns: ``` company_id device_1_value device_1_date ... device_15_value device_15_date ``` I tried to use the LATERAL VIEW to explode the measurements array: ``` SELECT get_json_object(json_string,'$.company_id), d1.value, d1.date, ... d15.value, d15.date FROM T LATERAL VIEW explode(device_1.measurements) as d1 LATERAL VIEW explode(device_2.measurements) as d2 … LATERAL VIEW explode(device_15.measurements) as d15 ``` I can use the result of this SQL as an input for another SQL which will extract the records with max(date) per device. My approach does not scale well: with 15 devices and 2 measurements per device the single row in input table will generate 2^15 = 32,768 rows using my SQL above. There are 500,000 rows in input table.
2021/10/15
['https://Stackoverflow.com/questions/69591239', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3440012/']
You can use the base case as 0, and implement like so: ``` def firstNCharsSame(string, string2, n): if n == 0: return True if n > min(len(string), len(string2)): return False return string[n - 1] == string2[n - 1] and firstNCharsSame(string, string2, n-1) ```
You only need to use the last parameter as a decreasing counter. Just compare the first characters and recurse for the rest: ``` def firstNCharsSame(a, b, n): return not n or a and b and a[0]==b[0] and firstNCharsSame(a[1:],b[1:],n-1) ```
98,715
When looking at the [USD/BRL conversion rate](https://www.xe.com/currencyconverter/convert/?Amount=1&From=USD&To=BRL) I see a rate more or less 1 USD = ~ 3.90BRL. Then when I want to transfer my funds from my contractor (in USD) to my local account (in BRL), I wait for a day with bigger rate. But, by example, the site shows this rate like "1 USD = ~ 3.90BRL" and when ask the transfer, the rate is something like "1 USD = ~ 3.62BRL". My questions: 1. Why does this happen? 2. How can I know the correct (or best approximate) conversion rate?
2018/08/17
['https://money.stackexchange.com/questions/98715', 'https://money.stackexchange.com', 'https://money.stackexchange.com/users/75994/']
> > Why this happens? > How can I know the correct (or best approximate) conversion rate? > > > Most sites show the Mid-Rate. This is a notional rate. When you are buying or selling, you get a "Buy Rate" or "Sell Rate". The difference is the spread. If you see the note on the site, just below the rate; it clearly calls out this is mid rate for reference and for actual rate sign in to the Account. > > All figures are live mid-market rates, which are not available to consumers and are for informational purposes only. To see the rates we quote for a money transfer, please sign up or log in to your XE Money Transfer account. > > >
Because there's is a difference between "Buy rate" and "Selling Rate" of a currency. The spread in between 2 is the margin which money exchanger earns. So, for example, a money exchanger buys 5 USD @ 70 INR/USD and sell USD @ 70.5 INR/USD, thereby making profit of 2.5 INR. You need to see currencies as commodities to understand this concept.
98,715
When looking at the [USD/BRL conversion rate](https://www.xe.com/currencyconverter/convert/?Amount=1&From=USD&To=BRL) I see a rate more or less 1 USD = ~ 3.90BRL. Then when I want to transfer my funds from my contractor (in USD) to my local account (in BRL), I wait for a day with bigger rate. But, by example, the site shows this rate like "1 USD = ~ 3.90BRL" and when ask the transfer, the rate is something like "1 USD = ~ 3.62BRL". My questions: 1. Why does this happen? 2. How can I know the correct (or best approximate) conversion rate?
2018/08/17
['https://money.stackexchange.com/questions/98715', 'https://money.stackexchange.com', 'https://money.stackexchange.com/users/75994/']
> > Why this happens? > How can I know the correct (or best approximate) conversion rate? > > > Most sites show the Mid-Rate. This is a notional rate. When you are buying or selling, you get a "Buy Rate" or "Sell Rate". The difference is the spread. If you see the note on the site, just below the rate; it clearly calls out this is mid rate for reference and for actual rate sign in to the Account. > > All figures are live mid-market rates, which are not available to consumers and are for informational purposes only. To see the rates we quote for a money transfer, please sign up or log in to your XE Money Transfer account. > > >
Banks/brokers/currency traders etc... are in the business of making money, not speculating on where an asset class is going to move. Currency is just another "asset" it can change value just like a stock can depending on supply and demand, or a host of other factors. If the bank/broker just bought and sold at the market rate everyone sees, they would end up breaking even at best. More realistically they would lose money because they have to pay people to do this for you, and they have to provide the infrastructure to make these trades. All of that costs money. Losing money is not good for business. How do banks/brokers get around this? The same way that a casino makes money, they put a system in place where they always win. If the quoted market conversion rate is 1:3.90 then the bank will charge you a percent of that (typically 1.5-2%), it shows up in the rate they give you. When you buy the currency they will over charge you by 2% (so you get less of the currency than you should). When you sell the currency they will give you 2% less then what you would theoretically get in the open market. That is why you see a buy rate and a sell rate, the bank has to make money. They keep the difference, they make a profit, you get your desired currency. Everyone wins. If you want to speculate on where the currency goes, or you just want the money to go traveling. It doesn't matter one bit to them they have a business to run they need to make money. If they always buy for less than what the currency is worth and sell it for more, they will always make money in the long run. Typically the rate they use is based on an average of where the rate was for the past 12 hour period, then in 12 hours they change it. So if the currency moves 2% in that period (unlikely but does happen) that will also show because they are giving you an older rate. The best conversion rate is what someone is willing to give you, some companies charge 1.5%, some charge 2%, some charge more it depends on their cost structure. If it is a big concern to you shop around and do business with the people that give you the best rate. Some basic math shows you (3.90-3.62)/3.90 = 0.072, it looks like you are getting charged 7.2% if those are the numbers they give you. Some part of that is also going to be the difference in trading rate between those 12 hour periods.
98,715
When looking at the [USD/BRL conversion rate](https://www.xe.com/currencyconverter/convert/?Amount=1&From=USD&To=BRL) I see a rate more or less 1 USD = ~ 3.90BRL. Then when I want to transfer my funds from my contractor (in USD) to my local account (in BRL), I wait for a day with bigger rate. But, by example, the site shows this rate like "1 USD = ~ 3.90BRL" and when ask the transfer, the rate is something like "1 USD = ~ 3.62BRL". My questions: 1. Why does this happen? 2. How can I know the correct (or best approximate) conversion rate?
2018/08/17
['https://money.stackexchange.com/questions/98715', 'https://money.stackexchange.com', 'https://money.stackexchange.com/users/75994/']
Banks/brokers/currency traders etc... are in the business of making money, not speculating on where an asset class is going to move. Currency is just another "asset" it can change value just like a stock can depending on supply and demand, or a host of other factors. If the bank/broker just bought and sold at the market rate everyone sees, they would end up breaking even at best. More realistically they would lose money because they have to pay people to do this for you, and they have to provide the infrastructure to make these trades. All of that costs money. Losing money is not good for business. How do banks/brokers get around this? The same way that a casino makes money, they put a system in place where they always win. If the quoted market conversion rate is 1:3.90 then the bank will charge you a percent of that (typically 1.5-2%), it shows up in the rate they give you. When you buy the currency they will over charge you by 2% (so you get less of the currency than you should). When you sell the currency they will give you 2% less then what you would theoretically get in the open market. That is why you see a buy rate and a sell rate, the bank has to make money. They keep the difference, they make a profit, you get your desired currency. Everyone wins. If you want to speculate on where the currency goes, or you just want the money to go traveling. It doesn't matter one bit to them they have a business to run they need to make money. If they always buy for less than what the currency is worth and sell it for more, they will always make money in the long run. Typically the rate they use is based on an average of where the rate was for the past 12 hour period, then in 12 hours they change it. So if the currency moves 2% in that period (unlikely but does happen) that will also show because they are giving you an older rate. The best conversion rate is what someone is willing to give you, some companies charge 1.5%, some charge 2%, some charge more it depends on their cost structure. If it is a big concern to you shop around and do business with the people that give you the best rate. Some basic math shows you (3.90-3.62)/3.90 = 0.072, it looks like you are getting charged 7.2% if those are the numbers they give you. Some part of that is also going to be the difference in trading rate between those 12 hour periods.
Because there's is a difference between "Buy rate" and "Selling Rate" of a currency. The spread in between 2 is the margin which money exchanger earns. So, for example, a money exchanger buys 5 USD @ 70 INR/USD and sell USD @ 70.5 INR/USD, thereby making profit of 2.5 INR. You need to see currencies as commodities to understand this concept.
3,363,352
I have a TreeView on my page. It's bound to a collection of clients containing contracts, like: ``` public class Client { public int ClientID { get; set; } public string Name { get; set; } public List<Contract> Contracts { get; set; } } public class Contract { public int ContractID { get; set; } public int ClientID { get; set; } public string Name { get; set; } } ``` The XAML for my TreeView is as follows: ``` <sdk:TreeView x:Name="tvClientContract" ItemsSource="{Binding ClientContracts}"> <sdk:TreeView.ItemTemplate> <sdk:HierarchicalDataTemplate ItemsSource="{Binding Path=Contracts}"> <TextBlock Text="{Binding Path=Name}" /> </sdk:HierarchicalDataTemplate> </sdk:TreeView.ItemTemplate> </sdk:TreeView> ``` Where ClientContracts is a `List<Clients>`. The binding works fine and I have a hierarchical grid. The issue that I'm having is when opening the form with the TreeView on it I want to select the current Client, I currently use the following code: ``` TreeViewItem client = (TreeViewItem)tvClientContract.ItemContainerGenerator.ContainerFromItem(aClient); ``` or ``` TreeViewItem client = (TreeViewItem)tvClientContract.ItemContainerGenerator.ContainerFromIndex(tvClientContract.Items.IndexOf(aClient)); client.IsSelected = true; ``` but this returns inconsistent results, for example I open the form when client 'ABC' is selected and client will be null. I open it again when client 'ABC' is selected and it returns the correct TreeViewItem. Has anyone came across this before or know anything I can look at to help solve the issue? I run the above code within the Loaded event of the TreeView.
2010/07/29
['https://Stackoverflow.com/questions/3363352', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/83096/']
I figured out what's happening here, the clue is in the MSDN documentation for the return value of `ItemContainerGenerator.ContainerFromItem()`: > > A UIElement that corresponds to the > given item. Returns null if the item > does not belong to the item > collection, or if a UIElement has not > been generated for it. > > > It looks like when null is returned, a UIElement hasn't been created for the item yet. I got round this by using `tvClientContract.UpdateLayout();` to update the layout and ensure a UIElement exists before calling ``` ItemContainerGenerator.ContainerFromItem() ```
I think that there could be some condition where "UpdateLoayout will not work": if the TreeView is in recycling mode and the item is not in the visible portion and/or also in a "add" operation where the TreeViewItem is created on another thread. The solution is to use similar solution as I describe in: [WPF: Select TreeViewItem broken past the root level](https://stackoverflow.com/questions/1905995/wpf-select-treeviewitem-broken-past-the-root-level)
1,064,259
I am in the process of writing a rule engine that performs simple assignments as determined by conditional constructs. It is a prerequisite of the project that the rules be in XML format. I have modeled my XML schema to resemble simple code blocks. I wish to parse the XML and to then transform it into Java code. I then wish to compile (and run) this code at runtime. Doing so would mean that my rule engine no longer acts as an interpreter but executes native Java Byte Code. I have figured out the parsing stage and more or less the Java code generation phase. I would now like to figure out the last phase - the compile at runtime phase. Following this thread: [Compile to java bytecode (without using Java)](https://stackoverflow.com/questions/688098/compile-to-java-bytecode-without-using-java) I have become aware of the following possible solutions: * [ASM](http://asm.objectweb.org/) * [BCEL](http://jakarta.apache.org/bcel/) * [Trove](http://teatrove.sourceforge.net/trove.html) I would love a comparison of these as well as other suggestions for solving the Java compile at runtime phase.
2009/06/30
['https://Stackoverflow.com/questions/1064259', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/101715/']
You could transform it into Clojure code, and the Clojure compiler will turn it into bytecode for you.
you can fork a process like this ``` Process p = Runtime.getRuntime().exec("java -classpath "..." SomeClassContainingMain ...other arguments); //you need to consume the outputs of the command if output/error is large otherwise the process is going to hang if output/error buffer is full. and create a seperate thead for it (not created here). log.debug("PROCESS outputstream : " + p.getInputStream() ); log.debug("PROCESS errorstream : " + p.getErrorStream()); p.waitFor(); // Wait till the process is finished ``` and can compile and run it.
1,064,259
I am in the process of writing a rule engine that performs simple assignments as determined by conditional constructs. It is a prerequisite of the project that the rules be in XML format. I have modeled my XML schema to resemble simple code blocks. I wish to parse the XML and to then transform it into Java code. I then wish to compile (and run) this code at runtime. Doing so would mean that my rule engine no longer acts as an interpreter but executes native Java Byte Code. I have figured out the parsing stage and more or less the Java code generation phase. I would now like to figure out the last phase - the compile at runtime phase. Following this thread: [Compile to java bytecode (without using Java)](https://stackoverflow.com/questions/688098/compile-to-java-bytecode-without-using-java) I have become aware of the following possible solutions: * [ASM](http://asm.objectweb.org/) * [BCEL](http://jakarta.apache.org/bcel/) * [Trove](http://teatrove.sourceforge.net/trove.html) I would love a comparison of these as well as other suggestions for solving the Java compile at runtime phase.
2009/06/30
['https://Stackoverflow.com/questions/1064259', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/101715/']
Save yourself the hassle and use [BeanShell](http://www.beanshell.org/) as alluded to here [Executing java code given in a text file](https://stackoverflow.com/questions/1057796/executing-java-code-given-in-a-text-file). > > **What is BeanShell?** > > > BeanShell is a small, free, embeddable > Java source interpreter with object > scripting language features, written > in Java. BeanShell dynamically > executes standard Java syntax and > extends it with common scripting > conveniences such as loose types, > commands, and method closures like > those in Perl and JavaScript. > > > You can use BeanShell interactively > for Java experimentation and debugging > as well as to extend your applications > in new ways. Scripting Java lends > itself to a wide variety of > applications including rapid > prototyping, user scripting extension, > rules engines, configuration, testing, > dynamic deployment, embedded systems, > and even Java education. > > > BeanShell is small and embeddable, so > you can call BeanShell from your Java > applications to execute Java code > dynamically at run-time or to provide > extensibility in your applications. > Alternatively, you can use standalone > BeanShell scripts to manipulate Java > applications; working with Java > objects and APIs dynamically. Since > BeanShell is written in Java and runs > in the same VM as your application, > you can freely pass references to > "live" objects into scripts and return > them as results. > > > In short, BeanShell is dynamically > interpreted Java, plus a scripting > language and flexible environment all > rolled into one clean package. > > >
you can fork a process like this ``` Process p = Runtime.getRuntime().exec("java -classpath "..." SomeClassContainingMain ...other arguments); //you need to consume the outputs of the command if output/error is large otherwise the process is going to hang if output/error buffer is full. and create a seperate thead for it (not created here). log.debug("PROCESS outputstream : " + p.getInputStream() ); log.debug("PROCESS errorstream : " + p.getErrorStream()); p.waitFor(); // Wait till the process is finished ``` and can compile and run it.
1,064,259
I am in the process of writing a rule engine that performs simple assignments as determined by conditional constructs. It is a prerequisite of the project that the rules be in XML format. I have modeled my XML schema to resemble simple code blocks. I wish to parse the XML and to then transform it into Java code. I then wish to compile (and run) this code at runtime. Doing so would mean that my rule engine no longer acts as an interpreter but executes native Java Byte Code. I have figured out the parsing stage and more or less the Java code generation phase. I would now like to figure out the last phase - the compile at runtime phase. Following this thread: [Compile to java bytecode (without using Java)](https://stackoverflow.com/questions/688098/compile-to-java-bytecode-without-using-java) I have become aware of the following possible solutions: * [ASM](http://asm.objectweb.org/) * [BCEL](http://jakarta.apache.org/bcel/) * [Trove](http://teatrove.sourceforge.net/trove.html) I would love a comparison of these as well as other suggestions for solving the Java compile at runtime phase.
2009/06/30
['https://Stackoverflow.com/questions/1064259', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/101715/']
Groovy, BeanShell or any other scripting language which is based on JVM have such a facility to inject, modify, add and run code at runtime. Actually all the scripting language are interpreted, so actually those are not compiling at runtime.
you can fork a process like this ``` Process p = Runtime.getRuntime().exec("java -classpath "..." SomeClassContainingMain ...other arguments); //you need to consume the outputs of the command if output/error is large otherwise the process is going to hang if output/error buffer is full. and create a seperate thead for it (not created here). log.debug("PROCESS outputstream : " + p.getInputStream() ); log.debug("PROCESS errorstream : " + p.getErrorStream()); p.waitFor(); // Wait till the process is finished ``` and can compile and run it.
1,064,259
I am in the process of writing a rule engine that performs simple assignments as determined by conditional constructs. It is a prerequisite of the project that the rules be in XML format. I have modeled my XML schema to resemble simple code blocks. I wish to parse the XML and to then transform it into Java code. I then wish to compile (and run) this code at runtime. Doing so would mean that my rule engine no longer acts as an interpreter but executes native Java Byte Code. I have figured out the parsing stage and more or less the Java code generation phase. I would now like to figure out the last phase - the compile at runtime phase. Following this thread: [Compile to java bytecode (without using Java)](https://stackoverflow.com/questions/688098/compile-to-java-bytecode-without-using-java) I have become aware of the following possible solutions: * [ASM](http://asm.objectweb.org/) * [BCEL](http://jakarta.apache.org/bcel/) * [Trove](http://teatrove.sourceforge.net/trove.html) I would love a comparison of these as well as other suggestions for solving the Java compile at runtime phase.
2009/06/30
['https://Stackoverflow.com/questions/1064259', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/101715/']
Javassist is almost a full Java compiler written in Java, and it's completely made of Java. You can't give it a whole .java file at once, but you can give it the code string for individual functions and add them to the same CtClass object, which becomes bytecode and then a java.lang.Class. I just released version 0.1 of GigaLineCompile, which uses Javassist (compiler) and Beanshell (interpreter) together and gives you control over which code to optimize and when. In later versions, it will change between Javassist and Beanshell at a smaller granularity so if you have many strings of code that share some substrings, the substrings will be compiled and the other parts run in beanshell. Its mostly useful for artificial intelligence that generates Java code, but its also an alternative to Clojure or the extremes of Javassist/Beanshell alone. Javassist, Beanshell, and GigaLineCompile can be downloaded (with source) here: <http://sourceforge.net/projects/gigalinecompile>
you can fork a process like this ``` Process p = Runtime.getRuntime().exec("java -classpath "..." SomeClassContainingMain ...other arguments); //you need to consume the outputs of the command if output/error is large otherwise the process is going to hang if output/error buffer is full. and create a seperate thead for it (not created here). log.debug("PROCESS outputstream : " + p.getInputStream() ); log.debug("PROCESS errorstream : " + p.getErrorStream()); p.waitFor(); // Wait till the process is finished ``` and can compile and run it.
14,551,196
In this program the second and forth scanf get skipping , don't know the reason . can some please tell the reason ? ``` #include<stdio.h> main() { int age; char sex,status,city; printf("Enter the persons age \n"); scanf("\n%d",&age); printf("enter the gender\n"); scanf("%c",&sex); printf("enter the health status"); scanf("%c",&status); printf("where the person stay city or village"); scanf("%c",&city); if(((age>25)&&(age<35))&&(sex=='m')&&(status=='g')&&(city=='c')) printf("42"); else if(age>25&&age<35&&sex=='f'&&status=='g'&&city=='c') printf("31"); else if(age>25&&age<35&&sex=='m'&&status=='b'&&city=='v') printf("60"); else printf("no"); } ```
2013/01/27
['https://Stackoverflow.com/questions/14551196', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1813332/']
When reading chars using scanf(), it leaves a newline char in the input buffer. Change : ``` scanf("%c",&sex); printf("enter the health status"); scanf("%c",&status); printf("where the person stay city or village"); scanf("%c",&city); ``` to: ``` scanf(" %c",&sex); printf("enter the health status"); scanf(" %c",&status); printf("where the person stay city or village"); scanf(" %c",&city); ``` Notice the leading whitespace in scanf's format string which tells scanf to ignore whitespaces. Alternatively, you can use [**getchar()**](http://pubs.opengroup.org/onlinepubs/009695299/functions/getchar.html) for consuming the newline chars. ``` scanf("%c",&sex); getchar(); printf("enter the health status"); scanf("%c",&status); getchar(); printf("where the person stay city or village"); scanf("%c",&city); getchar(); ```
I always get the same problem as you using `scanf`, therefore, I use strings instead. I would use: ``` #include<stdio.h> main() { int age; char sex[3],status[3],city[3]; printf("Enter the persons age \n"); scanf("\n%d",&age); printf("enter the gender\n"); gets(sex); printf("enter the health status"); gets(status); printf("where the person stay city or village"); gets(city); if(((age>25)&&(age<35))&&(sex[0]=='m')&&(status[0]=='g')&&(city[0]=='c')) printf("42"); else if(age>25&&age<35&&sex[0]=='f'&&status[0]=='g'&&city[0]=='c') printf("31"); else if(age>25&&age<35&&sex[0]=='m'&&status[0]=='b'&&city[0]=='v') printf("60"); else printf("no"); } ``` If the first `scanf` is still giving you problems (skipping the second question, `gets`), you can use a little trick, but you have to include a new library ``` #include<stdlib.h> ... char age[4]; ... gets(age); ... if(((atoi(age)>25)&&(atoi(age)<35))&&(sex[0]=='m')&&(status[0]=='g')&&(city[0]=='c')) ``` And use `atoi` every time you use `age`, because `atoi` converts a char string into an integer (int).
355,666
Is there a chain rule of any kind for the generalised directional derivative (of the Clarke type)? There is certainly a chain rule for the generalised gradient. The generalised directional derivative is: $$f^\circ(x;v)=\limsup\_{y \to x, t \downarrow 0} \frac{f(y+tv) - f(y)}{t},$$ where $x,v \in \mathbb R^n$ for some $n$, and $f:\mathbb R^n \to \mathbb R^m$. Albeit, the definition is valid over any Banach space (but I'd like to keep things to finite dimensions for simplicity's sake). Some information about it can be found here: <https://www.encyclopediaofmath.org/index.php/Clarke_generalized_derivative> [edit] The naive version of the chain rule is false: Consider $f(x) = |x|, g(x) = -x$. We have that $(f\circ g)^\circ(0;1) = 1$ while $f^\circ(g(0); g^\circ(0;1)) = f^\circ(0;-1) = -1$. What I'm looking for must therefore be an inequality.
2020/03/25
['https://mathoverflow.net/questions/355666', 'https://mathoverflow.net', 'https://mathoverflow.net/users/75761/']
A nice and non-trivial extension of the chain-rule occurs from the DiPerna-Lions theory of rough vector fields: take on an open subset $\Omega$ of $\mathbb R^n$ a vector field $X$ with $L^\infty\_{loc}(\Omega)$ coefficients and null divergence such that $X\in W^{1,1}\_{loc}(\Omega)$. Let $u$ be an $L^\infty\_{loc}(\Omega)$ function such that $Xu\in L^1\_{loc}(\Omega)$. Then $$ X(u^2)=2u Xu. $$ The previous chain-rule formula is the main point to prove uniqueness of weak solutions for these vector fields. There are generalizations in several directions: instead of looking at $u^2$, you may check $$ X(F(u))=F'(u) Xu, \quad F\in C^1. $$ Also, you can relax the regularity $W^{1,1}$ to $BV$, play a bit with regularity $W^{1,p}$ and relax as well the condition on the divergence by requiring only absolute continuity wrt Lebesgue measure.
The straightforward generalization of the [usual chain rule](https://en.wikipedia.org/wiki/Gradient#Chain_rule) would give $$(f\circ g)^\circ(x,v)=v\cdot\bigl(Dg(x)\bigr)^{\rm T}\cdot\bigl(\nabla f(y)\bigr),$$ with $Dg$ the Jacobian matrix and $g(x)=y$.
355,666
Is there a chain rule of any kind for the generalised directional derivative (of the Clarke type)? There is certainly a chain rule for the generalised gradient. The generalised directional derivative is: $$f^\circ(x;v)=\limsup\_{y \to x, t \downarrow 0} \frac{f(y+tv) - f(y)}{t},$$ where $x,v \in \mathbb R^n$ for some $n$, and $f:\mathbb R^n \to \mathbb R^m$. Albeit, the definition is valid over any Banach space (but I'd like to keep things to finite dimensions for simplicity's sake). Some information about it can be found here: <https://www.encyclopediaofmath.org/index.php/Clarke_generalized_derivative> [edit] The naive version of the chain rule is false: Consider $f(x) = |x|, g(x) = -x$. We have that $(f\circ g)^\circ(0;1) = 1$ while $f^\circ(g(0); g^\circ(0;1)) = f^\circ(0;-1) = -1$. What I'm looking for must therefore be an inequality.
2020/03/25
['https://mathoverflow.net/questions/355666', 'https://mathoverflow.net', 'https://mathoverflow.net/users/75761/']
According to theorem 8.14 of <https://arxiv.org/pdf/1708.04180.pdf>, we have that for locally Lipschitz $g:Y\to \mathbb R$ and Frechet-differentiable $f: X \to Y$, that $$(g\circ f)^\circ(x;v) \leq g^\circ(f(x);f'(x)v).$$ Equality holds if $g$ is *regular.* We can furthermore say that: $$(g\circ f)^\circ(x;v) \geq -g^\circ(f(x);-f'(x)v)$$ under the same conditions.
The straightforward generalization of the [usual chain rule](https://en.wikipedia.org/wiki/Gradient#Chain_rule) would give $$(f\circ g)^\circ(x,v)=v\cdot\bigl(Dg(x)\bigr)^{\rm T}\cdot\bigl(\nabla f(y)\bigr),$$ with $Dg$ the Jacobian matrix and $g(x)=y$.
355,666
Is there a chain rule of any kind for the generalised directional derivative (of the Clarke type)? There is certainly a chain rule for the generalised gradient. The generalised directional derivative is: $$f^\circ(x;v)=\limsup\_{y \to x, t \downarrow 0} \frac{f(y+tv) - f(y)}{t},$$ where $x,v \in \mathbb R^n$ for some $n$, and $f:\mathbb R^n \to \mathbb R^m$. Albeit, the definition is valid over any Banach space (but I'd like to keep things to finite dimensions for simplicity's sake). Some information about it can be found here: <https://www.encyclopediaofmath.org/index.php/Clarke_generalized_derivative> [edit] The naive version of the chain rule is false: Consider $f(x) = |x|, g(x) = -x$. We have that $(f\circ g)^\circ(0;1) = 1$ while $f^\circ(g(0); g^\circ(0;1)) = f^\circ(0;-1) = -1$. What I'm looking for must therefore be an inequality.
2020/03/25
['https://mathoverflow.net/questions/355666', 'https://mathoverflow.net', 'https://mathoverflow.net/users/75761/']
According to theorem 8.14 of <https://arxiv.org/pdf/1708.04180.pdf>, we have that for locally Lipschitz $g:Y\to \mathbb R$ and Frechet-differentiable $f: X \to Y$, that $$(g\circ f)^\circ(x;v) \leq g^\circ(f(x);f'(x)v).$$ Equality holds if $g$ is *regular.* We can furthermore say that: $$(g\circ f)^\circ(x;v) \geq -g^\circ(f(x);-f'(x)v)$$ under the same conditions.
A nice and non-trivial extension of the chain-rule occurs from the DiPerna-Lions theory of rough vector fields: take on an open subset $\Omega$ of $\mathbb R^n$ a vector field $X$ with $L^\infty\_{loc}(\Omega)$ coefficients and null divergence such that $X\in W^{1,1}\_{loc}(\Omega)$. Let $u$ be an $L^\infty\_{loc}(\Omega)$ function such that $Xu\in L^1\_{loc}(\Omega)$. Then $$ X(u^2)=2u Xu. $$ The previous chain-rule formula is the main point to prove uniqueness of weak solutions for these vector fields. There are generalizations in several directions: instead of looking at $u^2$, you may check $$ X(F(u))=F'(u) Xu, \quad F\in C^1. $$ Also, you can relax the regularity $W^{1,1}$ to $BV$, play a bit with regularity $W^{1,p}$ and relax as well the condition on the divergence by requiring only absolute continuity wrt Lebesgue measure.
48,983,929
There are the two tables `Client` and `Stock`: ``` Table Client Column IDC (primary key, int, not null) Table Stock Column IDS (primary key, int, not null) Column IDC (int, not null) Column Type (bit, not null) Column Issued (bit, not null) Column Price (decimal(10,2), null) ``` They are to be taken as connected by `Client.IDC = Stock.IDC`. Discussion [here](https://stackoverflow.com/questions/48943585/sql-exclude-values-of-a-column-which-meet-a-requirement-at-least-once) shows how to split `IDC` into the following two groups: 1. `IDC` with `Type = 1` and `Price not NULL`, and 2. Remaining `IDC`, i.e. `IDC` which have no row with `Type = 1` and `Price not NULL` at all For the second group, is it feasible to return `IDC` together with `Price` in case of `Issued = 1`? The desired output should contain `IDC` for which no row with `Type = 1` and `Price not NULL` exists, but for which rows with `Issued = 1` and `Price not NULL` are available. Example: ``` Table Client IDC 1 2 3 4 5 6 7 8 9 Table Stock IDS IDC Type Issued Price 1 1 1 0 20 2 1 0 1 50 3 3 1 0 NULL 4 3 0 1 90 5 4 1 0 10 6 4 0 0 70 7 5 1 0 NULL 8 5 0 0 30 9 6 0 0 40 10 6 0 1 80 11 7 0 1 NULL 12 8 1 1 60 13 9 1 1 NULL Desired return [IDC, Price]: [3,90], [6,80] ``` My attempt is not successful: ``` SELECT C.IDC, S.Price FROM Client C LEFT JOIN Stock S ON C.IDC = S.IDC AND S.Type = 1 AND S.Price IS NOT NULL WHERE S.IDC IS NULL AND S.Issued = 1 ``` My assumption is, that the second condition in the `WHERE` clause is made redundant by the first condition in the `WHERE` clause. However, I can't really figure it out. I'm using Microsoft SQL Server 2008.
2018/02/26
['https://Stackoverflow.com/questions/48983929', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6198659/']
Is that what you wanna get? ``` SELECT z.IDC, z.PRICE FROM Stock z WHERE z.IDC IN ( SELECT c.IDC IDC FROM [Client] c LEFT JOIN Stock S on C.IDC = S.IDC AND S.Type = 1 AND S.Price IS NOT NULL WHERE S.IDC IS NULL ) AND Z.PRICE IS NOT NULL AND z.Issued = 1 ``` Yes, it in fact can be written with `Stock` only (without `JOIN` with `Client`): ``` SELECT Z.IDC, Z.Price FROM Stock Z WHERE Z.IDC NOT IN ( SELECT S.IDC FROM Stock S WHERE S.Type = 1 AND S.Price IS NOT NULL ) AND Z.Issued = 1 AND Z.Price IS NOT NULL ```
You may be looking for this ``` SELECT C.IDC, S.Price FROM Client C LEFT JOIN Stock S ON C.IDC = S.IDC WHERE (S.IDC IS NULL AND S.Issued = 1) OR (S.Type = 1 AND S.Price IS NOT NULL) ```
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Add `&amp;wmode=transparent` to the url and you're done, tested. I use that technique in my own wordpress plugin [YouTube shortcode](http://wordpress.org/extend/plugins/youtube-shortcode) Check its source code if you encounter any issue.
recently I saw that sometimes the flash player doesn't recognize `&wmode=opaque`, istead you should pass `&WMode=opaque` too (notice the uppercase).
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Add `&amp;wmode=transparent` to the url and you're done, tested. I use that technique in my own wordpress plugin [YouTube shortcode](http://wordpress.org/extend/plugins/youtube-shortcode) Check its source code if you encounter any issue.
I know this is an old question, but it still comes up in the top searches for this issue so I'm adding a new answer to help those looking for one for IE: Adding `&wmode=opaque` to the end of the URL does NOT work in IE 10... However, adding `?wmode=opaque` does the trick! --- Found this solution here: <http://alamoxie.com/blog/web-design/stop-iframes-covering-site-elements>
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Try adding `?wmode=opaque` to the URL or `&wmode=opaque` if there already is a parameter. If it doesn't work try this instead, `&amp;wmode=transparent` which will work in IE browser as well.
Try adding `?wmode=transparent` to the end of the URL. Worked for me.
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Add `&amp;wmode=transparent` to the url and you're done, tested. I use that technique in my own wordpress plugin [YouTube shortcode](http://wordpress.org/extend/plugins/youtube-shortcode) Check its source code if you encounter any issue.
`&wmode=opaque` didn't work for me (chrome 10) but `&amp;wmode=transparent` cleared the issue right up.
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
If you are using the new asynchronous API, you will need to add the parameter like so: ``` <!-- YOUTUBE --> // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); // 3. This function creates an <iframe> (and YouTube player) // after the API code downloads. var player; var initialVideo = 'ApkM4t9L5jE'; // YOUR YOUTUBE VIDEO ID function onYouTubePlayerAPIReady() { console.log("onYouTubePlayerAPIReady" + initialVideo); player = new YT.Player('player', { height: '381', width: '681', wmode: 'transparent', // SECRET SAUCE HERE videoId: initialVideo, playerVars: { 'autoplay': 1, 'rel': 0, 'wmode':'transparent' }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } ``` This is based on the google documentation and example here: <http://code.google.com/apis/youtube/iframe_api_reference.html>
recently I saw that sometimes the flash player doesn't recognize `&wmode=opaque`, istead you should pass `&WMode=opaque` too (notice the uppercase).
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Just a tip!--make sure you up the z-index on the element you want to be over the embedded video. I added the wmode querystring, and it still didn't work...until I upped the z-index of the other element. :)
`&wmode=opaque` didn't work for me (chrome 10) but `&amp;wmode=transparent` cleared the issue right up.
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Try adding `?wmode=transparent` to the end of the URL. Worked for me.
Just a tip!--make sure you up the z-index on the element you want to be over the embedded video. I added the wmode querystring, and it still didn't work...until I upped the z-index of the other element. :)
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Adding `?wmode=opaque` to the URL seems to solve this problem for me, although I have not tested it in IE yet. For those of you having troubles with the previously proposed solution, note that an inital ampersand will only work if you are already supplying other arguments to the URL. The first argument must have an initial question mark: `http://www.example.com?first=foo&second=bar`
Add `&amp;wmode=transparent` to the url and you're done, tested. I use that technique in my own wordpress plugin [YouTube shortcode](http://wordpress.org/extend/plugins/youtube-shortcode) Check its source code if you encounter any issue.
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
Try adding `?wmode=transparent` to the end of the URL. Worked for me.
If you are using the new asynchronous API, you will need to add the parameter like so: ``` <!-- YOUTUBE --> // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); // 3. This function creates an <iframe> (and YouTube player) // after the API code downloads. var player; var initialVideo = 'ApkM4t9L5jE'; // YOUR YOUTUBE VIDEO ID function onYouTubePlayerAPIReady() { console.log("onYouTubePlayerAPIReady" + initialVideo); player = new YT.Player('player', { height: '381', width: '681', wmode: 'transparent', // SECRET SAUCE HERE videoId: initialVideo, playerVars: { 'autoplay': 1, 'rel': 0, 'wmode':'transparent' }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } ``` This is based on the google documentation and example here: <http://code.google.com/apis/youtube/iframe_api_reference.html>
4,050,999
Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video. Any ideas how to solve the issue?
2010/10/29
['https://Stackoverflow.com/questions/4050999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/427235/']
If you are using the new asynchronous API, you will need to add the parameter like so: ``` <!-- YOUTUBE --> // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); // 3. This function creates an <iframe> (and YouTube player) // after the API code downloads. var player; var initialVideo = 'ApkM4t9L5jE'; // YOUR YOUTUBE VIDEO ID function onYouTubePlayerAPIReady() { console.log("onYouTubePlayerAPIReady" + initialVideo); player = new YT.Player('player', { height: '381', width: '681', wmode: 'transparent', // SECRET SAUCE HERE videoId: initialVideo, playerVars: { 'autoplay': 1, 'rel': 0, 'wmode':'transparent' }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } ``` This is based on the google documentation and example here: <http://code.google.com/apis/youtube/iframe_api_reference.html>
Just a tip!--make sure you up the z-index on the element you want to be over the embedded video. I added the wmode querystring, and it still didn't work...until I upped the z-index of the other element. :)
686,249
I'm trying to configure two subdomains using apache 2.4, but seems that there is a problem I can't resolve. Here is the apache configuration file ``` <VirtualHost *:80> ServerName www.subdomain1.myweb.com ServerAlias subdomain1.myweb.com DocumentRoot /srv/webapps/mywebapp <Directory /srv/webapps/mywebapp> AllowOverride all Options -MultiViews Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.subdomain2.myweb.com ServerAlias subdomain2.myweb.com DocumentRoot /srv/webapps/mywebapp2 <Directory /srv/webapps/mywebapp2> AllowOverride all Options -MultiViews Require all granted </Directory> ``` I tried defining the ServerName, but didn't solve the problem: ``` ServerName www.myweb.com ``` And tried using the server IP in VirtualHost, using wildcards, using domain in VirtualHost tag, etc... Anything worked as desired yet :( The point is that apache server *subdomain1.myweb.com*, but the *subdomain.myweb.com* don't. The only way I cant serve both subdomains it's settings the last one as: ``` <VirtualHost *:80> ServerName www.myweb.com ServerAlias myweb.com DocumentRoot /srv/webapps/mywebapp2 <Directory /srv/webapps/mywebapp2> AllowOverride all Options -MultiViews Require all granted </Directory> ``` So I can serve one subdomain and the other one in the root path, but that's not the desired behaviour. I guess that somehow apache it's matching the request with the first subdmain, don't know why. Apache shows this as virtual servers mapping: ``` VirtualHost configuration: *:80 is a NameVirtualHost default server www.myweb.com port 80 namevhost www.myweb.com alias subdomain1.myweb.com port 80 namevhost www.subdomain2.myweb.com alias subdomain2.com ServerRoot: "/etc/httpd" Main DocumentRoot: "/srv/http" Main ErrorLog: "/var/log/httpd/error_log" Mutex proxy: using_defaults Mutex default: dir="/run/httpd/" mechanism=default Mutex mpm-accept: using_defaults Mutex proxy-balancer-shm: using_defaults PidFile: "/run/httpd/httpd.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG ``` Thank you in advance! **EDIT** httpd.conf basically the default configuration because I got this problem since first moment and I didn't configure anything yet, excepting the virtual hosts. ServerRoot "/etc/httpd" ``` Listen 80 <IfModule unixd_module> User http Group http </IfModule> <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/srv/http" <Directory "/srv/http"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "/var/log/httpd/error_log" LogLevel warn <Directory "/srv/http/cgi-bin"> AllowOverride None Options None Require all granted </Directory> # Server-pool management (MPM specific) Include conf/extra/httpd-mpm.conf # Multi-language error messages Include conf/extra/httpd-multilang-errordoc.conf # Fancy directory listings Include conf/extra/httpd-autoindex.conf # Language settings Include conf/extra/httpd-languages.conf # User home directories Include conf/extra/httpd-userdir.conf # Virtual hosts Include conf/extra/httpd-vhosts.conf # Various default settings Include conf/extra/httpd-default.conf #PHP Include conf/extra/php5_module.conf # Configure mod_proxy_html to understand HTML4/XHTML1 <IfModule proxy_html_module> Include conf/extra/proxy-html.conf </IfModule> <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> ``` http-vhosts.conf is the same as the initial question httpd-default.conf ``` # # This configuration file reflects default settings for Apache HTTP Server. # # You may change these, but chances are that you may not need to. # # # Timeout: The number of seconds before receives and sends time out. # Timeout 60 # # KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # KeepAlive On # # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. # MaxKeepAliveRequests 100 # # KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. # KeepAliveTimeout 5 # # UseCanonicalName: Determines how Apache constructs self-referencing # URLs and the SERVER_NAME and SERVER_PORT variables. # When set "Off", Apache will use the Hostname and Port supplied # by the client. When set "On", Apache will use the value of the # ServerName directive. # UseCanonicalName Off # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess # # ServerTokens # This directive configures what you return as the Server HTTP response # Header. The default is 'Full' which sends information about the OS-Type # and compiled in modules. # Set to one of: Full | OS | Minor | Minimal | Major | Prod # where Full conveys the most information, and Prod the least. # ServerTokens Full # # Optionally add a line containing the server version and virtual host # name to server-generated pages (internal error documents, FTP directory # listings, mod_status and mod_info output etc., but not CGI generated # documents or custom error documents). # Set to "EMail" to also include a mailto: link to the ServerAdmin. # Set to one of: On | Off | EMail # ServerSignature Off # # HostnameLookups: Log the names of clients or just their IP addresses # e.g., www.apache.org (on) or 204.62.129.132 (off). # The default is off because it'd be overall better for the net if people # had to knowingly turn this feature on, since enabling it means that # each client request will result in AT LEAST one lookup request to the # nameserver. # HostnameLookups Off # # Set a timeout for how long the client may take to send the request header # and body. # The default for the headers is header=20-40,MinRate=500, which means wait # for the first byte of headers for 20 seconds. If some data arrives, # increase the timeout corresponding to a data rate of 500 bytes/s, but not # above 40 seconds. # The default for the request body is body=20,MinRate=500, which is the same # but has no upper limit for the timeout. # To disable, set to header=0 body=0 # <IfModule reqtimeout_module> RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500 </IfModule> ``` I tried to play with *http-default.conf* changing *UseCanonicalName* or *HostnameLookups* to give them a shot, but nothing worked so far... **SOLUTION** Finally seems that it was a DNS configuration problem, more than a virtual host configuration. Using in this case Google domains, just adding a custom resource record for every subdomain, and pointing to the IP address that will handle the request (in my case the same server, that will handle the request with the virtual hosts as the OP shows), made it work. Thank you all!
2015/04/28
['https://serverfault.com/questions/686249', 'https://serverfault.com', 'https://serverfault.com/users/284206/']
I noticed in your subdomain2, you didn't include the . Not sure if that's just in the config here, or yours. Did you do service httpd reload (or service apache2 reload depending on OS) Is your DNS pointed at your IP using those domain names?
TL;DR delete www www is already a subdomain of example.com. so you certainly are able to define 3rd or 4th level domains from your original domain. But you most likely do not want something.www.yourdomain.com as your subdomain. What you probably want is subdomain.yourdomain.com, thus just delete the wwww. Havent tested your configuration yet, so I dont know about the rest.
6,839,242
We recently moved to jQuery 1.6 and ran into the attr() versus prop() back-compat issue. During the first few hours after the change was deployed everything was fine, then it started breaking for people. We identified the problem pretty quickly and updated the offending JS, which was inline. No we have a situation where some folks are still having issues. In every case thus far, I could get the user up and running again by telling them to load the page in question then manually refresh it in the browser. So something must still be cached somewhere. But there are basically only two potential culprits: First, the jQuery library itself, but this is loaded with the version number in the query string so I think browsers will be refreshing it in their cache. Second, the inline javascript. Is it possible that this is being cached in the browser? We are using APC, apc.stat=1 so it should be detecting that the PHP files have changed. Just to be on the safe side I nuked the opcode cache anyway. To summarize, I have two questions: 1. Could some browsers be ignoring the query string when jQuery is loaded? 2. Could some browsers be caching an older version of the inline javascript? Any other ideas very welcome too. UPDATE: In the course of checking that there wasn't any unexpected caching going on using Firebug, I discovered a case where the old jQuery library would load. That doesn't explain why we had trouble after deploying the site and before we updated the inline code, but if it solves the problem I'll take it.
2011/07/27
['https://Stackoverflow.com/questions/6839242', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/123749/']
The answer to both your questions is no. *Unless* the whole page is being cached. A browser can't cache part of a file, since it would have to download it to know which parts it had cached and by that time it's downloaded them all anyways. It makes no sense :) You could try sending some headers along with your page that force the browser not to use it's cached copy.
I'd say the answers to your questions are 1) No and 2) Yes. jQuery versions are different URLs so there's no caching problems there unless you somehow edit a jQuery file directly without changing the version string. Browser pages (including inline javascript) will get cached according to both the page settings and the browser settings (that's what browsers do). The inline javascript isn't cached separately, but if the web page is cached, then the inline javascript is cached with it. What kind of permissible caching have you set for your web pages (either in meta tags or via http headers)? Lots to read on the subject of web page cache control [here](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html) and [here](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) if needed. It is very important to plan/design an upgrade strategy when you want to roll out upgrades that works properly with cached files in the browser. Doing this wrong can result in your user either staying on old content/code until caches expire or even worse ending with a mix of old/new content/code that doesn't work. The safest thing to do is to change source URLs when you have new content. Then there is zero possibility that an old cached page will ever get the new content so you avoid the mixing possibility. For example, on the Smugmug photo sharing web site, whenever any site owner updates an image to a new version of the image, a version number in the image URL is changed. Then, when the source page that shows that image is served from the web server, it includes the new image URL so, no matter whether the old version of the image is in the browser cache or not, the new version image is shown to the user. It is obviously not always practical to change the URL of all pages (especially top level pages) so those pages often have to be set with short cache settings so the browsers won't cache them for long and they will regularly pull fresh content.
65,878,482
I am upgrading Spring Cloud version from `Hoxton.SR6` to `2020.0.0` as part of Spring boot version upgrade from `2.3.4.RELEASE` to `2.4.2`. ``` <spring-cloud.version>2020.0.0</spring-cloud.version> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ``` Existing code had `spring-cloud-sleuth-core` dependency which is satisfied by `Hoxton.SR6`. But for `2020.0.0` this dependency is not available . ``` <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-sleuth-core</artifactId> </dependency> ``` What is the alternative dependency for this in `2020.0.0` ? ***Update***: `org.springframework.cloud.openfeign.ribbon` package no longer available in `2020.0.0`. What is the alternative for this? ``` import org.springframework.cloud.openfeign.ribbon.CachingSpringLoadBalancerFactory; import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient; ```
2021/01/25
['https://Stackoverflow.com/questions/65878482', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1869846/']
You should not depend on `spring-cloud-sleuth-core`, here's what you need: * The Spring Cloud BOM: `org.springframework.cloud:spring-cloud-dependencies` * The Sleuth starter: `org.springframework.cloud:spring-cloud-starter-sleuth` * The Zipkin module (if you want to send traces there): `org.springframework.cloud:spring-cloud-sleuth-zipkin` That's all, with these it should work. Answer for your update: Spring Cloud OpenFeign does not have too much to do with Sleuth, it should be a different question. I think Ribbon was removed, you can use Spring Cloud LoadBalancer instead.
Just add this dependecy: ``` <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-openfeign-core</artifactId> <version>2.2.8.RELEASE</version> </dependency> ```
9,417,618
I'm getting permissions errors while trying to deploy my rails app to a friend's server. I'm running rails 3.1.3, ruby-1.9.2-p290, capistrano 2.11.2, Mac OS 10.6.8, and we have ssh keys set up. However, we can't figure out where the permission issues are coming from. We think it might be that capistrano is trying to push the code from the git repo AS THE GIT USER to the deploy directory, or something like that. But this is our first deploy attempt, so we're not sure. Any help would be hugely appreciated! Oh, and here's some more details that my friend told me to specify: appsrv-04.example.ca is the canonical FQDN of the host, and project.example.ca is a CNAME pointing to the A record of appsrv-04.example.ca. The known\_hosts file for the git and deploy users contains all of appsrv-04, appsrv-04.example.ca, project, and project.example.ca. Below is the output from running cap deploy:update. ``` [user@workstation]~/Code/projectapi $ cap deploy:update * executing `deploy:update' ** transaction: start * executing `deploy:update_code' updating the cached checkout on all servers executing locally: "git ls-remote ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git master" Enter passphrase for key '/Users/user/.ssh/id_rsa': command finished in 4478ms * executing "if [ -d /usr/local/www/sites/project.example.ca/public/shared/cached-copy ]; then cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e71d220f299271522517f7b4f028a9275d53326a && git clean -q -d -x -f; else git clone -q ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git /usr/local/www/sites/project.example.ca/public/shared/cached-copy && cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git checkout -q -b deploy e71d220f299271522517f7b4f028a9275d53326a; fi" servers: ["project.example.ca"] Enter passphrase for /Users/user/.ssh/id_dsa: [project.example.ca] executing command ** [project.example.ca :: err] Permission denied, please try again. ** [project.example.ca :: err] Permission denied, please try again. ** [project.example.ca :: err] Permission denied (publickey,password). ** [project.example.ca :: err] fatal: The remote end hung up unexpectedly command finished in 650ms *** [deploy:update_code] rolling back * executing "rm -rf /usr/local/www/sites/project.example.ca/public/releases/20120222225453; true" servers: ["project.example.ca"] [project.example.ca] executing command command finished in 465ms failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2-p290@project' -c 'if [ -d /usr/local/www/sites/project.example.ca/public/shared/cached-copy ]; then cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e71d220f299271522517f7b4f028a9275d53326a && git clean -q -d -x -f; else git clone -q ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git /usr/local/www/sites/project.example.ca/public/shared/cached-copy && cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git checkout -q -b deploy e71d220f299271522517f7b4f028a9275d53326a; fi'" on project.example.ca ``` And here's my deploy file: ``` $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) require "rvm/capistrano" set :application, "Project" set :scm, "git" set :repository, "ssh://git@appsrv-04.example.ca/usr/local/git_root/project.git" set :user, "deploy" #set :rvm_bin_path, "/usr/local/rvm/bin" set :rvm_ruby_string, "1.9.2-p290@project" ssh_options[:forward_agent] = true set :branch, "master" set :deploy_via, :remote_cache set :deploy_to, "/usr/local/www/sites/project.example.ca/public/" set :use_sudo, false set :domain, 'project.example.ca' role :app, domain role :web, domain role :db, domain, :primary => true ```
2012/02/23
['https://Stackoverflow.com/questions/9417618', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1034602/']
You've almost certainly diagnosed this issue correctly; you're trying to check out the github repository as the deploy user and the forwarded key isn't being set up correctly. It looks like you have forward\_agent turned on in Capistrano... are you adding your key to your agent so that it gets forwarded correctly? Try doing that with `ssh-add ~/.ssh/id-rsa` and deploying again.
Problem solved. The virtual host was created by cloning an existing one and changing the IP. I updated the /etc/hosts file to use the new hostname, but apparently not the new IP. So when the deploy user was trying to ssh as the git user... it was failing because there is no git user on the IP it was using.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
**Basic hygiene** Have you any idea what happens to a dead body if you just leave it lying around. It will stink, get infested with maggots, the internal organs may explode, excrement will be expelled, etc. Obviously just using the skin (and preferably using some form of preservative) will avoid all this disgusting mess. Sure demons are horrible and scary but they are not zombies.
While demons ligation to the physical plane is much more tenuous than our own they are still corporeal beings. They can move through air and earth alike but density obscures their conveyance. To realize greater advantage a demon must exist in the void of a vessel; unhindered by blood and bone. For it is the boundaries between thick and thin that allows demons to gain the most purchase on the physical realm. The older the boundary the stronger the interaction. This is why a demon can only escape through freshly broken earth or an adult is a better surrogate than a child.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
Because they have to be removed. This is a magic system that you're creating. By definition, the rules are also yours to define. **Why do you need a ritual circle?** Because demons only arrive via ritual circle. **Why do victims have to be hollowed out like a pumpkin?** Because when they tried it on someone who still had their insides, their spleen exploded, killing the victim and three practitioners. **Why can't we at least keep their skin on? Flaying someone is messy work.** Because when a victim had their skin on, the demon couldn't secure a foothold inside them and was dragged back to the nether regions, and a bunch of expensive reagents were wasted.
**Basic hygiene** Have you any idea what happens to a dead body if you just leave it lying around. It will stink, get infested with maggots, the internal organs may explode, excrement will be expelled, etc. Obviously just using the skin (and preferably using some form of preservative) will avoid all this disgusting mess. Sure demons are horrible and scary but they are not zombies.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
> > Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them? > > > I don't know mate, that's non traditional lore and totally on you. Which sort of makes this question "opinion based" and closeable. But if you are asking for a mythologically justifiable reason that could be tied to this then perhaps: 1) **(logically) preservation-** skin aka leather lasts a whole lot longer if removed from more decomposable flesh. Afterall you want your demon slave sticking around for a good long time. 2) The Egyptians believed **the heart** was the seat of the soul, since the soul prevents possession then removing the heart is critical. 3) **Temptation** - Physical appearance leads to raw impure carnal sexual attraction which leads to sin. By this logic the skin could be the only organ inherently unholy enough to support the demon. It also justifies self flagellation as a means of penance.
While demons ligation to the physical plane is much more tenuous than our own they are still corporeal beings. They can move through air and earth alike but density obscures their conveyance. To realize greater advantage a demon must exist in the void of a vessel; unhindered by blood and bone. For it is the boundaries between thick and thin that allows demons to gain the most purchase on the physical realm. The older the boundary the stronger the interaction. This is why a demon can only escape through freshly broken earth or an adult is a better surrogate than a child.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
> > Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them? > > > I don't know mate, that's non traditional lore and totally on you. Which sort of makes this question "opinion based" and closeable. But if you are asking for a mythologically justifiable reason that could be tied to this then perhaps: 1) **(logically) preservation-** skin aka leather lasts a whole lot longer if removed from more decomposable flesh. Afterall you want your demon slave sticking around for a good long time. 2) The Egyptians believed **the heart** was the seat of the soul, since the soul prevents possession then removing the heart is critical. 3) **Temptation** - Physical appearance leads to raw impure carnal sexual attraction which leads to sin. By this logic the skin could be the only organ inherently unholy enough to support the demon. It also justifies self flagellation as a means of penance.
Evolved Protection =================== Since demons are real it can be assume that they existed throughout our evolution. It could be that back in time (a little after primordial soup, when skin evolved) that demons could at will take over any organic being. They did this because while they were in control they would feast on the victims organs (if not feast then they would get some other benefit derived from organs). Skin was an evolutionary defensive response against this (Those that could not get possessed had a better chance of surviving). Now since skin is our shield against demons, it could also be used to trap them. The reason why everything else is removed is simply so that the demon has nothing to feast on and get stronger (could get strong enough to break the sigils).
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
Because they have to be removed. This is a magic system that you're creating. By definition, the rules are also yours to define. **Why do you need a ritual circle?** Because demons only arrive via ritual circle. **Why do victims have to be hollowed out like a pumpkin?** Because when they tried it on someone who still had their insides, their spleen exploded, killing the victim and three practitioners. **Why can't we at least keep their skin on? Flaying someone is messy work.** Because when a victim had their skin on, the demon couldn't secure a foothold inside them and was dragged back to the nether regions, and a bunch of expensive reagents were wasted.
Evolved Protection =================== Since demons are real it can be assume that they existed throughout our evolution. It could be that back in time (a little after primordial soup, when skin evolved) that demons could at will take over any organic being. They did this because while they were in control they would feast on the victims organs (if not feast then they would get some other benefit derived from organs). Skin was an evolutionary defensive response against this (Those that could not get possessed had a better chance of surviving). Now since skin is our shield against demons, it could also be used to trap them. The reason why everything else is removed is simply so that the demon has nothing to feast on and get stronger (could get strong enough to break the sigils).
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
Because they have to be removed. This is a magic system that you're creating. By definition, the rules are also yours to define. **Why do you need a ritual circle?** Because demons only arrive via ritual circle. **Why do victims have to be hollowed out like a pumpkin?** Because when they tried it on someone who still had their insides, their spleen exploded, killing the victim and three practitioners. **Why can't we at least keep their skin on? Flaying someone is messy work.** Because when a victim had their skin on, the demon couldn't secure a foothold inside them and was dragged back to the nether regions, and a bunch of expensive reagents were wasted.
Have you ever looked at a property online but the windows are boarded up and there’s no natural light? Or gone to view a new flat only to find it’s full of a lifetime’s-worth of clutter and cardboard boxes? It’s the supernatural equivalent of that. Demons simply won’t want to inhabit a body if it’s cluttered up with icky internal organs and hasn’t got a nice view to the outside world. Etching the runes is an occult ‘property for rent’ sign (and a cosy corporeal body is waaay better than your typical infernal bedsit), but before any tenant will move in and start working for the roof over their head (so to speak), they want to know that the place will be properly cleaned out and opened up or they simply won’t sign the lease. Basically your average dark sorcerer needs to be a reasonable landlord or not even the prospect of a physical bachelor pad will draw in the demons.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
**Basic hygiene** Have you any idea what happens to a dead body if you just leave it lying around. It will stink, get infested with maggots, the internal organs may explode, excrement will be expelled, etc. Obviously just using the skin (and preferably using some form of preservative) will avoid all this disgusting mess. Sure demons are horrible and scary but they are not zombies.
Have you ever looked at a property online but the windows are boarded up and there’s no natural light? Or gone to view a new flat only to find it’s full of a lifetime’s-worth of clutter and cardboard boxes? It’s the supernatural equivalent of that. Demons simply won’t want to inhabit a body if it’s cluttered up with icky internal organs and hasn’t got a nice view to the outside world. Etching the runes is an occult ‘property for rent’ sign (and a cosy corporeal body is waaay better than your typical infernal bedsit), but before any tenant will move in and start working for the roof over their head (so to speak), they want to know that the place will be properly cleaned out and opened up or they simply won’t sign the lease. Basically your average dark sorcerer needs to be a reasonable landlord or not even the prospect of a physical bachelor pad will draw in the demons.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
> > Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them? > > > I don't know mate, that's non traditional lore and totally on you. Which sort of makes this question "opinion based" and closeable. But if you are asking for a mythologically justifiable reason that could be tied to this then perhaps: 1) **(logically) preservation-** skin aka leather lasts a whole lot longer if removed from more decomposable flesh. Afterall you want your demon slave sticking around for a good long time. 2) The Egyptians believed **the heart** was the seat of the soul, since the soul prevents possession then removing the heart is critical. 3) **Temptation** - Physical appearance leads to raw impure carnal sexual attraction which leads to sin. By this logic the skin could be the only organ inherently unholy enough to support the demon. It also justifies self flagellation as a means of penance.
### Demons are corporeal on Earth Demons may be incorporate in the netherworld, but on Earth they must be corporeal. After all, every creature with a will on the Earth is corporeal. Ghosts? Those are just stories. If a demon comes through the portal from the netherworld, then its essence takes a corporeal form on this side of the portal, just as if a wizard wishes to go into the netherworld, his corporeal body cannot enter and only his astral projection will pass through. ### Demon's corporeal forms on Earth is ... messy While you and I and horses and trees are made of the normal stuff of Earth, (Fire, Earth, Air and Water) demons are ... not. Their corporeal forms are made of all sorts of impossible magical elements. Not only would they drive humans to gibbering insanity by just looking at them, but their unstable bodies interact in strange ways with the environment. Just try touching them with iron, for example, and see what happens. In order to contain a demon's form on Earth, it must be covered with something, and something that was once alive, at that. The skin of a creature, imbued with the proper magical rituals, can both allow a demon to take a set form on Earth, and contain their magical power to prevent unfortunate reactions. ### To do useful work on Earth, Demons needs a 'covering' to put over their forms What better way than human skin? This gives several advantages, not least that the demon is molded into a human form and can do human work and interact with humans. After all, succubi would be very inefficient if they were trapped in the skin of a cow. Plus, one advantage of a skin suit is that a perfectly normal looking human can suddenly pull back his face, revealing his true form, and rendering anyone who sees him mad. Demons don't *have* to be trapped in a human form, of course, you can make some sort of vessel for the demon, known as a familiar. But, generally, humans and small animals are the only demon-summoning recipes you will find in musty old tomes, which explains why you don't see many demon rhinos.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
> > Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them? > > > I don't know mate, that's non traditional lore and totally on you. Which sort of makes this question "opinion based" and closeable. But if you are asking for a mythologically justifiable reason that could be tied to this then perhaps: 1) **(logically) preservation-** skin aka leather lasts a whole lot longer if removed from more decomposable flesh. Afterall you want your demon slave sticking around for a good long time. 2) The Egyptians believed **the heart** was the seat of the soul, since the soul prevents possession then removing the heart is critical. 3) **Temptation** - Physical appearance leads to raw impure carnal sexual attraction which leads to sin. By this logic the skin could be the only organ inherently unholy enough to support the demon. It also justifies self flagellation as a means of penance.
Have you ever looked at a property online but the windows are boarded up and there’s no natural light? Or gone to view a new flat only to find it’s full of a lifetime’s-worth of clutter and cardboard boxes? It’s the supernatural equivalent of that. Demons simply won’t want to inhabit a body if it’s cluttered up with icky internal organs and hasn’t got a nice view to the outside world. Etching the runes is an occult ‘property for rent’ sign (and a cosy corporeal body is waaay better than your typical infernal bedsit), but before any tenant will move in and start working for the roof over their head (so to speak), they want to know that the place will be properly cleaned out and opened up or they simply won’t sign the lease. Basically your average dark sorcerer needs to be a reasonable landlord or not even the prospect of a physical bachelor pad will draw in the demons.
129,645
Demons are incorporate, malicious spirits from the depths of hell. They require a human form in order to pass into the mortal realm. A dark sorcerer can sacrifice an individual in order to trap a demon in the victims body, enslaving the spirit to their will. This is a risky process that can come back to harm the user if the demon isn't bound correctly. Ancient runes and sigils must be carved into a living victim's skin. This will bind the demon to the body, trapping it and subjecting it to the sorcerer's will. Then the victim is killed through a dark ritual. The organs are removed from the body, as well as the bones, cartilage, etc, until only the skin is left. It is then placed over a ritual circle, while the sorcerer chants an ancient incantation that opens the gates to the netherworld. The circle provides the passageway, splitting the ground and allowing the demon to inhabit the skin of the victim. The runes keep the demon in the skin of the victim, trapping it similar to a prison. Since demons are just bodiless spirits, why would a victim's insides have to be removed in order for the demon to possess them?
2018/11/08
['https://worldbuilding.stackexchange.com/questions/129645', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/52361/']
Because they have to be removed. This is a magic system that you're creating. By definition, the rules are also yours to define. **Why do you need a ritual circle?** Because demons only arrive via ritual circle. **Why do victims have to be hollowed out like a pumpkin?** Because when they tried it on someone who still had their insides, their spleen exploded, killing the victim and three practitioners. **Why can't we at least keep their skin on? Flaying someone is messy work.** Because when a victim had their skin on, the demon couldn't secure a foothold inside them and was dragged back to the nether regions, and a bunch of expensive reagents were wasted.
### Demons are corporeal on Earth Demons may be incorporate in the netherworld, but on Earth they must be corporeal. After all, every creature with a will on the Earth is corporeal. Ghosts? Those are just stories. If a demon comes through the portal from the netherworld, then its essence takes a corporeal form on this side of the portal, just as if a wizard wishes to go into the netherworld, his corporeal body cannot enter and only his astral projection will pass through. ### Demon's corporeal forms on Earth is ... messy While you and I and horses and trees are made of the normal stuff of Earth, (Fire, Earth, Air and Water) demons are ... not. Their corporeal forms are made of all sorts of impossible magical elements. Not only would they drive humans to gibbering insanity by just looking at them, but their unstable bodies interact in strange ways with the environment. Just try touching them with iron, for example, and see what happens. In order to contain a demon's form on Earth, it must be covered with something, and something that was once alive, at that. The skin of a creature, imbued with the proper magical rituals, can both allow a demon to take a set form on Earth, and contain their magical power to prevent unfortunate reactions. ### To do useful work on Earth, Demons needs a 'covering' to put over their forms What better way than human skin? This gives several advantages, not least that the demon is molded into a human form and can do human work and interact with humans. After all, succubi would be very inefficient if they were trapped in the skin of a cow. Plus, one advantage of a skin suit is that a perfectly normal looking human can suddenly pull back his face, revealing his true form, and rendering anyone who sees him mad. Demons don't *have* to be trapped in a human form, of course, you can make some sort of vessel for the demon, known as a familiar. But, generally, humans and small animals are the only demon-summoning recipes you will find in musty old tomes, which explains why you don't see many demon rhinos.
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
This is called type introspection or reflection and is not supported by the C language. You would probably have to write your own reflection library, and it would be a significant effort.
There is a `typeof` extension in GCC, but it's not in ANSI C: <http://tigcc.ticalc.org/doc/gnuexts.html#SEC69>
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
This is called type introspection or reflection and is not supported by the C language. You would probably have to write your own reflection library, and it would be a significant effort.
The fact that `foo` is an `int` is bound to the name `foo`. It can never change. So how would such a test be meaningful? The only case it could be useful at all is in macros, where `foo` could expand to different-type variables or expressions. In that case, you could look at some of my past questions related to the topic: [Type-generic programming with macros: tricks to determine type?](https://stackoverflow.com/questions/4331474/type-generic-programming-with-macros-tricks-to-determine-type) [Determining presence of prototype with correct return type](https://stackoverflow.com/questions/4483757/determining-presence-of-prototype-with-correct-return-type)
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
This is called type introspection or reflection and is not supported by the C language. You would probably have to write your own reflection library, and it would be a significant effort.
The only time you wouldn't know the type is if the type of foo is defined by a typedef -- if that's the case, your example should reflect it. And why do you need to something dependent on the type? There may well be a way to solve your actual problem, but you haven't presented your actual problem.
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
This is called type introspection or reflection and is not supported by the C language. You would probably have to write your own reflection library, and it would be a significant effort.
Since C11, you can do that with `_Generic`: ``` if (_Generic(foo, int: 1, default: 0)) // if(typeof(foo)==int) { // do something } ```
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
There is a `typeof` extension in GCC, but it's not in ANSI C: <http://tigcc.ticalc.org/doc/gnuexts.html#SEC69>
The only time you wouldn't know the type is if the type of foo is defined by a typedef -- if that's the case, your example should reflect it. And why do you need to something dependent on the type? There may well be a way to solve your actual problem, but you haven't presented your actual problem.
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
There is a `typeof` extension in GCC, but it's not in ANSI C: <http://tigcc.ticalc.org/doc/gnuexts.html#SEC69>
Since C11, you can do that with `_Generic`: ``` if (_Generic(foo, int: 1, default: 0)) // if(typeof(foo)==int) { // do something } ```
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
The fact that `foo` is an `int` is bound to the name `foo`. It can never change. So how would such a test be meaningful? The only case it could be useful at all is in macros, where `foo` could expand to different-type variables or expressions. In that case, you could look at some of my past questions related to the topic: [Type-generic programming with macros: tricks to determine type?](https://stackoverflow.com/questions/4331474/type-generic-programming-with-macros-tricks-to-determine-type) [Determining presence of prototype with correct return type](https://stackoverflow.com/questions/4483757/determining-presence-of-prototype-with-correct-return-type)
The only time you wouldn't know the type is if the type of foo is defined by a typedef -- if that's the case, your example should reflect it. And why do you need to something dependent on the type? There may well be a way to solve your actual problem, but you haven't presented your actual problem.
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
The fact that `foo` is an `int` is bound to the name `foo`. It can never change. So how would such a test be meaningful? The only case it could be useful at all is in macros, where `foo` could expand to different-type variables or expressions. In that case, you could look at some of my past questions related to the topic: [Type-generic programming with macros: tricks to determine type?](https://stackoverflow.com/questions/4331474/type-generic-programming-with-macros-tricks-to-determine-type) [Determining presence of prototype with correct return type](https://stackoverflow.com/questions/4483757/determining-presence-of-prototype-with-correct-return-type)
Since C11, you can do that with `_Generic`: ``` if (_Generic(foo, int: 1, default: 0)) // if(typeof(foo)==int) { // do something } ```
5,127,797
Has a way to get the datatype in C? For example: ``` int foo; if (foo is int) { // do something } ``` or something like: ``` if (typeof(foo) == typeof(int)) { // do something } ``` Thanks in advance.
2011/02/26
['https://Stackoverflow.com/questions/5127797', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/464230/']
Since C11, you can do that with `_Generic`: ``` if (_Generic(foo, int: 1, default: 0)) // if(typeof(foo)==int) { // do something } ```
The only time you wouldn't know the type is if the type of foo is defined by a typedef -- if that's the case, your example should reflect it. And why do you need to something dependent on the type? There may well be a way to solve your actual problem, but you haven't presented your actual problem.
24,306,512
When rotating a group in fabric.js, the .left and .top values of the group "jump". Is that a fabric.js bug or somehow explainable/intended? ``` group.on "moving", -> #Yields values of about 100 px, also after the group was rotated group.on "rotating", -> #Yields values of about 130 px ``` JSFiddle -> <http://jsfiddle.net/thomasf1/X76X9/2/>
2014/06/19
['https://Stackoverflow.com/questions/24306512', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/377671/']
The difference is due to the originX and originY values changing upon rotation. originX and originY will become 'center' in place of their typical values of 'left' and 'top'. I encountered a similar issue where the positioning would change and found that I needed to be aware of the origin values.
I faced similar problem, but not with group, but single object. Solution for me was not taking the top and left positions of rotated object, but top left Oocord x and y position. For example: ``` fabricPlace.on('object:modified', function(event){ var object = event.target; var save = {}; save.position = {}; save.id = object.id; save.position.y = object.oCoords.tl.y; save.position.x = object.oCoords.tl.x; save.position.angle = object.angle; console.log(object); changeObject(save); }); ```
56,464,704
I have release apk with signed keys but it's not installing on android devices, its shows this message "**The apk failed to install Error: Could not parse error string"** but debugging mode apk, the app works fine. release command flutter build apk --release. I did follow this [question](https://stackoverflow.com/questions/48054291/cant-build-release-apk-for-flutter?rq=1) to solve it, hope it helps someone.
2019/06/05
['https://Stackoverflow.com/questions/56464704', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6654129/']
If you're trying to install a signed APK after using a debugging mode APK, Android will detect differences in signature, and refuse to install it. Make sure you've uninstalled the unsigned debugging APK first from the device, and try to install again.
Please check available disk space on the target Android Device before doing any actions. For most of cases it is a due to insuffisant space on the device.
20,363,283
Cannot increment variable `N` by 1 using `is/2` predicate. `N` is always 0 in the repeat loop. Why? How to increment it? ``` :- dynamic audible/1, flashes/1,tuned/1. audible(false). flashes(false). tuned(false). turn :- N is 0 , repeat , ( incr(N,N1) , N1 =:= 5000 , audible(true) , flashes(true) -> retractall(tuned) , retractall(flashes) , retractall(audible) , assert( tuned(true) ) , assert( flashes(true) ) , assert( audible(true) ) ) . incr(X,X1) :- X1 is X+1 . ```
2013/12/03
['https://Stackoverflow.com/questions/20363283', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/480632/']
Because `N is 0`. Variables in Prolog are not [assignables](https://existentialtype.wordpress.com/2012/02/01/words-matter/). Here's what happens if you trace your loop: ``` ?- trace, turn. Call: (7) turn ? Call: (8) _G492 is 0 ? Exit: (8) 0 is 0 ? Call: (8) repeat ? Exit: (8) repeat ? Call: (8) incr(0, _G493) ? Call: (9) _G495 is 0+1 ? Exit: (9) 1 is 0+1 ? Exit: (8) incr(0, 1) ? Call: (8) 1=:=5000 ? Fail: (8) 1=:=5000 ? Redo: (8) repeat ? Exit: (8) repeat ? Call: (8) incr(0, _G493) ? Call: (9) _G495 is 0+1 ? Exit: (9) 1 is 0+1 ? Exit: (8) incr(0, 1) ? Call: (8) 1=:=5000 ? Fail: (8) 1=:=5000 ? Redo: (8) repeat ? Exit: (8) repeat ? Call: (8) incr(0, _G493) ? Call: (9) _G495 is 0+1 ? Exit: (9) 1 is 0+1 ? Exit: (8) incr(0, 1) ? Call: (8) 1=:=5000 ? Fail: (8) 1=:=5000 ? Redo: (8) repeat ? ``` See what's happening there? You're repeatedly asking if 1 is 5000, which fails, and then you try again. But the value of N and N1 will never change within the body of a predicate. Prolog does not have block-scoped variables like you're accustomed to. You need to make the body of the loop into a separate predicate and use recursion to accomplish what you're trying to do. It's going to look something like this: ``` turn :- loop(0). loop(5000) :- audible(true), ... loop(N) :- incr(N, N1), loop(N1). ``` By the way, there's already a predicate `succ/2` that does what you're trying to do with `incr/2`.
I haven't a clue what you're trying to accomplish here, but it would appear that you're trying to write procedural prolog code. It doesn't work. Prolog variables are write-once: having been unified with an object they cease to be variable. They become that object, until that unification is undone via backtracking. You need to learn to think *recursively* and to use recursion loops to do what you want. Your turn/0 predicate ``` turn :- N is 0 , repeat , ( incr(N,N1) , N1 =:= 5000 , audible(true) , flashes(true) -> retractall(tuned) , retractall(flashes) , retractall(audible) , assert( tuned(true) ) , assert( flashes(true) ) , assert( audible(true) ) ) . ``` does the following. It: * unifies N with 0, * increments N1 with N+1, making N1 = 1 * fails if N1 is something other than 5000 (which it is). * On failure, the prolog engine starts backtracking... * backtracking through incr/2 undoes N1's binding, making it variable again. * backtracking into repeat/0, succeeds again. At this point, you're back to where you started, with N bound to 0. Wash, rinse, repeat.
47,974,629
app.component.html: ``` <div class="container"> <router-outlet></router-outlet> </div> ``` child1.componet.html: ``` <div class="panel panel-primary "> <div class="panel-heading"> ........ </div> </div> ``` child1.component.ts ``` @Component({ selector: 'tb-child1', templateUrl: './child1.component.html', styleUrls: ['./child1.component.css'] }) ``` app.component.css: ``` .container{ width:1200px } ``` I want the container width should be 1500px for only child1. Is there any way to change that?.
2017/12/26
['https://Stackoverflow.com/questions/47974629', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3968098/']
I can override the parent class in Child's css class by disabling the view encapsulaion like below in my child component ``` encapsulation: ViewEncapsulation.None ```
Please try like this **app.component.html:** ``` <div class="container subclass"> <router-outlet></router-outlet> </div> ``` In your **child1.component.css** add the below code ``` .container.subclass {width: 1500px !important;} ```
62,282
I would like to know if there are more than one decimal in bitcoin numbers. While playing online slots with Bitcoin, I hit a big win for 100900 x 5 credits totaling 5207.17.The total was displayed as 5,207.17 Please explain to me how this is supposed to exactly read. Thank you
2017/11/09
['https://bitcoin.stackexchange.com/questions/62282', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/38558/']
A Bitcoin is divisible down to 8 decimal places (that is x.xxxxxxxx).
There are 8 decimal places behind the decimal point to a bit coin. There are only 2 decimal places behind the decimal point, legally allowed to equate the Australian dollar. There fore if your rates notice not invoice depicts the R.I.D rate in dollar as 00.00466450 X Deliberatly Under valued home to 1/3 C.I.V:- $333k = $0 And 1 million bit coins 1,000,000. equals $1. 0.00 is netural and any further decimal place is a negative , a negative x a positive is always a negative figure . Bit coins another sad furphy
62,282
I would like to know if there are more than one decimal in bitcoin numbers. While playing online slots with Bitcoin, I hit a big win for 100900 x 5 credits totaling 5207.17.The total was displayed as 5,207.17 Please explain to me how this is supposed to exactly read. Thank you
2017/11/09
['https://bitcoin.stackexchange.com/questions/62282', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/38558/']
Its common for sites to measure coins in milli- or micro-bitcoins, one milli-bitcoin is a thousandth of a bitcoin while a micro-bitcoin is a millionth of a bitcoin. 1 BTC = 1,000,000 µBTC (micro-bitcoin) 1 BTC = 1,000 mBTC (milli-bitcoin) 1 µBTC = 100 Satoshi I'm not sure what website you are using, but I would hesitate a guess that those "credits" are mBTC, so 5207.17 is 5.20717 BTC which is around $40,000 USD at current rate, does that sound right?
There are 8 decimal places behind the decimal point to a bit coin. There are only 2 decimal places behind the decimal point, legally allowed to equate the Australian dollar. There fore if your rates notice not invoice depicts the R.I.D rate in dollar as 00.00466450 X Deliberatly Under valued home to 1/3 C.I.V:- $333k = $0 And 1 million bit coins 1,000,000. equals $1. 0.00 is netural and any further decimal place is a negative , a negative x a positive is always a negative figure . Bit coins another sad furphy
21,141
One of the things I really hate about 2010 and the packaging solution that comes out-of-the box is that it encourages bad practices (plopping everything - web code, static artifacts, packaging) into one project. There are lots of issues with this, but the most egregious issue -- in my opinion -- is that it forces the creation of artifacts in a hierarchy that needs to map to the SharePoint deployment targets instead of making sense in the logical structure of the application and code. I find that this decreases navigability and if some code *is* separated out into other libraries, just makes things that much harder to find and find a home for. With 2007 and even with 2010, when using WSPBuilder, I've followed the standard project layout pattern of having at least three projects: 1. **Package** - The package project that encapsulates the deployment artifacts and the deployment artifacts **ONLY** 2. **Web** - The UI project that contains the static web artifacts, the ASPX pages, the ASMX endpoints, the WCF endpoints, etc. - has no direct reference to SharePoint 3. **Core** - A class library project with the core business logic - encapsulates the direct reference to SharePoint. Feature receivers, event receivers, base classes, domain model classes, data mapping classes, helper classes, etc. go here. With WSPBuilder, it was easy to separate the artifacts by simply using XCOPY on pre- or post-build to move artifacts from the **Web** project to the **Package** project before calling the WSPBuilder executable. WSPBuilder didn't care if the .aspx or .js or .css file was part of the VS solution tree; it would include it in the package if it was in the directory on the file system. This allowed me to separate web code from the SharePoint code and build a nice boundary to prevent "leakage" of SharePoint API calls to the web artifacts (as well as logically organize the web code into a hierarchy that made more sense). In other words, it forced everything on the front-end in **Web** to call through a domain model in **Core**. The **Web** project becomes a "pure" ASP.NET web application that has no knowledge of SharePoint. I can have strong ASP.NET developers work on the front-end and strong SharePoint developers work on the domain model without giving the ASP.NET guys a chance to "cheat" and write "dirty" code in the codebehind since they have no reference to SharePoint. I've been trying to figure out how exactly this type of separation can be duplicated with the OOB packaging with Visual Studio 2010. The core problem with VS2010 is that the contents of mapped folders (i.e. Layouts) don't get included in the manifest and package if they are not included in the project in the VS solution. In other words, if I just XCOPY the files from the **Web** project to the **Package** project, they don't get added to the package because -- even though they are in the file system -- they are not part of the solution. One workaround is to manually create "stubs" for the files (same name) in mapped Layouts directory so that when the XCOPY occurs, it's copying the latest file and replacing the placeholder in the package. But this seems a pain in the butt, redundant, and easy for developers to forget when adding new files. But I'm curious how other shops out there are handling this issue. I feel strongly that for any non-prototype code, this type of separation becomes a must to ensure maintainability and approachability of the code for new developers. Are there workarounds to short-circuit the OOB packaging quirks that can be automated and remove manual steps like creating a stub .aspx? Are there alternative patterns for separating logic out of the package?
2011/10/11
['https://sharepoint.stackexchange.com/questions/21141', 'https://sharepoint.stackexchange.com', 'https://sharepoint.stackexchange.com/users/803/']
After installing SP1, you need to install the latest Cumulative Update (CU), which is currently the Aug 2011 CU. After running that CU you'll need to re-run the SharePoint Product config wizard again after that is installed. If I was doing a fresh install, I would install and configure SP2010, and run the config wizard to make sure it all came up as expected and worked. and then I would install SP1, and the Aug CU and then re-run the config wizard. I am not certain if you can skip the PS Config wizard after the initial installation of 2010.
The verdict is still unclear as to whether or not the latest CU is needed for SharePoint 2010, you'll hear arguments on both sides with some saying "stop at SP1 and go no further" and some saying "go on to the latest CU", I've seen farms configured both ways with no issues. You don't need to run the config wizard until all components are installed if you're doing a first-time install. My suggestion is to do it this way: 1. Look up how to "SlipStream" the service pack 1 install into SharePoint 2010, and do so, this way you can install both at the same time - After installing, run config wizard and start your farm - (Optional depending on your point of view) install the latest CU - Run the config wizard again
11,807,684
Is there a simple method to hide the bigger part of website, display loader.gif and nicely show the content with jquery until whole DOM is ready ? How can I code it ? Ofc I do not want use AJAX, just jquery.
2012/08/04
['https://Stackoverflow.com/questions/11807684', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1403568/']
use `visibility:hidden / visible` on the part you don't want to show until dom is ready. and once The DOM is ready ( `$('document').ready();`) , make your content visible with animation or anyway you like.
You can do it by using jQuery document.ready, which will only apply its functions/actions once the whole DOM is loaded. You can do this by setting the body to be `visibility:hidden`, and then add a class with the document.ready function, which changes this to `visibility:visible`. [jsFiddle](http://jsfiddle.net/wigster/vvYVK/) - have a look how it works. (Try changing the `"show"` to any other word if you want to test that it's working.) I personally wouldn't suggest this though, on slow connections the website may just appear broken, or potentially flick on/off as the css is loaded, and then jQuery. As mentioned in the comments if you need content loaded in a cleaner fashion AJAX is usually the way to go.
37,289,389
I was working with an example regarding seg fault: ``` char m[10]="dog"; strcpy(m+1,m); ``` In my centOs machine the result was as expected: segmentation fault. but on Ubuntu nothing happen. then I add a printf("%s",m); to the code on ubuntu and surprisingly I got the "ddog" as result. I am using GCC and the ubuntu version was the latest. can anyone tell me why the results are different. I also check it on raspbian and I also received segmentation fault. Thanks,
2016/05/18
['https://Stackoverflow.com/questions/37289389', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2088861/']
This causes [undefined behaviour](https://stackoverflow.com/a/4105123/1505939). `strcpy` may only be used between areas that do not overlap. To fix this code you could write: ``` memmove(m+1, m, strlen(m) + 1); ```
The memory for `m` is: ``` +---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+ ``` Whe you initialize it with: ``` char m[10] = "dog"; ``` the first four elements `m` are initialized. The rest are initialized. ``` +---+---+---+----+---+---+---+---+---+---+ | d | o | g | \0 | ? | ? | ? | ? | ? | ? | +---+---+---+----+---+---+---+---+---+---+ ``` I am using `?` to indicate uninitialized memory locations. They could contain anything. Let's walk through the execution of ``` strcpy(m+1, m); ``` step by step. Step 1: `m[0]` is copied to `m[1]`. So you have: ``` +---+---+---+----+---+---+---+---+---+---+ | d | d | g | \0 | ? | ? | ? | ? | ? | ? | +---+---+---+----+---+---+---+---+---+---+ ``` Step 2: `m[1]` is copied to `m[2]`. So you have: ``` +---+---+---+----+---+---+---+---+---+---+ | d | d | d | \0 | ? | ? | ? | ? | ? | ? | +---+---+---+----+---+---+---+---+---+---+ ``` Step 3: `m[2]` is copied to `m[3]`. So you have: ``` +---+---+---+---+---+---+---+---+---+---+ | d | d | d | d | ? | ? | ? | ? | ? | ? | +---+---+---+---+---+---+---+---+---+---+ ``` `strcpy` terminates when it encounters the null character in the source argument. As you can see, the terminating criteria for `strcpy` will never be met. Hence, the program keeps on reading data from memory beyond the valid limits and writing data to memory beyond valid limits. That is cause for undefined behavior. To get the desired result, `"ddog"`, you can to use: ``` size_t len = strlen(m); for ( int i = len; i >= 0; --i ) { m[i+i] = m[i]; } ```
28,301,641
I want to write a small console application (C# 4.0/4.5) that will serve as a logger to a remote database. Said application could be called from numerous peripheral automation components/programs, not of all which will be .NET based. (calls would be made via commandline: e.g., logme.exe appID, taskID, statusID, msg) Question: what would happen if two or more of these programs were to execute the logger either a) at the same time, or b) while it's already in use elsewhere? I'm unsure of the execution fundamentals and whether I should be concerned with this or not. Thank you
2015/02/03
['https://Stackoverflow.com/questions/28301641', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4155665/']
I found a way, by using an inset drawable: First, create a new inset drawable (e.g. radio\_button\_inset.xml) with your desired padding and a link to the theme radio button drawable like this: ``` <inset xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="?android:attr/listChoiceIndicatorSingle" android:insetLeft="@dimen/your_padding_value"/> ``` Second, use this new drawable for your radio button: ``` <RadioButton android:id="@+id/radio_blue" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="How to set the padding on the left of radio pin" android:background="@drawable/container_dropshadow" android:button="@drawable/radio_button_inset"/> ```
Try using paddingStart on the [RadioGroup](http://developer.android.com/reference/android/widget/RadioGroup.html). Since it's extends from a ViewGroup, [LinearLayout](http://developer.android.com/reference/android/widget/LinearLayout.html), all of the child elements will be affected. ``` <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/radiobuttons" android:paddingBottom="@dimen/activity_vertical_margin" android:dividerPadding="30dp" android:paddingStart="8dp"> <RadioButton android:id="@+id/radio_blue" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="How to set the padding on the left of radio pin" android:background="@drawable/container_dropshadow"/> <!-- other radio buttons... --> </RadioGroup> ``` Try this in your background resource. ``` <!-- Background --> <item> <shape> <padding android:left="8dp" /> <solid android:color="@android:color/white" /> <corners android:radius="3dp" /> </shape> </item> ```
52,738,149
[enter image description here](https://i.stack.imgur.com/ZRDlD.png)I have 2 different datagrid, the first DG1 is my item list and DG2 is the item queues for purchased items. My goal is whenever i click an item in DG2, DG1 is also selected with the same name or id. I want to ignore the index because my item queue is different from item list order. ``` private void dgItems_CellClick(object sender, DataGridViewCellEventArgs e) { int rowindex = dgItems.Rows[e.RowIndex].Index; int columnindex = dgItems.Columns[e.ColumnIndex].Index; dgItemList.Rows[rowindex].Cells[columnindex].Selected = true; } ```
2018/10/10
['https://Stackoverflow.com/questions/52738149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7725975/']
You can always create models: ``` export class User { id: string, username: string, first_name: string, last_name: string, email: string, is_active: boolean, is_superuser: boolean } export class UserDetails{ user:User; role:string; } ``` Then: ``` // Assume you have received the json in string form in 'resultlist' variable let dataList = <Array<UserDetails>>JSON.parse(resultlist); ``` Or: ``` // Assume you have received the json in object form in 'resultlist' variable let dataList = <Array<UserDetails>>resultlist; ```
`this.userData["role"] = this.user.role` should be `this.userData["role"] = this.role`
52,738,149
[enter image description here](https://i.stack.imgur.com/ZRDlD.png)I have 2 different datagrid, the first DG1 is my item list and DG2 is the item queues for purchased items. My goal is whenever i click an item in DG2, DG1 is also selected with the same name or id. I want to ignore the index because my item queue is different from item list order. ``` private void dgItems_CellClick(object sender, DataGridViewCellEventArgs e) { int rowindex = dgItems.Rows[e.RowIndex].Index; int columnindex = dgItems.Columns[e.ColumnIndex].Index; dgItemList.Rows[rowindex].Cells[columnindex].Selected = true; } ```
2018/10/10
['https://Stackoverflow.com/questions/52738149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7725975/']
I think the best way is, create an Object corresponding with the JSON's structure and you assign just the data JSON to the Array of the object. ```js class User{ id:string; username:string; firstName:string; lastName:string; email:string; isActive:boolean; isSuperviser:boolean; } class JSONData{ user:User; role:string } data:JSONData[] = yourJson.data; ``` You adjust the property name in the json data as in your class and you can handle the data correctly and easily, please refer on this link for [more infos](https://www.typescriptlang.org/docs/handbook/classes.html)
`this.userData["role"] = this.user.role` should be `this.userData["role"] = this.role`
52,738,149
[enter image description here](https://i.stack.imgur.com/ZRDlD.png)I have 2 different datagrid, the first DG1 is my item list and DG2 is the item queues for purchased items. My goal is whenever i click an item in DG2, DG1 is also selected with the same name or id. I want to ignore the index because my item queue is different from item list order. ``` private void dgItems_CellClick(object sender, DataGridViewCellEventArgs e) { int rowindex = dgItems.Rows[e.RowIndex].Index; int columnindex = dgItems.Columns[e.ColumnIndex].Index; dgItemList.Rows[rowindex].Cells[columnindex].Selected = true; } ```
2018/10/10
['https://Stackoverflow.com/questions/52738149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7725975/']
You can always create models: ``` export class User { id: string, username: string, first_name: string, last_name: string, email: string, is_active: boolean, is_superuser: boolean } export class UserDetails{ user:User; role:string; } ``` Then: ``` // Assume you have received the json in string form in 'resultlist' variable let dataList = <Array<UserDetails>>JSON.parse(resultlist); ``` Or: ``` // Assume you have received the json in object form in 'resultlist' variable let dataList = <Array<UserDetails>>resultlist; ```
No need to convert. It s already json format but you should use array index then set user variable. For example : ``` let user:any = {}; user = this.user[arrayIndex].user; this.userData["user"] = user this.userData["role"] = this.user[arrayIndex].role; ``` if you want o get data from json array , you should use array index. Like this. ``` let user:any = {}; user = this.user[0].user; this.userData["role"] = this.user[0].role; ```
52,738,149
[enter image description here](https://i.stack.imgur.com/ZRDlD.png)I have 2 different datagrid, the first DG1 is my item list and DG2 is the item queues for purchased items. My goal is whenever i click an item in DG2, DG1 is also selected with the same name or id. I want to ignore the index because my item queue is different from item list order. ``` private void dgItems_CellClick(object sender, DataGridViewCellEventArgs e) { int rowindex = dgItems.Rows[e.RowIndex].Index; int columnindex = dgItems.Columns[e.ColumnIndex].Index; dgItemList.Rows[rowindex].Cells[columnindex].Selected = true; } ```
2018/10/10
['https://Stackoverflow.com/questions/52738149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7725975/']
I think the best way is, create an Object corresponding with the JSON's structure and you assign just the data JSON to the Array of the object. ```js class User{ id:string; username:string; firstName:string; lastName:string; email:string; isActive:boolean; isSuperviser:boolean; } class JSONData{ user:User; role:string } data:JSONData[] = yourJson.data; ``` You adjust the property name in the json data as in your class and you can handle the data correctly and easily, please refer on this link for [more infos](https://www.typescriptlang.org/docs/handbook/classes.html)
No need to convert. It s already json format but you should use array index then set user variable. For example : ``` let user:any = {}; user = this.user[arrayIndex].user; this.userData["user"] = user this.userData["role"] = this.user[arrayIndex].role; ``` if you want o get data from json array , you should use array index. Like this. ``` let user:any = {}; user = this.user[0].user; this.userData["role"] = this.user[0].role; ```
52,738,149
[enter image description here](https://i.stack.imgur.com/ZRDlD.png)I have 2 different datagrid, the first DG1 is my item list and DG2 is the item queues for purchased items. My goal is whenever i click an item in DG2, DG1 is also selected with the same name or id. I want to ignore the index because my item queue is different from item list order. ``` private void dgItems_CellClick(object sender, DataGridViewCellEventArgs e) { int rowindex = dgItems.Rows[e.RowIndex].Index; int columnindex = dgItems.Columns[e.ColumnIndex].Index; dgItemList.Rows[rowindex].Cells[columnindex].Selected = true; } ```
2018/10/10
['https://Stackoverflow.com/questions/52738149', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7725975/']
You can always create models: ``` export class User { id: string, username: string, first_name: string, last_name: string, email: string, is_active: boolean, is_superuser: boolean } export class UserDetails{ user:User; role:string; } ``` Then: ``` // Assume you have received the json in string form in 'resultlist' variable let dataList = <Array<UserDetails>>JSON.parse(resultlist); ``` Or: ``` // Assume you have received the json in object form in 'resultlist' variable let dataList = <Array<UserDetails>>resultlist; ```
I think the best way is, create an Object corresponding with the JSON's structure and you assign just the data JSON to the Array of the object. ```js class User{ id:string; username:string; firstName:string; lastName:string; email:string; isActive:boolean; isSuperviser:boolean; } class JSONData{ user:User; role:string } data:JSONData[] = yourJson.data; ``` You adjust the property name in the json data as in your class and you can handle the data correctly and easily, please refer on this link for [more infos](https://www.typescriptlang.org/docs/handbook/classes.html)
51,924,559
I am new to JS and rails so recently facing lots of difficulties about using ajax in rails environment. I will very appreciate if you contribute to developing my project. What I am trying to do is that Once a user selects data from the modal, I want to send the selected data to an action in the controller so that I can handle the data. I am not really sure where I can start with that. Please help guys :( Thanks a lot view: ``` <form id= "selected_form" action="" method=""> <div id= "selected_form"> <p id="checkids"></p> </div> </form> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <div> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Select Task</h4> </div> <div class="modal-body"> <fieldset> <% @tasks.each do |task|%> <div> <label><input type="checkbox" value="<%=task.id%>" name="selected"><%=task.title%></label> </div> <% end %> </fieldset> </div> <div class="modal-footer"> <button type="button" id="save" class="btn btn-default" data-dismiss="modal">Save</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> </div> </div> </div> </div> </div> ``` JS ``` <script> $(function(){ $(document).ready(function(){ $("#save").click(function(){ var checkedItem = []; $.each($("input[name='selected']:checked"), function(){ checkedItem.push($(this).val()); }); $('#values').html("selected values are: " + checkedItem.join(", ")); $.ajax({ type: "POST", // request method for your action like get,post,put,delete url: "/users/<%= current_user.id %>/test", // route of your rails action data: {checked_items: checkedItem.join(", ")}, // attach data here you will get this data in your controller action with params[:checked_items] success: function(data, textStatus, jqXHR){}, // do whatever you want when it success error: function(jqXHR, textStatus, errorThrown){} }) }); }); }); </script> ```
2018/08/20
['https://Stackoverflow.com/questions/51924559', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8592732/']
Please check script below ``` <script> $(function(){ $(document).ready(function(){ $("#save").click(function(){ var checkedItem = []; $.each($("input[name='selected']:checked"), function(){ checkedItem.push($(this).val()); }); $('#values').html("selected values are: " + checkedItem.join(", ")); $.ajax({ type: "POST", // request method for your action like get,post,put,delete url: "/things", // route of your rails action data: {checked_items: checkedItem }, // attach data here you will get this data in your controller action with params[:checked_items] success: function(data, textStatus, jqXHR){...}, // do whatever you want when it success error: function(jqXHR, textStatus, errorThrown){...} }) }); }); }); </script> ```
For simplicity you can inject rails path to that controller as dataset attribute. for e.g ``` <form method="post" data-url="<%= tasks_path %>"> ``` and in js part ``` $('#save').on('click', function (e) { e.preventDefault(); $.ajax({ type: $(this).method || "GET", url: this.dataset.url, data: $(this).serialize(), success: function (response) { console.log(response) }, error: function (error) { console.log(error); } }); }); ```
49,578,996
I am getting error like ``` /hackerearth/CPP14_28/s_e3.cpp: In function ‘int main()’: /hackerearth/CPP14_28/s_e3.cpp:6:10: error: declaration of ‘auto x’ has no initializer auto x; ^ ``` My code is , ``` #include <iostream> using namespace std; int main() { auto x; cin >> x; cout << x; return 0; } ``` I want similar functionality that data type should be dynamically assigned
2018/03/30
['https://Stackoverflow.com/questions/49578996', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1119372/']
You're misusing the `auto` keyword. **The type that actually gets used is determined by the value used to initialize the variable at compile time.** It has nothing to do with the ability to determine the type of variable to use at runtime. For example, if you write `auto x = 0`, the compiler sees that you're initializing the variable with an int and pretty much compiles it as if it was `int x = 0`. Depending on what you're trying to do, you might want to take the input as a string and parse it later, or somehow determine what type of input it is before reading the value.
Objects declared with auto typing need to copy their static type from their initializers; What your 'x' is missing. C++ - just like C - is a statically typed language. Extra string processing is needed to decode the input string value. If the set of possible types is limited to a known countable set, a proper std::variant could be used to hold the value.
64,324,695
I have the following table. ``` Fights (fight_year, fight_round, winner, fid, city, league) ``` I am trying to query the following: For each year that appears in the Fights table, find the city that held the most fights. For example, if in year 1992, Jersey held more fights than any other city did, you should print out (1992, Jersey) Here's what I have so far but I keep getting the following error. I am not sure how I should construct my group by functions. ERROR: column, 'ans.fight\_round' must appear in the GROUP BY clause or be used in an aggregate function. Line 3 from (select \* ``` select fight_year, city, max(*) from (select * from (select * from fights as ans group by (fight_year)) as l2 group by (ans.city)) as l1; ```
2020/10/12
['https://Stackoverflow.com/questions/64324695', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9905254/']
* If the `pandas.Series` have been converted to a `datetime` format, they will not contain `None`, they will contain `NaT`, which leads me to think, the `Series` are not formatted as `datetime` objects. * Given a `pandas.DataFrame` with two columns of dates * Convert the columns to a datetime, with `pandas.to_datetime` * `.fillna` on column `b`, which will ensure the time difference is < 10 minutes * If both columns are `None`, fill them with `pandas.Timedelta(0)` ```py import pandas as pd import numpy as np from datetime import timedelta a = ['2017-12-31 16:00:00-08:00', '2017-12-31 17:00:00-08:00', '2017-12-31 18:00:00-08:00', None] b = ['2017-12-31 17:00:00-08:00', None, '2017-12-31 18:00:10-08:00', None] # dataframe df = pd.DataFrame({'a': a, 'b': b}) # convert columns to datetime format df[['a', 'b']] = df[['a', 'b']].apply(pd.to_datetime) a b 0 2017-12-31 16:00:00-08:00 2017-12-31 17:00:00-08:00 1 2017-12-31 17:00:00-08:00 NaT 2 2017-12-31 18:00:00-08:00 2017-12-31 18:00:10-08:00 3 NaT NaT # fillna in column b with values from column a df.b = df.b.fillna(df.a) # if both columns are None, fillna with Timedelta(0) df[['a', 'b']] = df[['a', 'b']].fillna(pd.Timedelta(0)) a b 0 2017-12-31 16:00:00-08:00 2017-12-31 17:00:00-08:00 1 2017-12-31 17:00:00-08:00 2017-12-31 17:00:00-08:00 2 2017-12-31 18:00:00-08:00 2017-12-31 18:00:10-08:00 3 0 days 00:00:00 0 days 00:00:00 # function def date_check(x, y): return (np.abs(x - y)) < timedelta(minutes=10) # function call date_check(df.a, df.b) [out]: 0 False 1 True 2 True 3 True dtype: bool # add a column to the dataframe df['time_diff'] = np.abs(df.a - df.b) < pd.Timedelta(minutes=10) a b time_diff 0 2017-12-31 16:00:00-08:00 2017-12-31 17:00:00-08:00 False 1 2017-12-31 17:00:00-08:00 2017-12-31 17:00:00-08:00 True 2 2017-12-31 18:00:00-08:00 2017-12-31 18:00:10-08:00 True 3 0 days 00:00:00 0 days 00:00:00 True ```
It can't perform the operations on `NoneTypes` so just handle separately with a try/except block. ``` def date_check(x, y): try: return (np.abs(x - y)) > timedelta(minutes=10) except: return True ```
44,162,581
I want to run a script where I can specifically select ID tag where parameters are **\_string\_n\_n** where *'\_string'* = release (in this case) and *'n'* = are numbers # e.g. **\_release\_8\_3** Here's my code... where I wan to run the script and get content of tag where ID matches \_string\_n\_n ``` <div class="sect2"> <h3 id="_release_8_3">Release 8.3</h3> <div class="sect3"> <h4 id="_qa_test_release_1_2_4_to_take_a_look_at_manifest">QA TEST release 1.2.4 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.4.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_test_release_1_2_3_to_take_a_look_at_manifest">QA TEST release 1.2.3 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.3.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_release_8_3_1">QA release 8.3.1</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-8.2.6.html">Release Manifest</a></p> </li> <li> <p>Bugs <a href="link">fixed in this release</a></p> </li> <li> <p>Package updates:</p> <div class="literalblock"> <div class="content"> <pre>user-portal 8.2</pre> </div> </div> </li> <li> <p>Database migration scripts to run:</p> <div class="literalblock"> <div class="content"> <pre>none</pre> </div> </div> </li> </ul> </div> </div> </div> <div class="sect2"> <h3 id="_release_8_2">Release 8.2</h3> <div class="sect3"> <h4 id="_qa_test_release_1_2_4_to_take_a_look_at_manifest_2">QA TEST release 1.2.4 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.4.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_test_release_1_2_3_to_take_a_look_at_manifest_2">QA TEST release 1.2.3 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.3.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_release_8_2_6">QA release 8.2.6</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-8.2.6.html">Release Manifest</a></p> </li> <li> <p>Bugs <a href="link">fixed in this release</a></p> </li> <li> <p>Package updates:</p> <div class="literalblock"> <div class="content"> <pre>user-portal 8.2</pre> </div> </div> </li> <li> <p>Database migration scripts to run:</p> <div class="literalblock"> <div class="content"> <pre>none</pre> </div> </div> </li> </ul> </div> </div> </div> ```
2017/05/24
['https://Stackoverflow.com/questions/44162581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5326191/']
Select all elements with an ID containing the following string (in this case `_release_`: `document.querySelectorAll("[id*='_release_']");` In jQuery: `$("[id*='_release_']")` Here are [more wildcards](https://stackoverflow.com/a/8714421/1451422) if you need a different reaction. ```js console.dir(document.querySelectorAll("[id*='_release_']")) ``` ```html <div class="sect2"> <h3 id="_release_8_3">Release 8.3</h3> <div class="sect3"> <h4 id="_qa_test_release_1_2_4_to_take_a_look_at_manifest">QA TEST release 1.2.4 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.4.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_test_release_1_2_3_to_take_a_look_at_manifest">QA TEST release 1.2.3 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.3.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_release_8_3_1">QA release 8.3.1</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-8.2.6.html">Release Manifest</a></p> </li> <li> <p>Bugs <a href="link">fixed in this release</a></p> </li> <li> <p>Package updates:</p> <div class="literalblock"> <div class="content"> <pre>user-portal 8.2</pre> </div> </div> </li> <li> <p>Database migration scripts to run:</p> <div class="literalblock"> <div class="content"> <pre>none</pre> </div> </div> </li> </ul> </div> </div> </div> <div class="sect2"> <h3 id="_release_8_2">Release 8.2</h3> <div class="sect3"> <h4 id="_qa_test_release_1_2_4_to_take_a_look_at_manifest_2">QA TEST release 1.2.4 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.4.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_test_release_1_2_3_to_take_a_look_at_manifest_2">QA TEST release 1.2.3 (to take a look at manifest)</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-1.2.3.html">Release Manifest</a></p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_qa_release_8_2_6">QA release 8.2.6</h4> <div class="ulist"> <ul> <li> <p><a href="release-manifest-8.2.6.html">Release Manifest</a></p> </li> <li> <p>Bugs <a href="link">fixed in this release</a></p> </li> <li> <p>Package updates:</p> <div class="literalblock"> <div class="content"> <pre>user-portal 8.2</pre> </div> </div> </li> <li> <p>Database migration scripts to run:</p> <div class="literalblock"> <div class="content"> <pre>none</pre> </div> </div> </li> </ul> </div> </div> </div> ```
e.g. \_release\_8\_3 ``` var string = 'release'; var number1 = 8; var number2 = 3; var selector = '#_'+ [ string, number1, number2 ].join( '_' ); var element = $(selector); element = document.querySelector(selector); element = document.getElementById('_'+ [ string, number1, number2 ].join( '_' ) ); ``` Have you tried any of these? If instead you are wanting to find all ids that match a pattern, use a class instead. You can do pattern matching in lookups, however it is less performant and javascript will have to examine every single element in the dom to see if it matches your attribute pattern. Instead by giving like patterned id elements the same class, you can perform a class lookup which, along with id and tagName lookups, are some of the fastest lookups your browser can perform. Otherwise if you feel you absolutely must do this, I would instead try to steer you towards using one of the more efficient selectors, and then using filter to find what you want. For instance in your example it looks like the pattern you gave is associated with h3 elements, so you could do. ``` $('h3').filter(function(){ return /^[_]release[_][0-9]+[_][0-9]+$/.test(this.id); }); ``` Provided I got my regex right, this would find all the h3 elements and then filter to return only those that match the pattern `_release_#_#` where # is any number
19,422,647
I'm new in using codeigniter so am a bit confused now. When I pass the players data object to the view, it lists all correctly. I'm trying to use codeigniter's pagination. I loaded the pagination in a function in my controller: ``` public function playersHub(){ $playersData = $this->cms_model->getAllPlayers(); $pageConf = array( 'base_url' => base_url('home/playersHub/'), 'total_rows' => count($playersData), 'per_page' => 20, 'uri_segment' => 3, ); $this->pagination->initialize($pageConf); $data = array( 'players'=> $playersData, 'content'=> 'home', 'link' => $this->pagination->create_links() ); $this->load->view('template/template',$data); } ``` In my view: ``` <div class="container-fluid"> <div class="row-fluid"> <table class = "table table-strip"> <?php foreach($players as $p): ?> <tr> <td><?php echo $p->ufbid; ?></td> <td><?php echo $p->uname; ?></td> <td><?php echo $p->ulocation; ?></td> <td><?php echo $p->uemail; ?></td> <td><?php echo $p->umobile; ?></td> <td><?php echo (($p->ugrand == 0) ? 'no':'yes'); ?></td> <td><?php echo $p->points; ?></td> <td><?php echo $p->pticks; ?></td> </tr> <?php endforeach; ?> <tr><td colspan = "9"><?php echo $link; ?></td></tr> </table> </div> ``` I loaded the pagination in my constructor method. It creates a pagination but the data is still in one page. When I click 2 or "next", it still does the same thing.
2013/10/17
['https://Stackoverflow.com/questions/19422647', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2889753/']
1.Load the pagination library first: ``` $this->load->library('pagination'); ``` 2.Return the correct count from the database, make a different function to return the total count. dont count the data returned by the `getAllPlayers()`. Use `getAllPlayers()` to return `20 (per_page)` data to show in the page depending on the `offset($this->uri->segment(3))` in your case. Eg. ``` function playersHub(){ $perPage = 20; $playersData = $this->cms_model->getAllPlayers($perPage, $this->uri->segment(3)); $pageConf = array( 'base_url' => base_url('home/playersHub/'), 'total_rows' => $this->model_name->count_all(), 'per_page' => $perPage, 'uri_segment' => 3, ); $this->pagination->initialize($pageConf); $data = array( 'players'=> $playersData, 'content'=> 'home', 'link' => $this->pagination->create_links() ); $this->load->view('template/template',$data); } #function to count all the data in the table function count_all(){ return $this->db->count_all_results('table_name'); } #function to return data from the table depending on the offset and limit function getAllPlayers($limit, $offset = 0){ return $this->db->select('')->where('')->get('table_name', $limit, $offset)->result_array(); } ```
Something like this ``` public function playersHub(){ $playersData = $this->cms_model->getAllPlayers(); $pageConf = array( 'base_url' => base_url('home/playersHub/'), 'total_rows' => count($playersData), 'per_page' => 20, 'uri_segment' => 3, ); $this->pagination->initialize($pageConf); //get the start $start = ($this->uri->segment(3))?$this->uri->segment(3):0; //apply the pagination limits.You may need to modify your model function $playersData = $this->cms_model->getAllPlayers($start,$pageConf['per_page']); $data = array( 'players'=> $playersData, 'content'=> 'home', 'link' => $this->pagination->create_links() ); $this->load->view('template/template',$data); ``` }
18,233,232
I want to create an ul li tree menu based on html and css only, maybe a small jQuery. so this is my html: ``` <div class="wfm"> <ul class="firstUl"> <li> <span>Parent1</span> <ul> <li> <span>Parent2</span> <ul> <li> <span>Parent3</span> <ul> <li> <span>Parent4</span> <ul> <li> <span>Child4</span> </li> <li> <span>Child4</span> </li> <li> <span>Child4</span> </li> </ul> </li> <li> <span>Parent4</span> </li> <li> <span>Parent4</span> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> ``` and this is the css trick to show ul content: ``` .subParent,.subParent1,.subParent2,.subParent3{ display: none; } li:focus .subParent,li:focus .subParent1,li:focus .subParent2,li:focus .subParent3{ display: block; } ``` My problems: 1: when I click on first parent all tree is expanded and not only parent2; 2: I can hide that ul's using css `display:none` and bring back with `:focus` event but how can I collapse that tree. **[FIDDLE](http://jsfiddle.net/DMfvx/206/)**
2013/08/14
['https://Stackoverflow.com/questions/18233232', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1192687/']
Well, why not leverage details/summary elements of HTML5.1? It requires no JavaScript and customizable via CSS. Here an example ``` <details class="tree-nav__item is-expandable"> <summary class="tree-nav__item-title">The Realm of the Elderlings</summary> <details class="tree-nav__item is-expandable"> <summary class="tree-nav__item-title">The Six Duchies</summary> <a class="tree-nav__item-title"><i class="icon ion-ios-bookmarks"></i> Assassin’s Apprentice</a> </details> </details> ``` <https://codepen.io/dsheiko/pen/MvEpXm/> [![enter image description here](https://i.stack.imgur.com/K8Xhh.png)](https://i.stack.imgur.com/K8Xhh.png) Evergreen browser all support the elements, for legacy to can use a polyfill. e.g. <https://github.com/javan/details-element-polyfill>
Just created a single HTML with CSS and JS embedded for this kind of task. [GitHub repo](https://github.com/Leedehai/expandable-tree-list), the link will stay valid as I have no plan to remove it.
46,272,260
I need help making my module accept my newly generated pages. In my terminal I used the ionic command `ionic generate page` to create two new pages in my file tree. One called privacy-policy and the other terms-of-use. It built the new pages just fine: \*\*privacy policy page \*\* ``` /* Generated class for the PrivacyPolicy page. Ionic pages and navigation. */ @Component({ selector: 'page-privacy-policy', templateUrl: 'privacy-policy.html' }) export class PrivacyPolicyPage { constructor(public navCtrl: NavController) {} ionViewDidLoad() { console.log('Hello PrivacyPolicyPage Page'); } } ``` **terms of use page** ``` /* Generated class for the TermsOfUse page. */ @Component({ selector: 'page-terms-of-use', templateUrl: 'terms-of-use.html' }) export class TermsOfUsePage { constructor(public navCtrl: NavController) {} ionViewDidLoad() { console.log('Hello TermsOfUsePage Page'); } } ``` But when I went to push the pages to a nav controller on another page. I got build errors in the terminal first that said `cannot determine module for component PrivacyPolicyPage` (and terms of use page respectively), then when I added the pages to the module in `app.module.ts`. I got an error that said `unexpected value PrivacyPolicyPage declared by the module AppModule`. What am I supposed to do here? This is the entire **app.module.ts** file: ``` import { NgModule, ErrorHandler } from '@angular/core'; import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; //other imports import { TermsOfUsePage } from '../terms-of-use/terms-of-use'; import { PrivacyPolicyPage } from '../privacy-policy/privacy-policy'; @NgModule({ declarations: [ *otherPages*, *otherPages*, TermsOfUsePage, PrivacyPolicyPage ], imports: [ IonicModule.forRoot(MyApp) ], bootstrap: [IonicApp], entryComponents: [ *otherPages*, *otherPages*, TermsOfUsePage, PrivacyPolicyPage ], providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}] }) export class AppModule {} ```
2017/09/18
['https://Stackoverflow.com/questions/46272260', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1319386/']
1. Check if its name is precisely `pre-push` (not `pre-push.sh`, not `pre-push.py`, precisely `pre-push`, with no file extension). 2. Check if it's in `.git/hooks/`. If you have set `core.hooksPath=xxx` in the config, make sure it's under the directory `xxx`. 3. Check if it's executable. 4. Check if the user that runs `pre-push` also has the permission to run `npm run coverage`.
for your short description,I can't locate the reason. But you can try`husky` or `ghooks`. `husky` or `ghooks` provide git hooks,such as `precommit`,`prepush`: ``` //husky { "scripts": { "precommit": "npm test", "prepush": "npm run coverage", "...": "..." } } ```
46,272,260
I need help making my module accept my newly generated pages. In my terminal I used the ionic command `ionic generate page` to create two new pages in my file tree. One called privacy-policy and the other terms-of-use. It built the new pages just fine: \*\*privacy policy page \*\* ``` /* Generated class for the PrivacyPolicy page. Ionic pages and navigation. */ @Component({ selector: 'page-privacy-policy', templateUrl: 'privacy-policy.html' }) export class PrivacyPolicyPage { constructor(public navCtrl: NavController) {} ionViewDidLoad() { console.log('Hello PrivacyPolicyPage Page'); } } ``` **terms of use page** ``` /* Generated class for the TermsOfUse page. */ @Component({ selector: 'page-terms-of-use', templateUrl: 'terms-of-use.html' }) export class TermsOfUsePage { constructor(public navCtrl: NavController) {} ionViewDidLoad() { console.log('Hello TermsOfUsePage Page'); } } ``` But when I went to push the pages to a nav controller on another page. I got build errors in the terminal first that said `cannot determine module for component PrivacyPolicyPage` (and terms of use page respectively), then when I added the pages to the module in `app.module.ts`. I got an error that said `unexpected value PrivacyPolicyPage declared by the module AppModule`. What am I supposed to do here? This is the entire **app.module.ts** file: ``` import { NgModule, ErrorHandler } from '@angular/core'; import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; //other imports import { TermsOfUsePage } from '../terms-of-use/terms-of-use'; import { PrivacyPolicyPage } from '../privacy-policy/privacy-policy'; @NgModule({ declarations: [ *otherPages*, *otherPages*, TermsOfUsePage, PrivacyPolicyPage ], imports: [ IonicModule.forRoot(MyApp) ], bootstrap: [IonicApp], entryComponents: [ *otherPages*, *otherPages*, TermsOfUsePage, PrivacyPolicyPage ], providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}] }) export class AppModule {} ```
2017/09/18
['https://Stackoverflow.com/questions/46272260', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1319386/']
check .git/hooks. If it's empty try to uninstall husky and install again. my sh history ``` ls .git/hooks npm uninstall husky npm i husky -D ls .git/hooks ``` it helped me
for your short description,I can't locate the reason. But you can try`husky` or `ghooks`. `husky` or `ghooks` provide git hooks,such as `precommit`,`prepush`: ``` //husky { "scripts": { "precommit": "npm test", "prepush": "npm run coverage", "...": "..." } } ```
46,272,260
I need help making my module accept my newly generated pages. In my terminal I used the ionic command `ionic generate page` to create two new pages in my file tree. One called privacy-policy and the other terms-of-use. It built the new pages just fine: \*\*privacy policy page \*\* ``` /* Generated class for the PrivacyPolicy page. Ionic pages and navigation. */ @Component({ selector: 'page-privacy-policy', templateUrl: 'privacy-policy.html' }) export class PrivacyPolicyPage { constructor(public navCtrl: NavController) {} ionViewDidLoad() { console.log('Hello PrivacyPolicyPage Page'); } } ``` **terms of use page** ``` /* Generated class for the TermsOfUse page. */ @Component({ selector: 'page-terms-of-use', templateUrl: 'terms-of-use.html' }) export class TermsOfUsePage { constructor(public navCtrl: NavController) {} ionViewDidLoad() { console.log('Hello TermsOfUsePage Page'); } } ``` But when I went to push the pages to a nav controller on another page. I got build errors in the terminal first that said `cannot determine module for component PrivacyPolicyPage` (and terms of use page respectively), then when I added the pages to the module in `app.module.ts`. I got an error that said `unexpected value PrivacyPolicyPage declared by the module AppModule`. What am I supposed to do here? This is the entire **app.module.ts** file: ``` import { NgModule, ErrorHandler } from '@angular/core'; import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; //other imports import { TermsOfUsePage } from '../terms-of-use/terms-of-use'; import { PrivacyPolicyPage } from '../privacy-policy/privacy-policy'; @NgModule({ declarations: [ *otherPages*, *otherPages*, TermsOfUsePage, PrivacyPolicyPage ], imports: [ IonicModule.forRoot(MyApp) ], bootstrap: [IonicApp], entryComponents: [ *otherPages*, *otherPages*, TermsOfUsePage, PrivacyPolicyPage ], providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}] }) export class AppModule {} ```
2017/09/18
['https://Stackoverflow.com/questions/46272260', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1319386/']
1. Check if its name is precisely `pre-push` (not `pre-push.sh`, not `pre-push.py`, precisely `pre-push`, with no file extension). 2. Check if it's in `.git/hooks/`. If you have set `core.hooksPath=xxx` in the config, make sure it's under the directory `xxx`. 3. Check if it's executable. 4. Check if the user that runs `pre-push` also has the permission to run `npm run coverage`.
check .git/hooks. If it's empty try to uninstall husky and install again. my sh history ``` ls .git/hooks npm uninstall husky npm i husky -D ls .git/hooks ``` it helped me
47,318,119
I am trying to wrap a Python script into an exe using PyInstaller (development version) for windows. The script uses Pandas and I have been running into an error when running the exe. ``` Traceback (most recent call last): File "site-packages\pandas\__init__.py", line 26, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\_libs\__init__.py", line 4, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "G5k Version file Extract (with tkinter).py", line 15, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\__init__.py", line 35, in <module> ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. ``` I have tried doing this for programs without pandas and everything was fine. This is very similar to [another question](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358) already solved for Python 2, but I am using Python 3 and that solution does not apply the same way due to the changed .spec file format. Python 3.6 PyInstaller - version 3.3 Pandas - version 0.20.3
2017/11/15
['https://Stackoverflow.com/questions/47318119', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8436718/']
PyInstaller 3.3, Pandas 0.21.0, Python 3.6.1. I was able to solve this thanks to not-yet published/committed fix to PyInstaller, see [this](https://github.com/pyinstaller/pyinstaller/issues/2978) and [this](https://github.com/lneuhaus/pyinstaller/blob/017b247064f9bd51a620cfb2172c05d63fc75133/PyInstaller/hooks/hook-pandas.py). AND keeping the ability to pack it into one executable file. Basically: 1. Locate PyInstaller folder..\hooks, e.g. `C:\Program Files\Python\Lib\site-packages\PyInstaller\hooks`. 2. Create file hook-pandas.py with contents (or anything similar based on your error): ``` hiddenimports = ['pandas._libs.tslibs.timedeltas'] ``` 3. Save it + I deleted .spec file, build and dist folders just to be sure. 4. Run `pyinstaller -F my_app.py`. This fix should work as long as you don't upgrade or reinstall PyInstaller. So you don't need to edit .spec file. Maybe they will include the fix sooner for us! :)
I'm not sure it may help you but following the solution on the post you mention work for me with python 3.6 pyinstaller 3.3 and pandas 0.21.0 on windows 7. So adding this to the spec file just after analysis : ``` def get_pandas_path(): import pandas pandas_path = pandas.__path__[0] return pandas_path dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"]) a.datas += dict_tree a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries) ``` Also my spec file format is the same as the one in [the post you mention](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358).
47,318,119
I am trying to wrap a Python script into an exe using PyInstaller (development version) for windows. The script uses Pandas and I have been running into an error when running the exe. ``` Traceback (most recent call last): File "site-packages\pandas\__init__.py", line 26, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\_libs\__init__.py", line 4, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "G5k Version file Extract (with tkinter).py", line 15, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\__init__.py", line 35, in <module> ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. ``` I have tried doing this for programs without pandas and everything was fine. This is very similar to [another question](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358) already solved for Python 2, but I am using Python 3 and that solution does not apply the same way due to the changed .spec file format. Python 3.6 PyInstaller - version 3.3 Pandas - version 0.20.3
2017/11/15
['https://Stackoverflow.com/questions/47318119', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8436718/']
I'm not sure it may help you but following the solution on the post you mention work for me with python 3.6 pyinstaller 3.3 and pandas 0.21.0 on windows 7. So adding this to the spec file just after analysis : ``` def get_pandas_path(): import pandas pandas_path = pandas.__path__[0] return pandas_path dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"]) a.datas += dict_tree a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries) ``` Also my spec file format is the same as the one in [the post you mention](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358).
If you are using Anaconda, it is highly likely that when you were trying to uninstall some package it has disrupted pandas dependency and unable to get the required script. If you just run `conda install pandas` you might end up with another error: > > `module 'pandas' has no attribute 'compat'`. > > > So, try uninstalling and reinstalling pandas `conda uninstall pandas`, Install it again using `conda install pandas` this will solve the problem. On the other hand, if you are not using Anaconda., try doing the same on Command prompt pointing to Python scripts folder `pip uninstall pandas & pip install pandas`. Most of the times, this should solve the problem. Just to be cover all the possibilities, don't forget to Launch Spyder from Anaconda after installing pandas.
47,318,119
I am trying to wrap a Python script into an exe using PyInstaller (development version) for windows. The script uses Pandas and I have been running into an error when running the exe. ``` Traceback (most recent call last): File "site-packages\pandas\__init__.py", line 26, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\_libs\__init__.py", line 4, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "G5k Version file Extract (with tkinter).py", line 15, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\__init__.py", line 35, in <module> ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. ``` I have tried doing this for programs without pandas and everything was fine. This is very similar to [another question](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358) already solved for Python 2, but I am using Python 3 and that solution does not apply the same way due to the changed .spec file format. Python 3.6 PyInstaller - version 3.3 Pandas - version 0.20.3
2017/11/15
['https://Stackoverflow.com/questions/47318119', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8436718/']
PyInstaller 3.3, Pandas 0.21.0, Python 3.6.1. I was able to solve this thanks to not-yet published/committed fix to PyInstaller, see [this](https://github.com/pyinstaller/pyinstaller/issues/2978) and [this](https://github.com/lneuhaus/pyinstaller/blob/017b247064f9bd51a620cfb2172c05d63fc75133/PyInstaller/hooks/hook-pandas.py). AND keeping the ability to pack it into one executable file. Basically: 1. Locate PyInstaller folder..\hooks, e.g. `C:\Program Files\Python\Lib\site-packages\PyInstaller\hooks`. 2. Create file hook-pandas.py with contents (or anything similar based on your error): ``` hiddenimports = ['pandas._libs.tslibs.timedeltas'] ``` 3. Save it + I deleted .spec file, build and dist folders just to be sure. 4. Run `pyinstaller -F my_app.py`. This fix should work as long as you don't upgrade or reinstall PyInstaller. So you don't need to edit .spec file. Maybe they will include the fix sooner for us! :)
I managed to solve this problem by using the "--hidden-import" flag. Hopefully this can be helpful to someone else that comes across this thread. ``` pyinstaller --onefile --hidden-import pandas._libs.tslibs.timedeltas myScript.py ```
47,318,119
I am trying to wrap a Python script into an exe using PyInstaller (development version) for windows. The script uses Pandas and I have been running into an error when running the exe. ``` Traceback (most recent call last): File "site-packages\pandas\__init__.py", line 26, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\_libs\__init__.py", line 4, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "G5k Version file Extract (with tkinter).py", line 15, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\__init__.py", line 35, in <module> ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. ``` I have tried doing this for programs without pandas and everything was fine. This is very similar to [another question](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358) already solved for Python 2, but I am using Python 3 and that solution does not apply the same way due to the changed .spec file format. Python 3.6 PyInstaller - version 3.3 Pandas - version 0.20.3
2017/11/15
['https://Stackoverflow.com/questions/47318119', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8436718/']
PyInstaller 3.3, Pandas 0.21.0, Python 3.6.1. I was able to solve this thanks to not-yet published/committed fix to PyInstaller, see [this](https://github.com/pyinstaller/pyinstaller/issues/2978) and [this](https://github.com/lneuhaus/pyinstaller/blob/017b247064f9bd51a620cfb2172c05d63fc75133/PyInstaller/hooks/hook-pandas.py). AND keeping the ability to pack it into one executable file. Basically: 1. Locate PyInstaller folder..\hooks, e.g. `C:\Program Files\Python\Lib\site-packages\PyInstaller\hooks`. 2. Create file hook-pandas.py with contents (or anything similar based on your error): ``` hiddenimports = ['pandas._libs.tslibs.timedeltas'] ``` 3. Save it + I deleted .spec file, build and dist folders just to be sure. 4. Run `pyinstaller -F my_app.py`. This fix should work as long as you don't upgrade or reinstall PyInstaller. So you don't need to edit .spec file. Maybe they will include the fix sooner for us! :)
If you are using Anaconda, it is highly likely that when you were trying to uninstall some package it has disrupted pandas dependency and unable to get the required script. If you just run `conda install pandas` you might end up with another error: > > `module 'pandas' has no attribute 'compat'`. > > > So, try uninstalling and reinstalling pandas `conda uninstall pandas`, Install it again using `conda install pandas` this will solve the problem. On the other hand, if you are not using Anaconda., try doing the same on Command prompt pointing to Python scripts folder `pip uninstall pandas & pip install pandas`. Most of the times, this should solve the problem. Just to be cover all the possibilities, don't forget to Launch Spyder from Anaconda after installing pandas.
47,318,119
I am trying to wrap a Python script into an exe using PyInstaller (development version) for windows. The script uses Pandas and I have been running into an error when running the exe. ``` Traceback (most recent call last): File "site-packages\pandas\__init__.py", line 26, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\_libs\__init__.py", line 4, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "G5k Version file Extract (with tkinter).py", line 15, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pandas\__init__.py", line 35, in <module> ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. ``` I have tried doing this for programs without pandas and everything was fine. This is very similar to [another question](https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas/32974358#32974358) already solved for Python 2, but I am using Python 3 and that solution does not apply the same way due to the changed .spec file format. Python 3.6 PyInstaller - version 3.3 Pandas - version 0.20.3
2017/11/15
['https://Stackoverflow.com/questions/47318119', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8436718/']
I managed to solve this problem by using the "--hidden-import" flag. Hopefully this can be helpful to someone else that comes across this thread. ``` pyinstaller --onefile --hidden-import pandas._libs.tslibs.timedeltas myScript.py ```
If you are using Anaconda, it is highly likely that when you were trying to uninstall some package it has disrupted pandas dependency and unable to get the required script. If you just run `conda install pandas` you might end up with another error: > > `module 'pandas' has no attribute 'compat'`. > > > So, try uninstalling and reinstalling pandas `conda uninstall pandas`, Install it again using `conda install pandas` this will solve the problem. On the other hand, if you are not using Anaconda., try doing the same on Command prompt pointing to Python scripts folder `pip uninstall pandas & pip install pandas`. Most of the times, this should solve the problem. Just to be cover all the possibilities, don't forget to Launch Spyder from Anaconda after installing pandas.
39,528,273
I have this file with 20k+ IPs inside: ``` 104.20.15.220,104.20.61.219,104.20.62.219,104.20.73.221,104.20.74.221,104.20.14.220 104.20.15.220,104.20.73.221,104.20.74.221,104.25.195.107,104.25.196.107,104.20.14.220 91.215.154.209 ... ``` The question is how to split in into single IPs on each string: ``` 104.20.15.220 104.20.61.219 ```
2016/09/16
['https://Stackoverflow.com/questions/39528273', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5311904/']
Just replace a comma with a new line with either of these commands: ``` tr ',' '\n' < file sed 's/,/\n/g' file perl 's/,/\n/g' file awk 'gsub(/,/,"\n")' file ``` ... or match every block of text up to a comma or the end of line: ``` grep -oP '.*?(?=,|$)' file ``` ... or loop through the fields and print them: ``` awk -F, '{for(i=1;i<=NF;i++) print $i}' file ``` ... or set the record separator to the comma and let `awk` do all the work: ``` awk -v RS=, '1' file awk 1 RS=, file ``` ... or match the IPs, you can use the regex from [Matching IPv4 Addresses](https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html): ``` grep -oE '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' file ``` --- They all return: ``` 104.20.15.220 104.20.61.219 104.20.62.219 104.20.73.221 ... ```
This will transform all the commands into newline. ``` tr ',' '\n' <filename ``` or ``` awk 'BEGIN{FS=",";OFS="\n"}{$1=$1}1' filename ```
976,120
I have a PHP script running that lists files in a certain directory on the server. Is there any way to access the file's icon metadata? Lots of issues with this I suppose (eg: depends on the OS hosting the script. depends on whether the file is using a custom icon. still have to convert the icn file to something that can be displayed in a browser) but any suggestions are welcome. I guess I could display a different icon depending on the file extension, but it would be nice to do it automatically.
2009/06/10
['https://Stackoverflow.com/questions/976120', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4939/']
You might be able to plug into the /icons folder that most apache installations have setup for their default directory listings. It's not OS dependent at least. You should be able to craft a url that displays an icon for a particular extension.
[GDLib](http://php.oregonstate.edu/manual/en/book.image.php) or [ImageMagic](http://php.oregonstate.edu/manual/en/book.imagick.php) possibly is that what you are looking for... But if you want to access metadata GDLib won't help. Not sure about ImageMagic. Actually, you can create thumbnails with their help and cache them somewhere to avoid performance issues.