title
stringlengths 10
150
| body
stringlengths 17
64.2k
| label
int64 0
3
|
---|---|---|
How to get value from previous field to new field | <p>Is there any way to call value from previous field to the new field by using trigger?
i have tried with following method and this method is working perfectly with first row but when i moved to second row it automatically copy data from "remaining" to "monthly" field:</p>
<pre><code>BEGIN
IF (:REMAINING IS NULL) THEN
:REMAINING=:MONTHLY-:FEE;
NEXT_ITEM;
:MONTHLY:=:REMAINING;
END IF;
END;
</code></pre> | 3 |
CSS animation-delay timing | <p>I took this example code from JSFiddle and played with it, but there is code confusing me</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.backgroundimg {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
#back5 {
background: url("http://duananhalotus.com/upload/album/0904234.jpg") no-repeat center fixed;
z-index: -1;
}
#back4 {
background: url("http://www.chinadaily.com.cn/world/images/attachement/jpg/site1/20120806/d4bed9d534551189e67329.jpg") no-repeat center fixed;
z-index: -1;
}
#back3 {
background: url("https://amazingslider.com/wp-content/uploads/2012/12/dandelion.jpg") no-repeat center fixed;
z-index: -1;
}
#back2 {
background: url("https://cdn.pixabay.com/photo/2013/04/06/11/50/image-editing-101040_960_720.jpg") no-repeat center fixed;
z-index: -1;
}
#back1 {
background: url("http://www.gettyimages.com/gi-resources/images/Embed/new/embed2.jpg") no-repeat center fixed;
z-index: -1;
}
@keyframes backgroundchangeFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
@-webkit-keyframes backgroundchangeFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#backgroundchange div:nth-of-type(1) {
animation-delay: 8s;
-webkit-animation-delay: 8s;
}
#backgroundchange div:nth-of-type(2) {
animation-delay: 6s;
-webkit-animation-delay: 6s;
}
#backgroundchange div:nth-of-type(3) {
animation-delay: 4s;
-webkit-animation-delay: 4s;
}
#backgroundchange div:nth-of-type(4) {
animation-delay: 2s;
-webkit-animation-delay: 2s;
}
#backgroundchange div:nth-of-type(5) {
animation-delay: 0;
-webkit-animation-delay: 0;
}
#backgroundchange div {
animation-name: backgroundchangeFadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 8s;
-webkit-animation-name: backgroundchangeFadeInOut;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 8s;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="inner">
<div id="backgroundchange">
<div class="backgroundimg" id="back1"></div>
<div class="backgroundimg" id="back2"></div>
<div class="backgroundimg" id="back3"></div>
<div class="backgroundimg" id="back4"></div>
<div class="backgroundimg" id="back5"></div>
</div>
</div></code></pre>
</div>
</div>
</p>
<p>It takes 2 seconds for each image to crossfade to the next, I tried changing it to 3 seconds by adding one second on each nth-of-type but didn't work. I need your help with this please!</p> | 3 |
Event listeners overwriting one another? | <pre><code>function newMenu(items,results){
document.getElementById("menu").innerHTML = "";
for (var i = 0; i < items.length; i++) {
document.getElementById("menu").innerHTML += "<li>" + items[i] + "</li>";
document.getElementById("menu").childNodes[i].addEventListener("click",function(){document.write("foo")});
};
}
</code></pre>
<p>I am trying to use this code to generate a list and then give each of the list items a different function to be activated when they are clicked (right now I've just made them all write "foo" to test that the event listeners work). However, when I run this function, it will write all of the list content correctly (they're passed as an array into 'items').</p>
<p>My problem arises with the event listeners. Only the last list item's event listener works. That is to say, only when I click on the last li in the list does it execute document.write("foo"). I've tried changing the size of the items array and every time it's the last list item, regardless of length. Why might this be? Are the event listeners overwriting one another?</p> | 3 |
Print transaction status on TextArea | <p>I am developing a project which does the following :</p>
<p>1.truncate a temporary table T1. </p>
<p>2.insert some thousand rows into temporary table T1.</p>
<p>3.Execute a procedure which has some commit statements in it.</p>
<p>4.insert rows from table T1 to other identical table(with respect to structure) T2</p>
<p>5.Execute 2 more procedures.</p>
<p>Now i have made a swing UI which contains TextArea on which i want to print transaction status. Something like this</p>
<p>Reading Excel File..
Validating Excel File..
inserting entries into table T1.. and so on</p>
<p>I have made the following method to update status at each step.</p>
<pre><code>public void updateStatus(String message){
String temp = this.statusText.getText();
this.statusText.setText(temp + message + "\n");
}
</code></pre>
<p>Calling this method along with statements where i do</p>
<p><code>log.debug(message)</code> does the job for me ! However this complicates my code design. Every DAO Component now depends on this method. Can anyone suggest me a better design option.</p>
<p>Thanks in Advance !</p> | 3 |
OpenCover and GoogleTest - Complains missing PDBs | <p>The build I am currently working on uses Visual Studio 2008 (Professional) in a 32bit environment to compile. We have been using Google Test Framework to create unit test. We are trying to use OpenCover to report code coverage, and it returns </p>
<pre><code>"no results - no assemblies that matched the supplied filter were instrumented. this could be due to missing PDBs for the assemblies that match the filter. please review the output file and refer to the Usage guide (Usage.rtf)"
</code></pre>
<p>The Test executable did run as I saw the result displayed on the console. The PDB is at the same directory as the Google Test Executable. The command that I have used:</p>
<pre><code>OpenCover.Console.exe -target:<Full Path Unit Test Executable> -targetdir:<Directory of the exeutable which also includes the PDB> -output:cover.xml
</code></pre>
<p>Note: The directory and exeutable do not contains space, so I have omitted quotation, but I have tried using it or without, and the result is the same</p>
<p>Things I have tried:</p>
<ul>
<li>I have explicitly registered the OpenCover.Profile.dll </li>
<li>I have used -register:user argument</li>
<li>I have tried to use -targetargs:"/noshadow" (and the noisolation), which I believe these are specific to MSTest and NUnit, but not for GoogleTest</li>
<li>I have tried omitting the targetdir parameter</li>
<li>I have installed the VS 2010 redistribution </li>
</ul>
<p>All of them yield the same result. I am able to run the sample that comes with the installation. </p>
<p>Has anyone successfully integrate Google Testing Framework with OpenCover? Or is there specific compilation setup on the project? (I have turned on/off profiling, and it didn't make a difference)</p>
<p>Thanks!</p> | 3 |
Works in localhost but not when uploaded on server | <p>I have a problem...
When I use</p>
<pre><code>header('location: index.php?error=3');
</code></pre>
<p>It works in localhost but not in my website uploaded.
I mean, in localhost everything goes fine, but online it doesn't change page, it load only half of the page and that's it, with no image, et cetera.</p>
<p>EDIT:
It does it with all header();</p>
<p>Thank you.</p> | 3 |
Single quote argument is converted to double quoted argument when passed to oracle function and called from shell script | <p>I am trying to execute one oracle function from shell script.
This function just takes two string arguments and returns full their concatenated string.
Here is the oracle function</p>
<pre><code>create or replace package temp as
function getName(v_fname in varchar2, v_lname varchar2) return varchar2;
end temp;
create or replace package body temp as
function getName(v_fname in varchar2, v_lname in varchar2) return varchar2 is
v_fullname varchar2(17);
begin
--DBMS_OUTPUT.PUT_LINE(v_name);
v_fullname := concat(v_fname,v_lname);
return v_fullname;
end getName;
end temp;
/
</code></pre>
<p>Here is snippet of shell script</p>
<pre><code>fullname=$(sqlplus -s myuser/password@DBinstance << !
set heading off
set feedback off
SELECT TEMP.GETNAME('Vishal','Tavande') FROM DUAL;
!)
echo $fullname
</code></pre>
<p>When I execute <code>SELECT TEMP.GETNAME('Vishal','Tavande') FROM DUAL</code> in Oracle, I can get the result as 'VishalTavande'; but when I execute this in Shell, what I get is</p>
<blockquote>
<p>fullname=SELECT TEMP.GETNAME("Vishal","Tavande") FROM DUAL ERROR at
line 1: ORA-00904: "Vishal": invalid identifier</p>
</blockquote>
<p>Any help is really appreciable.
Thanks</p> | 3 |
Uncaught TypeError: Cannot read property 'value' of null using joomla | <p>this error comes up when using the following :
field <strong>otherinfo</strong> has id=idOtherInfo and is declared in a <strong>.xml</strong> file under Models, Forms in <strong>joomla</strong>.
The field has a default value in the declaration to prevent the null (shows the default value in the browser) and using the
<code>onchange="dosomething()"</code>
I am running a javascript file, which runs ok as it shows an alert and then it halts on the command
<code>var first1 = document.getElementById("idOtherInfo").value;</code>
The javascript file is loaded by </p>
<pre><code>JHtml::script(JURI::root() . 'media/com_hr/js/validateFields.js', true);
</code></pre>
<p>also can be loaded by</p>
<pre><code>$document = JFactory::getDocument();
$document->addScript(JURI::root().'media/com_hr/js/validateFields.js');
</code></pre>
<p>Can you please help?
Thanks</p> | 3 |
Angular ng-repeat like parameters binding | <p>Is it possible to bind angular ng-repeat parameters to do something like this:</p>
<pre><code>ng-repeat="[BIND_THIS]"
</code></pre>
<p>Furthermore, I'd like to be able to bind in this kind of scenario:</p>
<pre><code><input type="text" ng-model="customSelected" placeholder="Custom template" typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-template-url="customTemplate.html" class="form-control">
</code></pre>
<p>Would become</p>
<pre><code><input type="text" ng-model="customSelected" placeholder="Custom template" typeahead="[BIND_THIS]" typeahead-template-url="customTemplate.html" class="form-control">
</code></pre>
<p>Thanks</p> | 3 |
module array output | <p>I'm writing a module to add functionality to the FlagShihTzu gem.</p>
<p>Basically it goes through the flags and outputs the keys for the ones assigned to the object. It's working, but I also want to be able to use a block in the view to do things with the output.</p>
<p>The problem is that it's outputting both the array from the module and the output from the block in the view.</p>
<pre><code>module AwesomeFlags
def my_flags(column = nil)
a = self.flag_mapping
if column.nil?
c = a.values.map {|var| var.keys}.flatten
else
b = a[column]
c = Array.[](b.keys).flatten
end
c.map {|var| self.send(var) ? "#{var.to_s} " : nil}.compact!
end
end
</code></pre>
<p>In the view:</p>
<pre><code>= book_offer.my_flags.each do |flag|
= flag.titleize
</code></pre>
<p>What I get is:</p>
<pre><code>Regular Complimentary regular complimentary
</code></pre> | 3 |
Is it safe to reuse a conduit? | <p>Is it safe to perform multiple actions using the same conduit value? Something like</p>
<pre><code>do
let sink = sinkSocket sock
something $$ sink
somethingElse $$ sink
</code></pre>
<p>I recall that in the early versions of conduit there were some dirty hacks that made this unsafe. What's the current status?</p>
<p>(Note that <code>sinkSocket</code> doesn't close the socket.)</p> | 3 |
Variable sized packet | <p>I am trying to define a packet whose length is determined during an ns-3 simulation (think of it as a packet sent on the downlink containing schedule information whose length depends on the number of nodes in the network which can join/leave the network during simulation). Does anyone have any idea how I could approach this? </p> | 3 |
apply parent's hover to jquery ui autocomplete child | <p>I'm in a similar situation a my other problem <a href="https://stackoverflow.com/questions/16195454/prevent-datepicker-from-triggering-parent-mouseleave/16196098?noredirect=1#16196098">prevent datepicker from triggering parent mouseleave</a>, but that solution doesn't seem to apply to jQuery UI autocomplete.</p>
<p>How can the hover also apply to autocomplete children? In other words, if one <code>mouseenter</code>s on an autocomplete suggestion, <code>#hoverMe</code> should stay open. Also, suggestion/code on how to handle <code>select</code>ing a selection that's outside of <code>#hoverMe</code> while keeping <code>#hoverMe</code> shown until one <code>mouseenter</code>s back in would be great!</p>
<p><a href="http://jsfiddle.net/Kzp87/" rel="nofollow noreferrer">http://jsfiddle.net/Kzp87/</a></p>
<p><strong>html</strong></p>
<pre><code><div id="hoverAnchor">hover me</div>
<div id="hoverMe" style="display:none">arbitrary text
<input type="text" id="autocompletor"></div>
</div>
</code></pre>
<p><strong>js</strong></p>
<pre><code>$(document).ready(function () {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#autocompletor").autocomplete({
source: availableTags
});
var _enter = false;
$("#hoverAnchor").add($("#hoverMe")).mouseenter(function () {
if (!_enter) {
$("#hoverMe").stop(true, false).animate({
height: 'toggle',
opacity: 'toggle'
}, 200);
}
_enter = true;
}).mouseleave(function () {
_enter = false;
$("#hoverMe").stop(true, false).animate({
height: 'toggle',
opacity: 'toggle'
}, 200);
});
});
</code></pre> | 3 |
Resizing lots of images via PHP, keeping aspect and not using all my RAM? | <p>I have a problem that I thought was easily solved, but is turning out a little more difficult than anticipated.</p>
<p>I am working on a site which someone can upload images for a product, and it resizes them twice (500x500 and 150x150) on the fly. I am trying to keep the aspect ratio, for example if I had 600x500 image it would resize to 500x417 and 150x125.</p>
<p>I have found (lots) of code that does this, such as <a href="http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/" rel="nofollow">this class</a>, however I always run into memory issues. I think the class isn't unloading/destroying the temporary images after resizing.</p>
<p>I had the host upgrade my memory-limit to 64M from 32, however I run out of memory later. I'm stuck with PHP 5.2.13 as well, so no garbage collector for me.</p>
<p>My PHP is fairly new, so it's very alien to me how classes work, otherwise I would try adding the imagedestroy() function where required. I fiddled with the linked class for hours without success.</p>
<p>Can anyone either:</p>
<p>-Point me in the direction of a magic class that keeps aspect as well as unloading/destroying temporary images after resizing is complete, to keep RAM usage under control?</p>
<p>-Give me some (much needed!) guidance on where and how I could modify a class (such as the one posted) to destroy temporary images.</p>
<p>-Tell me if I'm going around this extremely wrong?</p>
<p>Oh, and I had the WideImage class working at one point, and it worked great, then suddenly stopped. I spent hours trying to fix it with no success.</p>
<p>My PHP install has GD, but not ImageMagick.</p>
<p>Thanks!</p> | 3 |
available CRAN vignettes | <p>There's the <code>available.packages()</code> function to list all packages available on CRAN. Is there a similar function to find all available vignettes? If not how would I get a list of all vignettes and the packages they're associated with?</p>
<p>As a corner case to keep in mind the <code>data.table</code> package has 3 vignettes associated with it. </p>
<p><strong>EDIT: Per Andrie's response I realize I wasn't clear. I know about the vignette function for finding all the available local vignettes, I'm after a way to get all the vignettes of all packages on CRAN.</strong></p> | 3 |
Read XML with c# | <p>I have a xml file that looks like this </p>
<pre><code> <?xml version="1.0" standalone="yes"?>
<Ribbon>
<Tab Text="Tab1">
<Grupi Text="Grupi1">
<Buttoni Moduli="Appdec.Simea.Modulet.DepartamentetM.dll" />
</Grupi>
<Grupi Text="Grupi2" />
</Tab>
<Tab Text="Tab2">
<Grupi Text="Grupi1">
<Buttoni Moduli="Appdec.Simea.Modulet.DhomatM.dll" />
</Grupi>
<Grupi Text="Grupi2">
<Buttoni Moduli="Appdec.Simea.Modulet.KategoriteEArtikujveM.dll" />
<Buttoni Moduli="Appdec.Simea.Modulet.KategoriteEArtikujveM.dll" />
</Grupi>
</Tab>
</Ribbon>
</code></pre>
<p>How to iterate throught each element and print the value</p> | 3 |
Arranging elements with a variable size on a fixed canvas | <p>Input:
I have created and filled an array/table in velocity. This array currently contains 3 things:</p>
<p>(note that this example is pure fiction)</p>
<ol>
<li>Top level community name (e.g. Stack Overflow USA, Stack Overflow BEL)</li>
<li>Subcommunity (e.g. stackOverflow.com/r/USA/CSS and stackOverflow.com/r/BEL/JSON)</li>
<li>Owner(s) of the subcommunity (e.g. Frank) </li>
</ol>
<p>Depending on the situation and the point in time, the amount of top level communities, that have a variable number of subcommunities are each owned by a variable number of owners. And, each top level community can also have one or more owners.</p>
<p>(input) table example:</p>
<pre><code>SO USA, , Phil
SO USA, CSS, Frank
SO USA, JSON, Marc
SO BEL, CSS, Marieke
SO BEL, CSS, Francis
SO BEL, JSON, Patrick
SO FRA, , Francois
</code></pre>
<p>output:</p>
<p>I now want to position these communities and sub communities graphically on a webpage like this</p>
<p><img src="https://imgur.com/lX1rF" alt=""></p>
<p>Depending on the amount of subcommunities, the top level community will have a different size, and should therefore be parsed where it fits best on the page (e.g on a 600pxx800px canvas).</p>
<p>Here are my questions:</p>
<ul>
<li>does somebody know code that has already been written to solve this kind of problem?</li>
<li>if not, how would I best tackle this?</li>
</ul> | 3 |
Dynamic dropdown list | <ol>
<li>subjects</li>
<li>course</li>
<li>chapters</li>
</ol>
<p>I want to add 2 dynamic dropdown lists, one is for subjects, and one is for course. When I select subject, courses which is added to that subject should be loaded in the course dropdown list, and then add chapters to that courses.</p>
<p>How do I do that? </p>
<p>Any help would be appreciated.</p>
<p>Here is my code:</p>
<pre><code><div class="content-form-inner">
<div id="page-heading">Enter the details</div>
<div class="form_loader" id="thisFormLoader"></div>
<div id="error_message"></div>
<form name="thisForm" id="thisForm" action="editchapters.php?mode=<?php echo $_REQUEST['mode']; ?>&id=<?php echo $id; ?>" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="0" id="id-form" >
<tr>
<th valign="top" style="width:0%"><span class="required">*</span>Subject</th>
<td style="width: 0%">
<select name="subject_name" class="select-form required " style="color:#000 !important;width:200px !important">
<option value="">Select</option>
<?php
$sql = "select * from mock_subject ";
$res = mysqli_query($dbhandle,$sql);
$numrows =mysqli_num_rows($res);
echo mysql_error();
if($numrows){
while($obj = mysqli_fetch_object($res)){
if($obj->status == 1){
if($subject == $obj->id){
echo '<option value="'.$obj->id.'" selected>'.($obj->subject_name).'</option>';
}
else{
echo '<option value="'.$obj->id.'">'.($obj->subject_name).'</option>';
}
}
}
}
?>
</select>
</td>
<td style="width: 0%;">
<div id="subject_id-error" class="error-inner"></div>
</td>
<td></td>
</tr>
<tr>
<th valign="top" style="width:0%"><span class="required">*</span>Course</th>
<td style="width: 0%">
<select name="course_name" class="select-form required " style="color:#000 !important;width:200px !important">
<option value="">Select</option>
<?php
$sql = "select * from mock_course ";
$res = mysqli_query($dbhandle,$sql);
$numrows =mysqli_num_rows($res);
echo mysql_error();
if($numrows){
while($obj = mysqli_fetch_object($res)){
if($obj->status == 1){
if($course == $obj->id){
echo '<option value="'.$obj->id.'" selected>'.($obj->course_name).'</option>';
}
else{
echo '<option value="'.$obj->id.'">'.($obj->course_name).'</option>';
}
}
}
}
?>
</select>
</td>
<td style="width: 0%;">
<div id="course_id-error" class="error-inner"></div>
</td>
<td></td>
</tr>
<tr>
<th><span class="required">*</span>Chapter</th>
<td><input type="text" name="chapter_name" class="inp-form required" value="<?php echo $chapter;?>" style="color:#000 !important;"></td>
<td>
<div></div>
</td>
</tr>
<tr>
<th>&nbsp;</th>
<td valign="top"><input type="submit" name="submit_button" value="<?php echo $mode=="edit"? "Update" : "Add" ?>" class="form-submit" />
<input type="reset" value="Reset" class="form-reset" />
</tr>
</table>
</form>
<div class="clear"></div>
</div>
</code></pre> | 3 |
Issues with creating a new isolated scope in factory | <p>I'd like to know what the consequences / issues of creating a new isolated scope in a factory are, by doing <code>$rootScope.$new()</code></p>
<p>I'm trying to allow the user of my library to do something like <code>$cordovaPush.$on('notReceived')</code>, rather than using <code>$rootScope.$on('...')</code> (even though it may be pointless to do this). I've seen other comments about memory leaks and various other issues with creating a new scope, but I haven't found any proof or real convincing arguments as to why this should not be done.</p>
<p>Here's some code as a reference to what I'm doing:</p>
<pre><code>.factory('$cordovaPush', ['$q', '$window', '$rootScope', '$timeout', function ($q, $window, $rootScope, $timeout) {
var $cordovaPush = $rootScope.$new(true);
$cordovaPush.onNotification = function (notification) {
$timeout(function () {
$cordovaPush.$broadcast('notificationReceived', notification);
});
};
$cordovaPush.register = function (config) {
...
};
$cordovaPush.unregister = function (options) {
...
};
$cordovaPush.setBadgeNumber = function (number) {
...
};
return $cordovaPush;
}]);
</code></pre>
<p>ALSO</p>
<p>If creating a new scope <strong>is OK</strong>, what is the best practice for destroying the scope? Is it necessary to destroy the scope if the app is closed and opened again?</p> | 3 |
How to find out the source of iphone CoreLocation Data? | <p>Core Location uses the available GPS, cell, and Wi-Fi networks to determine the user Location.How do I find out the current Source?.Is it possible?.Thanks
Note. suppose if the source is cellular i use some calculations to improve accuracy.</p> | 3 |
React router v6 component not loading | <p>The issue is the ProdDetails component is not called when it is nested (products/:id). Even though the URL changes on the address bar, No changes in UI</p>
<p>Here is App.tsx</p>
<pre><code>function App() {
return (
<div className="App">
<Routes>
<Route path='/' element={<Home />} />
<Route path='products' element={<ProdList />} >
<Route path=":id" element={<ProdDetails />} />
</Route>
</Routes>
</div>
);
}
</code></pre>
<p>The ProdList component</p>
<pre><code>const ProdList: React.FC = () => {
const [prods, setProdList] = useState<IProducts>([])
useEffect(() => {
ProdAPI.getAll()
.then((list: IProducts) => {
setProdList(list)
})
}, [])
return(
<div>
<div>
{prods.map((prod) => (
<li key={(prod.id).toString()}>
<Link to={(prod.id).toString()}>
{prod.title}
</Link>
</li>
))}
</div>
</div>
)
}
export default ProdList
</code></pre>
<p>It works when it is not nested. What is the reason for that?</p> | 3 |
How to pass 'quotaUser' parameter for queries to MySQL server in GCP from cloud function? | <p>I'm working on a project right now that shows a list of items. To retrieve this data, the page calls a callable cloud function which queries the data from a MySQL server. This MySQL server, like our cloud functions, is part of our project on the Google Cloud Platform.</p>
<p>The page that shows the items is used quite a lot by our customer and last Tuesday they reported some problems that the data wasn't showing or took a long time to show up.
Having looked at the cloud function logs at that time, we see a lot of timeouts followed by a few of these errors:</p>
<blockquote>
<p>CloudSQL warning: your action is needed to update your function and avoid potential disruptions. Please see <a href="https://cloud.google.com/functions/docs/sql#troubleshooting" rel="nofollow noreferrer">https://cloud.google.com/functions/docs/sql#troubleshooting</a> for additional details: googleapi: Error 429: Quota exceeded for quota group 'default' and limit 'Queries per user per 100 seconds' of service 'sqladmin.googleapis.com' for consumer 'project_number:[some number]'., rateLimitExceeded</p>
</blockquote>
<p>I'm not entirely sure if this is the cause of the issue, but it does seem like something we should do something about anyway.
As I understand it, we can send 300 queries per user per 100 seconds to the MySQL server. So about 3 per second. The cloud function itself only sends 2 queries to the server. One to retrieve the data for the current page with the applied filters and another one to get a total record count.
However, we don't send any user info when performing the query. So I think that if 150 users each trigger the callable, 300 queries will be performed and counted towards the quota as if they were done by a single user. Because it's a server, the cloud function, that actually performs the query. The error also mentions the quota group 'default'.</p>
<p>The following page tells me that I should be able to pass a 'quotaUser' parameter to specify a specific user that requests should count towards for the quota.</p>
<p><a href="https://cloud.google.com/apis/docs/capping-api-usage#limiting_requests_per_second_per_user" rel="nofollow noreferrer">https://cloud.google.com/apis/docs/capping-api-usage#limiting_requests_per_second_per_user</a></p>
<p>However... I have no idea how to pass that parameter with our queries. I've read something that this parameter can be used in the url parameters or in the headers, but we are using the Node.js mysql package to perform these queries, and I don't know how to tell it to send this parameter.
This is the guide we followed to set up the mysql connection. We are using the same mysql package.</p>
<p><a href="https://cloud.google.com/sql/docs/mysql/connect-functions#node.js" rel="nofollow noreferrer">https://cloud.google.com/sql/docs/mysql/connect-functions#node.js</a></p>
<p>I would think that if a GCP guide tells us to use that mysql package, it should also somehow be possible to specify this quotaUser.</p>
<p>If anyone can help me out with this, it would be greatly appreciated. I'm a bit stuck and can't find any documentation or examples on how to pass this parameter for MySQL queries.</p>
<p>This is how we connect to the MySQL server:</p>
<pre><code>import { config } from '../config';
import { createConnection, Connection, ConnectionConfig } from 'mysql';
export function connectToMySQLDatabase(): Connection {
const connectionName: string | undefined = process.env.INSTANCE_CONNECTION_NAME || `${config.firebaseProjectId}:${config.mysqlConfig.regionId}:${config.mysqlConfig.instanceId}`;
const dbUser: string | undefined = process.env.SQL_USER || config.mysqlConfig.user;
const dbPassword: string | undefined = process.env.SQL_PASSWORD || config.mysqlConfig.password;
const dbName: string | undefined = process.env.SQL_NAME || config.mysqlConfig.databaseName;
const mysqlConfig: ConnectionConfig = {
user: dbUser,
password: dbPassword,
database: dbName,
dateStrings: true,
socketPath = `/cloudsql/${connectionName}`;
};
return createConnection(mysqlConfig);
}
</code></pre>
<p>And how we perform a query:</p>
<pre><code>exports.itemQuerySQL = functions
.region(config.region)
.runWith({
timeoutSeconds: 60,
memory: '1GB'
})
.https
.onCall(async (request: GetItemsRequest, context) => {
const mysqlConnection: Connection = connectToMySQLDatabase();
try {
return await queryItems(request, mysqlConnection);
} catch (error) {
throw error;
}
finally {
mysqlConnection.end();
}
});
async function queryItems(request: GetItemsRequest, mysqlConnection: Connection): Promise<CallableQueryResponse<string>> {
let query = '';
let values = [];
// Removed a bunch of code irrelevant to the issue that builds up the query and values array.
const results: any[] = await performQuery(mysqlConnection, sqlQuery, sqlQueryValues);
return {
results: results,
// Some other properties
};
}
async function performQuery(mysqlConnection: Connection, query: string, values?: (string | string[] | number | null)[]): Promise<any> {
return new Promise((resolve: (value?: unknown) => void, reject: (reason?: any) => void): void => {
mysqlConnection.query(query, values, (error: MysqlError, results: any) => {
if (error) {
return reject(error);
} else {
return resolve(results);
}
});
});
}
</code></pre>
<p>Besides the code that constructs the query itself, I also left out most of the error handling to keep these examples small.</p> | 3 |
How to get scroll Position in reactjs when click on button | <p>As you can see it I am not able to scroll down the page when I click on the button, This all code running in one file in App.js
<br>
Even I tried with useRef() and UseState() also but not working
<br>
I need help in JavaScript logic only
<br>
<strong>Javascript:</strong></p>
<pre><code>const myFunction = () => {
const element = document.getElementById("myDIV");
element.scrollLeft = 50;
element.scrollTop = 10;
};
</code></pre>
<p><strong>HTML:</strong></p>
<pre><code><div
id="myDiv"
style={{ height: "250px", width: "250px", overflow: "auto" }}
>
<div
id="content"
style={{
height: "800px",
width: "2000px",
backgroundColor: "coral",
}}
>
<button onClick={myFunction}>Scroll</button>
<p>Some text inside a div element.</p>
<p>Some text inside a div element.</p>
<p>Some text inside a div element.</p>
<p>Some text inside a div element.</p>
</div>
</div>
</code></pre> | 3 |
Use of markdown in loops in Jupyter notebooks | <p>I have a Python program (more exactly a suite of programs) which I want to add more markdown comments in order to be train/document using them. In some of them the comments would naturally be placed go inside long loops.</p>
<p>My understanding is that if you split the loop by inserting a markdown cell the notebook will not execute the loop, since it sees the end of the cell as being the end of an executable block.</p>
<p>Is there a way round this? If so then what strategies do people adopt in such circumstances. Obviously, heavy standard-format Python commenting within the code is one option, but rather seems to defeat the purpose of Jupyter particularly if the comments need to be fairly detailed.</p> | 3 |
FCM messages is not always delivered | <p>I push Firebase messages from PHP and they usually get the target Android app.</p>
<p>Nonetheless, and occasionally, a push message is not correctly delivered if the target Android mobile was inactive for some period of time. Then, if I open the app, the message is delivered immediately.</p>
<p>I read about the Doze status; the battery optimizations; etc. I don't want to bother the user to explicitly whitelist the app.</p>
<p>Thanks in advance !</p>
<p>PHP:</p>
<pre><code> private function sendFirebaseMessage($msg, $to_uid) {
// getting firebase token ID
$user_token_id = DB::getInstance()->getUserFirebaseTokenId($to_uid);
#API access key from Google API's Console
define( 'API_ACCESS_KEY', 'A...7' );
$fields = array
(
'to' => $user_token_id,
'data' => $msg,
"priority" => "high"
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
#Send Reponse To FireBase Server
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
#Echo Result Of FireBase Server
return $user_token_id . "]XXX[" . $result;
}
</code></pre>
<p>Android/Java:</p>
<pre><code> @Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
// Check if message contains a data payload.
Map<String, String> data = remoteMessage.getData();
if (data.size() > 0) {
Log.d(TAG, "StorableMessage data payload: " + data);
if (data.containsKey("sender_id") &&
data.containsKey("sender_name") &&
data.containsKey("chat_topic")) {
if (!ChatActivity.IsVisible) {
NotifsManager.showFirebaseNotif(this,
data.get("sender_name"),
data.get("sender_id"),
data.get("chat_topic"));
}
}
}
}
</code></pre> | 3 |
How to add interleaving rows as result of sort / groups? | <p>I have the following sample input data:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'col1': ['x', 'y', 'z'], 'col2': [1, 2, 3], 'col3': ['a', 'a', 'b']})
</code></pre>
<p>I would like to sort and group by <code>col3</code> while interleaving the summaries on top of the corresponding group in <code>col1</code> and get the following output:</p>
<pre><code> col1 col2
0 a 3
1 x 1
2 y 2
3 b 3
4 z 3
</code></pre>
<p>I can of course do the part:</p>
<pre><code>df.sort_values(by=['col3']).groupby(by=['col3']).sum()
col2
col3
a 3
b 3
</code></pre>
<p>but I am not sure how to interleave the group labels on top of <code>col1</code>.</p> | 3 |
How to pass array or arraylist by intent which has unserializable data? | <p>What I want to do is passing DataModel array between Activity by Intent.</p>
<p>DataModel class has Bitmap object and FirebaseVisionLabel object. I found many sites to implement this. </p>
<p>Many people said that DataModel class should implements Serializable or Parceable interface to pass <code>DataModel[]</code> or <code>ArrayList<DataModel></code>.</p>
<p>So I tried, but the real problem was FirebaseVisionLabel class cannot be serializable. Also, I cannot modify that class because it is firebase library.</p>
<p>How can I pass DataModel array by intent??</p>
<blockquote>
<p>Point</p>
<ol>
<li>Want to pass array or arraylist of my own class by intent.</li>
<li>that class has unserializable object and I cannot modify.</li>
<li>how can I pass or deal with it?</li>
</ol>
</blockquote> | 3 |
Using CUDA atomicInc to get unique indices | <p>I have CUDA kernel where basically each thread holds a value, and it needs to add that value to one or more lists in shared memory. So for each of those lists, it needs to get an index value (unique for that list) to put the value.</p>
<p>The real code is different, but there are lists like:</p>
<pre><code>typedef struct {
unsigned int numItems;
float items[MAX_NUM_ITEMS];
} List;
__shared__ List lists[NUM_LISTS];
</code></pre>
<p>The values <code>numItems</code> are initially all set to 0, and then a <code>__syncthreads()</code> is done.</p>
<p>To add its value to the lists, each thread does:</p>
<pre><code>for(int list = 0; list < NUM_LISTS; ++list) {
if(should_add_to_list(threadIdx, list)) {
unsigned int index = atomicInc(&lists[list].numItems, 0xffffffff);
assert(index < MAX_NUM_ITEMS); // always true
lists[list].items[index] = my_value;
}
}
</code></pre>
<p>This works most of the time, but it seems that when making some unrelated changes in other parts of the kernel (such as not checking asserts that always succeed), sometimes two threads get the same index for one list, or indices are skipped.
The final value of <code>numSamples</code> always becomes correct, however.</p>
<p>However, when using the following custom implementation for <code>atomicInc_</code> instead, it seems to work correctly:</p>
<pre><code>__device__ static inline uint32_t atomicInc_(uint32_t* ptr) {
uint32_t value;
do {
value = *ptr;
} while(atomicCAS(ptr, value, value + 1) != value);
return value;
}
</code></pre>
<p>Are the two <code>atomicInc</code> functions equivalent, and is it valid to use <code>atomicInc</code> that way to get unique indices?</p>
<p>According the the <a href="https://docs.nvidia.com/cuda/cuda-c-programming-guide/#atomic-functions" rel="nofollow noreferrer">CUDA programming guide</a>, the atomic functions do not imply memory ordering constraints, and different threads can access the <code>numSamples</code> of different lists at the same time: could this cause it to fail?</p>
<p><strong>Edit:</strong></p>
<p>The real kernel looks like this:</p>
<p>Basically there is a list of <em>spot blocks</em>, containing <em>spots</em>. Each <em>spot</em> has XY coordinates (<em>col</em>, <em>row</em>). The kernel needs to find, for each spot, the spots that are in a certain window (col/row difference) around it, and put them into a list in shared memory.</p>
<p>The kernel is called with a fixed number of warps. A CUDA block corresponds to a group of <em>spot blocks</em>. (here 3) These are called the <em>local</em> spot blocks.</p>
<p>First it takes the spots from the block's 3 spot blocks, and copies them into shared memory (<code>localSpots[]</code>).
For this it uses one warp for each spot block, so that the spots can be read coalesced. Each thread in the warp is a spot in the local spot block.
The spot block indices are here hardcoded (<code>blocks[]</code>).</p>
<p>Then it goes through the <em>surrounding</em> spot blocks: These are all the spot blocks that may contain spots that are close enough to a spot in the <em>local spot blocks</em>. The surrounding spot block's indices are also hardcoded here (<code>sblock[]</code>).</p>
<p>In this example it only uses the first warp for this, and traverses <code>sblocks[]</code> iteratively. Each thread in the warp is a spot in the surrounding spot block.
It also iterates through the list of all the local spots. If the thread's spot is close enough to the local spot: It inserts it into the local spot's list, using <code>atomicInc</code> to get an index.</p>
<p>When executed, the printf shows that for a given local spot (here the one with row=37, col=977), indices are sometimes repeated or skipped.</p>
<p>The real code is more complex/optimized, but this code already has the problem. Here it also only runs one CUDA block.</p>
<pre><code>#include <assert.h>
#include <stdio.h>
#define MAX_NUM_SPOTS_IN_WINDOW 80
__global__ void Kernel(
const uint16_t* blockNumSpotsBuffer,
XGPU_SpotProcessingBlockSpotDataBuffers blockSpotsBuffers,
size_t blockSpotsBuffersElementPitch,
int2 unused1,
int2 unused2,
int unused3 ) {
typedef unsigned int uint;
if(blockIdx.x!=30 || blockIdx.y!=1) return;
int window = 5;
ASSERT(blockDim.x % WARP_SIZE == 0);
ASSERT(blockDim.y == 1);
uint numWarps = blockDim.x / WARP_SIZE;
uint idxWarp = threadIdx.x / WARP_SIZE;
int idxThreadInWarp = threadIdx.x % WARP_SIZE;
struct Spot {
int16_t row;
int16_t col;
volatile unsigned int numSamples;
float signalSamples[MAX_NUM_SPOTS_IN_WINDOW];
};
__shared__ uint numLocalSpots;
__shared__ Spot localSpots[3 * 32];
numLocalSpots = 0;
__syncthreads();
ASSERT(numWarps >= 3);
int blocks[3] = {174, 222, 270};
if(idxWarp < 3) {
uint spotBlockIdx = blocks[idxWarp];
ASSERT(spotBlockIdx < numSpotBlocks.x * numSpotBlocks.y);
uint numSpots = blockNumSpotsBuffer[spotBlockIdx];
ASSERT(numSpots < WARP_SIZE);
size_t inOffset = (spotBlockIdx * blockSpotsBuffersElementPitch) + idxThreadInWarp;
uint outOffset;
if(idxThreadInWarp == 0) outOffset = atomicAdd(&numLocalSpots, numSpots);
outOffset = __shfl_sync(0xffffffff, outOffset, 0, 32);
if(idxThreadInWarp < numSpots) {
Spot* outSpot = &localSpots[outOffset + idxThreadInWarp];
outSpot->numSamples = 0;
uint32_t coord = blockSpotsBuffers.coord[inOffset];
UnpackCoordinates(coord, &outSpot->row, &outSpot->col);
}
}
__syncthreads();
int sblocks[] = { 29,30,31,77,78,79,125,126,127,173,174,175,221,222,223,269,270,271,317,318,319,365,366,367,413,414,415 };
if(idxWarp == 0) for(int block = 0; block < sizeof(sblocks)/sizeof(int); ++block) {
uint spotBlockIdx = sblocks[block];
ASSERT(spotBlockIdx < numSpotBlocks.x * numSpotBlocks.y);
uint numSpots = blockNumSpotsBuffer[spotBlockIdx];
uint idxThreadInWarp = threadIdx.x % WARP_SIZE;
if(idxThreadInWarp >= numSpots) continue;
size_t inOffset = (spotBlockIdx * blockSpotsBuffersElementPitch) + idxThreadInWarp;
uint32_t coord = blockSpotsBuffers.coord[inOffset];
if(coord == 0) return; // invalid surrounding spot
int16_t row, col;
UnpackCoordinates(coord, &row, &col);
for(int idxLocalSpot = 0; idxLocalSpot < numLocalSpots; ++idxLocalSpot) {
Spot* localSpot = &localSpots[idxLocalSpot];
if(localSpot->row == 0 && localSpot->col == 0) continue;
if((abs(localSpot->row - row) >= window) && (abs(localSpot->col - col) >= window)) continue;
int index = atomicInc_block((unsigned int*)&localSpot->numSamples, 0xffffffff);
if(localSpot->row == 37 && localSpot->col == 977) printf("%02d ", index); // <-- sometimes indices are skipped or duplicated
if(index >= MAX_NUM_SPOTS_IN_WINDOW) continue; // index out of bounds, discard value for median calculation
localSpot->signalSamples[index] = blockSpotsBuffers.signal[inOffset];
}
} }
</code></pre>
<p>Output looks like this:</p>
<pre><code>00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 23
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
00 01 02 02 03 03 04 05 06 07 08 09 10 11 12 06 13 14 15 16 17 18 19 20 21
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 23
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
</code></pre>
<p>Each line is the output of one execution (the kernel is run multiple times). It is expected that indices appear in different orders. But for example on the third-last line, index 23 is repeated.</p>
<p>Using <code>atomicCAS</code> seems to fix it. Also using <code>__syncwarp()</code> between executions on the outer for-loop seems to fix it. But it is not clear why, and if that always fixes it.</p>
<hr />
<p><strong>Edit 2:</strong>
This is a full program (main.cu) that shows the problem:</p>
<p><a href="https://pastebin.com/cDqYmjGb" rel="nofollow noreferrer">https://pastebin.com/cDqYmjGb</a></p>
<p>The CMakeLists.txt:</p>
<p><a href="https://pastebin.com/iB9mbUJw" rel="nofollow noreferrer">https://pastebin.com/iB9mbUJw</a></p>
<p>Must be compiled with -DCMAKE_BUILD_TYPE=Release.</p>
<p>It produces this output:</p>
<pre><code>00(0:00000221E40003E0)
01(2:00000221E40003E0)
02(7:00000221E40003E0)
03(1:00000221E40003E0)
03(2:00000221E40003E0)
04(3:00000221E40003E0)
04(1:00000221E40003E0)
05(4:00000221E40003E0)
06(6:00000221E40003E0)
07(2:00000221E40003E0)
08(3:00000221E40003E0)
09(6:00000221E40003E0)
10(3:00000221E40003E0)
11(5:00000221E40003E0)
12(0:00000221E40003E0)
13(1:00000221E40003E0)
14(3:00000221E40003E0)
15(1:00000221E40003E0)
16(0:00000221E40003E0)
17(3:00000221E40003E0)
18(0:00000221E40003E0)
19(2:00000221E40003E0)
20(4:00000221E40003E0)
21(4:00000221E40003E0)
22(1:00000221E40003E0)
</code></pre>
<p>For example the lines with 03 show that two threads (1 and 2), get the same result (3), after calling <code>atomicInc_block</code> on the same counter (at <code>0x00000221E40003E0</code>).</p> | 3 |
Data Validation should be pulling based off of previous Options. Returning Undefined | <p>The Bid Sheet is ultimately supposed to enable the user to enter the various Options and it will give them a list if Items with those Options. I suspect my attempt to use the same scripting as the single validation Option is insufficient to handle the multiple Options, but I am too inexperienced to know a better path.</p>
<p>Everything works except for this piece. Which returns "undefined".</p>
<pre><code> var cell = ws.getRange(r,OptionDesc);
var FullOptions = ws.getRange(r, 2, 1, 7).getValues();
var listToApplyDesc = FullOptions.map(function (o) { return o[7] });
applyValidationtoCell(listToApplyDesc,cell);
</code></pre>
<p>I've included the full script and a link to a copy of the Sheet since I'm not confident enough to simplify to the "minimum reproducible example".</p>
<p><a href="https://drive.google.com/open?id=1Y0VT3KYD1wbj6QR1gTLepn7KtxU91rQoqRLL2Zg9-FI" rel="nofollow noreferrer">https://drive.google.com/open?id=1Y0VT3KYD1wbj6QR1gTLepn7KtxU91rQoqRLL2Zg9-FI</a></p>
<pre><code>var mainWsName = "Bid Sheet";
var nameData = "Data";
var Category = 2;
var ManualAutomatic = 3;
var OptionA = 4;
var OptionB = 5;
var OptionC = 6;
var OptionD = 7;
var OptionE = 8;
var OptionDesc = 9;
var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(mainWsName);
var wsData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(nameData);
var manAutoOption = wsData.getRange(2, 1,wsData.getLastRow()-1,9).getValues();
//Must change getLastRow Column count to include any added Options
function onEdit(e){
var activeCell = e.range;
var val = activeCell.getValue();
var r = activeCell.getRow();
var c = activeCell.getColumn();
var designator = ws.getRange(r, 1);
var designatorValue = designator.getValue();
if (designatorValue != "x") return;//designator IF only allows the script to run on rows with x.
var wsName = activeCell.getSheet().getName();
if (wsName === mainWsName && c === Category && r > 10){
OptionsValidation (val,r);
}
}//end onEdit
//OptionsValidation required to clear Option cells on Category change
function OptionsValidation (val,r){
if(val === ""){
ws.getRange(r,ManualAutomatic, 1, 7).clearContent();
ws.getRange(r,ManualAutomatic, 1, 7).clearDataValidations();
} else {
ws.getRange(r,ManualAutomatic, 1, 7).clearContent();
//Sets a Data Validation Dropdown based off of input from Category
var filterOptions = manAutoOption.filter(function(o){ return o[0] === val });
var firstLevelColValue = ws.getRange(r, Category).getValue();
var filterOptions = manAutoOption.filter(function(o){ return o[0] === firstLevelColValue});
var listToApplyMA = filterOptions.map(function (o) { return o[1] });
var cell = ws.getRange(r,ManualAutomatic);
applyValidationtoCell(listToApplyMA,cell);
var listToApplyA = filterOptions.map(function (o) { return o[2] });
var cell = ws.getRange(r,OptionA);
applyValidationtoCell(listToApplyA,cell);
var listToApplyB = filterOptions.map(function (o) { return o[3] });
var cell = ws.getRange(r,OptionB);
applyValidationtoCell(listToApplyB,cell);
var listToApplyC = filterOptions.map(function (o) { return o[4] });
var cell = ws.getRange(r,OptionC);
applyValidationtoCell(listToApplyC,cell);
var listToApplyD = filterOptions.map(function (o) { return o[5] });
var cell = ws.getRange(r,OptionD);
applyValidationtoCell(listToApplyD,cell);
var listToApplyE = filterOptions.map(function (o) { return o[6] });
var cell = ws.getRange(r,OptionE);
applyValidationtoCell(listToApplyE,cell);
var cell = ws.getRange(r,OptionDesc);
var FullOptions = ws.getRange(r, 2, 1, 7).getValues();
var listToApplyDesc = FullOptions.map(function (o) { return o[7] });
applyValidationtoCell(listToApplyDesc,cell);
}
}
function applyValidationtoCell(list,cell){
var rule = SpreadsheetApp
.newDataValidation()
.requireValueInList(list)
.setAllowInvalid(false)
.build();
cell.setDataValidation(rule);
}
</code></pre> | 3 |
Display rows like a columns | <p>How to display rows like a column? I need turn this table for each meta_key value.</p>
<p>I have following table:</p>
<pre><code>CREATE TABLE wp_postmeta (
meta_id int NOT NULL,
post_id int NOT NULL DEFAULT '0',
meta_key varchar(255) DEFAULT NULL,
meta_value varchar(255)
)
INSERT INTO wp_postmeta ([meta_id], [post_id], [meta_key], [meta_value]) VALUES
(14454, 1614, 'price_bin', '2'),
(14453, 1614, 'price_current', '1'),
(14452, 1614, 'post_tags', ''),
(14451, 1614, 'price_reserve', '3'),
(14450, 1614, 'price_shipping', '4'),
(14449, 1614, 'condition', '1'),
(14448, 1614, 'auction_type', '1'),
(14447, 1614, 'listing_expiry_days', '1'),
(14446, 1614, 'city', '2'),
(14445, 1614, 'listing_price_due', '25'),
(14444, 1614, 'showgooglemap', 'no'),
(14443, 1614, 'topcategory', 'yes'),
(14442, 1614, 'visitorcounter', 'no'),
(14441, 1614, 'html', 'yes'),
(14440, 1614, 'featured', 'no'),
(14439, 1614, 'listing_price', '25'),
(14724, 1658, '_edit_last', '1'),
(14438, 1614, 'listing_expiry_date', ''),
(14437, 1614, 'hits', '0')
</code></pre>
<p>I'm trying to use the following script:</p>
<pre><code> DECLARE @idList varchar(500),
@sqlToRun varchar(1000)
SET @idList = STUFF((SELECT (meta_key)
FROM wp_postmeta
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
SET @sqlToRun ='
SELECT post_id, ' + @idList + ',
FROM (
SELECT
post_id, meta_key, meta_value
FROM wp_postmeta
WHERE post_id = 1614
) as s
PIVOT
(
Max(meta_value)
FOR [meta_key] IN ('+ @idList +')
)AS pvt'
EXEC (@sqlToRun)
</code></pre>
<p><a href="https://i.stack.imgur.com/Yk6IZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yk6IZ.png" alt="enter image description here"></a></p>
<p>But I getting NULL results. How to fix it?</p>
<p>Output should like this:</p>
<pre><code>post_id, price_bin, price_current, price_shipping
1614 2 1 4
</code></pre> | 3 |
i use the 'angular-froala-wysiwyg',but menu bar reduced | <p>I build a new project for angular and introduced 'angular-froala-wysiwyg', the menu is all right ,bug I introduced '<code>angular-froala-wysiwyg</code>' in my angular project, the menu is few.
this is new project's menu:
<img src="https://i.stack.imgur.com/HkcEE.png" alt="enter image description here"></p>
<p>and this is my project:
<img src="https://i.stack.imgur.com/UAiiq.png" alt="enter image description here"></p> | 3 |
Rename default context menu title on right click in webview for cocoa [Objective C] | <p>I need to open a link in new tab in webview. But on right clik, the context menu is showing <code>Open Link In New Window</code> with other menus but no <code>Open Link In New Tab</code>. And on clicking <code>Open Link In New Window</code>, it'll open in new tab (I enabled tabbing mode on). But I am <strong>unable to change the title</strong> from <code>Open Link In New Window</code> to <code>Open Link In New Tab</code> and <strong>if I change the title, it won't work</strong>. I couldn't find the solution yet. I am using webView, not WKWebView.</p>
<p><strong>If my question is duplicate, please refer me to original.</strong></p>
<p><strong>Objective C please..</strong></p>
<p>Edit: My code</p>
<pre><code>-(NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{
NSMutableArray *modifiedMenuItems=[[NSMutableArray alloc]init];
modifiedMenuItems=[defaultMenuItems mutableCopy];
NSMenuItem *mItem=[[NSMenuItem alloc]init];
int i=0;
while(i<[modifiedMenuItems count])
{
mItem=[modifiedMenuItems objectAtIndex:i];
if([mItem tag]==WebMenuItemTagOpenLinkInNewWindow)
{
[mItem setTitle:@"Open Link in New Tab"];
[modifiedMenuItems replaceObjectAtIndex:i withObject:mItem];
//Here I renamed the title and replaced. But it doesn't works.
//It is showing like a disabled one.
//So I added the next line code prior to replacement.
[mItem setEnabled:YES];
}
}
return modifiedMenuItems;
}
</code></pre> | 3 |
Flask + Flask-RESTful: Match specific variables to routes | <p>How can I achieve the following?</p>
<pre><code># only if model_type in ['a', 'b', 'c']
api.add_resource(FooAPI, '/<string:model_type'>
# only if model_type in ['x', 'y', 'z']
api.add_resource(BarAPI, '/<string:model_type'>
</code></pre>
<p>Rather than having the following code:</p>
<pre><code>api.add_resource(FooAAPI, '/a'>
api.add_resource(FooBAPI, '/b'>
api.add_resource(FooCAPI, '/c'>
api.add_resource(BarXAPI, '/x'>
api.add_resource(BarYAPI, '/y'>
api.add_resource(BarZAPI, '/z'>
</code></pre> | 3 |
How to plot points specified by ID column only with linespoints and multiple plots using gnuplot? | <p>Say I have two files, each has 3 columns<br>
file1: </p>
<pre><code>ID X Y
10 0.1 some data as X
20 0.2
30 0.3
... ...
120 0.5
</code></pre>
<p>file2: </p>
<pre><code>ID X Y
15 0.1 some data as X
30 0.2
45 0.3
60 0.4
... ...
120 0.6
</code></pre>
<p>I am doing </p>
<pre><code>plot \
"file1" using 2:3 w linespoints lt 1 dt 1 lw 1 lc 1 title "file1",\
"file2" using 2:3 w linespoints lt 1 dt 1 lw 1 lc 2 title "file2"
</code></pre>
<p>which shows every point on the file. </p>
<p>If I only want points which its Row ID(first column) is 30, 60 ,90 ,120<br>
How should I do? Thank you. </p>
<p>*In the actually case, I need to plot 12 file in one plot and each of them have 10000 rows but I only want to show 6 points. </p> | 3 |
create local ubuntu package repository | <p>I am attempting to create an offline package repo for ubuntu 16.04LTS.
I have a repo served out over a small web service, and my sources.list updated to use my local copy. my sources.list contains the following</p>
<pre><code>deb http://192.168.0.169:8080/ubuntu/ xenial main universe multiverse restricted
deb http://192.168.0.169:8080/ubuntu/ xenial-updates main universe multiverse restricted
deb http://192.168.0.169:8080/ubuntu/ xenial-security main universe multiverse restricted
</code></pre>
<p>I am attempting to update the locally installed version of perl for example, the currently installed version is 5.22.1-9ubuntu0.5 and the version in the Packages file and in the repo is 5.22.1-9ubuntu0.6.
apt update successfully finds the correct Package.gz file containing this package, yet when I do an apt list --upgradeable or apt upgrade perl, I am told that the latest version is installed.
What am I missing?</p> | 3 |
Reactivity not working inside the loop for unknown reason in vuejs | <p>I'm struggling to get working the reactivity in vue.js inside the loop. Loop is rendering without any issue, But, when trying to fire an event it updates the content but not visible or render data in the page.</p>
<p>I've used the latest version of vue.js with bootstrap and jquery. I've tried adding <code>key</code> in the loop item but not working. But, when to update any other content by using <code>v-model</code> then it works.</p>
<p><strong>Markup</strong></p>
<pre class="lang-html prettyprint-override"><code><div id="app">
<div class="props">
<div class="prop-item" v-for="prop in modules.variations.properties">
<p>=== <strong v-text="prop.name"></strong> ===</p>
<ul>
<li v-for="value in prop.values" @click="activeProp(prop,value)">
<span v-text="value.name"></span>
</li>
</ul>
</div>
</div>
<input type="text" v-model="message">
<pre>{{ actives }}</pre>
<pre>{{ message }}</pre>
</div>
<script>
window.spdata = {
"variations":{
"properties":[
{
"id":1,
"name":"Color",
"values":[
{
"id":1,
"name":"Black",
},
{
"id":2,
"name":"Red",
},
{
"id":3,
"name":"Blue",
}
]
},
{
"id":2,
"name":"Size",
"values":[
{
"id":4,
"name":"XL",
},
{
"id":5,
"name":"XXL",
},
{
"id":6,
"name":"XXXL",
},
]
},
{
"id":3,
"name": "Type",
"values":[
{
"id":8,
"name":"Premium",
},
{
"id":9,
"name":"Standard",
},
{
"id":10,
"name":"Luxary",
}
]
}
]
}
};
</script>
</code></pre>
<p><strong>Javascript</strong></p>
<pre class="lang-js prettyprint-override"><code>
new Vue({
el: "#app",
data: {
modules: window.spdata,
actives: {},
message: '',
},
created() {
this.modules.variations.properties.forEach((prop) => {
this.actives[prop.id] = null
});
},
methods: {
activeProp(prop, val) {
if (this.actives[prop.id] === val.id) {
this.actives[prop.id] = null;
} else {
this.actives[prop.id] = val.id;
}
}
}
})
</code></pre> | 3 |
Client server authentication with self signed certificate - Curl is working but Apache HttpClient throws exception | <p>I'm trying to implement client and server authentication with Apache HTTPClient,
and to test it with a self signed certificate.
I've tried to follow several tutorials and answers to similar questions here but
with no success. I've tried to detail as much as possible all the steps that I've
been doing, hopefully someone can point out what I'm doing wrong:</p>
<ol>
<li><p>Created a file <code>req.conf</code> for configuration</p>
<pre><code>[req]
prompt=no
distinguished_name = req_distinguished_name
[ req_distinguished_name ]
O=selfSignedO
CN=selfSignedCn
DC=selfSignedDc
</code></pre></li>
<li><p>Generated server private key and the self-signed certificate</p>
<pre><code>openssl req \
-config req.conf \
-x509 \
-newkey rsa:4096 \
-keyout server/server-private-key.pem \
-out server/server.crt \
-days 3650 \
-nodes
</code></pre></li>
<li><p>Created PKCS12 keystore containing the private key and certificate created in the previous step</p>
<pre class="lang-sh prettyprint-override"><code> openssl pkcs12 \
-export \
-out server/server-key-store.p12 \
-inkey server/server-private-key.pem \
-in server/server.crt
</code></pre>
<p>let's say the password I used was <code>123456</code></p></li>
<li><p>Generated a client private key and a certificate signing request</p>
<pre class="lang-sh prettyprint-override"><code>openssl req \
-config req.conf \
-new \
-newkey rsa:4096 \
-out client/client-request.csr \
-keyout client/client-private-key.pem \
-nodes
</code></pre></li>
<li><p>Signed the client's certificate signing request with the server's private key
and certificate</p>
<pre class="lang-sh prettyprint-override"><code>openssl x509 \
-req \
-days 360 \
-in client/client-request.csr \
-CA server/server.crt \
-CAkey server/server-private-key.pem \
-CAcreateserial \
-out client/client-signed-cert.crt \
-sha256
</code></pre></li>
<li><p>Created a PKCS12 keystore containing the client's private key and certificate certificate created in the previous step.</p>
<pre class="lang-sh prettyprint-override"><code> openssl pkcs12 \
-export \
-out client/client-keystore.p12 \
-inkey client/client-private-key.pem \
-in client/client-signed-cert.crt \
-certfile server/server.crt
</code></pre>
<p>we used <code>123456</code> as password again.</p></li>
<li><p>Generated server trust store containing the client signed certificate</p>
<pre class="lang-sh prettyprint-override"><code>keytool \
-import \
-trustcacerts \
-alias root \
-file client/client-signed-cert.crt \
-keystore server/server-trust-store.jks
</code></pre>
<p>password? <code>123456</code></p></li>
<li><p>Curl is working, but only with <code>-k</code></p>
<pre class="lang-sh prettyprint-override"><code>curl -k \
--cert client/client-signed-cert.crt \
--key client/client-private-key.pem \
https://localhost:443:/my/endpoint
</code></pre>
<p>without the <code>-k</code> I get the error:</p>
<pre class="lang-sh prettyprint-override"><code>curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.
</code></pre></li>
<li><p>Configured Apache HTTPClient:</p>
<pre class="lang-java prettyprint-override"><code>private HttpClient createClient() throws Exception {
String keyPassword = "123456";
KeyStore ks = KeyStore.getInstance("PKCS12");
ks.load(resourceAsStream("/client/client-key-store.p12"), keyPassword.toCharArray());
SSLContext sslContext = new SSLContextBuilder()
.setProtocol("TLSv1.2")
.loadKeyMaterial(ks, keyPassword.toCharArray())
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
.build()
return HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(new NoopHostnameVerifier())
.build();
}
</code></pre>
<p>(The construction is done via multiple methods that I squeezed here to one, so if something is weird or missing please let me know, perhaps I miscopy-pasted something.) </p></li>
</ol>
<p>but when trying to send the same request as with Curl I'm getting:</p>
<pre><code>Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2038)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1135)
at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1779)
at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124)
at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:1156)
at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1266)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1178)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1052)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:987)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
</code></pre> | 3 |
How to import data from another package | <p>I have one package (say <code>testpackage1</code>) which contains a method called <code>readData()</code>.</p>
<p>This method reads a <code>test.data.rda</code> file that is placed in the data folder of <code>testpackage1</code> and after some operations, returns a data frame.</p>
<p>This is the only R file in <code>testpackage1</code>:</p>
<pre><code>#' Reads data and transforms it
#'
#' @return a data.frame
#' @export
#'
#' @examples my.df <- readData()
readData <- function() {
return(subset(test.data, x < 50))
}
initPackage <- function() {
test.data <- data.frame(x = seq(1, 100),
y = seq(101, 200))
devtools::use_data(test.data, overwrite = TRUE)
}
</code></pre>
<p>Calling the <code>initPackage</code> method creates the data frame and saves it as a .rda file in the data folder.</p>
<p>Now I have created a second package named <code>testpackage2</code>, that also has only one R file:</p>
<pre><code>#' Gets the data
#'
#' @import testpackage1
#' @export
#'
#' @examples hello()
hello <- function() {
print(testpackage1::readData())
}
</code></pre>
<p>I built both packages, then started a fresh R session and typed:</p>
<pre><code>> library(testpackage2)
> hello()
</code></pre>
<p>But I have this error:</p>
<pre><code>Error in subset(test.data, x < 50) : object 'test.data' not found
4. subset(test.data, x < 50) at hello.R#8
3. testpackage1::readData()
2. print(testpackage1::readData()) at hello.R#8
1. hello()
</code></pre>
<p>If I type <code>require(testpackage1)</code> before calling method <code>hello()</code>, then it works.</p>
<p>But I thought loading <code>testpackage2</code> would have automatically loaded its dependencies. I could add <code>require(testpackage1)</code> in the <code>hello()</code> function, but it seems redundant with the <code>@import</code> statement.</p>
<p>Moreover, the <code>readData()</code> IS correctly imported, why not the data? Should I somehow export the data as well?</p> | 3 |
Best way to sync VBOs between threads | <p>So I have a minecraft-like chunk system, meaning it's one block of render data. When the player moves around and enters another chunk, out-of-range chunks are being unloaded while new ones are being loaded, which makes it quite demanding since render data has to be calculated in another thread first before it can be shown.</p>
<p>Assuming the data is already loaded from the disk it looks like this</p>
<p>Main/Render Thread Render Data Generation Thread</p>
<pre><code> | Request Chunk |
| -------------------------------> |
| |
| | Generating render data (FloatBuffer)
| |
| .
| .
| .
| Get Ready Chunks |
| <------------------------------- |
| |
| Upload Data |
| |
| Render |
| |
</code></pre>
<p>"Request Chunk" and "Get Ready Chunks" are not synchronized so the render thread really works independently.</p>
<p>The problem with this is that uploading a lot of chunks at once causes framedrops, but calculating how much time I have left to upload can't be done reliably. If I only uploade one per frame I would miss out on alot of speed, although it works fine (That's how it's implemented at the moment).</p>
<p>Since I'm using only one GL context I can only create VBOs in the main thread at the moment.</p>
<p>Is there any way to solve this to be more efficently, like creating VBOs in the other thread and just passing them over to the main thread?</p> | 3 |
Inheritance: use inherited methods from parent pointer | <p>I'm working with some production code, some of which I cannot safely modify (without breaking things). My issue is that it I would like to use a specific method, one of the parameters of which is a pointer to a class. However the class as the parameter does not do what I want it to. </p>
<p>So I wrote a sub-class of that class and am attempting to call the above function, but it still uses the parent class' methods. </p>
<p>I have a MWE below:</p>
<pre><code>#include <iostream>
class Parent
{
public:
Parent() {};
void method() {std::cout<<"in Parent\n";}
};
class Child : public Parent
{
public:
Child() {};
void method() {std::cout<<"in Child\n";}
};
void secondMethod(Parent* Pptr)
{
Pptr->method();
}
int main()
{
Child c = Child();
Parent* parentPtr = &c;
c.method();
parentPtr->method();
secondMethod(parentPtr);
secondMethod(&c);
return 0;
}
</code></pre>
<p>In the above example running this the output is of course:</p>
<pre><code>in Child
in Parent
in Parent
in Parent
</code></pre>
<p>I believe the issue is slicing? Basically I'm casting to the pointer of the parent class, so it is considered as a Parent.</p>
<p>I have seen some ways around this by making methods virtual in the parent class but I don't have that option.</p>
<p>Is there some way to make secondMethod actual use the child's method? Specifically without changing the Parent class OR the secondMethod.</p> | 3 |
Different types JSON file using ObjectMapper | <p>I am using AlamofireObjectMapper to communicate with a backend server. The result of one of the requests is an array of items, which contain two values:</p>
<ul>
<li>A "typeIdentifier" indicating which type of data the second value ("arbitraryData") is of</li>
<li>A "arbitraryData":
<ul>
<li>If "typeIdentifier" CONTAINS "X", arbitraryData is of type ArbitraryDataTypeX</li>
<li>If "typeIdentifier" CONTAINS "Y", arbitraryData is of type ArbitraryDataTypeY</li>
</ul></li>
</ul>
<p>The two ArbitraryDataType classes do not share any common ancestor (except Mappable). It could be even a primitive type, an array, an optional, etc.</p>
<p>How can I make AlamofireObjectMapper parse the "arbitraryData" field using the appropriate type.</p>
<p>See the following JSON file:</p>
<pre><code>{
"arrayOfItems": [
{
"typeIdentifier": "X",
"arbitraryData":
{
"value": "BLA",
}
},
{
"typeIdentifier": "Y",
"arbitraryData":
{
"anotherValue": "BLUBB",
}
}
]
}
</code></pre>
<p>My corresponding Swing file looks like the following:</p>
<pre><code>class Item : Mapping {
var typeIdentifier = "X"
var arbitraryData: Mappable? = nil
init?(_ map: Map) {
self.init()
mapping(map)
}
func mapping(map: Map) {
typeIdentifier <- map["typeIdentifier"]
// THIS LINE CONTAINS MY QUESTION: HOW CAN I TELL OBJECTMAPPER, THAT,
// IF typeIdentifier CONTAINS "X", arbitraryData IS OF TYPE
// ArbitraryDataTypeX, AND IF "Y" arbitraryData IS OF TYPE
// ArbitraryDataTypeY?
arbitraryData <- map["arbitraryData"]
}
}
class ArbitraryDataTypeX : Mapping {
var value = "BLA"
init?(_ map: Map) {
self.init()
mapping(map)
}
func mapping(map: Map) {
value <- map["value"]
}
}
class ArbitraryDataTypeY : Mapping {
var anotherValue = "BLUBB"
init?(_ map: Map) {
self.init()
mapping(map)
}
func mapping(map: Map) {
anotherValue <- map["anotherValue"]
}
}
</code></pre>
<p>Background information: I am using AlamofireObjectMapper to communicate with a backend server. The result of one of the requests is an array of Item. The typeIdentifier-mechanism (infact it is a little bit more complex, but let's leave this out) is given by the backend and cannot be changed.</p> | 3 |
How to keep text horizontally during rotating transform of containing view | <p>Making custom UI control, something like rotation wheel, looks like this:
<a href="https://i.stack.imgur.com/XXici.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XXici.png" alt="enter image description here"></a></p>
<p>As you can see labels positioned "on radiuses", but i need place all labels horizontal, and keep em same way when I will rotate container view</p> | 3 |
How to compare trimmed variable in SQL statement? | <p>I have a SQL statement which includes three database tables. I am comparing some IDs and DESCRIPTIONs and now I need to compare results FIRSTNAME, MIDDLENAME and SURNAME. </p>
<pre><code>SELECT UGOVARATELJ_OSIGURANJA AS ULJEZ FROM INS_RAZNO.TEST_DOWNJONES
WHERE UGOVARATELJ_OSIGURANJA IN
(SELECT FIRSTNAME||' '||MIDDLENAME||' '||SURNAME
AS IME_PREZIME
FROM (SELECT FIRSTNAME, MIDDLENAME, SURNAME
FROM INS_RAZNO.AML_CTF
WHERE ID IN (SELECT ID FROM INS_RAZNO.AML_CTF_DESCRIPTIONS
WHERE DESCRIPTION1='1' OR DESCRIPTION1='2')));
</code></pre>
<p>Variable <code>UGOVARATELJ_OSIGURANJA</code> is actually name of the client in form NAME MIDDNAME SURNAME, with spaces between each part of the name.
My idea was to remove those spaces with <code>REMOVE()</code> but when I compare after that with second table there is no correct result.</p>
<p>I tried to test my statement with this: THIS IS ONLY TEST STATEMENT</p>
<pre><code>SELECT REPLACE(UGOVARATELJ_OSIGURANJA, ' ','') AS ULJEZ FROM
INS_RAZNO.TEST_DOWNJONES WHERE UGOVARATELJ_OSIGURANJA LIKE '%IVAN F%'
</code></pre>
<p>Notice that I had to set space between name and middname <code>LIKE %IVAN F%</code> and correct way would be %IVANF%.</p>
<p>Any idea how to solve this? Thanks in advance</p>
<p>EDIT: I am doing this replacing (trimming) because some of the peops on my lists have not MIDDLENAME</p>
<p>EDIT:
This is working statement for names which has MIDDLENAME.
The statement is not working properly when someone has no MIDDLENAME because of one space too much.</p> | 3 |
Prevent link from looking like button | <p>I need my links to look like links and not buttons.
I've tried using removeClass to remove</p>
<pre><code>class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-hover"
</code></pre>
<p>and removeAttr to remove </p>
<pre><code>role="button"
</code></pre>
<p>but both don't work. How should I prevent these classes from appending or just plainly make my links look like links?</p> | 3 |
swift 3.1 reading CSV or PLIST file from web | <p>I'd like to use readStringFromURL method to obtain a file from a plist and then use it on insertDataInArrayFromPlist in order to display it or put it on CoreData, substituting <code>let path = Bundle.main.path(forResource: plistFileName, ofType: plistFileExtension)</code>. </p>
<p>the ISSUE the try statement gives me this ERROR </p>
<pre><code>Argument labels '(contentsOfURL:, usedEncoding:)' do not match any available overloads
</code></pre>
<p>in my viewDidLoad:</p>
<pre><code>let obtainedfile = readStringFromURL(stringURL: kremoteSamplePlist)
print(obtainedfile ?? "nothing to print")
</code></pre>
<p>I retrive the file from web</p>
<pre><code> func readStringFromURL(stringURL:String)-> String!{
if let url = NSURL(string: stringURL) {
do {
return try String(contentsOfURL: url, usedEncoding: nil)
} catch {
print("Cannot load contents")
return nil
}
} else {
print("String was not a URL")
return nil
}
}
</code></pre>
<p>then I put the data in a struct</p>
<pre><code>func insertDataInArrayFromPlist(arrayOfEntities: inout [product]) {
let path = Bundle.main.path(forResource: plistFileName, ofType: plistFileExtension)
let localArray = NSArray(contentsOfFile: path!)!
for dict in localArray {
var futureEntity = product()
let bdict = dict as! [String: AnyObject]
futureEntity.name = bdict["Name"] as? String
futureEntity.ProductId = bdict["Product Id"] as? String
arrayOfEntities.append(futureEntity)
}
for element in arrayOfEntities {
print("name is \(element.name!), the id is \(element.ProductId!)")
}
}
</code></pre> | 3 |
Linq results are displayed in different ordering | <p>I am currently fiddeling around with the AdventureWorks sample database and LinqPad, for scratching out some ideas.</p>
<p>This is the query in question:</p>
<pre><code>SalesOrderHeaders.GroupBy (soh => new {soh.CustomerID, soh.BillToAddressID})
.Where(soh => soh.Skip(1).Any())
.Dump();
</code></pre>
<p>The idea was to find duplicates based on some criteria and then display them except the first set of data. The result should be deleted from the table.</p>
<p>After executing the query I get result A)
<img src="https://i.stack.imgur.com/25jar.png" alt="First Result"></p>
<p>After executing the query again I get Result B)
<img src="https://i.stack.imgur.com/QFcKA.png" alt="enter image description here"></p>
<p>I do not care about the correct results of the query, but about the ordering of the resultset. Only those two possibilities exist and they alternate on every run of the query.
Surely I could just order by Key, but I am more interested in why does this even occur? Why is the order chaning/alternating?</p> | 3 |
PHP calculation result not showing correct currency format | <p>In the following code I am trying to get the results:</p>
<pre><code>$time_base_cost_day;
</code></pre>
<p>and</p>
<pre><code>$time_base_cost_month;
</code></pre>
<p>to show with correct currency comma separators like <code>$1,456.00</code> or <code>$100,456.00</code></p>
<p>I have tried a couple of examples but not sure where I am not adding the function correctly. </p>
<p>Thank you for your help</p>
<pre><code><?php
$choose_industry = $_POST['choose_industry'];
$company_name = $_POST['company_name'];
$hourly_rate = $_POST['hourly_rate'];
$billable_rate = $_POST['billable_rate'];
$working_days = $_POST['working_days'];
$wasted_time_per_day = $_POST['wasted_time_per_day'];
$no_of_trucks = $_POST['no_of_trucks'];
$fuel_price_per_liter = $_POST['fuel_price_per_liter'];
$fuel_wasted_per_hr = $_POST['fuel_wasted_per_hr'];
$time_base_cost_day = $hourly_rate*$wasted_time_per_day;
$time_base_cost_month = $time_base_cost_day*$working_days;
$productivity_costs_day = $billable_rate*$wasted_time_per_day;
$productivity_costs_month = $productivity_costs_day*$working_days;
$fuel_base_cost_day = $wasted_time_per_day*$fuel_price_per_liter*$fuel_wasted_per_hr;
$fuel_base_cost_month = $fuel_base_cost_day*$working_days;
$monthly_cost_per_unit = 35;
$lost_per_vehicle_per_month = ($time_base_cost_month+$productivity_costs_month+$fuel_base_cost_month) - $monthly_cost_per_unit ;
$monthly_savings_per_truck = $lost_per_vehicle_per_month;//Monthly Savings = (Monthly Time Based Costs + Monthly Productivity Costs + Monthly Fuel Based Costs) – Monthly Costs per Unit.
$monthly_savings_per_fleet = $monthly_savings_per_truck*$no_of_trucks;
$monthly_cost_per_fleet = $no_of_trucks*$monthly_cost_per_unit;
$link = mysql_connect('##', '##', '##');
mysql_select_db('##', $link);
if( (!empty($choose_industry)) && (!empty($company_name)) && (!empty($hourly_rate)) && (!empty($billable_rate)) && (!empty($working_days)) && (!empty($wasted_time_per_day)) && (!empty($no_of_trucks)) && (!empty($fuel_price_per_liter)) && (!empty($fuel_wasted_per_hr)) && (!empty($time_base_cost_day)) && (!empty($time_base_cost_month)) && (!empty($productivity_costs_day)) && (!empty($productivity_costs_month)) && (!empty($fuel_base_cost_day)) && (!empty($fuel_base_cost_month)) && (!empty($monthly_savings_per_truck)) && (!empty($monthly_savings_per_fleet)) ){
$result = mysql_query("INSERT into wp_calculate (id, choose_industry, company_name, hourly_rate, billable_rate, working_days, wasted_time_per_day, no_of_trucks, fuel_price_per_liter, fuel_wasted_per_hr, time_base_cost_day, time_base_cost_month, productivity_costs_day, productivity_costs_month, fuel_base_cost_day, fuel_base_cost_month, monthly_savings_per_truck, monthly_savings_per_fleet, monthly_cost_per_unit, monthly_cost_per_fleet, Date ) values ('', '$choose_industry','$company_name', '$hourly_rate', '$billable_rate', '$working_days', '$wasted_time_per_day', '$no_of_trucks', '$fuel_price_per_liter', '$fuel_wasted_per_hr', '$time_base_cost_day', '$time_base_cost_month', '$productivity_costs_day', '$productivity_costs_month', '$fuel_base_cost_day', '$fuel_base_cost_month', '$monthly_savings_per_truck', '$monthly_savings_per_fleet', '$monthly_cost_per_unit', '$monthly_cost_per_fleet', now() )");
$last_id = mysql_insert_id();
$sql = "UPDATE wp_calculate SET pdf_link='/main/downloadpdf.php?user_id=$last_id' WHERE id=$last_id";
$retval = mysql_query($sql);
?>
<div class="offset-wrapper push-down3" id="cost_based">
<!--<div class="span6"></div>
<div class="span6"></div>-->
<div class="row cost_row" id="cost_row">
<div class="custom-calc-inner-2 wow bounceInLeft" data-wow-duration="3s" data-wow-delay="1s">
<h4>Time Based Costs</h4>
<p>Cost of wasted time (per driver)</p>
<div class="result">
<div class="pos-left">
<p class="value">DAY</p><p class="lbl">$<?php echo $time_base_cost_day; ?></p>
</div>
<div class="pos-right">
<p class="lbl">$<?php echo $time_base_cost_month; ?></p><p class="value">MONTH</p>
</div>
</div>
<div class="clear"></div>
</div>
</code></pre> | 3 |
What is the syntax for target multiple tags in css | <p>How should one go about targeting multiple html tags at once in css? Is it essentially just: </p>
<pre><code>h1 h2 h3 h4 h5 h6 {
font-weight:lighter;
}
</code></pre> | 3 |
Guidance needed - how to track nginx-docker-rails performance issue | <p>My Rails application is deployed on Amazon elastic beanstalk using Docker. Web requests flow into an nginx web server that forwards them to the thin rails server residing in docker. Somewhere along the way there's a bottleneck. Once every 50 requests (or so) I see nginx reports serving time which is x40 higher than the time the rails thin server reports.</p>
<p>here's an example:</p>
<p>NGINX (7490ms):</p>
<blockquote>
<p>146.185.56.206 - silo [18/Mar/2015:13:35:55 +0000] "GET /needs/117.json?iPhone HTTP/1.1" 200 2114 "-" "Mozilla/5.0 (Macintosh;
Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/40.0.2214.115 Safari/537.36" <strong>7.490</strong> 7.490 .</p>
</blockquote>
<p>THIN (rails server): 171ms</p>
<blockquote>
<p>2015-03-18 13:35:48.349 [INFO] method=GET path=/needs/117.json
format=json controller=needs action=show status=200
duration=<strong>171.96</strong> view=109.73 db=29.20 time=2015-03-18 13:35:47</p>
</blockquote>
<p>Can anyone supply some guidance how to troubleshoot such a situation? How do I find the source of the response time difference? I guess it could be either nginx or docker or thin or linux.</p> | 3 |
Offsetting time_t in C++ | <p>I am dealing with timestamps generated by a system where the epoch is not the standard UNIX epoch of seconds since midnight of Jan 1, 1970 (it starts somewhere in 1965 instead). <a href="https://stackoverflow.com/questions/20521750/ticks-between-unix-epoch-and-gps-epoch">This</a> question is kind of related. So, I have a "fixup" function to deal with this offset:</p>
<pre><code>time_t fix_time(uint32_t raw_time)
{
const int32_t epoch_offset = 157680000; /* offset wrt UNIX epoch */
time_t fixedTime = static_cast<time_t>(raw_time - epoch_offset);
return fixedTime;
}
</code></pre>
<p>and continue using the standard library functions in rest of the code: </p>
<pre><code>uint32_t raw_time;
time_t timestamp = fix_timestamp(raw_time);
struct tm timeinfo;
gmtime_r(&timestamp, &timeinfo);
</code></pre>
<p>It seems to work as intended (held up to a mix of real and synthetic test data, so far). However, is there a better way to deal with this scenario? Are there any subtle ways in which this might break? Additional info if it matters: the timestamps are spread out over 1981 to the current day and the program runs on a Linux machine.</p> | 3 |
Emulator crashes after running code | <p>This is the XML file for the main fragment that i am currently dealing with. the problem i am having is that when i clean the project it does not give me any errors but when i run the program the emulator crashes.</p>
<pre><code> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.budgetfuel.MainActivity$PlaceholderFragment" >
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Select Car:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price Per Litre:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="@+id/editText1"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<Space
android:id="@+id/Space1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical" />
<LinearLayout
android:id="@+id/LinearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.66"
android:text="Litres:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="@+id/editText2"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_weight="0.27"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_weight="0.80"
android:text="Odo Reading:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="@+id/editText3"
android:layout_width="186dp"
android:layout_height="wrap_content"
android:layout_weight="0.40"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="Date:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="@+id/buttonDateSet"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="Change Date:" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/LinearLayout6"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/Output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
</code></pre> | 3 |
How to set current page dynamically in flexbook? | <p>I am using a Flexbook which contains 2 BorderContainer. The code is shown below</p>
<pre><code><controls:FlexBook id="book" x="20" y="20"
width="100%" height="100%" horizontalCenter="0"
animateCurrentPageIndex="true"
showCornerTease="true" animatePagesOnTurn="true"
activeGrabArea="edge"
edgeAndCornerSize="20"
hardbackPages="false"
hardbackCovers="false"
pageShadowStrength="1"
curveShadowStrength="1"
pageSlope="0"
itemSize="page"
backgroundColor="0xC3D1D9"
borderThickness="0"
borderColor="0xC3D1D9"
cover="{null}"
backCover="{null}"
showPageSlopeAtRest="false"
cacheAsBitmap="true">
<s:BorderContainer id="page1">
<mx:ColumnChart x="0" y="35" id="ccMain" height="90%" width="99%"
cacheAsBitmap="true"
showDataTips="true" dataTipFunction="{getDataTip}" type="clustered" backgroundElements="{bge4}">
<!-- column chart code goes here -->
</mx:ColumnChart>
</s:BorderContainer>
<s:BorderContainer id="page2" creationComplete="productMainPg2.addElement(lineChart)">
<mx:Legend dataProvider="{lineChart}" height="21" x="10" width="95%" color="#b1b7f4"/>
</s:BorderContainer>
</code></pre>
<p></p>
<p>This code shows page1 as current page. <strong>I want to show the BorderContainer (id= page2) as my current page dynamically on a button click.</strong> I tried setting currentPageIndex = 1, but I get a blank page by doing this.</p> | 3 |
Custom action on failed user login | <p>Is it possible to run custom action (e.g. run some script) on failed login attempt in windows? I'm thinking about .NET application that would send messages if someone would try to access my laptop but I really don't know where to start...</p> | 3 |
print lines if $2<25 from text files with sed or awk | <p>I would like to <code>print $1 and $2 if $2<25</code>from text files. I also need to get the total number of students with marks less than 25 from all files. How can I do this with awk or sed?</p>
<pre><code>students marks
jerry 12
peter 35
john 5
jerry 15
john 10
</code></pre>
<p>Desired output</p>
<pre><code>jerry 12
john 5
jerry 15
john 10
Total no:of students :- 4
</code></pre> | 3 |
Why does this boost::spirit::qi rule not match the input? | <p>I tried to continue to work on my previous example and expand the rules. My problem is, that rules that use ID_IDENTIFIER do not work - although I know that the lexer is working (using unit tests).</p>
<p>Here's the example:</p>
<pre><code>#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
namespace qi = boost::spirit::qi;
namespace lex = boost::spirit::lex;
enum LexerIDs { ID_IDENTIFIER, ID_WHITESPACE, ID_INTEGER, ID_FLOAT, ID_PUNCTUATOR };
template <typename Lexer>
struct custom_lexer : lex::lexer<Lexer>
{
custom_lexer()
: identifier ("[a-zA-Z_][a-zA-Z0-9_]*")
, white_space ("[ \\t\\n]+")
, integer_value ("[1-9][0-9]*")
, hex_value ("0[xX][0-9a-fA-F]+")
, float_value ("[0-9]*\\.[0-9]+([eE][+-]?[0-9]+)?")
, float_value2 ("[0-9]+\\.([eE][+-]?[0-9]+)?")
, punctuator ("\\[|\\]|\\(|\\)|\\.|&>|\\*\\*|\\*|\\+|-|~|!|\\/|%|<<|>>|<|>|<=|>=|==|!=|\\^|&|\\||\\^\\^|&&|\\|\\||\\?|:|,")// [ ] ( ) . &> ** * + - ~ ! / % << >> < > <= >= == != ^ & | ^^ && || ? : ,
{
using boost::spirit::lex::_start;
using boost::spirit::lex::_end;
this->self.add
(identifier , ID_IDENTIFIER)
/*(white_space , ID_WHITESPACE)*/
(integer_value, ID_INTEGER)
(hex_value , ID_INTEGER)
(float_value , ID_FLOAT)
(float_value2 , ID_FLOAT)
(punctuator , ID_PUNCTUATOR);
this->self("WS") = white_space;
}
lex::token_def<std::string> identifier;
lex::token_def<lex::omit> white_space;
lex::token_def<int> integer_value;
lex::token_def<int> hex_value;
lex::token_def<double> float_value;
lex::token_def<double> float_value2;
lex::token_def<> punctuator;
};
template< typename Iterator, typename Skipper>
struct custom_grammar : qi::grammar<Iterator, Skipper>
{
template< typename TokenDef >
custom_grammar(const TokenDef& tok) : custom_grammar::base_type(ges)
{
ges = qi::token(ID_IDENTIFIER);
BOOST_SPIRIT_DEBUG_NODE(ges);
}
qi::rule<Iterator, Skipper > ges;
};
int main(int argc, _TCHAR* argv[])
{
std::string test("testidentifier");
typedef char const* Iterator;
typedef lex::lexertl::token<Iterator, lex::omit, boost::mpl::true_> token_type;
typedef lex::lexertl::lexer<token_type> lexer_type;
typedef qi::in_state_skipper<custom_lexer<lexer_type>::lexer_def> skipper_type;
typedef custom_lexer<lexer_type>::iterator_type iterator_type;
custom_lexer<lexer_type> my_lexer;
custom_grammar<iterator_type, skipper_type> my_grammar(my_lexer);
Iterator first = test.c_str();
Iterator last = &first[test.size()];
bool r = lex::tokenize_and_phrase_parse(first,last,my_lexer,my_grammar,qi::in_state( "WS" )[ my_lexer.self ]);
std::cout << std::boolalpha << r << "\n";
std::cout << "Remaining unparsed: '" << std::string(first,last) << "'\n";
return 0;
}
</code></pre>
<p>a similar rule with ID_INTEGER matches fine for "1234"</p> | 3 |
Text coming through onto overlapping div? | <p>I have a table where each cell has some text in it. I want a div to pop up and to cover the table but when the div pops up, it covers the table's borders, but not the text. It looks as if the text in just on the div. I have played around with the background-color and opacity, but nothing seems to work. Can anyone help me?</p>
<p>P.S. I can not make the table disappear in anyway because the overlapping div will go away eventually.</p> | 3 |
RuntimeError: Can't determine home directory | <p>I'm trying to run a PYthon Script on a server using xampp. When trying to import matplotlib I get the following error:</p>
<pre><code>[Fri Mar 13 10:46:36.219708 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py", line 5, in <module>\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.220702 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: from LambWaveModes import *\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.220702 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\xampp-portable-win32-7.2.1-0-VC15\\xampp\\htdocs\\Python\\LambWaveModes.py", line 13, in <module>\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.221697 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: from matplotlib import pyplot as plt\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.221697 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\Python\\lib\\site-packages\\matplotlib\\pyplot.py", line 32, in <module>\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.221697 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: import matplotlib.colorbar\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.222692 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\Python\\lib\\site-packages\\matplotlib\\colorbar.py", line 31, in <module>\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.222692 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: import matplotlib.contour as contour\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.223688 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\Python\\lib\\site-packages\\matplotlib\\contour.py", line 16, in <module>\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.223688 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: import matplotlib.font_manager as font_manager\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.224683 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\Python\\lib\\site-packages\\matplotlib\\font_manager.py", line 103, in <module>\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.224683 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: os.path.join(str(Path.home()), r'AppData\\Local\\Microsoft\\Windows\\Fonts'),\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.225680 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\Python\\lib\\pathlib.py", line 1079, in home\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.225680 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: return cls(cls()._flavour.gethomedir(None))\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.225680 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: File "C:\\Users\\gfranosc\\Downloads\\Python\\lib\\pathlib.py", line 264, in gethomedir\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.226676 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: raise RuntimeError("Can't determine home directory")\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.226676 2020] [cgi:error] [pid 15320:tid 2012] [client ::1:54631] AH01215: RuntimeError: Can't determine home directory\r: C:/Users/gfranosc/Downloads/xampp-portable-win32-7.2.1-0-VC15/xampp/htdocs/Python/test.py
[Fri Mar 13 10:46:36.228667 2020] [authz_core:error] [pid 15320:tid 2012] [client ::1:54631] AH01630: client denied by server configuration: C:/xampp/apache
</code></pre>
<p>Can someone help me? Do I "just" have to clarify the home directory? If yes, how can I do that?</p> | 3 |
Android ViewFlipper auto animation / looping breaks at last child view | <p>I have made a ViewFlipper to simulate a slideshow component looping the slides continuously.
I configured it be:</p>
<pre><code>mViewFlipper.setAnimateFirstView(true);
mViewFlipper.setAutoStart(true);
</code></pre>
<p><strong>Everything works fine until the last slide (or child view).
At this moment the first slide appears abruptly without sliding !!!</strong></p>
<p>I checked the ViewFlipper and ViewAnimation source code and found the following:</p>
<pre><code> void showOnly(int childIndex, boolean animate) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (i == childIndex) {
if (animate && mInAnimation != null) {
child.startAnimation(mInAnimation);
}
child.setVisibility(View.VISIBLE);
mFirstTime = false;
} else {
if (animate && mOutAnimation != null && child.getVisibility() == View.VISIBLE) {
child.startAnimation(mOutAnimation);
} else if (child.getAnimation() == mInAnimation)
child.clearAnimation();
child.setVisibility(View.GONE);
}
}
}
</code></pre>
<p>As you can see this method always starts with the lowest index to animate-in.</p>
<p>For example if I have 5 slides:</p>
<p>when the slide #4 is visible and should be replaced by slide #0, the slide #0 is animated-in before slide #4 is animated-out, which makes the animation sudden and not smooth at all.</p>
<p>Does anybody have any workaround to this problem ?</p>
<p>Thanks</p> | 3 |
Catching uncaught exceptions | <p>In my workplace we are mantaining a lot of ecommerce websites, some coded better than others. On some of those, sometimes uncaught exceptions are thrown, and showed by the alertbox from the flash player debug (If you have it installed).</p>
<p>To rise the average user experience I'd like to report all those exceptions throught a in house tool we already have.</p>
<p>Is there a way to catch those exceptions?
Maybe the flash player debug exposes them to javascript, or in some other way.</p> | 3 |
Cocos2d Changing Scenes: BAD_ACCESS Exception | <p>I have sincerely tried to understand the error from any remotely related question I have seen here. However, the issue that I am having is that when I try to transition from my level1 scene to levelselector scene, the game crashes with the bad access exception. The menus and transitions worked flawlessly while I was using them among main menu, credits, levelselector and all.
Now I do know that the error is on the main thread.
The selector shows that it is at </p>
<pre><code> int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
</code></pre>
<p>now on my level1 scene, I do have three thread using [self schedule] and I have put in the corresponding [self unschedule];</p>
<p>I also have a NSMutableArray which I tried releasing and pointing to nil but I get another error. I put it in the dealloc method of the scene. I did the same with the [self unschedule] as well. Is there a better place to put it?</p>
<p>here is how it looks like, had forgotten to retain the stuff. release is working fine now but still crashes right after the transition. the scene loads as in I can see it, but then it crashes right away. </p>
<pre><code>[enemies release];
[player release];
[accel release];
[pausedLabel release];
[pausedLayer release];
[health release];
[score release];
enemies = nil;
player = nil;
accel = nil;
pausedLabel = nil;
pausedLayer = nil;
health = nil;
score = nil;
[self unschedule:@selector(updateGameLogic)];
[self unschedule:@selector(throwEnemey)];
[self unschedule:@selector(enemyShoot)];
[super dealloc];
</code></pre>
<p>I used [[Class init] alloc] retain] this time around for each of the objects above</p> | 3 |
How do you download a file from Azure Data Lake when you know the type of the file but not the name? | <p>I can run the following to download the file "some/path/known_name.json"</p>
<pre><code>def download_file():
try:
file_system_client = FileSystemClient.from_connection_string(...)
full_file_location = "some/path/known_name.json"
target_file_client = file_system_client.get_file_client(full_file_location)
download=target_file_client.download_file()
downloaded_bytes = download.readall()
local_file = open('my_file.json','wb')
local_file.write(downloaded_bytes)
local_file.close()
except Exception as e:
print(e)
</code></pre>
<p>My question is: how do I download from some other path when the name of the file is unknown but the file type is known e.g. "different/path/xxx.json"</p> | 3 |
Create a record for each record from another table and set the id to the field | <p>I need to write a migration. There is a profile_details table and an account table. I need to create an record in profile_details for each record in the account table and set the profile_details_id field from the account table to any id from the profile_details table. It doesn't matter which id the account record will get, all records at the beginning will be the same, the main thing is that they are unique.</p>
<pre><code>with profile as (
INSERT INTO profile_details
(id, company_name, country_code, address)
SELECT uuid_generate_v4(), '', '', ''
from account
returning *
)
update account
Set profile_details_id = profile.id
FROM profile
</code></pre>
<p>This option does not work due to an error</p>
<pre><code>ERROR: duplicate key value violates unique constraint "UQ_1b48abd3c37e09aac8235b3cd22"
DETAIL: Key (profile_details_id)=(0ee5ead1-c0f0-4cd3-ae60-a1b493b0d460) already exists.
SQL state: 23505
</code></pre> | 3 |
Reactjs docker nginx app keeps throwing EMFILE: too many open files, open '/app/build/ | <p>I'm running into this issue anytime there's a lot of traffic on the site.
Below is a snapshot of the error logs. I've been trying to pin point what's causing the error with no success. I can't replicate the error locally.</p>
<p>I'm serving the production built using</p>
<pre><code>npx serve -s build -l 80
</code></pre>
<pre><code>- INFO: Gracefully shutting down. Please wait...
- events.js:174
- throw er; // Unhandled 'error' event
^
- Error: EMFILE: too many open files, open '/frontend/build/index.html'
- Emitted 'error' event at:
- at lazyFs.open (internal/fs/streams.js:115:12)
- at FSReqWrap.args [as oncomplete] (fs.js:140:20)
</code></pre> | 3 |
Need to implement custom action on ACTION_PROCESS_TEXT | <p>I am trying to implement a custom action when we select a text written in EditText in android. I tried to check multiple sources for this but I am not sure why its not working for me I followed the tutorials or medium blogs but was not able to do so.</p>
<p>Links followed by me:<br />
<a href="https://medium.com/androiddevelopers/custom-text-selection-actions-with-action-process-text-191f792d2999#.3o3ic42c8" rel="nofollow noreferrer">Link 1</a></p>
<p><a href="https://www.titanwolf.org/Network/q/3cde4fec-b06e-498f-9afa-fc2441d164f9/y" rel="nofollow noreferrer">Link 2</a></p>
<p><a href="https://dev.to/bigaru/providing-custom-text-selection-actions-in-android-1akc" rel="nofollow noreferrer">Link 3</a></p>
<p>I want to achieve something like showed in the image <a href="https://i.stack.imgur.com/Xq0ER.png" rel="nofollow noreferrer">Image of Implementation</a></p> | 3 |
Path = "C:\Temp\abcd.pdf" why its not printing full path? "C:\Temp\abcd.pdf" | <p>I am trying to print</p>
<pre><code>Path = "C:\Temp\abcd.pdf"
print(Path)
</code></pre>
<p>output:<code>C:\Tempbcd.pdf</code></p>
<p>Why its not printing full path? <code>"C:\Temp\abcd.pdf"</code></p>
<p>Does it read \new line?</p> | 3 |
Papaparse local file not showing any data | <p>I'm trying to parse a local relative csv file using papaparse however it doesn't return any data at all. The two files are located in the same folder locally. Not sure what im doing wrong here.</p>
<p>Here is my code so far....</p>
<p><strong>index.html</strong></p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="js/papaparse.min.js"></script>
</head>
<body>
<h1>CSV Analytics</h1>
<div class="row" id="csv_list"></div>
<!-- scripts -->
<script type="text/javascript">
$(document).ready(function () {
parseDataFile();
function parseDataFile() {
console.log("loading...");
const file = new File(["csv"], "data.csv", {
type: "text/plain",
});
Papa.parse(file, {
delimiter: "auto",
header: true,
dynamicTyping: true,
complete: displayData,
});
}
function displayData(results) {
console.log(results);
}
});
</script>
</body>
</html>
</code></pre>
<p><strong>data.csv</strong></p>
<pre><code>For Reorder,Inventory ID,Name,Description,Unit Price,Quantity in Stock,Inventory Value,Reorder Level,Reorder Time in Days,Quantity in Reorder,Discontinued?
0,IN0001,Item 1,Desc 1,$51.00,25,"$1,275.00",29,13,50,
0,IN0002,Item 2,Desc 2,$93.00,132,"$12,276.00",231,4,50,
0,IN0003,Item 3,Desc 3,$57.00,151,"$8,607.00",114,11,150,
0,IN0004,Item 4,Desc 4,$19.00,186,"$3,534.00",158,6,50,
0,IN0005,Item 5,Desc 5,$75.00,62,"$4,650.00",39,12,50,
0,IN0006,Item 6,Desc 6,$11.00,5,$55.00,9,13,150,
0,IN0007,Item 7,Desc 7,$56.00,58,"$3,248.00",109,7,100,Yes
0,IN0008,Item 8,Desc 8,$38.00,101,"$3,838.00",162,3,100,
0,IN0009,Item 9,Desc 9,$59.00,122,"$7,198.00",82,3,150,
0,IN0010,Item 10,Desc 10,$50.00,175,"$8,750.00",283,8,150,
0,IN0011,Item 11,Desc 11,$59.00,176,"$10,384.00",229,1,100,
0,IN0012,Item 12,Desc 12,$18.00,22,$396.00,36,12,50,
0,IN0013,Item 13,Desc 13,$26.00,72,"$1,872.00",102,9,100,
0,IN0014,Item 14,Desc 14,$42.00,62,"$2,604.00",83,2,100,
0,IN0015,Item 15,Desc 15,$32.00,46,"$1,472.00",23,15,50,
0,IN0016,Item 16,Desc 16,$90.00,96,"$8,640.00",180,3,50,
0,IN0017,Item 17,Desc 17,$97.00,57,"$5,529.00",98,12,50,Yes
0,IN0018,Item 18,Desc 18,$12.00,6,$72.00,7,13,50,
0,IN0019,Item 19,Desc 19,$82.00,143,"$11,726.00",164,12,150,
0,IN0020,Item 20,Desc 20,$16.00,124,"$1,984.00",113,14,50,
0,IN0021,Item 21,Desc 21,$19.00,112,"$2,128.00",75,11,50,
0,IN0022,Item 22,Desc 22,$24.00,182,"$4,368.00",132,15,150,
0,IN0023,Item 23,Desc 23,$29.00,106,"$3,074.00",142,1,150,Yes
0,IN0024,Item 24,Desc 24,$75.00,173,"$12,975.00",127,9,100,
0,IN0025,Item 25,Desc 25,$14.00,28,$392.00,21,8,50,
</code></pre> | 3 |
Is there any VS code extension for FreeBSD? | <p>I want to open a folder on a remote machine which runs <code>FreeBSD</code>. Is there any extension in VS code? Is there any alternate way to easily edit files on a remote machine?</p> | 3 |
Python: Modifying pprint behavior for a class or object? | <p><strong>Note:</strong> This question is about the mechanics of pprint and not asking about namedtuples. Namedtuples are used as a tangible example, but the question is not "how do I make namedtuple more beautiful for pprinting?"</p>
<hr />
<p>What method does <code>pprint</code> call to display an object's data?
How can I override this?</p>
<p>In this example, I would like to pretty print the named tuple <code>d</code> so that it prints one data element per line, similar to how the dict <code>a</code> is being printed.</p>
<pre><code>>>> import pprint
>>> import collections
>>> a={'a': 'a'*40, 'b': 'b'*40}
>>> d=collections.namedtuple('D', 'a b')('a'*40, 'b'*40)
>>> # How do I make d print similarly to a?
>>> pprint.pprint(a)
{'a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'b': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}
>>> pprint.pprint(d)
D(a='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', b='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')
</code></pre> | 3 |
Finding max path in a maze skipping 2 cells | <p><a href="https://i.stack.imgur.com/O5bMY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O5bMY.png" alt="enter image description here" /></a></p>
<p>Finding max path from (0,0) to (5,7) skips cells 1,5 and 2,5. Can anyone explain why? I get 3 different paths, but not the max path which the question needs.</p>
<pre><code>int visited[10][10];
int max_len=0;
void max_path(int a[][10],int x,int y,int x1,int y1,int value=0){
if(x==x1 && y==y1){
if(max_len<value)
max_len=value;
}
else{
if(x+1<10 && !visited[x+1][y] && a[x+1][y]!=0){
visited[x][y]=1;
max_path(a,x+1,y,x1,y1,value+1);
visited[x][y]=0;
}
if(y+1<10 && !visited[x][y+1] && a[x][y+1]!=0){
visited[x][y]=1;
max_path(a,x,y+1,x1,y1,value+1);
visited[x][y]=0;
}
if(y-1>=0 && !visited[x][y-1] && a[x][y-1]!=0){
visited[x][y]=1;
max_path(a,x,y-1,x1,y1,value+1);
visited[x][y]=0;
}
if(x-1>=0 && !visited[x-1][y] && a[x-1][y]!=0){
visited[x][y]=1;
max_path(a,x-1,y,x1,y1,value+1);
visited[x-1][y]=0;
}
}
}
</code></pre> | 3 |
How to run DatabaseUtil.precomputedKNNQuery method of LOF class on two different threads | <p>I want to reduce runtime of DatabaseUtil.precomputedKNNQuery method by running this method on two different threads and KNNQuery is an interface.</p>
<pre><code> KNNQuery<O> knnq = DatabaseUtil.precomputedKNNQuery(database, relation, getDistanceFunction(), k);
</code></pre>
<p>I divided this method of LOF class in two parts like this</p>
<pre><code> Callable<KNNQuery> task1(Database database, Relation<O> relation){
DBIDs idss = relation.getDBIDs();
ArrayDBIDs aids = (ArrayDBIDs) idss;
aids = aids.slice(0, (aids.size() / 2));
aids.size();
ProxyView<O> pv = new ProxyView<>(aids, relation);
return () -> {
return DatabaseUtil.precomputedKNNQuery(database, pv,
getDistanceFunction(), k);
};
}
Callable<KNNQuery> task2(Database database, Relation<O> relation) {
DBIDs idss = relation.getDBIDs();
ArrayDBIDs aids = (ArrayDBIDs) idss;
aids = aids.slice(((aids.size() / 2) - 1), aids.size());
aids.size();
ProxyView<O> pv2 = new ProxyView<>(aids, relation);
return () -> {
return DatabaseUtil.precomputedKNNQuery(database, pv2, getDistanceFunction(), k);
};
}
</code></pre>
<p>Then i invoked both these tasks on two different threads like this in run() method of LOF class </p>
<pre><code> public OutlierResult run(Database database, Relation<O> relation) {
StepProgress stepprog = LOG.isVerbose() ? new StepProgress("LOF", 3) : null;
DBIDs ids = relation.getDBIDs();
LOG.beginStep(stepprog, 1, "Materializing nearest-neighbor sets.");
ExecutorService executor = Executors.newFixedThreadPool(2);
List<Callable<KNNQuery>> callables = Arrays.asList(
task1(database, relation),
task2(database, relation));
for (Future<KNNQuery> future : executor.invokeAll(callables)) {
KNNQuery<O> knnq = future.get();
// Compute LRDs
// compute LOF_SCORE of each db object
// Build result representation
}
}
</code></pre>
<p>But i am getting exception which is saying something like this because forEach is providing only output of first future in knnq variable but not the combined output of both future's. Please help me how can i get rid of this exception with example thanks?</p>
<pre><code>de.lmu.ifi.dbs.elki.datasource.FileBasedDatabaseConnection.load: 505 ms
LOF #1/3: Materializing nearest-neighbor sets.
de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor.k: 4
de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor.k: 4
Materializing k nearest neighbors (k=4): 21751 [100%] de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor.precomputation-time: 21470 ms
Materializing k nearest neighbors (k=4): 21750 [100%]
de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor.precomputation-time: 22355 ms
LOF #2/3: Computing Local Reachability Densities (LRD).
Task failed
de.lmu.ifi.dbs.elki.database.datastore.ObjectNotFoundException: Object
21751 was not found in the database.
at de.lmu.ifi.dbs.elki.database.datastore.memory.ArrayStore.get(ArrayStore.java:69)
at de.lmu.ifi.dbs.elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor.get(AbstractMaterializeKNNPreprocessor.java:118)
at de.lmu.ifi.dbs.elki.database.query.knn.PreprocessorKNNQuery.getKNNForDBID(PreprocessorKNNQuery.java:84)
at de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF.computeLRD(LOF.java:292)
at de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF.computeLRDs(LOF.java:277)
at de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF.run(LOF.java:244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm.run(AbstractAlgorithm.java:89)
at de.lmu.ifi.dbs.elki.workflow.AlgorithmStep.runAlgorithms(AlgorithmStep.java:100)
at de.lmu.ifi.dbs.elki.KDDTask.run(KDDTask.java:109)
at de.lmu.ifi.dbs.elki.application.KDDCLIApplication.run(KDDCLIApplication.java:58)
at [...]
</code></pre> | 3 |
Bundle synchronization in B2C project | <p>I am working on a B2C project.</p>
<p>We are using customized bundle implementation in our project.</p>
<p>However we were struggling with making bundle synchronization work.</p>
<p>With some effort, we managed to find the ImpEx to synchronize the Bundle:</p>
<pre><code> UPDATE CatalogVersionSyncJob;code[unique=true];roottypes(code)[mode=append];
;$syncJobCode;BundleTemplate,BundleTemplateStatus;
</code></pre>
<p>However, I am worried whether this will also synchronize the ChangeProductPriceBundleRule available out of the box.</p>
<p>Also how do I synchronize this from backoffice?Is running this cronjob from the Backoffice the only solution?How do Backoffice users see a Synchronize button?Is creating a separate node necessary?</p> | 3 |
Laravel eloquent order by subquery | <p>I have a problem with ordering by columns in subquery (lastname, firstname).</p>
<p>I already tried this code as suggested by other posts:</p>
<pre><code>->with(['customer' => function ($query) {
$query->orderBy("lastname", "asc")
->orderBy("firstname", "asc");
}])
</code></pre>
<p>Here my full code, but it doesn't work.</p>
<pre><code>return Membership::forCompany($companyId)
->whereIn('state', ['ATTIVA', 'IN ATTESA DI ESITO', 'DA INVIARE'])
->where(function ($query) {
$query->where('end_date', '>=', Carbon::now()->toDateString())
->orWhereNull('end_date');
})
->with('federation')
->with(['customer' => function ($query) {
$query->orderBy("lastname", "asc")
->orderBy("firstname", "asc");
}]);
</code></pre>
<p>Here the relationships:</p>
<p>In customer model I have:</p>
<pre><code>public function memberships() {
return $this->hasMany('App\Models\Membership');
}
</code></pre>
<p>In Membership model I have:</p>
<pre><code>public function customer() {
return $this->belongsTo("App\Models\Customer");
}
</code></pre> | 3 |
Determine whether in two rows one is a header or not | <p>I am trying to do a task that is quite simple to do by a human: detect whether the first of two rows is a header row. Here's an example of sample inputs:</p>
<p>Example1: yes</p>
<pre><code>name,age
bob,12
</code></pre>
<p>Example2: yes</p>
<pre><code>first,last
bob,jones
</code></pre>
<p>Example3: no</p>
<pre><code>1,2
8,hi
</code></pre>
<p>Example4: no</p>
<pre><code>bob,jones
tom,smith
</code></pre>
<p>I'm a bit lost of where to begin to make an educated guess here. It doesn't have to be perfect (80% would be good), but what might be a good short-hand algorithm to determine the above? Some things I was thinking of:</p>
<pre><code># header is usually always strings (wrong in case 4)
for val in header:
is val.replace(',','').replace('.','').replace('-','').isdigit():
header = False
else:
header = True
</code></pre> | 3 |
How to get Title Text color of Toolbar? | <p>In my current project, I'm trying to translate color of Toolbar and it's Title Text from current color to a new color. But I can't find a function in the Toolbar something like <code>toolbar.getTitleTextColor()</code> but there is a function to set color. </p>
<p>Here's my layout </p>
<pre><code><com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:alpha="0.7"
android:id="@+id/bottombarAppbar"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/bottombarToolbar"
app:navigationIcon="@drawable/ic_hide"
app:title="Categories"
app:titleTextColor="#fafafa"
android:layout_width="match_parent"
android:layout_height="?actionBarSize" />
</com.google.android.material.appbar.AppBarLayout>
</code></pre>
<p>The statement below causes error because it's not defined.</p>
<pre><code>bottombarToolbar.getTitleTextColor()
</code></pre>
<p>Did I miss anything?</p> | 3 |
JPA Hibernate Configuration Errors | <p>I want to enable JPA for an EJB module, in an IntelliJ J2E project. I don't have an existing database schema to import; I want to generate the schema and tables from my EJB POJO class. I then want to generate ORM mappings.</p>
<p>I've enabled JavaEE Persistence framework support in IntelliJ, with Hibernate as the provider. I've updated persistence.xml and assigned MySQL@localhost as the data source, to the JPA persistence unit. I've also added the JPA descriptor to the ear artifact.</p>
<p>When I try to add the JPA annotations to my POJO, e.g. @Table, @Column etc, I get an error "Cannot resolve table 'TABLE_NAME'"...same applies for columns. The context action I get is 'Assign Data Sources', but the data source is showing as assigned to the persistence unit.</p>
<p>I've run the code and now just get a huge stack trace.</p>
<p>The tutorials i've found are either for importing an existing schema (which I don't have), or use other IDEs. My persistence.xml and one of my pojos are included below</p>
<p>Thanks in advance..</p>
<pre><code> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="NewPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/MySQL"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="***"/>
<!--Hibernate properties-->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>
</persistence>
</code></pre>
<p>POJO</p>
<pre><code>@Entity
@Table(name = "CATALOG_ITEM")
public class CatalogItem {
@Id
@Column(name = "CATALOG_ITEM_ID")
private Long itemID;
private String name;
private String manufacturer;
private String description;
private Date availableDate;
public CatalogItem() {
}
</code></pre>
<p>GlassFish Log</p>
<pre><code>[2020-05-29 12:56:46,830] Artifact jpa:ear: Error during artifact deployment. See server log for details.
[2020-05-29 12:56:46,830] Artifact jpa:ear: java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while preparing the app : [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory. Please see server.log for more details.
Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method : javax.persistence.PersistenceException: [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
[PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
</code></pre>
<p>Server Log</p>
<pre><code>[2020-05-29T00:56:46.782+0100] [glassfish 5.1] [SEVERE] [] [] [tid: _ThreadID=52 _ThreadName=Thread-9] [timeMillis: 1590710206782] [levelValue: 1000] [[
org.glassfish.deployment.common.DeploymentException: [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:158)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:901)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:195)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:467)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:516)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:512)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:511)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:542)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:534)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:533)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1441)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:86)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1823)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1699)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:510)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:200)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:166)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1314)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1240)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:175)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:83)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:199)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:206)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:144)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:901)
at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:285)
at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:64)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:131)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:128)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:208)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:217)
RAR5038:Unexpected exception while creating resource for pool DerbyPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused (Connection refused).]]
RAR5117 : Failed to obtain/create connection from connection pool [ DerbyPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused (Connection refused).]]
RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused (Connection refused).]]]
HHH000342: Could not obtain connection to query metadata : Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused (Connection refused).]]
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:243)
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:128)
... 40 more
Caused by: org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@45dad759)?
at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:46)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:175)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:94)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1237)
... 56 more
]]
[2020-05-29T00:56:46.784+0100] [glassfish 5.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=52 _ThreadName=admin-listener(4)] [timeMillis: 1590710206784] [levelValue: 1000] [[
Exception while preparing the app]]
[2020-05-29T00:56:46.784+0100] [glassfish 5.1] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=52 _ThreadName=admin-listener(4)] [timeMillis: 1590710206784] [levelValue: 1000] [[
Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:158)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:901)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:195)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:467)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:516)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:512)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:511)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:542)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:534)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:533)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1441)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:86)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1823)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1699)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:510)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:200)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:166)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1314)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1240)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:175)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:83)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:199)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:206)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:144)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:901)
at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:285)
at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:64)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:131)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:128)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:208)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:217)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:243)
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:128)
... 40 more
Caused by: org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@45dad759)?
at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:46)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:175)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:94)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1237)
... 56 more
]]
[2020-05-29T00:56:46.812+0100] [glassfish 5.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=52 _ThreadName=admin-listener(4)] [timeMillis: 1590710206812] [levelValue: 1000] [[
Exception while preparing the app : [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
javax.persistence.PersistenceException: [PersistenceUnit: NewPersistenceUnit] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1314)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1240)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:175)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:83)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:199)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:206)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:144)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:901)
at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:285)
at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:64)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:131)
at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:128)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:208)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:217)
at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:243)
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:128)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:901)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:195)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:467)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:516)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:512)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:511)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:542)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:534)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:533)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1441)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:86)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1823)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1699)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:510)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:200)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:166)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:515)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@45dad759)?
at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:46)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:175)
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:94)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1237)
... 56 more
]]
</code></pre> | 3 |
chrome extension - force default_pop content | <p>current using content_scripts to produce an alert upon url match, example:</p>
<pre><code>"content_scripts": [
{
"matches": ["https://www.google.co.uk/*"],
"js": ["alert.js"]
}
]
</code></pre>
<p>alert.js:</p>
<pre><code>alert( 'Hello, world!' );
</code></pre>
<p>but rather than producing an alert is it possible to force open my default_open within manifest.json?</p>
<pre><code>"default_popup": "index.html"
</code></pre> | 3 |
SLURM squeue format argument fails from subprocess.Popen | <p>I'm trying to call the <a href="https://slurm.schedmd.com/squeue.html" rel="nofollow noreferrer">SLURM squeue</a> from a python script. The command,</p>
<p><code>/usr/bin/squeue --Format=username,jobid,name,timeleft</code></p>
<p>Works fine from the command line, but fails from <a href="https://docs.python.org/3/library/subprocess.html#subprocess.Popen" rel="nofollow noreferrer"><code>subprocess.Popen</code></a> with:</p>
<pre><code> p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/n/home00/DilithiumMatrix/.conda/envs/py35/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/n/home00/DilithiumMatrix/.conda/envs/py35/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/squeue --Format=username,jobid,name,timeleft'
</code></pre>
<p>MWE:</p>
<pre><code>import subprocess
command = "/usr/bin/squeue --Format=username,jobid,name,timeleft"
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
text = p.stdout.read()
print(text)
</code></pre>
<p><code>/usr/bin/squeue</code> works fine from both the command line or <code>Popen</code>.</p>
<p>Could it be failing because it requires some information about the user/group that's executing the <code>squeue</code> command and that is (somehow) lost when running via python? What else could be causing this?</p> | 3 |
jQuery Scroll Event Not Working With Section | <p>I'm trying to make a simple scrollspy with jQuery Scroll event but it fails. Here is my JavaScript part:</p>
<pre><code><script>
$(document).ready(function(){
$("#credit_card").scroll(function(){
console.log('OK');
});
});
</script>
</code></pre>
<p>And HTML part:</p>
<pre><code><section class="method first-of-group" id="credit_card">
...
</section>
</code></pre>
<p>As you might have guessed, <code>console.log</code> is just for testing. This section is under a div and this div has "content" id. If I change my JavaScript code for "content" id, it is working. It's really weird. </p>
<p>If you want to see it live, please visit <a href="https://projects.denizb16.com/document/" rel="nofollow noreferrer">here</a>.</p>
<p>Thanks in advance.</p> | 3 |
Most efficient way to detect current element in scroll navigation | <p>Im not sure how to find what I need (name it) so I count on you to explain it for me.</p>
<p>I need to create javascript content navigation based on "post" or "comment" system. First of all I want to emphasize that content is not plain text but It contain HTML, images and other objects that can resize during usage.</p>
<p><strong>How does it look?</strong>
One container for content divided to sections and one for dedicated navigation scroll - this scroll is snapped relatively to sections.</p>
<p><a href="https://i.stack.imgur.com/YKLVE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YKLVE.png" alt="enter image description here"></a></p>
<p>Whole system is very simillar to discourse posts navigation -
<a href="https://try.discourse.org/" rel="nofollow noreferrer">check discourse here</a></p>
<ul>
<li>Most important thing for me is to keep synchronization for scroll and content.</li>
<li>If you click 3th post in scroll, content should scroll to this post - this is easy.</li>
<li>If you scroll by mouse content is scrolled + dedicated navigation is automatically synchronised - this is my problem I think.</li>
</ul>
<p><strong>What is the best* way to check which one section is my current section.
Should I find visible element? bounding rectangle? calculate it based on heights of all sections?</strong></p>
<p>PS If you have any library working in similar way you can post it as addition - it can be helpful for me.</p>
<p><strong>//edit</strong></p>
<p><strong>*best</strong> - simple, not too slow if I get more elements (100-1000), takes into consideration dynamic content (resize) and also supported by all modern browsers. Probably there is more than 3 methods but if you post more alternatives, Me or someone else can pick suitable solution.</p> | 3 |
React Component div id will not hide what used in map loop | <p>I have this code in an index.html file which loads with the application:</p>
<pre><code>$(window).on('load', () => {
$('#one').hide();
$('#oneb').hide();
});
</code></pre>
<p>And this affects the component:</p>
<pre><code>import React from 'react';
const Test = (props) => <div id="MyDiv">
<div>
<div id="one">
THIS IS ONE
</div>
{
props.list.map((data, i) => {
return <div id="oneb" key={i}>
THIS IS ONEB
</div>
})
}
</div>
</div>
</code></pre>
<p>What is happening here is that div with id="one" will hide BUT id="oneb" will still show up.</p>
<p>Why is this happening? How can I fix this?</p> | 3 |
Text shows in header instead of new section BS4 | <p>I have a problem with my one-page website. My new text section shows in my header video. instead in my new section. I want it after video header. What am I doing wrong?</p>
<p>My HTML</p>
<pre><code><header>
<div class="container">
<div class="bg-wrap">
<video poster="poster.png" autoplay="true" loop muted>
<source src="img/video.mp4" type="video/mp4">
<source src="img/video.webm" type="video/webm">
</video>
<div class="header-text">
<h1>Elektro Sikora</h1>
<p>Informační portál Elektro Sikora Český Těšín</p>
</div>
<div id="scroll">
<div class="round">
<div class="wheel"></div>
</div>
<div class="scrolling">
<span class="arrow"></span>
</div>
</div>
</div>
</div>
</header>
<section id="content-space">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<p>
Kompletní nabídka produktů, které nabízíme. Najdete zde od elektroniky až po zdravou výživu.
</p>
</div>
</div>
</div>
</section>
</code></pre>
<p>My CSS</p>
<pre><code>/* Nav */
.navbar {
padding: 1,2rem;
}
/* Video */
.bg-wrap {
position: fixed;
z-index: -1000;
width: 100%;
height: 100%;
overflow: hidden;
top: 0;
left: 0;
}
video {
top: 70px;
left: 0;
min-height: 100%;
min-width: 100%;
}
.header-text {
position: absolute;
width: 100%;
min-height: 100%;
z-index: 1000;
background-color: rgba(0, 0, 0, 0.4);
}
.header-text h1 {
text-align: center;
font-size: 65px;
text-transform: uppercase;
font-weight: 300;
color: #fff;
padding-top: 15%;
margin-bottom: 10px;
}
.header-text p {
text-align: center;
font-size: 20px;
letter-spacing: 3px;
color: #fff;
}
#scroll {
cursor: pointer;
display: block;
position: absolute;
bottom: 50px;
left: 50%;
z-index: 1000;
}
.round {
height: 21px;
width: 14px;
border-radius: 10px;
transform: none;
border: 2px solid #fff;
top: 170px;
}
.wheel {
animation-delay: 0s;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-name: scrolling;
animation-play-state: running;
animation-timing-function: linear;
background: #fff none repeat scroll 0 0;
border-radius: 10px;
height: 3px;
margin-left: auto;
margin-right: auto;
position: relative;
top: 4px;
width: 2px;
}
.scrolling span {
display: block;
width: 5px;
height: 5px;
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
border-right: 2px solid #fff;
border-bottom: 2px solid #fff;
margin: 3px 0 3px 5px;
}
.arrow {
margin-top: 6px;
}
header {
height: 100vh;
overflow: hidden;
}
</code></pre>
<p><a href="https://i.stack.imgur.com/Jzm3k.jpg" rel="nofollow noreferrer">Nav dissapear and scrollable video</a></p> | 3 |
Merge columns from Multiple Sheets into Summary Sheet without blanks | <p>I have many sheets of which some are <strong>A, B, C and D.</strong>
Each of them have different data sets, however columns <strong>E,F,G</strong> have the same type of data.</p>
<p>I would like to merge the data from the columns E,F,G of the sheets A, B, C and D Paste in <strong>Columns A,B,C</strong> of <strong>Sheet Summary</strong>. </p>
<p>The problem I am facing is that the range E2:G(last row with data) has empty rows in the beginning and also in the Middle. Example: E2:G10 is blank and data might be present from E11:G30. This is making my copy paste erroneous.</p>
<p>The Following is the Code I have written. But, for some reason the data in the Sheet D is altered. Also, as I did not know how to exempt empty rows while copying, I used a separate code block to delete the empty rows at the end of copy paste activity in the Sheet Summary.</p>
<pre><code>Sub CopyRange()
Dim bottomD As Integer
Dim ws As Worksheet
For Each ws In Sheets(Array("A", "B", "C", "D"))
ws.Activate
bottomD = Range("E" & rows.Count).End(xlUp).Row
Range("E2:G" & bottomD).Copy Sheets("Summary").Cells(rows.Count,"E").End(xlUp).Offset(1, 0)
Next ws
Dim r As Range
Dim rows2 As Long
Dim i As Long
Set r = ActiveSheet.Range("A:A")
rows2 = r.rows.Count
For i = rows2 To 1 Step (-1)
If WorksheetFunction.CountA(r.rows(i)) = 0 Then r.rows(i).Delete
Next
End Sub
</code></pre> | 3 |
ssrs footer dynamic textbox | <p>In the <code>footer</code> of my report, It contains <code>textbox 1</code> and <code>textbox2</code>. </p>
<p>I want to textbox 1 be <em>hidden both on the page 1 and 2</em>. But, I only know how to hide it on the page 1.
I am using expression <code>=IIf(cstr(Globals!PageNumber)="1", True, False)</code>in the visibility . </p>
<p>Do anyone know how to hide the textbox 1 for page 1 and 2? </p> | 3 |
Fixed iOS status bar overlap in PhoneGap but status bar not Showing | <p>I developed IOS application using <code>PhoneGap</code>.Status bar overlap in Our page content,Now i Played </p>
<p>I am not using storyboard, so I can use this code in your <code>AppDelegate.m</code> in did <code>finishlaunching</code>:</p>
<pre><code>if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
</code></pre>
<p><code>OverLap</code> issue fixed but Status bar not showing.</p>
<p>Please give me any idea. How to solved Status bar overlap in <code>PhoneGap</code>.</p> | 3 |
SQL: Relation between different rows of two tables | <p>I'm creating er-diagram for "Airport" database. And I got stick with tables "Flight" and "Airport" .
In table "Flight" I have 2 columns: "Departure_place" and "Arrival_ place". Both of it should be connected to values in table "Airport".
So, How can I make that in the proper way on er-diagram and on sql?</p>
<p><a href="https://i.stack.imgur.com/Nx4Mv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nx4Mv.png" alt="enter image description here"></a></p> | 3 |
ode45 error, index out of bounds because numel(x)=1 | <pre><code> function xx = test(x, t)
xx(1) = x(2);
xx(2) = x(3) * cos(x(4) + x(1));
xx(3) = 0;
xx(4) = 0;
end
</code></pre>
<p>That is my script, confused as to why I am getting this error. </p> | 3 |
How to read the `<td>` values of a webpage `html` table? | <p>I have a webpage, and when I view the source I get the following:</p>
<pre><code><td>
<a href="www.example.com">Ryhanu Datta</a>
</td>
<td> daffodil</td>
<td> b2/24 </td>
</code></pre>
<p>How can I read the <code><td></code> values of a table on a webpage using <code>selenium-webdriver</code> in Ruby?</p> | 3 |
Firebase data ordering | <p>I feel as if I'm missing something big when I use firebase in my android app. I have been using</p>
<pre><code>push();
</code></pre>
<p>to put my data in firebase with a unique id.
I have been accessing this data in an activity using the ChildEventListener:</p>
<pre><code>ref.addChildEventListener(new ChildEventListener() {
// Retrieve new posts as they are added to the database
@Override public void onChildAdded(DataSnapshot snapshot, String previousChildKey) {
Map<String, Object> newPost = (Map<String, Object>) snapshot.getValue();
}
});
</code></pre>
<p>I believe that</p>
<pre><code>snapshot.getValue()
</code></pre>
<p>should provide me with all my unique ids but how do I order them to display them in order from newest to oldest?</p>
<p>Thanks for your help!</p> | 3 |
C++: ADT Base class with hard-coded Derived classes vs all-encompassing class built from file-input | <p>Which is a better design: An ADT Base class with hard-coded, concrete derived classes and instances or all-encompassing class whose instances are built from file input?</p>
<p><strong>EXAMPLE:</strong></p>
<pre><code>class ADTSpell {
ADTSpell(std::string name, int min_damage, int max_damage);
virtual ~ADTSpell()=0;
//...
};
class Fire : public ADTSpell {
Fire() : ADTSpell("Fire", 14, 15) { }
//...
};
/* Other concrete derived classes */
</code></pre>
<p>--OR--</p>
<pre><code>class Spell {
Spell(std::string name, int min_damage, int max_damage, /*...*/ )
//...
};
File: Spells.txt
Fire 14 15
Heal -3 -5
Ice 5 8
</code></pre> | 3 |
In meteorjs, where should I declare a function, so calls to it work from anywhere? | <p>And if this function needs other libraries declared before it?
(such as bootstrap, less, paperjs)</p>
<p>In other words, how can I control the import order?</p> | 3 |
SQL Statement Using Embedded Selects | <p>Okay, this works:</p>
<pre><code>SELECT DISTINCT(USER), COUNT(DISTINCT (USER)) AS numrows
FROM `sometable`
GROUP BY USER
ORDER BY USER asc
LIMIT 0, 20
</code></pre>
<p>What I need to do now is to limit results to numrows > X. Tried a number of solutions using embedded selects, but no luck.</p> | 3 |
Sticky navbar makes content jump on way back up | <p>I Have a simple site set up with a header, navbar and content. When the page reaches the navbar, the position becomes fixed so the navbar sits at the top of the page - at this point, the navbar height also gets a bit smaller (as I like this effect) - I have done this by adding separate classes, fixed and thinner to the navbar.</p>
<p>Most people are aware of the issue that occurs when you add "position:fixed" to an inline element in that it makes the content suddenly "jump" upwards. To counteract this i have added a div called "stop_the_jump" which is hidden until the navbar becomes fixed, at which point it is displayed in it's place. All of this runs smoothly on the way down, but as you scroll back up you get a jump due to the fact that the navbar is now thinner.</p>
<p>I'm pulling my hair out over this one, how can I eliminate this jump that occurs on the way back up.</p>
<p>Here is a JSFiddle clearly showing my issue:
<a href="http://jsfiddle.net/gnac14qa/" rel="nofollow">http://jsfiddle.net/gnac14qa/</a></p>
<p>My jQuery code is as follows:</p>
<pre><code>$(window).scroll(function() {
var Scroll = $(window).scrollTop();
var ScrollFXfullHeight = $('.header-wrapper').height();
if (Scroll == ScrollFXfullHeight) {
$("#navigation").addClass("fixed");
$(".stop_the_jump").css('display','block');
} else if (Scroll > ScrollFXfullHeight) {
if(!$("#navigation").hasClass('fixed')) {
$(".stop_the_jump").css('display','block');
$("#navigation").addClass("fixed");
}
$("#navigation").addClass("thinner");
} else {
$("#navigation").removeClass("thinner fixed");
$(".stop_the_jump").removeClass("thinner");
$(".stop_the_jump").css('display','none');
}
});
</code></pre>
<p>Any help would be much appreciated.</p> | 3 |
How to get number of resources in directory in spring? | <pre><code>@Value("file:" + "${d:/my/dir/}")
private Resource dir;
</code></pre>
<p>How can I get the number of files in that resource dir? Unfortunately the <code>Resource</code> interfaces does not offer any getFiles() method...</p> | 3 |
ListProperty vs StringListProperty on Google App Engine | <p>I want to store lists of integers (user ids), should I make them strings and use a StringListProperty, or just use a ListProperty, I'm wondering what is more optimized, the specific StringListProperty of the heterogeneous ListProperty (when used with only Integers).</p>
<p>I will need to add users to the list until it reaches a certain number, and then I create a group instance for those users (in a separate Entity Group). </p> | 3 |