text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
code are same as another function
else if(n) ... // 30 lines of code are same as another function
else if(o) ... // 30 lines of code are same as another function
else if(p) ... // 10 lines of 'map<string, int>& d' code
else if(q) ... // 10 lines of 'map<string, int>& d' code
}
}
```
You could factor out the common code:
```
void helper(int& a, string& b) {
... // 30 lines of common code
}
```
then use that in the functions:
```
void Foo(int& a, string& b, vector<int>& c) | [
-0.11655240505933762,
0.04368015378713608,
0.33912184834480286,
0.07227612286806107,
0.04179670661687851,
0.5958860516548157,
-0.01585233025252819,
-0.6289323568344116,
0.0122000053524971,
-0.7906194925308228,
-0.22636553645133972,
0.47906509041786194,
-0.52662193775177,
-0.174859568476676... | |
{
helper(a, b);
... // 10 lines of code to parse and assign value to vector<int>& c
}
void Foo(int& a, string& b, map<string, int>& d) {
helper(a, b);
. .. // 10 lines of code to parse and assign value to map<string, int>& d
}
```
Alternatively, you could use templates if the common code contains references to the containers as well:
```
template<template<typename T, typename Alloc> class Container>
void helper(int& a, string& b, Container& d) { | [
-0.15850847959518433,
-0.07461059093475342,
0.5444402098655701,
-0.024186480790376663,
0.02067399024963379,
0.7082751989364624,
-0.013696105219423771,
-0.4861750304698944,
-0.2589229345321655,
-0.7663364410400391,
-0.26980921626091003,
0.47748637199401855,
-0.5744965076446533,
-0.135678961... | |
... // 30 lines of common code
}
```
Note: You will have to use template specialization as not all containers have the same insertion (or access) method (e.g. vector, list: `push_back`; map: `insert`)
UPDATE: after OP added more code to question:
If the only difference is in the handling of the containers, but the "spirit" of the container handling is very similar, you could create (template) wrappers for the containers and pass the wrapper into a common function: the differences will be captured in the different implementations of the wrappers. | [
0.06253475695848465,
-0.18420566618442535,
0.17467136681079865,
0.0026260127779096365,
-0.021446891129016876,
0.0878339633345604,
-0.1811884343624115,
-0.4330480098724365,
-0.06665845215320587,
-0.8097407221794128,
-0.08144361525774002,
0.4771290421485901,
-0.41197603940963745,
-0.07936594... | |
Can you advice me good php ajax and mysql data grid. It is supposed to have certain functions such as filtering, search and grouping. I need to generate from database (it could be better if it is open source).
Just try this then :
<http://datatables.net/> | [
0.327759712934494,
-0.02192278951406479,
0.0325704887509346,
0.4276597201824188,
0.03146679699420929,
-0.4368213415145874,
0.12974098324775696,
0.251740425825119,
-0.08264461904764175,
-0.7073699235916138,
0.3931724429130554,
0.48528793454170227,
0.051075179129838943,
-0.21383705735206604,... | |
Ok, I'm going nuts here. I'm trying to implement a basic popup window to display images. If my javascript code is fully specified in an HTML tag with the onclick property, the window pops up correctly. If my IDENTICAL javascript code is called from either the script tag at the beginning of the HTML document or from a separate js file, the link (or image in my case) opens not in a popup, but in the same window. < frustration >
This opens a popup:
```
<a href="test.jpg" onclick="window.open('test.jpg','test_name','width=500,height=500,scrollbars=no'); return false">test_name</a>
```
This does not open a popup:
```
function cleanPopup(url, title) {
window.open(url, title, 'width=500,height=500,scrollbars=no');
return false;
}
<a href="test.jpg" | [
0.6791327595710754,
0.2952883541584015,
0.047621529549360275,
-0.026675131171941757,
-0.034363847225904465,
-0.17495080828666687,
0.6284001469612122,
-0.17752183973789215,
-0.006084016524255276,
-0.35271787643432617,
-0.28813445568084717,
0.48675110936164856,
-0.21326181292533875,
0.168198... | |
onclick="return cleanPopup('test.jpg', 'test_name')">test_name</a>
```
Any help would be appreciated.
PS: Tested in Chrome and Firefox.
EDIT:
I've discovered my problem. I originally only called the js file in the head tag. There is something about the layers of div's when created with multiple scripts of a templating tool (Template Toolkit in my case) that makes the original script element within the head element seemingly invisible to the deeper child elements.
I do not know exactly what's going on, and I don't have the time to explore it. I've added this edit just in case some other person has a similar issue and somehow stumbles across | [
0.5524352788925171,
0.20663677155971527,
0.36884626746177673,
-0.027719398960471153,
0.015377204865217209,
-0.19118301570415497,
0.4192162752151489,
0.057368285953998566,
0.033133365213871,
-0.6562007665634155,
0.08251078426837921,
0.3329926133155823,
-0.3846857249736786,
-0.00900800339877... | |
this thread. If someone understands this phenomenon, and can explain it, please do.
EDIT 2:
**The "name" parameter of the window.open method can not contain spaces for the popup to work in IE. Thanks M$.**
[DEMO HERE](http://plungjan.name/test/test_popup.html)
This code is the closest to foolproof you can get in my opinion.
Tested on
* Windows - Fx, Chrome, IE8 and Safari
* iPhone: Mobile Safari
1. adding a target makes the link open in a new window or tab if allowed - in case the script fails for any reason - this is a SIDE-EFFECT which is useful but not the answer to the question.
2. returning true if | [
0.5679906606674194,
0.0002984232269227505,
0.2281741350889206,
0.0415060818195343,
-0.18674637377262115,
-0.4256315231323242,
0.5563218593597412,
-0.14205409586429596,
0.05828239768743515,
-0.6150496006011963,
0.20872634649276733,
0.4858032464981079,
-0.46979397535324097,
-0.15184991061687... | |
the window.open fails will also make the click follow the link, hopefully invoking the target - Note that some browsers no longer reacts to target.
3. the height (and width) in the 3rd parameters will enforce the opening in a new window rather than a new tab unless the browser is set to open all new windows in a tab
```
<html>
<head>
<script type="text/javascript">
window.onload=function() {
document.getElementById('popup').onclick=function() {
var w = window.open(this.href, this.target,
'width=500,height=500,scrollbars=no');
return (!w); // opens in new window/tab if allowed
}
}
</script>
</head>
<body>
<a id="popup" href="test.jpg" target="test_name">test_name</a>
</body>
</html>
``` | [
0.007800979074090719,
0.07578633725643158,
0.9255661964416504,
-0.11177166551351547,
0.05720958113670349,
-0.038395900279283524,
0.5945310592651367,
-0.47037577629089355,
0.016359182074666023,
-0.8353714346885681,
-0.4637664556503296,
0.4595664441585541,
-0.24790208041667938,
0.17502830922... | |
I am using a cron job to get the users tweets etc and we are saving it in a text file. Now when the user visits the site we need to show these contents. Which of the following is better?
* Curl or file\_get\_contents()
I researched a lot on this and found that curl is better over FGC. but all of them are for external domains. What we need is the answer for same domain.
Also can you suggest a better way for doing this? than saving it as a text file and presenting to users? Will it be more effective if we | [
0.5739238262176514,
0.24223960936069489,
0.3775236904621124,
0.1634436845779419,
-0.3193446397781372,
-0.22865228354930878,
0.04029914736747742,
0.19137047231197357,
-0.29900357127189636,
-0.6242619156837463,
0.08723323792219162,
0.5277390480041504,
-0.35989198088645935,
0.1740743368864059... | |
create an extra DB table for these sort of contents?
[DEMO HERE](http://plungjan.name/test/test_popup.html)
This code is the closest to foolproof you can get in my opinion.
Tested on
* Windows - Fx, Chrome, IE8 and Safari
* iPhone: Mobile Safari
1. adding a target makes the link open in a new window or tab if allowed - in case the script fails for any reason - this is a SIDE-EFFECT which is useful but not the answer to the question.
2. returning true if the window.open fails will also make the click follow the link, hopefully invoking the target - Note that some browsers no longer reacts | [
0.6727797985076904,
-0.0633709728717804,
0.07162565737962723,
0.055490490049123764,
-0.321055144071579,
-0.3315243721008301,
0.7238040566444397,
-0.5232017636299133,
0.2379593402147293,
-0.5812724828720093,
0.14027024805545807,
0.4683733284473419,
-0.3138396441936493,
-0.3228715658187866,
... | |
to target.
3. the height (and width) in the 3rd parameters will enforce the opening in a new window rather than a new tab unless the browser is set to open all new windows in a tab
```
<html>
<head>
<script type="text/javascript">
window.onload=function() {
document.getElementById('popup').onclick=function() {
var w = window.open(this.href, this.target,
'width=500,height=500,scrollbars=no');
return (!w); // opens in new window/tab if allowed
}
}
</script>
</head>
<body>
<a id="popup" href="test.jpg" target="test_name">test_name</a>
</body>
</html>
``` | [
0.31290867924690247,
-0.17729951441287994,
0.9084031581878662,
-0.24017128348350525,
-0.07423502951860428,
0.05068963021039963,
0.13735462725162506,
-0.45586097240448,
0.0012343935668468475,
-0.7827323079109192,
-0.19744791090488434,
0.4565291702747345,
-0.1676628291606903,
-0.099852286279... | |
I have a master page, there's only one menu item and a contentplaceholder there. I have another web form that inherits form this master page. As nor mal I've put all my controls in the contentplaceholder. On my form's Page\_Load event I want to set Enabled=false of all the dropdownlist controls. For this purpose I write:
```
foreach (Control control in Page.Controls)
{
if (control is DropDownList)
{ | [
-0.0022883317433297634,
0.1425723433494568,
0.6483995318412781,
-0.15284843742847443,
0.10949493944644928,
-0.028738755732774734,
0.5216120481491089,
-0.022746244445443153,
-0.003444571513682604,
-0.7702363729476929,
-0.24790701270103455,
0.45582816004753113,
-0.2496458888053894,
0.2280806... | |
DropDownList ddl = (DropDownList)control;
ddl.Enabled = false;
}
}
```
But all the dropdownlists remain Enabled. When I check for the count of the Page.Control I see only one control and it's the menuitem of the form's masterpage. What should I do to get the list of controls that are in my current form?
Resource is simply something you want to limit access to. It could be a page, a record in your DB or whatever your application needs.
I wrote a | [
0.2009105682373047,
-0.13454143702983856,
0.6549080014228821,
0.07253734022378922,
0.028987372294068336,
0.041831500828266144,
0.28436243534088135,
-0.10825459659099579,
-0.1801312416791916,
-0.669310986995697,
-0.027238361537456512,
0.6780730485916138,
-0.32798993587493896,
0.204257681965... | |
three-part series on Zend\_Acl, in which I talk about what resources are amongst other things: <http://codeutopia.net/blog/2009/02/06/zend_acl-part-1-misconceptions-and-simple-acls/> | [
0.2098068743944168,
-0.12420328706502914,
-0.17312827706336975,
0.11813458055257797,
-0.19520063698291779,
-0.15465840697288513,
0.08276118338108063,
-0.1580534726381302,
0.05548454448580742,
-0.31016576290130615,
-0.26813215017318726,
0.47229596972465515,
0.12029088288545609,
-0.001224119... | |
How to add/replace some picture at the ▼ sign of *dijit.form.ComboBox* or *dijit.form.FilteringSelect*
and the picture can switch when mouse move in and move out.
And how to change popup's bg-color of the ComboBox.
[Like this web site](http://logistics.nostramap.com/)
(I need to copy like the original from that site. But this site use a custom widget then I don't know how to get the source.)
If anyone know how to customize like that please teach me. Thanks.
Changing the look and feel of Dojo widgets is done using themes.
<http://dojotoolkit.org/reference-guide/1.7/dijit/themes.html>
You can see the themes that ship by default at
<http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/themes/themeTester.html>
(NOTE: This page is based on a | [
0.3133159875869751,
-0.34608009457588196,
0.37972965836524963,
0.1585443615913391,
-0.13911259174346924,
-0.22778591513633728,
-0.018594639375805855,
-0.3306657373905182,
-0.3525007963180542,
-0.8155895471572876,
-0.0010511482832953334,
0.46087121963500977,
-0.3426031470298767,
0.035083457... | |
nightly build, so soemtimes it is broken)
Themes are applied using CSS.
I'd create your own css style sheet.
Add the theme name to the body node.
```
<body class="tundra myTheme">
```
The particular css you are looking for is
```
.myTheme .dijitComboBox .dijitDownArrowButton {} /* The grey box */
.myTheme .dijitComboBox .dijitDownArrowButton .dijitArrowButtonInner { /* The arrow */
background: url(images/spriteArrows.png) no-repeat scroll 0 center;
}
/* Hover */
.myTheme .dijitComboBox .dijitDownArrowButtonHover {} /* The grey box */
.myTheme .dijitComboBox .dijitDownArrowButtonHover .dijitArrowButtonInner {} /* The arrow */
/* Active (mouse down) */
.myTheme .dijitComboBox .dijitDownArrowButtonActive {} /* The grey box */
.myTheme .dijitComboBox .dijitDownArrowButtonActive .dijitArrowButtonInner {} /* The arrow */
```
Using | [
0.0902552455663681,
0.03694804757833481,
0.3348841965198517,
-0.016602514311671257,
-0.19161809980869293,
0.1993132382631302,
0.3908594250679016,
-0.28040897846221924,
-0.17044971883296967,
-0.730835497379303,
-0.33942627906799316,
0.43205779790878296,
0.03371121734380722,
0.06974059343338... | |
the developer tools with your browser will help you determine the css classes that you are looking to override. | [
0.233648881316185,
-0.008402148261666298,
-0.0998065322637558,
0.3428155481815338,
0.05453877151012421,
-0.2669973373413086,
0.21059542894363403,
0.2214699238538742,
0.04982466995716095,
-0.9196403622627258,
-0.16269706189632416,
0.3890216648578644,
0.0449129156768322,
-0.10159483551979065... | |
Why can't `<p>` be nested inside `<table>`? What is the correction I could make?
Removing the `<div>` and `<p>` tags corrupt my design. As the website follows a client provided design.
I have the following code and it works fine in VS2008, but I get warnings:
---
#### Code
```
<div class="right_articles">
<p>
<table>
<tr>
<td> | [
0.5394447445869446,
0.15960845351219177,
0.5524428486824036,
-0.0983612984418869,
-0.03767535090446472,
-0.2106606662273407,
0.3738318979740143,
-0.24921754002571106,
-0.19629742205142975,
-0.5145219564437866,
0.3219989240169525,
0.542250394821167,
-0.2978868782520294,
0.22192473709583282,... | |
<img alt="Img not found" src="images/ribbon.gif" style="width: 155px; height: 125px;" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br /> | [
-0.3203560411930084,
-0.260475754737854,
0.6068944334983826,
-0.19247838854789734,
-0.29614168405532837,
0.06405739486217499,
-0.09286405891180038,
-0.41356831789016724,
-0.5293194055557251,
-0.5060049891471863,
-0.2045738399028778,
0.0810750424861908,
-0.2140943855047226,
0.16976468265056... | |
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
</p>
<p> </p>
<p>
<table>
<tr> | [
-0.27694055438041687,
-0.31671595573425293,
0.4501693546772003,
-0.02359689585864544,
-0.25259602069854736,
0.13529594242572784,
-0.052941933274269104,
-0.4814024865627289,
-0.581936240196228,
-0.4224342405796051,
-0.38922643661499023,
0.01239266712218523,
-0.13796497881412506,
0.018940404... | |
<td>
<img alt="Img not found" src="images/medal.gif" style="width: 155px; height: 125px;" />
</td>
<td>
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label><br /> | [
0.015343586914241314,
-0.19456620514392853,
0.4386971592903137,
-0.08217008411884308,
-0.390685498714447,
-0.017492027953267097,
0.05953916907310486,
-0.5872655510902405,
-0.6092069149017334,
-0.2886712849140167,
-0.15789198875427246,
0.28541067242622375,
0.11856424063444138,
0.13477060198... | |
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
</p>
</div>
```
#### Warnings
```
Warning 1 This end tag has no matching start | [
0.10721682757139206,
-0.11201249063014984,
0.4116363227367401,
-0.12203595042228699,
-0.13792403042316437,
-0.21724221110343933,
0.12438555806875229,
-0.3963550925254822,
-0.2755270302295685,
-0.2837528586387634,
-0.36234554648399353,
0.22961537539958954,
-0.4553333520889282,
0.17622756958... | |
tag.
E:\WebSite4\test.master 121
Warning 2 Validation (XHTML 1.0 Transitional):
Text is not allowed between the opening and closing tags for element html'.
E:\WebSite4\test.master 5
Warning 3 Validation (XHTML 1.0 Transitional):
Element 'form' is missing its closing tag.
E:\WebSite4\test.master 21
Warning 4 The class or CssClass value is not defined.
E:\WebSite4\test.master 33
Warning 5 File 'spacer.gif' was not found.
E:\WebSite4\test.master 116
Warning 7 Validation (XHTML 1.0 Transitional):
Element 'img' | [
0.047589339315891266,
0.06342551857233047,
0.6445671319961548,
-0.22587956488132477,
0.020239591598510742,
-0.3562247157096863,
0.45085078477859497,
-0.27115312218666077,
-0.18385235965251923,
-0.3499569892883301,
-0.5983963012695312,
0.2203795313835144,
-0.6219174861907959,
-0.06998486816... | |
is missing required attribute 'alt'.
E:\WebSite4\test.master 116
Warning 8 Validation (XHTML 1.0 Transitional):
Element 'table' cannot be nested within element 'p'.
E:\WebSite4\test.master 78
Warning 9 Validation (XHTML 1.0 Transitional):
Element 'table' cannot be nested within element 'p'.
E:\WebSite4\test.master 93
```
In HTML it's important to understand that [`P` elements](http://www.w3.org/TR/html401/struct/text.html#h-9.3.1) cannot contain other block level elements and TABLE is a block level element. The `P` closing tag is optional and when you try to make a `P` element contain something that it cannot contain, the | [
-0.10885713249444962,
0.19059570133686066,
0.5436543822288513,
-0.1381211131811142,
0.253645658493042,
-0.10493159294128418,
0.14590485394001007,
-0.3880882263183594,
-0.47108638286590576,
-0.3206522762775421,
-0.6900392770767212,
0.09971059113740921,
-0.4559932351112366,
-0.26477247476577... | |
closing `P` tag is assumed by the browser.
> The P element represents a paragraph. It cannot contain block-level
> elements (including P itself).
<http://www.w3.org/TR/html401/struct/text.html#h-9.3.1> | [
-0.2762327194213867,
0.20270465314388275,
0.708251416683197,
-0.18996314704418182,
-0.0076153334230184555,
-0.04327122122049332,
0.19873937964439392,
-0.08128970116376877,
-0.09506465494632721,
-0.4175879955291748,
-0.7646110653877258,
0.007880497723817825,
-0.5570403933525085,
-0.06897407... | |
Currently, the WPF slider has some properties that allow defining and viewing **a single interval** on a slider: SelectionStart, SelectionEnd and IsSelectionRangeEnabled.
By setting these values
```
<Slider Minimum="0" Maximum="300" Value="150" IsSelectionRangeEnabled="True" SelectionStart="50" SelectionEnd="200"/>
```
you get the selected interval in the slider, colored in blue, like this:

What I would like to do is to be able to define **multiple intervals** - e.g. (50-100), (110-130), (170-200) and (210-240), which would look like this:

Any ideas on how to aproach this issue or what template I should try modifying in order to get this feature?
this may not be an answer | [
0.2871131896972656,
-0.42465296387672424,
0.7042077779769897,
-0.0596868097782135,
-0.05321570858359337,
0.06183416768908501,
-0.1911790817975998,
-0.3848063051700592,
-0.5198983550071716,
-0.7705766558647156,
0.1485435664653778,
0.2901241183280945,
-0.07343237847089767,
-0.009550312533974... | |
but a workaround. I place slider bar on canvas, then draw to canvas [Highlight segments on slider bar](https://stackoverflow.com/questions/9555955/highlight-segments-on-slider-bar) | [
0.2732638418674469,
-0.12414102256298065,
0.48635563254356384,
-0.06828001886606216,
0.034612178802490234,
-0.002250408986583352,
-0.033883459866046906,
-0.29267847537994385,
-0.49326756596565247,
-0.4655831754207611,
0.13880445063114166,
0.4500880241394043,
-0.059925880283117294,
-0.18774... | |
I have an images folder at the following URL.
```
www.mysite.com/uploads/
```
On a different page:
```
www.mysite.com/search.php/
```
I am trying to access the images wherein, with a correct tag link, however I get the :
```
Forbidden
You don't have permission to access /uploads/ on this server.
```
So I went and started dabbling with a `.htaccess` file, and I have no idea what I am doing ,I tried looking at some documentation but with no luck, I even took an example off another question..Here is how my `.htaccess` file looks atm:
```
<FilesMatch "\.(gif|jpe?g|png)$">
Order allow,deny
Allow from all
</FilesMatch>
<Directory /uploads>
# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all
</Directory>
```
Any | [
0.4405575394630432,
0.506549596786499,
0.5026169419288635,
-0.056057121604681015,
-0.007029728498309851,
-0.1452539563179016,
0.21453692018985748,
0.011860545724630356,
-0.2826571762561798,
-0.7454202175140381,
-0.06416881829500198,
0.6400206685066223,
-0.5445403456687927,
0.13298328220844... | |
ideas on how I can have it allow access to that folder?
```
<Directory /uploads>
Options +Indexes
</Directory>
``` | [
0.477687269449234,
0.18426728248596191,
0.19514058530330658,
0.22652395069599152,
0.44137197732925415,
-0.0520167201757431,
-0.14304353296756744,
0.1835826188325882,
-0.294794499874115,
-0.5238239765167236,
0.08445727080106735,
0.27891361713409424,
-0.010067294351756573,
0.2057484984397888... | |
Which validations are preferred : client side(using Javascript) or serverside (using validation controls in C# asp.net)?
You should *always* validate on the server. Client-side validation is fine to enhance the user experience, but anything that has come from the client is potentially dirty and should be validated on the sever again, as your server-side code is not vulnerable to malicious user manipulations (at least, not in the same way that client-side code is).
**Always finally validate on the server!!** | [
0.5814224481582642,
-0.043856363743543625,
0.567920982837677,
0.20150339603424072,
-0.2646048069000244,
-0.34948793053627014,
0.3305629789829254,
-0.23358891904354095,
-0.24998213350772858,
-0.37564629316329956,
-0.04732951521873474,
0.3215954303741455,
0.06348452717065811,
-0.092799931764... | |
I have a program that embeds Lua and implements a form of lazy function lookup.
The way it worked in Lua 5.1, whenever a symbol was undefined the interpreter would call a global function hook that would then resolve the symbol.
This is a small portion of C code that implemented this lazy function lookup:
```
int function_hook(lua_State *pLuaState)
{
// do the function lookup here
....
return 1;
}
......
//-- create table containing the hook details
lua_newtable(pLuaState);
lua_pushstring(pLuaState, "__index");
lua_pushcfunction(pLuaState, function_hook);
lua_settable(pLuaState, -3);
//-- set global index callback hook
lua_setmetatable(pLuaState, LUA_GLOBALSINDEX);
```
I'm now trying to move this code to Lua 5.2 and have run into a problem.
In Lua 5.2 the | [
-0.20314370095729828,
-0.14059923589229584,
0.549724280834198,
-0.4183010160923004,
-0.011522175744175911,
0.2909967005252838,
-0.05361142382025719,
-0.14072488248348236,
-0.10397841036319733,
-0.7379526495933533,
0.08480069786310196,
0.4635539650917053,
-0.5913592576980591,
0.116501800715... | |
LUA\_GLOBALSINDEX value is no longer defined so this line of code no longer compiles.
```
//-- set global call back hook
lua_setmetatable(pLuaState, LUA_GLOBALSINDEX);
```
There is a [reference](http://www.lua.org/manual/5.2/) to this change to LUA\_GLOBALSINDEX but unfortunately it has not helped.
What would be the best way to re-write this one line of code to have the interpreter call the function\_hook whenever it finds an unresolved symbol?
The [global environment](http://www.lua.org/manual/5.2/manual.html#2.2) is now stored at a special index in the [registry](http://www.lua.org/manual/5.2/manual.html#4.5). Try:
```
//-- get global environment table from registry
lua_rawgeti(pLuaState, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
//-- create table containing the hook details
lua_newtable(pLuaState);
lua_pushstring(pLuaState, "__index");
lua_pushcfunction(pLuaState, function_hook);
lua_settable(pLuaState, -3);
//-- set global index callback hook
lua_setmetatable(pLuaState, -2);
//-- remove the global environment table | [
-0.3174836039543152,
-0.07556663453578949,
0.698217511177063,
-0.3283684551715851,
-0.061855804175138474,
0.42057910561561584,
0.04640480503439903,
-0.17372478544712067,
-0.20234458148479462,
-0.6110779643058777,
-0.1902390569448471,
0.45524126291275024,
-0.5474474430084229,
0.145489931106... | |
from the stack
lua_pop(pLuaState, 1);
``` | [
-0.0692114308476448,
0.2574118375778198,
0.22603391110897064,
-0.24884453415870667,
0.09186544269323349,
0.27395081520080566,
-0.22590580582618713,
0.048587601631879807,
-0.4361553490161896,
-0.35071295499801636,
-0.5594555139541626,
0.21150098741054535,
-0.3126024305820465,
0.213719978928... | |
i use **org.json** library to work with JSON-data in my apps. But it seems that google app engine doesn't allow to use it, what's the best way to work with JSON on GAE-apps?
I hope [this](http://nadacode.com/2010/06/30/using-json-in-your-google-app-engine-java-app/) helps
you can also the google-json api [here](http://code.google.com/p/google-gson/) | [
0.24984055757522583,
0.2201162874698639,
0.3260359764099121,
0.018756145611405373,
-0.1350938081741333,
0.17010724544525146,
0.1936366707086563,
0.0041316174902021885,
-0.33706963062286377,
-0.5841599106788635,
0.03703518211841583,
0.6278809309005737,
-0.09713959693908691,
-0.4066884517669... | |
I have the following function from that I am setting an attribute of select tag which have sortBy id but its not working from this function i have given alert in this function after setting attribute but its giving null value.
Please Help Me.
```
function getXmlByPrice(mi,mx)
{
if(mi!="" && mx!="")
{
$("#min").text(mi);
$("#max").text(mx);
$("#sortBy").attr('onchange','getDataFromXmlByStar();');
alert($("#sortBy").attr('onchange'));
getDataFromXmlByStar();
} | [
0.029991289600729942,
-0.23350773751735687,
0.8075844049453735,
-0.10576420277357101,
0.32661208510398865,
0.2766086161136627,
0.5182414650917053,
-0.064725361764431,
-0.13331906497478485,
-0.6273707151412964,
-0.20984667539596558,
0.7826555371284485,
-0.3817563056945801,
0.071656495332717... | |
else
{
getXml();
}
}
```
if you are trying to add an `onchange` handler, instead of
```
$("#sortBy").attr('onchange','getDataFromXmlByStar();');
```
do this:
```
$("#sortBy").on('change',function{
getDataFromXmlByStar()
});
``` | [
-0.14663326740264893,
-0.4324466288089752,
0.7705903649330139,
-0.2590785324573517,
0.3908970057964325,
0.136918842792511,
-0.013880930840969086,
-0.12058225274085999,
-0.18752111494541168,
-0.5015340447425842,
-0.29063692688941956,
0.630517303943634,
-0.6108186841011047,
0.115488737821578... | |
I'm trying to create a simple To-Do list Java application connected to MS Access and I used **JTable** and **DefaultTableModel** to display the list. I want to mark completed tasks by changing its color when I click on a button. I have a boolean field named '*completed*' that serves as indicator.
```
String header[] = {"priority", "task"};
String data[][];
DefaultTableModel model = new DefaultTableModel(data, header);
JTable table = new JTable(model);
// to be replaced with code that affects only specific cells not the whole table
table.setFont(customFont);
```
I already have a Font object that I called *customFont*, which is ready to be applied. My question is, how do I | [
0.13959892094135284,
0.0047930567525327206,
0.7218894958496094,
-0.2901158928871155,
-0.05230852961540222,
0.2920052707195282,
0.06543677300214767,
-0.37073785066604614,
-0.41052573919296265,
-0.8399305939674377,
0.05036887153983116,
0.5452855229377747,
-0.2994365394115448,
-0.204733505845... | |
apply it only to specific cells where completed==true.
Sample codes would be much appreciated.
* easiest of ways is look at [prepareRenderer()](https://stackoverflow.com/a/9737299/714968), best of all is @camickr [Table Row Rendering](http://tips4java.wordpress.com/2010/01/24/table-row-rendering/)
* `JTable` is View, based on `TableModel`, in most cases you have to convert the view against model [converXxxToXxx](https://stackoverflow.com/a/7625488/714968) from inside of `prepareRenderer` or `getTableCellRendererComponent`, because `JTable` could be sorted of filtered
* methods
code
```
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
```
returns access to the specific cell in JTable - ([TableCellRenderer renderer, int row, int column](https://stackoverflow.com/a/6901508/714968)) | [
-0.30657708644866943,
0.07199091464281082,
0.6005944609642029,
-0.16072535514831543,
0.017477737739682198,
0.16600488126277924,
0.27810347080230713,
-0.4458881616592407,
-0.10185014456510544,
-0.8390212655067444,
-0.3344036936759949,
0.4445725977420807,
-0.30422642827033997,
-0.02659908682... | |
I'm getting into writing unit testing and have implemented a nice repository pattern/moq to allow me to test my functions without using "real" data. So far so good.. However..
In my repository interface for "Posts" `IPostRepository` I have a function:
`Post getPostByID(int id);`
I want to be able to test this from my Test class but cannot work out how.
So far I am using this pattern for my tests:
```
[SetUp]
public void Setup()
{
mock = new Mock<IPostRepository>();
}
[Test]
public void someTest()
{
populate(10); //This populates the mock with 10 fake entries
//do test here
}
```
In my function "someTest" I | [
0.4865569472312927,
0.326988160610199,
0.23678649961948395,
-0.04211663454771042,
-0.17491665482521057,
0.33585506677627563,
0.5022255778312683,
-0.11994844675064087,
0.04689463973045349,
-0.8641476035118103,
0.13736264407634735,
0.44340765476226807,
-0.11399384588003159,
-0.06818566471338... | |
want to be able to call/test the function `GetPostById`. I can find the function with `mock.object.getpostbyid` but the "object" is null.
Any help would be appreciated :)
iPostRepository:
```
public interface IPostRepository
{
IQueryable<Post> Posts {get;}
void SavePost(Post post);
Post getPostByID(int id);
}
```
If you want your mock object to return a result (not null), you need to set it up:
```
mock.Setup( m => m.GetPostByID( 5 ) ).Returns( new Post() );
```
What you return exactly is up to you of course.
**Update:**
If you need to use the method parameters you can also setup a [CallBack](http://code.google.com/p/moq/wiki/QuickStart#Callbacks). For example:
```
mock.Setup( m => m.GetPostByID( It.IsAny<int>() | [
0.16713747382164001,
0.1568463146686554,
0.4150867462158203,
0.10174349695444107,
-0.17367015779018402,
0.17912495136260986,
0.2708394229412079,
-0.2821417450904846,
-0.05142009258270264,
-0.7753433585166931,
-0.10826792567968369,
0.5644147396087646,
-0.3332701027393341,
-0.038364358246326... | |
) )
.Callback( id => return new Post{ Id = id; } );
```
This may make your setup code much easier since you don't need to prime the mock with data. | [
0.24211663007736206,
0.1814144253730774,
0.4960207939147949,
-0.3556419312953949,
-0.01648091711103916,
0.14422915875911713,
0.3643244504928589,
-0.4750456213951111,
0.04417499154806137,
-0.5783008933067322,
-0.20764459669589996,
0.7806232571601868,
-0.22688987851142883,
0.1813961714506149... | |
I'm creating a PreferenceScreen in runntime. But the screen blackout when trying to scroll through.
For `ListView` there is a state to avoid this sort of situation,
```
android:cacheColorHint="@android:color/transparent"
```
But no such state for PreferenceScreen.
How can I avoid screen blackout in PreferenceScreen ?
Try out this thing.
```
getListView().setBackgroundColor(Color.TRANSPARENT);
getListView().setBackgroundColor(Color.rgb(4, 26, 55));
``` | [
0.47582700848579407,
-0.18174129724502563,
0.49848803877830505,
-0.09089088439941406,
0.006271018646657467,
-0.03682000935077667,
0.3324160575866699,
-0.03596894070506096,
-0.06272090971469879,
-1.0725877285003662,
0.06931667029857635,
0.6660957336425781,
-0.4739273190498352,
0.08122282475... | |
How are users getting past a 1024 connection limit in Linux in association with doing MQTT for push notification?
I am using Mosquitto server, which I think I read does not have a 1024 connection limit built into the linux version. So, can I use a single server (no bridging etc) and get 5,000, 10,000+ users?
Or, do I absolutely need bridging? I haven't seen a lot of writing on how this is setup other than the config settings man page for mosquitto.
Or, can I get by with just modify a few linux configuration settings and I'm good to go | [
0.3132406175136566,
-0.06566643714904785,
0.36827993392944336,
0.09856459498405457,
-0.02132941037416458,
-0.3404983580112457,
0.31405407190322876,
0.2545325756072998,
-0.5632038116455078,
-0.6755335927009583,
-0.007079262752085924,
0.7296075820922852,
-0.19680233299732208,
0.1106509789824... | |
with a single mosquitto server?
My app is more or less an instant messaging app, so I expect to have ~10,000 maybe even 20,000 people using it with permanent 24/7 connections to mosquitto to alert them of messages.
Hmmm
In theory you could up the Linux setting for max number of sockets for mosquitto to what you need. The question then is around performance. The key metric is number of messages per second total. If you have 20k clients connected, how many will be active and how many messages will each be sending?
As an example, if half of your clients are active | [
0.27701255679130554,
-0.21111026406288147,
0.5101804733276367,
0.2887011468410492,
-0.12467259913682938,
-0.04075339064002037,
0.375262588262558,
0.06784737855195999,
-0.6274827718734741,
-0.5985680818557739,
-0.06355619430541992,
0.7364848256111145,
-0.18761299550533295,
-0.17407438158988... | |
and sending 1 message per second, there are 10k msps - incoming only of course. If each of those messages is 10 bytes, you're at a sustained 100kB/s or 800kbps.
Another aspect is how your topic hierarchy is arranged. I can't tell you what is best, but it will certainly have an effect.
My best suggestion would be to write a client that simulates a real person, then use it to so real testing of your scenario.
I have seen examples of extreme client count: <http://bit.ly/HytRpK> but have no more details.
One final point: IBM are currently producing a redbook on MQTT. It | [
0.1485362946987152,
-0.22158172726631165,
0.3799929618835449,
0.32909995317459106,
-0.07876839488744736,
0.060266513377428055,
0.26839375495910645,
0.05732295662164688,
-0.5412666201591492,
-0.7075104713439941,
-0.0021265740506350994,
0.3453023433685303,
-0.12164600938558578,
0.01360365748... | |
should be available 'in spring', i.e. soon. I think it will cover scaling issues. | [
0.3721962869167328,
-0.06212347745895386,
0.4768306612968445,
0.2801685333251953,
0.5225557088851929,
0.10336989164352417,
-0.01418977975845337,
0.13530665636062622,
-0.21598055958747864,
-0.6825348138809204,
-0.0051407525315880775,
0.1547246277332306,
0.3644954264163971,
-0.37963488698005... | |
I want to call the RunNotifier of a JUnitCore.
It's called fNotifier and is initiated in the JUnitCore class.
Source:
<https://github.com/KentBeck/junit/blob/master/src/main/java/org/junit/runner/JUnitCore.java>
Can I get this by reflection somehow, or is there any other way I can call this RunNotifier.
I want to use his `pleaseStop()` method.
Using reflection isn't the best method, but you can do it something like this:
```
public static void main(String[] args) throws Exception {
Computer computer = new Computer();
JUnitCore jUnitCore = new JUnitCore();
Field field = JUnitCore.class.getDeclaredField("fNotifier");
field.setAccessible(true);
RunNotifier runNotifier = (RunNotifier) field.get(jUnitCore);
runNotifier.pleaseStop(); | [
-0.15889503061771393,
-0.38455140590667725,
0.44580262899398804,
-0.12118295580148697,
-0.20648756623268127,
0.0027710660360753536,
0.32785746455192566,
-0.14842018485069275,
0.07886708527803421,
-0.7728531360626221,
-0.20604725182056427,
0.41175469756126404,
-0.5661628246307373,
0.1610501... | |
jUnitCore.run(computer, BeforeAfterTest.class, AssertionErrorTest.class);
}
```
This will throw a [org.junit.runner.notification.StoppedByUserException](https://github.com/KentBeck/junit/blob/master/src/main/java/org/junit/runner/notification/StoppedByUserException.java).
If you want more flexibility or control, a better way to do the above is to just copy the bits you want from JUnitCore into your class, and then you've got direct control over the notifier, and listeners, etc. This is the nicest way to do it. JUnitCore isn't really deisgned to be extended. | [
-0.0999479815363884,
-0.4345628321170807,
0.25090721249580383,
0.001575272879563272,
-0.3694392144680023,
-0.368184894323349,
0.42231109738349915,
0.15038196742534637,
0.030576657503843307,
-0.7815919518470764,
-0.015137962065637112,
0.5112593770027161,
-0.3310372829437256,
-0.125136777758... | |
I have an iOS application, which stores all downloaded `*.pdf` files in its cache. Is there a way to prevent this data from extracting? Encryption or something else? Thanks in advance.
You can protect PDF files with a password. I assume you create the PDF files not within the application but externally. For example you can use *Preview.app* in Mac OS X to secure existing PDF files with a password *(Hit Cmd-P, then select PDF in the print menu and there you can set security options. Or even more simple: in the menu choose Export...)*.
In iOS you can then open the | [
0.26769062876701355,
0.415027916431427,
0.42320236563682556,
0.11604128032922745,
0.17823339998722076,
-0.1310613751411438,
0.07996144145727158,
0.037792712450027466,
-0.26653915643692017,
-0.8925312161445618,
-0.19766919314861298,
0.7250565886497498,
-0.11863788962364197,
-0.1607066839933... | |
PDF files like this:
```
CGPDFDocumentRef documentRef = CGPDFDocumentCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:filePath]);
if (!CGPDFDocumentIsUnlocked(documentRef))
CGPDFDocumentUnlockWithPassword(documentRef, password);
...
``` | [
-0.16060495376586914,
0.02517351508140564,
0.9152055382728577,
0.13523603975772858,
0.007761053275316954,
-0.3297047019004822,
0.1729704588651657,
-0.28344985842704773,
-0.24061156809329987,
-0.752308189868927,
-0.4982680380344391,
0.6481028199195862,
-0.20573361217975616,
0.15798079967498... | |
I have a div with an id of `content` and I want to get the `id` of the first level `div` elements, eg. `box1`, `box2`, `box3`. How can this be done ?
```
<div id="content">
<div id="box1" class="box1class">
<div>...</div>
</div>
<div id="box2" class="box1class">
<div>...</div>
</div>
<div id="box3" class="box1class">
<div>...</div>
</div>
</div>
```
Use the `>` child seelctor.
```
var ids = [];
$("#content > div").each(function() { | [
0.21173186600208282,
-0.10357442498207092,
0.45634886622428894,
-0.08219153434038162,
-0.021491684019565582,
0.15004585683345795,
0.018468625843524933,
-0.5150542259216309,
0.2526441514492035,
-0.6790822744369507,
-0.25257760286331177,
0.28328555822372437,
-0.2641468346118927,
0.2864419519... | |
ids.push(this.id);
});
```
You could shorten this further by using `map()`:
```
var ids = $("#content > div").map(function() {
return this.id;
}).get();
``` | [
0.19323934614658356,
-0.2794395983219147,
0.7267282009124756,
-0.2198486179113388,
0.12647469341754913,
-0.3354063928127289,
0.26876577734947205,
-0.26346632838249207,
-0.04723481088876724,
-0.7799424529075623,
-0.43913447856903076,
0.6749268174171448,
-0.42903146147727966,
0.2008809447288... | |
I have an application working on the following envirnoment:
* Monotouch 2.1
* MonoDevelop 2.4.2
* MacOS 10.6.8
* iOS SDK 4.3
The same application, migrated to iOS 5.0/5.1 and Monotouch 5.2.10 with MonoDevelop 2.8.8.4 under, has the following problem: When i click a button to navigate in a UIWebView do not work.
Code is that:(obviously it's same in Monotouch 2.1)
```
public void ScrollToTop (object sender, EventArgs evt)
{
webView.EvaluateJavascript("window.scrollTo(0,0)");
}
```
What could i do?
SOLVED (with Jonathan.Peppers help):
```
public void ScrollToTop (object sender, EventArgs evt)
{
if((UIDevice.CurrentDevice.CheckVersion(5, 0)){ | [
0.07157813757658005,
-0.005362498573958874,
0.7223820686340332,
0.0642571747303009,
0.08658447116613388,
-0.12796327471733093,
0.6313515901565552,
-0.3918425440788269,
-0.007359371054917574,
-0.7680925130844116,
-0.15553182363510132,
0.6502965092658997,
-0.45742562413215637,
0.164002299308... | |
System.Drawing.PointF p = new System.Drawing.PointF(0, 0);
webView.ScrollView.SetContentOffset(p,true);
}
else{
webView.EvaluateJavascript("window.scrollTo(0,0)"); | [
-0.33213910460472107,
-0.3273884057998657,
0.8467755913734436,
-0.2772040367126465,
-0.1503921002149582,
0.2023075819015503,
0.31174156069755554,
-0.3762121796607971,
0.040883149951696396,
-0.7961710095405579,
-0.09789183735847473,
0.5359206795692444,
-0.30033016204833984,
-0.0056501161307... | |
}
}
```
i have made in that way because on 4.3 webView.ScrollView.SetContentOffset make application crash.
Use this XPath expression `"//*"` in this way
```
Document doc = ... // the document on which apply XPath
XPathExpression xp = XPathFactory.newInstance().newXPath().compile("//*");
NodeList elements = (NodeList) xp.evaluate(doc, XPathConstants.NODESET);
```
It return to you all the elements at any level. | [
0.11620505154132843,
0.2034011334180832,
0.7169405221939087,
-0.13306699693202972,
0.35041725635528564,
-0.12285307794809341,
0.3181474804878235,
-0.3247217833995819,
0.00031142521766014397,
-0.7356600761413574,
-0.20954996347427368,
0.7806453108787537,
-0.391591340303421,
0.01067134272307... | |
I am trying to retrieve product name and its ids as NameID object from EntityFramework using WebAPI. code for which is as following.
```
public class ProductController : ApiController
{
protected MainDataContext db = new MainDataContext();
// GET /api/values
public IQueryable<NameID> Get()
{
return db.Products.Select(x=>new NameID{ ID=x.ID,Name=x.Name }).AsQueryable();
}
// GET /api/values/5
public NameID Get(long id)
{
var result = db.Products.Select(x=>new NameID{ ID=x.ID,Name=x.Name }).SingleOrDefault(x => | [
0.1825801134109497,
0.12275540083646774,
0.5306812524795532,
-0.3862258791923523,
-0.03346279263496399,
0.27449071407318115,
0.3642617464065552,
-0.5258669257164001,
0.14044439792633057,
-0.7395954132080078,
-0.25119802355766296,
0.2312806248664856,
-0.1830800622701645,
0.5175307393074036,... | |
x.ID == id);
if (id == 0 || result == null)
throw new HttpResponseException(HttpStatusCode.NotFound);
return result;
}
}
public class NameID {
public long ID {get;set;}
public string Name {get;set;}
}
```
It throws error as following
```
The magic number in GZip header is not correct.
Make sure you are passing in a GZip stream.
at System.IO.Compression.GZipDecoder.ReadHeader(InputBuffer input)
at System.IO.Compression.Inflater.Decode()
at System.IO.Compression.Inflater.Inflate(Byte[] bytes, Int32 offset, Int32 length)
at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 | [
0.06368687748908997,
-0.16076481342315674,
0.5762282013893127,
-0.041849955916404724,
-0.02327069640159607,
-0.011249435134232044,
0.6644502878189087,
-0.45044565200805664,
-0.1892772614955902,
-0.8813029527664185,
-0.3798879384994507,
0.3865315914154053,
-0.451978862285614,
0.199347645044... | |
count)
at System.IO.Compression.GZipStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.Xml.XmlTextReaderImpl.InitStreamInput(Uri baseUri, String baseUriStr, Stream stream, Byte[] bytes, Int32 byteCount, Encoding encoding)
at System.Xml.XmlTextReaderImpl..ctor(Stream stream, Byte[] bytes, Int32 byteCount, XmlReaderSettings settings, Uri baseUri, String baseUriStr, XmlParserContext context, Boolean closeInput)
at System.Xml.XmlReaderSettings.CreateReader(Stream input, Uri baseUri, String baseUriString, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings, String baseUri)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Data.Entity.Migrations.Edm.ModelCompressor.Decompress(Byte[] bytes)
at System.Data.Entity.Migrations.History.HistoryRepository.GetLastModel(String& migrationId)
at System.Data.Entity.Migrations.History.HistoryRepository.GetLastModel()
at System.Data.Entity.Internal.InternalContext.QueryForModel()
at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata)
at System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata)
at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass8.<PerformDatabaseInitialization>b__6()
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c)
at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() | [
-0.059487611055374146,
0.10393793135881424,
0.5905811786651611,
0.12661196291446686,
0.046280328184366226,
0.3411870002746582,
0.03463427349925041,
-0.8197140097618103,
-0.3123844265937805,
-0.47625455260276794,
-0.15092450380325317,
0.4479861557483673,
-0.27593138813972473,
0.272403478622... | |
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)
at ProductAPI.Controllers.ProductController.Get() in D:\Demo\ProductAPI\Controllers\ProductController.cs:line 24
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext controllerContext, IDictionary`2 arguments)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
```
The stack trace seems to indicate the there is a problem reading the Entity Framework model metadata from the database.
`HistoryRepository.GetLastModel` calls `ModelCompressor.Decompress` that uses `XDocument.Load` to read some XML from a `GZipStream`. This fails and the model metadata in the database is most likely corrupted.
You can try to recreate the database to get around this problem. | [
-0.1488174945116043,
-0.09927978366613388,
0.6229578852653503,
0.15348482131958008,
0.11366523057222366,
-0.037209685891866684,
0.1591176688671112,
-0.3603385090827942,
-0.41551241278648376,
-0.5021405816078186,
-0.28922757506370544,
0.3559439480304718,
-0.22502601146697998,
0.407710582017... | |
I'm trying to make a preference screen for my android application, but I'm failing completely. I'm following [this guide](http://www.javacodegeeks.com/2011/01/android-quick-preferences-tutorial.html). When I try to install the application, I get this error message, and it won't install the app on my phone:
```
[2012-04-10 12:54:45 - AndroidCurrencyConverter] ------------------------------
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Android Launch!
[2012-04-10 12:54:45 - AndroidCurrencyConverter] adb is running normally.
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Performing ValutaConverter.namespace.AndroidValutaConverterActivity activity launch
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Automatic Target Mode: using device '3134BC2BBCA800EC'
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Uploading AndroidCurrencyConverter.apk onto device '3134BC2BBCA800EC'
[2012-04-10 12:54:46 - AndroidCurrencyConverter] Installing AndroidCurrencyConverter.apk...
[2012-04-10 12:54:49 - AndroidCurrencyConverter] Success!
[2012-04-10 12:54:49 - AndroidCurrencyConverter] Starting activity ValutaConverter.namespace.AndroidValutaConverterActivity on device 3134BC2BBCA800EC
[2012-04-10 12:54:52 | [
-0.14229951798915863,
-0.14778541028499603,
0.7060830593109131,
-0.27108079195022583,
-0.32865387201309204,
0.10211998969316483,
0.5763673782348633,
-0.43860846757888794,
0.003863988909870386,
-0.5390521883964539,
-0.31745031476020813,
0.7842154502868652,
-0.21525326371192932,
-0.146328255... | |
- AndroidCurrencyConverter] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=ValutaConverter.namespace/.AndroidValutaConverterActivity }
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=ValutaConverter.namespace/.AndroidValutaConverterActivity } from null (pid=11486, uid=2000) requires android.permission.INTERNET
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at android.os.Parcel.readException(Parcel.java:1327)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at android.os.Parcel.readException(Parcel.java:1281)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1631)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.commands.am.Am.runStart(Am.java:433)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.commands.am.Am.run(Am.java:107)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.commands.am.Am.main(Am.java:80)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.internal.os.RuntimeInit.finishInit(Native Method)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:238)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at dalvik.system.NativeStart.main(Native Method)
```
What I understood from this code was that when it tries to start the | [
-0.2902768850326538,
-0.05250552296638489,
0.4491352438926697,
-0.3024800419807434,
0.021821388974785805,
0.2958794832229614,
0.5632885098457336,
-0.6841247081756592,
-0.22316421568393707,
-0.5819970965385437,
-0.36463916301727295,
0.5051525831222534,
-0.10717141628265381,
-0.1619899570941... | |
Intent, it fails because it requires android.permission.INTERNET. But this is already defined in my manifest file.
I had the app working at some point, but I added a few things to my activity, added another activity, and some XML files. After this, it won't install the app on the phone. What I added was:
In the activity class:
```
addPreferencesFromResource(R.xml.preferences);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, 0, 0, "Show current settings");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
startActivity(new Intent(this, | [
0.20005761086940765,
-0.18081939220428467,
0.9656035900115967,
-0.22966709733009338,
0.4365050196647644,
0.07335970550775528,
0.5829606056213379,
-0.43087247014045715,
0.00548167759552598,
-0.6125586032867432,
-0.07252945005893707,
0.9101178646087646,
-0.4643481969833374,
-0.35527378320693... | |
ShowSettingsActivity.class));
return true;
}
return false;
}
```
If you need any other information about the code or the likes of that, I will gladly post some of it.
Help!
It should be,
```
<uses-permission
android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:name=".AndroidValutaConverterActivity"
android:theme="@android:style/Theme.DeviceDefault" > | [
0.07188151776790619,
-0.16914695501327515,
0.8375841379165649,
0.09218032658100128,
-0.15448015928268433,
-0.16372458636760712,
0.23991641402244568,
-0.1018778458237648,
-0.18395601212978363,
-0.5434147119522095,
-0.22214457392692566,
0.23468488454818726,
-0.4388270676136017,
0.06948931515... | |
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShowSettingsActivity"/>
</application>
```
remove it from activity tag in your manifest file. | [
0.1047261655330658,
-0.34611237049102783,
0.5703921914100647,
-0.5034042000770569,
-0.28547370433807373,
-0.09439321607351303,
0.23818127810955048,
-0.21485589444637299,
-0.035357728600502014,
-0.4701274633407593,
0.0633632093667984,
0.328146368265152,
-0.7333893179893494,
-0.2953763306140... | |
Although I know image resolutions and support them on the android is a fairly common question surrounding android I can't seem to find any questions or postings on-line that deal with what I'd like to do.
I have a map which I set as the background of the android device. I then overlay touchable points and images where a specific city exists. My problem is how do I should I correctly deal with positioning the cities on different devices?
I've got different images for different dpi's if someone was to ask. However is the correct way to pin the position of x | [
0.48413965106010437,
0.12250200659036636,
0.3656337857246399,
0.31981053948402405,
-0.14830808341503143,
0.456579327583313,
0.03570336103439331,
0.14831092953681946,
-0.25603383779525757,
-0.9767443537712097,
0.2617266774177551,
0.3630509376525879,
-0.2715972661972046,
-0.03183379769325256... | |
and y in this case using a percentage based on the scaled size of the background. It's the solution I keep coming back to however I'm yet to work out a way to get the scaled size of a background image.
Any feedback would be appreciated.
Ryan
It is really difficult within Android to try to layer images onto a specific location in the background using some combination of dpi/weights. One of the problems is how does the background scale? Are you using the suggested 9-patch images or just letting android crop or scale down your image? Even after this the "dpi" value | [
0.5549994707107544,
-0.07544133812189102,
0.17300064861774445,
0.29794612526893616,
-0.0628838837146759,
0.2766043543815613,
0.06996899098157883,
0.21565906703472137,
-0.22231543064117432,
-0.7246143817901611,
0.28977879881858826,
0.556466281414032,
-0.12556502223014832,
-0.105040058493614... | |
of the phones isn't exact, the OS is just using a predefined multiplier (such as 1.5x for hdpi) to quickly estimate the size of the image. To get the "true" dpi you would need something like:
```
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
float xDpi = dm.xdpi;
float yDpi = dm.ydpi;
```
and use those values in your calculation. In the end it really is best to simply use the true values of the screen and use percentages like you stated. I believe that is how most OpenGL apps do it as well (someone correct me if I'm wrong) and apps like this that are on the | [
0.23270896077156067,
-0.18206413090229034,
0.7680040597915649,
0.15024793148040771,
0.0030418469104915857,
0.1380489021539688,
0.22909411787986755,
-0.4102964699268341,
0.11830352991819382,
-0.601409375667572,
0.1346672624349594,
0.9406455159187317,
-0.16036909818649292,
-0.615652441978454... | |
verge of using a graphics engine should probably behave similarly. | [
-0.3687264323234558,
-0.11932791769504547,
0.536827027797699,
0.05061705410480499,
-0.0032308492809534073,
-0.1637663096189499,
-0.14073939621448517,
0.2837189733982086,
0.06696856766939163,
-0.6033183336257935,
0.2717989385128021,
0.6029922366142273,
0.2545225918292999,
-0.130308076739311... | |
I am having a file of around 4MB, the file is an ascii file containing normal keyboard characters only. I tried many classes in java.io package to read the file contents as string. Reading them character by character (using FileReader and BufferedReader) takes
approximately 40 seconds, reading the content using java.nio package (FileChannel and ByteBuffer) takes approximately 25 seconds. This is from my knowledge a little bit greater
amount of time. Does someone knows any way to reduce this time consumption to somewhat
around 10 seconds? Even solutions like creating file reader using C and calling from java will do. I used the | [
0.16319461166858673,
-0.0653919205069542,
0.41338109970092773,
-0.005628171376883984,
-0.03924134373664856,
0.09509307146072388,
0.12303923815488815,
-0.29568034410476685,
0.011451713740825653,
-0.8745531439781189,
-0.017422256991267204,
0.5311959385871887,
0.16234518587589264,
-0.05075288... | |
below snippet to read the 4 MB file in 22 seconds-
```
public static String getContents(File file) {
try {
if (!file.exists() && !file.isFile()) {
return null;
}
FileInputStream in = new FileInputStream(file);
FileChannel ch = in.getChannel();
ByteBuffer buf = ByteBuffer.allocateDirect(512); | [
0.09820955991744995,
-0.35232242941856384,
0.9785684943199158,
-0.23303741216659546,
0.09402147680521011,
0.16576117277145386,
0.4143791198730469,
-0.3051793575286865,
-0.2317829579114914,
-0.7679901719093323,
-0.2638060450553894,
0.5109454989433289,
-0.11341847479343414,
0.177175402641296... | |
Charset cs = Charset.forName("ASCII");
StringBuilder sb = new StringBuilder();
int rd;
while ((rd = ch.read(buf)) != -1) {
buf.rewind();
CharBuffer chbuf = cs.decode(buf);
for (int i = 0; i | [
0.024569164961576462,
0.012234723195433617,
0.5504430532455444,
-0.5736584067344666,
0.0027906238101422787,
0.4186963438987732,
0.6217253804206848,
-0.7131227850914001,
-0.2538699209690094,
-0.44615375995635986,
-0.4609118402004242,
0.2920706272125244,
-0.42355379462242126,
0.1647699773311... | |
< chbuf.length(); i++) {
sb.append(chbuf.get());
}
buf.clear();
}
String contents = sb.toString();
System.out.println("File Contents:\n"+contents);
return contents;
} catch (Exception exception) {
System.out.println("Error:\n" + exception.getMessage()); | [
-0.09059572964906693,
-0.019052226096391678,
0.44784316420555115,
-0.6887089610099792,
0.09031794965267181,
0.16981826722621918,
0.5721952319145203,
-0.5996509790420532,
-0.2604037821292877,
-0.40366658568382263,
-0.5142636299133301,
0.22784197330474854,
-0.5720894932746887,
0.274833709001... | |
return null;
}
}
```
I can't imagine what your hardware could be but it should take less than 0.1 seconds for a 4 MB file.
A fast way to read the file all at once is to read it into a byte[]
```
public static String readFileAsString(File file) {
try {
DataInputStream in = new DataInputStream(FileInputStream(file));
byte[] bytes = new byte[(int) file.length()];
in.readFully(bytes);
in.close(); | [
0.2938000559806824,
-0.1128232404589653,
0.6537925601005554,
-0.15665273368358612,
0.39842990040779114,
-0.04502324387431145,
0.16158130764961243,
-0.31126317381858826,
-0.042983636260032654,
-0.8242471814155579,
-0.2535918056964874,
0.6406546235084534,
-0.32928594946861267,
0.194406434893... | |
return new String(bytes, 0); // ASCII text only.
} catch (FileNotFoundException e) {
return null;
} catch (IOException e) {
System.out.println("Error:\n" + e.getMessage());
return null;
}
}
public static void main(String... args) throws IOException {
File tmp = File.createTempFile("deleteme", "txt");
tmp.deleteOnExit();
byte[] bytes = new byte[4 * 1024 * 1024];
Arrays.fill(bytes, (byte) 'a'); | [
-0.08586530387401581,
-0.23046496510505676,
0.35154998302459717,
-0.3132971227169037,
0.16286857426166534,
0.3919476568698883,
0.2873598635196686,
-0.15256692469120026,
-0.19961272180080414,
-0.5416424870491028,
-0.49809756875038147,
0.6388641595840454,
-0.5545552372932434,
0.1999891996383... | |
FileOutputStream fos = new FileOutputStream(tmp);
fos.write(bytes);
fos.close();
long start = System.nanoTime();
String s = readFileAsString(tmp);
long time = System.nanoTime() - start;
System.out.printf("Took %.3f seconds to read a file with %,d bytes%n",
time / 1e9, s.length());
}
```
prints
```
Took 0.026 seconds to read a file with 4,194,304 bytes
```
If you want to read the file even faster, I suggest using a memory mapped file as it will take less than 10 milli-seconds, but that | [
0.08448002487421036,
-0.33579757809638977,
0.7654011845588684,
-0.09437867254018784,
0.26679426431655884,
-0.00667787017300725,
0.19782252609729767,
-0.3243142068386078,
-0.3629119396209717,
-0.8473923206329346,
-0.03666633740067482,
0.4715897738933563,
-0.1659383922815323,
0.0909794643521... | |
is over kill in this case. | [
0.4001633822917938,
-0.060556069016456604,
0.4533723294734955,
-0.05504492670297623,
0.18306612968444824,
-0.2384120374917984,
0.20143498480319977,
0.00019806050113402307,
0.18831400573253632,
-0.4948563873767853,
-0.06145598739385605,
0.621171772480011,
0.16534404456615448,
-0.04494266957... | |
At the moment I have a module which can upload a file, extract it, reads some files and stores it in a database. Since I’m just a PHP developer and not a Drupal developer I’m not common with Content Types , Views and other Drupal stuff. I just want to display some things from the database to multiple pages and edit some things (not everything).
Doing it in PHP would be as easy as putting a brief in an envelope, but in Drupal it’s like you are putting a wheelchair in that envelope.
Do I have to define a content type | [
0.4656679332256317,
0.21181455254554749,
0.19399133324623108,
0.10703829675912857,
-0.3433353900909424,
-0.3622424006462097,
0.12074968218803406,
-0.008718692697584629,
-0.265091210603714,
-0.7275736331939697,
0.22655612230300903,
0.41327977180480957,
-0.18752257525920868,
0.16854664683341... | |
for it?
**Is it easy if I don’t use content types and having permissions controlled manually?**
Supposing that I have to define a content type. My database has 5 tables. Should I define 5 different content types?
You don't have to do it the Drupal way, if you need some Drupal things to work on you data too. I also have developed a module. It accesses a database, displays data from it, then an authorized user can update data and my module will save it. But these will not be nodes. Unless you need (for example) some hooks that run on nodes to | [
0.5116986632347107,
0.10555918514728546,
0.36490970849990845,
0.13091212511062622,
0.07760664820671082,
0.10326772928237915,
0.08840944617986679,
-0.2634246349334717,
-0.5311858654022217,
-0.48569104075431824,
0.01209848653525114,
0.4567164480686188,
-0.36616846919059753,
0.035151779651641... | |
run on your content, just use your PHP knowledge to create the content for the page.
You use hook\_menu to define the paths that will display your pages. For example in my code (detail\_pages module) the queries get two parameters in the path like example.com/strain/3/4, I define it like as follows, and I used php calls to database in my detail\_page($arg1, $arg2) function definition.
```
function detail_pages_menu() {
$items = array();
$items['strain/%/%'] = array(
'title' => t('Strain Detail Page'),
//'page callback' => 'strain_form',
'page callback' => | [
0.6963146328926086,
-0.1575072556734085,
0.5902141332626343,
0.0006495851557701826,
-0.13884001970291138,
0.08398846536874771,
0.3728402853012085,
-0.3642568290233612,
-0.13477320969104767,
-0.8005188703536987,
0.1472155600786209,
0.7341785430908203,
-0.25070980191230774,
-0.11233973503112... | |
'detail_page',//'drupal_get_form',
//'page arguments' => array('strain_detail_form'),
'page arguments' => array(1,2),
'access callback' => TRUE,
'access arguments' => array('access content'),
'description' => t('Detail Page'),
'type' => MENU_NORMAL_ITEM,
);
....
```
To answer your specific questions
> Do I have to define a content type for it?
No. You can use page render array, or even add direct html to pages in PHP.
> Is it easy if I don’t use content types and having permissions controlled manually?
Yes. | [
0.2843337059020996,
-0.07349830865859985,
0.6371262073516846,
0.20210637152194977,
-0.1423853188753128,
0.1945222169160843,
0.023678194731473923,
-0.5464193820953369,
0.0090386513620615,
-0.6183397173881531,
-0.17062276601791382,
0.7945060133934021,
-0.16065353155136108,
-0.215603455901145... | |
In the above example I wrote, this line is for permissions:
'access callback' => TRUE
this allows everybody to view. You can assign a function in place of TRUE, to return a boolean to represent if user it authorized to view that page.
> Supposing that I have to define a content type. My database has 5 tables. Should I define 5 different content types?
Especially if you need a nice database structure, you may want to avoid using nodes and defining content types. Drupal creates a table for what would be a column logically keyed by node ID. So you have many unnecessary | [
0.10875378549098969,
0.18054147064685822,
0.7437499761581421,
0.185360848903656,
-0.0638798177242279,
-0.2959437370300293,
0.31173503398895264,
-0.09142109006643295,
-0.37134018540382385,
-0.54510498046875,
0.07288553565740585,
0.415408194065094,
-0.2815665900707245,
0.3752083480358124,
... | |
tables... | [
-0.2287483662366867,
0.4625919461250305,
0.34853821992874146,
0.02980678901076317,
0.12979505956172943,
0.0065692756325006485,
-0.26602742075920105,
0.27751463651657104,
-0.6703564524650574,
-0.9017319679260254,
0.1060810536146164,
0.07021963596343994,
0.0602155402302742,
0.059782609343528... | |
I am designing a website that, just like [Reddit](http://www.reddit.com), has many filters for the front page such as 'new', 'top', 'historic', 'active'...
If you were to click on the filter 'new', our url would change from
```
www.mywebsite.com/main/
```
to
```
www.mywebsite.com/main/new
```
and the data displayed would change it's order in order to show the "newest" content.
However, I have heard that for SEO purposes, the more links you have pointing to your website the better, I thought it could be a good idea to keep the URI the same way even after you click on a filter, so you would click on 'new' and the URI would | [
0.8551400899887085,
0.04660392180085182,
0.4999546706676483,
-0.08807774633169174,
-0.11015873402357101,
-0.2877527177333832,
-0.016177164390683174,
0.30697301030158997,
-0.2797650992870331,
-0.7444941401481628,
0.08342094719409943,
0.19532567262649536,
-0.1858711689710617,
0.4542047679424... | |
still show
```
www.mywebsite.com/main/
```
Doing this, if 4 people share my website, it will be better shown on google right?
Because google will see this (even if they copy paste the URI while viewing a filter) and all 4 links are the same.
```
www.mywebsite.com/main/
www.mywebsite.com/main/
www.mywebsite.com/main/
www.mywebsite.com/main/
```
While if I don't do this people may share the 4 links like this
```
www.mywebsite.com/main/new
www.mywebsite.com/main/active
www.mywebsite.com/main/top
www.mywebsite.com/main/
```
and Google would think of them as different links thus giving less 'reputation' to my main page and spreading it through the different filters.
Well i found the answer myself. I had tried it before, but I thought it did not work.
```
diff -srq dir1/ dir2/ | grep identical
```
What | [
0.6868733167648315,
0.3378126621246338,
0.7034154534339905,
-0.11488258838653564,
-0.22069033980369568,
0.0360434353351593,
0.3126612901687622,
-0.0513167530298233,
-0.3918439447879791,
-0.48307111859321594,
0.21464507281780243,
0.2465493083000183,
-0.35142606496810913,
0.4150735139846802,... | |
**-srq** means? From **diff --help** :
```
-s --report-identical-files Report when two files are the same.
-r --recursive Recursively compare any subdirectories found.
-q --brief Output only whether files differ.
``` | [
0.002632367191836238,
0.16026940941810608,
0.39127689599990845,
-0.060395825654268265,
-0.16744719445705414,
0.04109364002943039,
0.31702399253845215,
-0.1378173530101776,
-0.09406266361474991,
-0.4922369122505188,
-0.5231410264968872,
0.3998854458332062,
-0.21599465608596802,
-0.023988706... | |
suppose i have div like
```
<div id='main'>
<div id='child'>my static content</div>
</div>
$('#main').append("<div class='mycontent'>I'm new box by append</div>");
or
$('#main').appendTo("<div class='mycontent'>I'm new box by append</div>");
```
i know i can use **append() and appendTo** method to insert anything into main div. but i need to know that how can i insert content into main div before child div. content will be pushed into main div before child div. please help me with concept.
thanks
<http://api.jquery.com/before/>
if you want it before the last child div:
```
$("#main > div:last-child").before("<div class='mycontent'>I'm new box by append</div>");
```
or if you want it before a specific div:
```
$("#child").before("<div class='mycontent'>I'm new box by append</div>");
``` | [
-0.07713950425386429,
-0.08676743507385254,
0.3413005769252777,
-0.04330454766750336,
0.1849363148212433,
0.2468971312046051,
-0.08950113505125046,
-0.21714532375335693,
0.04910585656762123,
-0.803488552570343,
-0.26790809631347656,
0.20155838131904602,
-0.003058365313336253,
0.26268711686... | |
I have an activity that starts after a certain time. Once this activity starts, the user is supposed to press a button that starts a new timer.
However, if the user does not press the button I want a toast to be displayed every 5 minutes until the button is pressed.
I have a listener for the button:
```
startBreakButton = (Button) findViewById(R.id.startBreakButton);
startBreakButton.setOnClickListener(mStartListener);
```
I have the code for displaying the toast and everything else is working well.
I'm just not sure where to put the code I want to run before the button is clicked. Within the | [
0.4464912712574005,
0.3050553500652313,
0.7363442182540894,
-0.4453110694885254,
-0.03797711431980133,
-0.30349093675613403,
0.6707242131233215,
0.03366140276193619,
-0.25386252999305725,
-1.0078531503677368,
-0.04989386722445488,
0.5792225003242493,
-0.0035165443550795317,
0.0564169883728... | |
mStartListener code or somewhere else such as within the onCreate method?
**UPDATE**
```
public class BreakActivity extends Activity {
Button startBreakButton; // button to start the break timer
Boolean clicked= false;
CountDownTimer counter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.breakscreen); // sets layout to breakscreen.xml
MyCount counter;
counter=new MyCount(5000,1000);
counter.start();
startBreakButton = (Button) findViewById(R.id.startBreakButton);
startBreakButton.setOnClickListener(mStartListener);
View.OnClickListener mStartListener = new OnClickListener() {
clicked=true;
//other listener code
};
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval); | [
0.16785117983818054,
-0.4087093472480774,
1.060701608657837,
-0.2281404286623001,
0.18837222456932068,
0.28941646218299866,
0.513450562953949,
-0.6699777841567993,
-0.2651333510875702,
-0.39157772064208984,
-0.5278822183609009,
0.6137816309928894,
-0.2320164144039154,
0.012779059819877148,... | |
}
@Override
public void onFinish() {
if(clicked==false){
Toast.makeText(getApplicationContext(), "TAKE A BREAK", Toast.LENGTH_LONG).show();
counter= new MyCount(5000,1000);
counter.start();
}
}
@Override
public void onTick(long millisUntilFinished) {
long s1 = millisUntilFinished;
}
}
};
```
EDIT - Above solution is not | [
0.4276343584060669,
-0.010297655127942562,
0.6883460283279419,
-0.27221760153770447,
0.21928192675113678,
-0.1615852266550064,
0.5406695604324341,
-0.33531466126441956,
-0.30145904421806335,
-0.533816397190094,
-0.38204899430274963,
0.5029832720756531,
-0.10209484398365021,
0.4813852608203... | |
working, it needed to be clicked==false, not clicked=false!!
Try like this..
in oncreate create a acountdowntimer..
```
MyCount counter;
counter=new MyCount(300000,1000);
counter.start();
```
MyCount class..
```
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
if(clicked=false){
//put the toast here
counter= new MyCount(300000,1000);
counter.start();
}
}
@Override
public void onTick(long millisUntilFinished) {
s1=millisUntilFinished;
}
}
}
```
and in onclicklistener of startBreakButton put
```
clicked=true;
``` | [
0.2998867332935333,
-0.07555020600557327,
0.8992440104484558,
-0.2466803342103958,
0.014938496984541416,
0.31211206316947937,
0.30252206325531006,
-0.3439718186855316,
-0.3133646249771118,
-0.4376204311847687,
-0.14445482194423676,
0.6799002885818481,
-0.03893956169486046,
0.37465927004814... | |
Currently I'm logging into my account. After proceeding some of the pages I have log-out my account. Now if I go back page using **back** button in browser, still I'm in login state. Is there anyway to set this status as logout?
The problem with browsers is that using the back button doesn't refresh the page to any data form a server or force the browser to run any loading JavaScript functions.
What you could do is have a JavaScript function set on a time-out to check if they are logged in every 10 seconds using AJAX.
I wouldn't bother though as | [
0.4111093580722809,
0.23059937357902527,
0.5911343097686768,
-0.16974881291389465,
-0.06451338529586792,
-0.06823482364416122,
0.5073337554931641,
0.6395125985145569,
-0.49729040265083313,
-0.8349355459213257,
0.20196610689163208,
0.38310709595680237,
0.11148123443126678,
0.296680063009262... | |
you are adding additional server load for no real benefit, as when the user refreshes the page or clicks on a link they would still be logged out and wouldn't be able to perform any logged in actions. | [
0.38079866766929626,
-0.038941916078329086,
0.32026833295822144,
0.19398818910121918,
-0.1287461668252945,
-0.3277698755264282,
0.3370493948459625,
0.19401592016220093,
-0.5173090100288391,
-0.5908186435699463,
-0.08982478082180023,
0.2831157147884369,
-0.20430491864681244,
0.1436530500650... | |
This is my try at creating a registration page however after the for loop whatever follows does not execute and I'm at a loss as to why?
Below is the javascript code and the form
```
<script type='text/javascript'>
myArray = ['username','email','password','password2'];
reply = ['User Name','Email','Password','Password Again'];
message = "Please Type you're ";
start = "<font color = red size='-1'>";
end = "</font>";
test = 10;
obj = validate();
alert (obj);
function validate(){
for (var i=0; i<=myArray.length; i++) {
if (document.getElementById("in"+myArray[i]).value == "")
{ | [
0.0330171212553978,
0.08476321399211884,
0.7892242670059204,
-0.20867972075939178,
-0.026834998279809952,
0.0735405758023262,
0.4825989603996277,
-0.5389907956123352,
0.045498114079236984,
-0.7237361669540405,
-0.22561953961849213,
0.24154743552207947,
-0.27344146370887756,
-0.102489478886... | |
document.getElementById(myArray[i]).innerHTML = start+message+reply[i]+end;
test = 30;
}
}
alert ("test");
}
```
```
<form action="echo.php" method="post" name="register" onsubmit="return validate();">
<table>
<tr>
<td width="185"><font size="2">First Name</font></td>
<td width="499"> | [
0.08759091049432755,
-0.2829653322696686,
0.7952027916908264,
0.005561653058975935,
-0.17439204454421997,
-0.027564115822315216,
0.35391733050346375,
-0.6204260587692261,
-0.14706917107105255,
-0.5420622229576111,
-0.39372819662094116,
0.33850812911987305,
-0.28215086460113525,
0.103731550... | |
<input id = "infirst_name" name="first_name" type="text" /><div id="first_name"></div></td>
</tr>
<tr>
<td><font size="2">Last Name</font></td>
<td><input id = "inlast_name" name="last_name" type="text" /><div id="last_name"></font></div></td>
</tr>
<tr>
<td><font size="2">Username*</font></td>
<td>
<input id = "inusername" name="username" type="text" /><div id="username"></div></td>
</tr>
<tr>
<td><font size="2">Email*</font></td>
<td><input id = | [
-0.7080287933349609,
0.010333076119422913,
0.24829767644405365,
-0.25768446922302246,
-0.016091154888272285,
0.3500838875770569,
0.12578661739826202,
-0.12042659521102905,
-0.050455834716558456,
-0.811342716217041,
-0.2505325973033905,
0.6601837873458862,
0.14560936391353607,
0.11404624581... | |
"inemail" name="email" type="text" /><div id="email"></div></td>
</tr>
<tr>
<td><font size="2">Password*</font></td>
<td><input id = "inpassword" name="password" type="password" /><div id="password"></div></td>
</tr>
<tr>
<td><font size="2">Repeat Password*</font></td>
<td>
<input id = "inpassword2" name="password2" type="password" /><div id="password2"></div></td>
</tr>
<tr>
<tr>
<td><font size="2">I have read and Agree to the Terms and Conditions</font></td> | [
-0.34824231266975403,
0.19960331916809082,
0.2939566373825073,
-0.020966295152902603,
-0.11751193553209305,
-0.09610716998577118,
0.44734278321266174,
-0.7550897002220154,
0.49748334288597107,
-0.7666066884994507,
0.0021288737189024687,
0.6361547112464905,
-0.17350097000598907,
-0.22120714... | |
<td>
<input id = "incheckme" name="checkme" type="checkbox" /><div id="checkme"></div></td>
</tr>
<tr>
<td><input type="submit" value="Register" /></td>
<td> </td>
</tr>
</table>
</form>
```
Try fixing your loop:
```
for (var i=0; i < myArray.length; i++) {
```
JavaScript will stop executing anything if it encounters an uncaught error. In your case it seems that you've looped past the last element (and tried to set innerHTML on an undefined object). | [
0.19763855636119843,
-0.2722858190536499,
0.16064263880252838,
-0.08485832065343857,
-0.189657524228096,
-0.12648344039916992,
0.636242151260376,
-0.49190905690193176,
-0.17934519052505493,
-0.28438618779182434,
-0.14335496723651886,
0.14674945175647736,
-0.5268084406852722,
0.061490427702... | |
i have 3 rows on "Services" table:
```
ID | name | ObrID
0 | A | 1
1 | B | 2
2 | C | -1
```
-1 is a none existing Obr, the service 2 doesn't contains any Obr or it was deleted.
if i fetch with `select * from Services`, it works as expected, but if i do my search sql:
```
select
*,
(select Name from Obrs where ID=ObrID) as ObrName
from
Services
where
(select Name from Obrs where | [
-0.3670528531074524,
0.33279988169670105,
0.5783175826072693,
-0.34693560004234314,
0.023792210966348648,
0.5972298383712769,
0.3619767427444458,
-0.26259228587150574,
-0.23357167840003967,
-0.7103984951972961,
-0.07005751132965088,
0.3411620259284973,
-0.3857541084289551,
0.34020578861236... | |
ID=ObrID) like '%SEARCH_STRING%'
```
it doesn't return the last line. Is there any way so it return something like:
```
ID | name | ObrID | ObrName
0 | A | 1 | ObrA
1 | B | 2 | ObrB
3 | C | -1 | NULL
```
You want to use left join.
[http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php](http://left%20join%20tutorial)
```
SELECT s.*,o.ObrName from Services s
LEFT JOIN Obrs o ON ID=ObrID
WHERE OrbName LIKE '%$SEARCH_STRING%' OR OrbName IS NULL
```
or:
```
SELECT * | [
-0.5072636008262634,
0.06035485863685608,
0.6198385953903198,
-0.2512175440788269,
-0.19194087386131287,
0.28893935680389404,
0.3672929108142853,
0.02027132920920849,
-0.04985636845231056,
-0.5618128180503845,
-0.2725132405757904,
0.24603869020938873,
-0.626076340675354,
0.2325932234525680... | |
FROM (select s.*,o.ObrName from Services s
LEFT JOIN Obrs o ON ID=ObrID) tmp
WHERE OrbName LIKE '%$SEARCH_STRING%' OR OrbName IS NULL
``` | [
-0.4426320195198059,
-0.11212093383073807,
0.4861798584461212,
-0.18431101739406586,
0.0889337882399559,
0.43766361474990845,
0.15700063109397888,
0.22692516446113586,
-0.1980844885110855,
-0.6504446268081665,
-0.46520209312438965,
0.3726179897785187,
-0.5055103898048401,
0.220554813742637... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.