text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
supplied `grade` is in your range, so just don`t refer to the instance variable`\_Grade`:
```
public static bool ValidateGrade(string grade)
{
return (grade == "N" || grade == "P" ...)
}
``` | [
0.15465866029262543,
0.3325537145137787,
0.10437584668397903,
-0.21607981622219086,
0.10610540956258774,
-0.17125581204891205,
0.12014025449752808,
-0.06602577865123749,
0.43810921907424927,
-0.19440659880638123,
-0.2758695185184479,
0.7732776403427124,
-0.04957341030240059,
0.352396726608... | |
I have to method in model of my asp.net mvc project.
```
public JsonResult GetProductsByDepList(string depID)
{
JsonResult jr = new JsonResult();
var _product = from a in DataContext.GetProductsByDep(Convert.ToInt32(depID))
select new { ID = a.ID, ProName = a.Name };
jr.Data = _product.ToList();
jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
return jr;
}
public JsonResult GetProductByCatList(string depID, string catID)
{
JsonResult jr = new JsonResult();
var _product = from a in
DataContext.GetProductsByCat(Convert.ToInt32(depID),Convert.ToInt32(catID))
select new { ID = a.ID, ProName = a.Name };
jr.Data = _product.ToList();
jr.JsonRequestBehavior | [
-0.20028997957706451,
-0.09698310494422913,
0.7275840044021606,
-0.44763147830963135,
0.18034489452838898,
0.3270009160041809,
0.6908893585205078,
-0.7557169198989868,
-0.012264878489077091,
-0.7167224884033203,
-0.4210182726383209,
0.335917204618454,
-0.19425663352012634,
0.41872370243072... | |
= JsonRequestBehavior.AllowGet;
return jr;
}
```
I want to combine these 2 method, it is work the same each other, except the parameter of the function.
Any ideas please.
Use an [optional argument](http://msdn.microsoft.com/en-us/library/dd264739.aspx):
```
public JsonResult GetProductByCatList(string depID, string catID = "0")
``` | [
-0.0699765607714653,
-0.34700077772140503,
0.37745022773742676,
-0.2029666304588318,
0.26070544123649597,
-0.028131265193223953,
0.343018501996994,
-0.10825490951538086,
-0.19550475478172302,
-0.6054267287254333,
-0.5387372970581055,
0.6962800621986389,
-0.408829003572464,
-0.0631341189146... | |
I would like to know whats wrong with following JavaScript code -
```
<html>
<script type="text/javascript">
var p = eval('new { "Color":"Red"}');
alert(p.Color);
</script>
</html>
```
It is giving me JavaScript error as -
```
Message: Object doesn't support this action
Line: 4
Char: 1
Code: 0
```
There are several problems with the code;
firstly you're telling the script to create something new, but you're not telling it *what* to create. If you aren't creating a custom object, you are creating an Object object, so you need to tell it that:
```
var p = eval('new Object()');
```
Now that you are creating a new Object object, you can configure the Color property:
```
var p = eval('new Object({"Color":"Red"})');
```
[Here is a working | [
0.32557937502861023,
0.029677025973796844,
0.27206069231033325,
-0.13061724603176117,
-0.0076258364133536816,
0.15723125636577606,
0.492814838886261,
-0.4510956406593323,
-0.19704914093017578,
-0.6171600818634033,
-0.11489640176296234,
0.5719586610794067,
-0.42792657017707825,
0.0370988920... | |
fiddle](http://jsfiddle.net/7Dcr2/)
But, why are you using eval in the first place? [eval is evil](http://javascript.crockford.com/code.html)! | [
0.15336719155311584,
0.17441144585609436,
0.15275128185749054,
-0.2403106391429901,
-0.29198044538497925,
-0.07950852066278458,
0.7739700078964233,
-0.616993248462677,
-0.617002546787262,
0.031222842633724213,
0.2925460636615753,
0.3719932436943054,
-0.39714518189430237,
-0.109040603041648... | |
I got the same problem with the questions here : [Tomcat started in eclipse but unable to connect to link to http://localhost:8085/](https://stackoverflow.com/questions/2280064/tomcat-started-in-eclipse-but-unable-to-connect-to-link-to-http-localhost8085), that means I can't open <http://localhost:8080/> at the browser :
```
HTTP Status 404 - /
type Status report
message /
description The requested resource (/) is not available.
Apache Tomcat/7.0.27
//Console info when tomcat started//
Apr 10, 2012 4:26:32 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to org.eclipse.jst.jee.server:SimpleServletProject' did not find a matching property.
Apr 10, 2012 4:26:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 10, 2012 4:26:33 PM | [
0.010179311968386173,
0.1756163239479065,
0.6249890327453613,
0.09108512103557587,
-0.25260743498802185,
-0.3425494432449341,
0.41221320629119873,
-0.4514857828617096,
-0.12317618727684021,
-0.4523269832134247,
-0.12800663709640503,
0.6877759695053101,
-0.006925459485501051,
-0.02888728864... | |
org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 10, 2012 4:26:33 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 880 ms
Apr 10, 2012 4:26:33 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 10, 2012 4:26:33 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Apr 10, 2012 4:26:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 10, 2012 4:26:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 10, 2012 4:26:33 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 495 ms
```
I'm using Tomcat 7.0.27, Eclipse Europa and Java 1.6.0\_32. I saw BalusC's answer, but the problem is that I couldn't select Tomcat installation (the picture below).
What could be wrong here?

EDIT1 : When I | [
-0.1597733348608017,
0.2085861712694168,
0.4062969982624054,
0.1897502839565277,
-0.04903160035610199,
0.020191393792629242,
0.08955793082714081,
-0.5075269341468811,
-0.1973605901002884,
-0.30561503767967224,
-0.10294093191623688,
0.4425196349620819,
0.3187287151813507,
-0.280329972505569... | |
tried to create demo webpage, it couldn't be opened too (with the same error).
EDIT2: Followed this thread [Why tomcat server location property is greyed in Eclipse](https://stackoverflow.com/questions/4919846/why-tomcat-server-location-property-is-greyed-in-eclipse) I can open <http://localhost:8080/> in the browser, but still cant access the demo web page..
```
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>SimpleServletProject</display-name>
<welcome-file-list>
<welcome-file> index.html</welcome-file>
</welcome-file-list>
</web-app>
```
PS : It seems that there's no more space to me to post index.hmtl (it's just a normal html | [
0.0963069424033165,
0.32876354455947876,
0.42873457074165344,
-0.24416068196296692,
-0.11971502006053925,
-0.12764038145542145,
0.19287854433059692,
-0.20400024950504303,
-0.5324995517730713,
-0.6152516603469849,
-0.19394832849502563,
0.6365277767181396,
-0.089442677795887,
-0.067027114331... | |
)..
You want to access the root application (http://server:port/) but I'm quite sure that Eclipse wont install a root application. Try to access the application you deployed within the (eclipse managed) tomcat under <http://server:port/yourapp>. | [
0.2838471531867981,
-0.005731579847633839,
0.42111220955848694,
-0.03389226272702217,
-0.14786460995674133,
-0.07815013825893402,
0.3506591022014618,
0.3853937089443207,
-0.40943682193756104,
-0.37307530641555786,
-0.2159913182258606,
0.6772863268852234,
-0.12174487113952637,
0.35591700673... | |
I am designing a web-service using java and eclipse which returns the user details who are marked as customer in the database
I was successfully able to return details for a single user (as there was only one entry in the dB) with the following code:
```
public class GetData {
public LoginDetails getDetails(){
Connection conn;
Statement stmt;
ResultSet rs;
try {
LoginDetails lds=new LoginDetails();
Class.forName(driver);
conn=DriverManager.getConnection(url,username,password); | [
0.23713378608226776,
-0.10245049744844437,
0.455697625875473,
-0.09655562043190002,
-0.08955693989992142,
0.18216709792613983,
0.46686533093452454,
-0.44521364569664,
-0.037347692996263504,
-0.5090379118919373,
-0.15250730514526367,
0.5108824372291565,
-0.2231123000383377,
0.23856177926063... | |
stmt=conn.createStatement();
String sql="select * from login where usertype='customer'";
rs=stmt.executeQuery(sql);
while(rs.next()){
lds.setUsername(rs.getString(1));
lds.setPassword(rs.getString(2));
lds.setUsertype(rs.getString(3));
lds.setActive(rs.getString(4));
} | [
0.3691234290599823,
-0.11485932022333145,
0.8330523371696472,
-0.37419241666793823,
-0.02674245461821556,
0.09661905467510223,
0.5593466758728027,
-0.48685017228126526,
-0.13638117909431458,
-0.35162773728370667,
-0.13724255561828613,
0.49847328662872314,
-0.4988690912723541,
0.19772857427... | |
return lds;
}
catch(ClassNotFoundException c){
c.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
```
What should I do if there are multiple values in dB matching the criteria and I want to display them all. Please advice.
Change your method signature to `public LoginDetails[] getDetails()`
And extend your while loop as follows:
```
Collection<LoginDetails> details = new ArrayList<LoginDetails>();
while(rs.next()){ | [
0.4117802679538727,
-0.11665431410074234,
0.2991293966770172,
-0.17910967767238617,
0.10800951719284058,
-0.013307526707649231,
0.40561506152153015,
-0.699261486530304,
-0.09693613648414612,
-0.36965909600257874,
0.032391730695962906,
0.5244007110595703,
-0.28207477927207947,
0.10609370470... | |
LoginDetails lds=new LoginDetails();
lds.setUsername(rs.getString(1));
lds.setPassword(rs.getString(2));
lds.setUsertype(rs.getString(3));
lds.setActive(rs.getString(4));
details.add(lds);
}
return details.toArray(new LoginDetails[0]);
``` | [
0.169332355260849,
-0.030942577868700027,
0.8228721618652344,
0.007379296235740185,
0.07978174835443497,
0.00043876434210687876,
0.5883713960647583,
-0.5777032375335693,
-0.31635957956314087,
-0.6738059520721436,
-0.3544313311576843,
0.6063570380210876,
-0.3972770571708679,
0.2614897787570... | |
I've built a C application, and when I build it, it shows no errors, but when I run it, it gives me the error "Segmentation Fault: 11".
If it helps, here is the code I am using:
```
#include <stdio.h>
int main(char *argv[]) {
printf("The project path is: ./Projects/%c", argv[1]);
return 0;
}
```
You have a number of problems:
* The signature for `main` is an argument count followed by an array of C strings.
* You should always check the count before using the array.
* The array is of strings so you need `%s` to print them.
This should work:
```
#include <stdio.h>
int main(int argc, char *argv[]) {
if | [
0.16206598281860352,
0.22362543642520905,
0.0059624710120260715,
-0.3425598442554474,
0.08373915404081345,
-0.012578709982335567,
0.3232994079589844,
-0.16356664896011353,
-0.19127888977527618,
-0.43008172512054443,
-0.051338955760002136,
0.615525484085083,
-0.4136587977409363,
-0.00608289... | |
(argc < 2)
fprintf (stderr, "Wrong number of arguments\n");
else
printf ("The project path is: ./Projects/%s\n", argv[1]);
return 0;
}
``` | [
-0.08975528925657272,
0.09866214543581009,
0.16371197998523712,
-0.28957587480545044,
0.24498745799064636,
0.05397988110780716,
0.20615307986736298,
-0.05888940766453743,
-0.11508557945489883,
-0.22712618112564087,
-0.40870609879493713,
0.6753115653991699,
-0.41386616230010986,
0.059911411... | |
Our project has two different git repositories A and B. Both A and B are multi module projects. B's code is finally built as a eclipse product using maven parent pom. B requires a component/ feature from A which needs to be included in the eclipse product. How can I achieve this functionality. Do I need to publish the results of A's build to a webserver, so that B can access it as a repository? or can I include A as dependency to B's build so that B can package this component in the final product? Where/ how can I | [
0.8227868676185608,
0.18018309772014618,
0.08809026330709457,
-0.006534793879836798,
-0.05755196511745453,
-0.13797545433044434,
0.2207007110118866,
-0.2965186834335327,
0.04580393806099892,
-0.546076774597168,
-0.06576001644134521,
0.22815784811973572,
-0.057521045207977295,
0.02032579109... | |
specify this configuration?
Let me know if any other information is required.
Thanks in Advance!
There are 2 causes to why this doesn't work:
1. The svg is empty.
Even though you gave it a height and width, I believe that some browsers don't assign it a real size until you actuall add a shape to it. You can get around this by placing an empty rect there:
`<rect x="0" y="0" width="300" height="300" stroke="black" stroke-width="0" fill="none"></rect>`
2. Because of the `pointer-events` property. You can read more [here](http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty). By default, it's value is `visiblePainted`, so I really don't know why Chrome and FF allow the events | [
0.08212557435035706,
-0.25535622239112854,
0.6159164905548096,
0.0015841887798160315,
0.04410144314169884,
-0.1327660083770752,
0.014753688126802444,
-0.03669007867574692,
-0.3095862865447998,
-0.7651329636573792,
0.14704428613185883,
0.5758165121078491,
-0.2964104413986206,
0.003145462367... | |
to get through. You need to set this to `"all"`
Also be carefull at the html, it's badly fromatted.
### Fix:
<http://jsfiddle.net/mihaifm/ptLrB/2/> | [
0.16750304400920868,
-0.22074371576309204,
0.5325227975845337,
-0.035920944064855576,
-0.0717579647898674,
-0.20290417969226837,
0.7802717685699463,
-0.10974238812923431,
-0.2879415452480316,
-0.5611658692359924,
-0.2603980600833893,
0.4366816580295563,
-0.36755257844924927,
-0.03530705720... | |
This is my first time around, so i would appreciate your patience with what might appear as a lame looking question :)
I'm trying to write a function called `do_n` that takes a function object and a number, `n`, as arguments and then call the given function `n` times. Here's the code:
```
def name():
print 'Jack'
def do_n(fo, x):
if x <= 0:
return
print fo
(fo, x-1)
```
When making a function call from within main:
```
do_n(name, 3)
```
I get the following outcome:
```
<function name at 0x01F93AF0>
```
I'm trying | [
0.007559621706604958,
0.3707399368286133,
0.17325791716575623,
-0.5509238243103027,
0.2144041508436203,
0.02246464230120182,
0.2349148541688919,
-0.2839203476905823,
-0.16189371049404144,
-0.3312414586544037,
-0.21360301971435547,
0.65137779712677,
-0.49959421157836914,
0.00545721594244241... | |
to get the program to print out:
```
Jack
Jack
Jack
```
Many thanks in advance
You are neither calling the function, nor are you actually doing the recursive call. Corrected version:
```
def name():
print 'Jack'
def do_n(fo, x):
if x <= 0:
return
fo()
do_n(fo, x - 1)
```
To call a function `n` times, you'd usually use a for loop instead of tail recursion in Python:
```
for dummy in range(10):
name()
``` | [
0.3960089087486267,
0.0608217753469944,
0.1077197939157486,
-0.2944434881210327,
0.23102854192256927,
-0.2145852893590927,
0.3806217908859253,
-0.3472210168838501,
-0.2650318443775177,
-0.03441185876727104,
-0.3690309524536133,
0.7411134243011475,
-0.4799244701862335,
-0.07756249606609344,... | |
I'm trying to write up an example of testing query string parsing when I got stumped on a Unicode issue. In short, the letter "Omega" (Ω) doesn't seem to be decoded correctly.
* Unicode: U+2126
* 3-byte sequence: \xe2\x84\xa6
* URI encoded: %E2%84%A6
So I wrote this test program verify that I could "decode" unicode query strings with URI::Encode.
```
use strict; | [
0.08516537398099899,
0.22246360778808594,
0.11838603019714355,
-0.1998898983001709,
-0.15329258143901825,
-0.11885165423154831,
0.5725946426391602,
-0.24710232019424438,
0.19880780577659607,
-0.5004859566688538,
-0.1631191074848175,
0.4690254330635071,
-0.4558347165584564,
-0.0349796712398... | |
[
-1.06126070022583,
-0.7003979086875916,
-0.42257601022720337,
0.09815213829278946,
-0.49541836977005005,
1.143049955368042,
0.859436571598053,
1.0905910730361938,
-0.6481311917304993,
-0.4323035180568695,
0.5117040276527405,
-0.018845291808247566,
0.3492005467414856,
-0.2664911150932312,
... | ||
use warnings;
use utf8::all; # use before Test::Builder clones STDOUT, etc.
use URI::Encode 'uri_decode';
use Test::More;
sub parse_query_string {
my $query_string = shift;
my @pairs = split /[&;]/ => $query_string;
my %values_for;
foreach my $pair (@pairs) {
my ( $key, $value ) = split( /=/, $pair );
$_ = uri_decode($_) for $key, $value; | [
0.41391268372535706,
0.054385956376791,
-0.10772904008626938,
-0.5211508274078369,
0.16111506521701813,
0.20783425867557526,
0.6920692324638367,
-0.41267767548561096,
0.29853665828704834,
-0.7359269261360168,
-0.44000813364982605,
0.5190848708152771,
-0.622119128704071,
0.22651726007461548... | |
$values_for{$key} ||= [];
push @{ $values_for{$key} } => $value;
}
return \%values_for;
}
my $omega = "\N{U+2126}";
my $query = parse_query_string('alpha=%E2%84%A6');
is_deeply $query, { alpha => [$omega] }, 'Unicode should decode correctly';
diag $omega;
diag $query->{alpha}[0];
done_testing;
```
And the output of the test:
```
query.t ..
not ok 1 - Unicode should decode correctly
# Failed test 'Unicode should decode correctly'
# at query.t line 23.
# Structures begin differing at:
# $got->{alpha}[0] = 'â¦'
# $expected->{alpha}[0] | [
0.02344786375761032,
0.34850063920021057,
0.39701610803604126,
-0.2313196361064911,
-0.0032156200613826513,
0.06513813138008118,
0.41910308599472046,
-0.6986910700798035,
0.1948310285806656,
-0.4586140513420105,
-0.45107051730155945,
0.4433903396129608,
-0.1067061573266983,
0.1102237328886... | |
= 'Ω'
# Ω
# â¦
1..1
# Looks like you failed 1 test of 1.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
Test Summary Report
-------------------
query.t (Wstat: 256 Tests: 1 Failed: 1)
Failed test: 1
Non-zero exit status: 1
Files=1, Tests=1, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.05 cusr 0.00 csys = 0.09 CPU)
Result: FAIL
```
It looks to me like URI::Encode may be broken here, but switching to URI::Escape and using the uri\_unescape function reports the same error. What am I missing?
the URI encoded characters simply represents utf-8 sequences, and URI::Encode and URI::Escape simply | [
-0.17032195627689362,
0.3393060266971588,
0.1458318829536438,
-0.040469929575920105,
0.2907472848892212,
0.37664514780044556,
0.6131575703620911,
-0.41678375005722046,
0.02798798494040966,
-0.38074609637260437,
-0.2056027203798294,
0.2587830424308777,
-0.324880450963974,
0.3055248856544494... | |
decodes them into a utf-8 byte string, and neither of them decode the bytestrings as UTF-8 (which is a correct behavior as a generic URI decoding library).
Put it another way, your code basically does:
`is "\N{U+2126}", "\xe2\x84\xa6"` and that will fail, since upon comparison, perl upgrades the latter as a 3-character-length latin-1 strings.
You have to manually decode the input value with `Encode::decode_utf8` after `uri_decode`, or instead compare encoded utf8 byte sequence. | [
0.00505491578951478,
0.0837581679224968,
0.3629675805568695,
0.10144281387329102,
-0.009910402819514275,
-0.02053358405828476,
0.3256886601448059,
-0.14726421236991882,
-0.17504270374774933,
-0.40107816457748413,
-0.3040618598461151,
0.3768545985221863,
-0.37142130732536316,
0.256047576665... | |
I wrote some code using `ZipInputStream` but there is something wrong with it.
```
ZipInputStream zin=null;
zin=new ZipInputStream(new BufferedInputStream(
new FileInputStream("e:/testzip.zip")));
ZipEntry ze;
while((ze=zin.getNextEntry())!=null) {
System.out.println("readfile"+ze.getName());
int c=0;
while((c=zin.read())>0) {
System.out.write(c);
}
}
zin.close();
```
There are 3 text files in the `testzip.zip`. That is, the right output should be the three file names and their contents. However, my output are 3 file names and 2 of their contents. Why only 2 contents, rather than 3?
I made a zip with 3 textfiles | [
0.3985403776168823,
0.13899123668670654,
0.4377027153968811,
-0.12496764212846756,
0.09493677318096161,
0.20181506872177124,
0.657203197479248,
-0.5737093091011047,
0.1125035360455513,
-0.6985055208206177,
0.011478391475975513,
0.3133421242237091,
-0.4215863049030304,
0.20707891881465912,
... | |
in; the fact that they are textfiles is important for the following code to work. I read all entries and write out it's names and contents:
```
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class Main {
public static void main(String[] args) throws Exception {
ZipFile zipFile = new ZipFile("D:\\zip.zip");
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while(entries.hasMoreElements()) {
ZipEntry zipEntry = entries.nextElement(); | [
-0.17802217602729797,
0.035278718918561935,
0.4684847891330719,
-0.4262755215167999,
0.341955304145813,
0.24880747497081757,
0.13054916262626648,
-0.3533141314983368,
-0.21308504045009613,
-0.7561270594596863,
-0.5679038166999817,
0.18107466399669647,
-0.6179477572441101,
0.198705747723579... | |
System.out.println(zipEntry.getName());
BufferedReader bufferedeReader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry)));
String line = bufferedeReader.readLine();
while(line != null) {
System.out.println(line);
line = bufferedeReader.readLine();
} | [
-0.4600352346897125,
-0.6550881266593933,
0.6733962297439575,
-0.24665965139865875,
0.35907742381095886,
0.4992865324020386,
0.1797141283750534,
-0.13636186718940735,
-0.3800400197505951,
-0.6611238121986389,
-0.5326266884803772,
0.2692367434501648,
-0.509064257144928,
0.36700573563575745,... | |
bufferedeReader.close();
}
zipFile.close();
}
}
``` | [
-0.03756318241357803,
-0.11729613691568375,
0.4524238109588623,
-0.2991233170032501,
0.4175257682800293,
0.09212613105773926,
-0.016964372247457504,
0.13366129994392395,
-0.054467570036649704,
-0.5773991346359253,
-0.4261508285999298,
0.3623026907444,
-0.5930145978927612,
0.100806303322315... | |
Can anyone please tell me the exact difference between `currentTarget` and `target` property in JavaScript events with example and which property is used in which scenario?
Events [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_bubbling_and_capture) by default. So the difference between the two is:
* `target` is the element that triggered the event (e.g., the user clicked on)
* `currentTarget` is the element that the event listener is attached to. | [
0.2737838327884674,
-0.4061206579208374,
0.11957147717475891,
-0.010788623243570328,
0.03575707972049713,
-0.32776644825935364,
-0.18806493282318115,
-0.043463367968797684,
-0.23485243320465088,
-0.22143526375293732,
-0.07968292385339737,
0.7543884515762329,
-0.22871121764183044,
0.1427472... | |
I am developing an app that is a question's game. I managed to show the answers to each question to a different button each time but i am having trouble to check the right answer. My approach is: I created an extra column to the database where i indicate the column where the right answer is(1,2,3 or 4). I use this code for showing the answers in different buttons.
```
cur = dbHelper.getRandomQuestion();
String corrans = cur.getString(cur.getColumnIndex("CorrectAnswer"));
a = Integer.parseInt(corrans);
String question = cur.getString(cur.getColumnIndex("QUESTIONS"));
String answer0 = cur.getString(cur.getColumnIndex("ANSWER1")); | [
-0.16265369951725006,
0.3155433237552643,
0.2893429696559906,
-0.07808130979537964,
-0.182491734623909,
0.2741483449935913,
0.09652020037174225,
-0.3379553556442261,
0.10178090631961823,
-0.4992155432701111,
-0.21373912692070007,
0.4498032033443451,
-0.5213767886161804,
0.20040802657604218... | |
String answer1 = cur.getString(cur.getColumnIndex("ANSWER2"));
String answer2 = cur.getString(cur.getColumnIndex("ANSWER3"));
String answer3 = cur.getString(cur.getColumnIndex("ANSWER4"));
txtQuest.setText(question);
ArrayList<String> lstAnswers = new ArrayList<String>();
lstAnswers.add(answer0);
lstAnswers.add(answer1);
lstAnswers.add(answer2);
lstAnswers.add(answer3);
score.setText("Your score is " + b +","+ a);
Random random = new Random();
int[] textViews = new int[] { R.id.button1, R.id.button2, R.id.button3, R.id.button4 };
int textViewIndex = 0;
while (lstAnswers.size() > 0) { | [
-0.2332926094532013,
-0.3942708373069763,
0.7443110942840576,
-0.2302362024784088,
-0.11111082136631012,
0.28225162625312805,
0.08153583109378815,
-0.34758007526397705,
-0.21502865850925446,
-0.17444175481796265,
-0.5206800699234009,
0.6940763592720032,
-0.39292973279953003,
0.191640883684... | |
int index = random.nextInt(lstAnswers.size());
if(a == index){ b = index;}
else{}
String randomAnswer = lstAnswers.remove(index);
((TextView)findViewById(textViews[textViewIndex])).setText(randomAnswer);
++textViewIndex;
}
```
To each button call to compare the values of a and b and then act accordingly. But it doesnt seem to work. I understand why but i cannot figure it out. Any | [
-0.1995684653520584,
-0.3981054723262787,
0.4708872437477112,
-0.24797283113002777,
0.02063007280230522,
0.07540208846330643,
0.2070508748292923,
-0.32240527868270874,
-0.22010409832000732,
-0.5907028317451477,
-0.054888442158699036,
0.3953140676021576,
-0.44181832671165466,
0.120893664658... | |
help appeciated.
use `Collections.shuffle(list)` to shuffle your answer array and then display the answer
Set a tag as "right" to your button where anwer is correct and later compare the the tagvalue and disply right or wrong
EDIT: below thing is just an outline
```
Here im displaying answers in buttons....
List<Integer> intList = new ArrayList<Integer>(Arrays.asList(0,1,2,3));
Collections.shuffle(intList);
Log.d("ERR","List after shuffling: " + intList);
// below answers will be assiagned randomly to buttons... | [
-0.42003095149993896,
-0.1935255229473114,
0.7146983742713928,
0.07087572664022446,
0.13925892114639282,
0.3518679440021515,
0.496905118227005,
-0.4711795747280121,
-0.21465204656124115,
-0.8891025185585022,
-0.3664104640483856,
0.6418806910514832,
-0.5823615789413452,
-0.3166957497596741,... | |
btn_cmpTagline[intList.get(0)].setText(answr1);
btn_cmpTagline[intList.get(0)].setTag("right");
btn_cmpTagline[intList.get(1)].setText(answr2);
btn_cmpTagline[intList.get(1)].setTag("wrong");
btn_cmpTagline[intList.get(2)].setText(answr3);
btn_cmpTagline[intList.get(2)].setTag("wrong");
btn_cmpTagline[intList.get(3)].setText(answr4);
btn_cmpTagline[intList.get(3)].setTag("wrong");
```
//On Click
```
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.btn_tag1: | [
0.1837318241596222,
-0.2392885386943817,
0.505266547203064,
-0.16830340027809143,
0.0735495537519455,
0.21048545837402344,
0.42388221621513367,
-0.507057785987854,
-0.26280495524406433,
-0.26517024636268616,
-0.4877359867095947,
0.5780794620513916,
-0.4996735453605652,
0.19773730635643005,... | |
Log.d("ERR", v.getTag().toString());
if(v.getTag().toString().equalsIgnoreCase("right")){
//this button has right answer .. do anything
}
break;
case R.id.btn_tag2:
Log.d("ERR", v.getTag().toString());
if(v.getTag().toString().equalsIgnoreCase("right")){ | [
-0.17129570245742798,
-0.3384992182254791,
0.7112927436828613,
-0.15217910706996918,
0.47742393612861633,
0.09483901411294937,
0.26357266306877136,
-0.2633014917373657,
-0.23751495778560638,
-0.3814784586429596,
-0.5763898491859436,
0.6603046655654907,
-0.4009396731853485,
-0.1251357793807... | |
//this button has right answer .. do anything
}
break;
case R.id.btn_tag3:
Log.d("ERR", v.getTag().toString());
if(v.getTag().toString().equalsIgnoreCase("right")){
//this button has right answer .. do | [
-0.2097180336713791,
-0.4447089731693268,
0.6337074637413025,
-0.11660777777433395,
0.532836377620697,
0.12515078485012054,
0.19218048453330994,
-0.2375631332397461,
-0.20620116591453552,
-0.43668273091316223,
-0.3929021656513214,
0.618708074092865,
-0.28688904643058777,
-0.167450472712516... | |
anything
}
--
--
}
``` | [
0.2012777030467987,
0.30713891983032227,
0.422985315322876,
0.15559124946594238,
0.46928611397743225,
-0.11772432178258896,
0.15728741884231567,
0.4490678310394287,
-0.009770090691745281,
-0.7012753486633301,
-0.1947396844625473,
0.6994955539703369,
-0.22803334891796112,
0.2509598433971405... | |
I have two table as given below in order
1. OPABC
2. OPHOST
I want to fetch the `CPU_ID` & `LOGIN_NAME` from the second table based on the `OPABC_JOB_NAME`, `JOB_NAME`, `OPABC_CYCLE_KEY`, `CYCLE_KEY` and `OPABC_JOB_REC` due to some of the cycle key as `NULL` I am getting incorrect values.
```
OPABC_JOB_NAME OPABC_JOB_REC OPABC_CYCLE_KEY
GENEXT DAEMON null
GENEXT FULL1 1
GENEXT FULL10 10
GENEXT FULL11 11
GENEXT FULL12 12
GENEXT FULL13 13
GENEXT FULL14 14
GENEXT FULL15 15
GENEXT FULL2 2
GENEXT FULL3 3
GENEXT FULL4 4
GENEXT FULL5 | [
0.004129456821829081,
0.5110578536987305,
0.29158881306648254,
-0.1750875860452652,
-0.09991993755102158,
0.4352380931377411,
0.12659329175949097,
-0.09240727871656418,
-0.17216280102729797,
-0.5453113317489624,
0.024141140282154083,
0.4415780007839203,
-0.22041159868240356,
0.183706045150... | |
5
GENEXT FULL6 6
GENEXT FULL7 7
GENEXT FULL8 8
GENEXT FULL9 9
JOB_NAME CYCLE_KEY CPU_ID LOGIN_NAME
GENEXT 1 sn25666 sbswrk6
GENEXT 10 sn25666 sbswrk6
GENEXT 11 sn25666 sbswrk6
GENEXT 12 sn25666 sbswrk6
GENEXT 13 sn25666 sbswrk6
GENEXT 14 sn25666 sbswrk6
GENEXT 15 sn25666 sbswrk6
GENEXT 2 sn25666 sbswrk6
GENEXT 3 sn25666 sbswrk6
GENEXT 4 sn25666 sbswrk6
GENEXT 5 sn25666 sbswrk6
GENEXT 6 sn25666 sbswrk6
GENEXT 7 | [
-0.3339364528656006,
0.09233998507261276,
0.4298020303249359,
-0.3372430205345154,
-0.17399215698242188,
0.30745697021484375,
0.3499864637851715,
-0.13039475679397583,
-0.18194197118282318,
-0.44151827692985535,
-0.4526536166667938,
0.4527369439601898,
-0.10476533323526382,
0.3965978920459... | |
sn25666 sbswrk6
GENEXT 8 sn25666 sbswrk6
GENEXT 9 sn25666 sbswrk6
GENEXT null sn25666 sbswrk6
```
Maybe you can use the `NVL` function while matching the `CYCLE_KEY`, which is common in both the tables.
```
SELECT DISTINCT OPABC_JOB_NAME,
JOB_NAME,
OPABC_CYCLE_KEY,
CYCLE_KEY, | [
-0.25511687994003296,
-0.04949713498353958,
0.21719570457935333,
-0.158261239528656,
0.07302748411893845,
0.3342842757701874,
0.1943136602640152,
-0.06234453245997429,
-0.4258243441581726,
-0.5111541748046875,
-0.07909875363111496,
0.28518345952033997,
-0.42005297541618347,
0.1315107792615... | |
OPABC_JOB_REC,
CPU_ID,
LOGIN_NAME
FROM OPHOST OH, OPABC OB
WHERE NVL(OH.CYCLE_KEY, 0) = NVL(OB.OPABC_CYCLE_KEY, 0)
```
This way on encountering `NULL` as `CYCLE_KEY`, 0 will be returned and you will get 16 rows. | [
-0.5149011611938477,
0.25272074341773987,
0.6759467720985413,
-0.4205886423587799,
0.2429686188697815,
0.7525619864463806,
-0.09139186888933182,
-0.09291542321443558,
-0.7135859131813049,
-0.5421119332313538,
-0.1639459878206253,
0.335354208946228,
-0.2439752072095871,
0.05767616629600525,... | |
C#/.NET 4.0
I need to parse a string containing a 18-digit number. I also need the substrings at the left and right side.
Example strings:
```
string a = "Frl Camp Gerbesklooster 871687120000000691 OPLDN 2010 H1";
string b = "some text with spaces 123456789012345678 more text";
```
How it should be parsed:
```
string aParsed[0] = "Frl Camp Gerbesklooster";
string aParsed[1] = "871687120000000691";
string aParsed[2] = "OPLDN 2010 H1";
string bParsed[0] = "some text with spaces";
string bParsed[1] = "123456789012345678";
string bParsed[2] = "more text";
```
There is always that 18-digit number in the middle of the string. I'm an absolute newbie to Regex so I don't actually have a try of my | [
-0.15194961428642273,
0.4687463939189911,
0.369749516248703,
-0.23566696047782898,
-0.07943764328956604,
0.06670496612787247,
0.45896482467651367,
-0.2588878273963928,
-0.27619171142578125,
-0.39082613587379456,
-0.28627845644950867,
0.8403985500335693,
-0.4565434753894806,
-0.312502503395... | |
own.
What is the best way to do this? Should I use regular expressions?
Thanks.
You can use something like the regex: `(.*)(\d{18})(.*)`.
The key here is to use `{18}` to specify that there must be exactly `18` digits and to capture each part in a group.
```
var parts = Regex.Matches(s, @"(.*)(\d{18})(.*)")
.Cast<Match>()
.SelectMany(m => m.Groups.Cast<Group>().Skip(1).Select(g=>g.Value))
.ToArray();
``` | [
0.046658363193273544,
-0.0973905697464943,
0.4012642502784729,
0.15725503861904144,
0.0735154002904892,
0.11509481817483902,
0.121231809258461,
-0.44599786400794983,
-0.3108031153678894,
-0.40424472093582153,
0.16677553951740265,
0.5742095708847046,
-0.3048516511917114,
-0.2127176821231842... | |
In my application I am using a simple JavaScript popup and successfully invoking it this way-
```
<a href="javascript:popup('Hello World')>Click Me</a>
```
I was wondering whether it is possible to invoke the same popup on other jQuery events. For instance
```
$("#some_button_id").click( function() {
javascript:popup('Hello World');
});
```
The above method doesn't work. Any other solution?
EDIT - You don't need the `javascript:` part because you are not attaching javascript inline.
But that is not the cause of the error so make sure that you wait until the DOM is ready before attaching | [
0.12410321086645126,
0.043439608067274094,
0.5865674018859863,
-0.1741023063659668,
-0.0893886387348175,
-0.10684206336736679,
0.20595280826091766,
-0.041576456278562546,
-0.04264435917139053,
-0.6258580684661865,
-0.19913548231124878,
0.6434738039970398,
-0.4303719997406006,
0.24030970036... | |
an event handler.
```
$(function(){
var popup = function(msg){
alert(msg);
}
$("#some_button_id").click( function() {
popup('Hello World');
});
});
```
and of course make sure you define `popup()` somewhere | [
-0.007843087427318096,
-0.24914777278900146,
0.48359644412994385,
-0.012451879680156708,
0.45042264461517334,
-0.12866203486919403,
0.1654200255870819,
0.5039560198783875,
-0.3771468698978424,
-0.5869465470314026,
-0.700713038444519,
0.28968364000320435,
-0.6986873745918274,
-0.05861583352... | |
I am trying to set a BOOL within Xcode and for some reason it is plain refusing to work. Nothing else is setting this bool, just this one instance. My code is below:
.h
```
@interface SuspectsViewController : UIViewController
{
BOOL boolContentChanged;
}
@property (nonatomic) BOOL boolContentChanged;
```
.m
```
@synthesize boolContentChanged;
-(IBAction)buttonPressed:(id)sender
{
boolContentChanged = true;
}
```
I have also tried using self.boolContentChanged but nothing happens either. To try and debug this I used po boolContentChanged and get the following output, the first po is before boolContentChanged = true and the second is after.
```
(lldb) po boolContentChanged
(BOOL) $4 = '\0' <nil>
(lldb) po boolContentChanged
(BOOL) $7 = '\0' <nil>
```
Does | [
0.017135880887508392,
0.030936263501644135,
0.6619782447814941,
-0.22042769193649292,
-0.1451089233160019,
0.12671193480491638,
0.30368274450302124,
-0.41214099526405334,
-0.03844249248504639,
-0.740123450756073,
0.2877761125564575,
0.5456432700157166,
-0.41494929790496826,
0.0358141921460... | |
the $ indicate that it's pointing to a certain address, or is that purely for debugging reference?
Also, is there any reason this would be nil? Surely it doesn't need implicitly setting if it is a bool and not a pointer?
Any advice on this is much appreciated as I can't work it out,
Thanks in advanced,
Elliott
I finally managed to figure out what was happening. In regards to the debugger it did make a practical difference using YES / NO as opposed to true / false, the values were still being set if I used p to explicitly find them, but when using | [
0.2220945507287979,
0.19784317910671234,
0.20300893485546112,
0.23059400916099548,
-0.21211902797222137,
0.02401537075638771,
0.5239787697792053,
-0.12065380811691284,
-0.0297892726957798,
-0.3910624086856842,
0.4407029151916504,
0.4958001673221588,
-0.15486228466033936,
0.0167034361511468... | |
YES / NO they would show automatically. So once again it seems to be the intellisense that is failing to update in certain situations.
Thanks for the help all. | [
0.08883918821811676,
-0.20693354308605194,
0.499181866645813,
0.45068123936653137,
-0.0010375393321737647,
-0.16304023563861847,
0.24142198264598846,
0.4417445957660675,
-0.005714218132197857,
-0.6159546375274658,
0.15176285803318024,
0.7706275582313538,
0.23590566217899323,
0.033442903310... | |
I'm relatively new to python and am starting to work with suffix trees. I can build them, but I'm running into a memory issue when the string gets large. I know that they can be used to work with DNA strings of size 4^10 or 4^12, but whenever I try to implement a method, I end up with a memory issue.
Here is my code for generating the string and the suffix tree.
```
import random
def get_string(length):
string=""
for i in range(length):
string += random.choice("ATGC")
return | [
0.4880821108818054,
0.05096956342458725,
-0.04428504779934883,
-0.20860061049461365,
-0.29219284653663635,
0.03860389441251755,
0.21886976063251495,
-0.22998972237110138,
-0.002580393338575959,
-0.4779164791107178,
0.37366244196891785,
0.7415876388549805,
-0.39545539021492004,
0.1482413113... | |
string
word=get_string(4**4)+"$"
def suffixtree(string):
for i in xrange(len(string)):
if tree.has_key(string[i]):
tree[string[i]].append([string[i+1:]][0])
else:
tree[string[i]]=[string[i+1:]]
return tree
tree={}
suffixtree(word)
```
When I get up to around 4\*\*8, I run into severe memory problems. I'm rather new to this so I'm sure I'm missing something with storing these things. Any advice would be greatly appreciated.
As a note: I want to do string searching to look for | [
-0.09987445920705795,
-0.28875839710235596,
0.37229692935943604,
-0.4796723425388336,
-0.06091839820146561,
0.026387060061097145,
0.6610945463180542,
-0.05353647470474243,
-0.35116368532180786,
-0.8793541789054871,
-0.05614898353815079,
0.7055146098136902,
0.00032763072522357106,
0.2199891... | |
matching strings in a very large string. The search string match size is 16. So, this would look for a string of size 16 within a large string, and then move onto the next string and perform another search. Since I'll be doing a very large number of searches, a suffix tree was suggested.
Many thanks
As others have said already, the data structure you are building is not a suffix tree. However, the **memory issues** stem largely from the fact that your data structure involves a lot of **explicit string copies.** A call like this
```
string[i+1:]
```
creates an actual (deep) copy of the | [
-0.1707281917333603,
0.06574507802724838,
0.2029488980770111,
-0.1206105500459671,
-0.24095283448696136,
0.027130799368023872,
0.3736092150211334,
-0.14260804653167725,
-0.14687331020832062,
-0.6949121952056885,
0.1410360485315323,
0.4902206063270569,
-0.4406050443649292,
0.221072271466255... | |
substring starting at `i+1`.
If you are still interested in constructing your original data structure (whatever its use may be), a good solution is to use **buffers** instead of string copies. Your algorithm would then look like this:
```
def suffixtree(string):
N = len(string)
for i in xrange(N):
if tree.has_key(string[i]):
tree[string[i]].append(buffer(string,i+1,N))
else:
tree[string[i]]=[buffer(string,i+1,N)]
return tree
```
I tried this embedded | [
-0.12048467993736267,
-0.15978354215621948,
0.2615826427936554,
-0.2978267967700958,
-0.3584912419319153,
-0.0727081447839737,
0.14656475186347961,
-0.2970360517501831,
-0.3011932373046875,
-0.6506811380386353,
-0.14471033215522766,
0.3826996684074402,
-0.35500651597976685,
0.1925324946641... | |
in the rest of your code, and confirmed that it requires significantly less then 1 GB of main memory even at a total length of 8^11 characters.
**Note that this will likely be relevant even if you switch to an actual suffix tree.** A correct suffix tree implementation will not store copies (not even buffers) in the tree edges; however, during tree construction you might need a lot of temporary copies of the strings. Using the `buffer` type for these is a very good idea to avoid putting a heavy burden on the garbage collector for all the unnecessary explicit string | [
0.024680130183696747,
0.12097382545471191,
0.230991393327713,
-0.024637769907712936,
-0.28165754675865173,
0.1687854677438736,
0.6770305037498474,
-0.020417865365743637,
-0.3708927035331726,
-0.9326299428939819,
-0.15516844391822815,
0.29818135499954224,
0.09377160668373108,
-0.27640092372... | |
copies. | [
0.13527922332286835,
0.0631202980875969,
-0.003819432109594345,
0.2755623161792755,
0.25482988357543945,
0.05297577381134033,
-0.1895289570093155,
0.05130517855286598,
-0.12134255468845367,
-0.6167510747909546,
-0.4452221989631653,
0.03327963501214981,
-0.11113080382347107,
0.0848425030708... | |
I wrote a function to convert the input month parameter to a certain format. such as if I passed 04 to the function and the function will return the "***\_****APR*\_". the function I wrote is like below:
```
function GetEnMonth()
{
param([string] $month)
switch ($month)
{
($_ -eq "01"){$result = "_JAN_"}
($_ -eq "02"){$result = "_FEB_"}
($_ -eq "03"){$result = "_MAR_"}
($_ -eq "04"){$result = "_APR_"}
($_ -eq "05"){$result = "_MAY_"}
($_ -eq "06"){$result = "_JUN_"}
($_ -eq "07"){$result = "_JUL_"}
($_ | [
-0.17623993754386902,
0.39995333552360535,
0.8408516049385071,
-0.3313501179218292,
-0.147495299577713,
0.29383498430252075,
0.4305643141269684,
-0.37410393357276917,
-0.05178337171673775,
-0.38103097677230835,
-0.08013767749071121,
0.5235744118690491,
0.01608404703438282,
0.02566968463361... | |
-eq "08"){$result = "_AUG_"}
($_ -eq "09"){$result = "_SEP_"}
($_ -eq "10"){$result = "_OCT_"}
($_ -eq "11"){$result = "_NOV_"}
($_ -eq "12"){$result = "_DEC_"}
default {$result ="_No_Result_"}
}
return [string]$result;
}
```
Then I use below command to execute the function to get the result:
```
$mYear = $today.substring(0,4)
$mMonth =$today.substring(4,2)
$mDate = $today.substring(6,2)
$monthInEn = GetEnMonth $mMonth
```
well, the result is always "\_No\_Result\_", why? below is the exception:
```
**** Exception type : System.Management.Automation.RuntimeException
**** Exception message : You cannot call a method on a null-valued expression.
```
Could anyone give me an answer for this?
I | [
-0.1795813888311386,
0.09757080674171448,
0.7209481000900269,
-0.24730715155601501,
0.11421584337949753,
0.01541629247367382,
0.3210921585559845,
-0.06500851362943649,
-0.36602455377578735,
-0.3575076758861542,
-0.45379379391670227,
0.6234232187271118,
-0.05133461207151413,
0.2580576241016... | |
have searched Google a lot but don't find useful solutions.
Your switch statment is wrong try this:
```
function GetEnMonth()
{
param([string] $month)
switch ($month)
{
"01" {$result = "_JAN_"}
"02" {$result = "_FEB_"}
"03" {$result = "_MAR_"}
"04" {$result = "_APR_"}
"05" {$result = "_MAY_"}
"06" {$result = "_JUN_"}
"07" {$result = "_JUL_"}
"08" {$result = "_AUG_"}
"09" {$result = "_SEP_"}
"10" {$result = "_OCT_"}
"11" {$result = "_NOV_"}
"12" | [
0.1383293867111206,
-0.0006548575474880636,
1.0138726234436035,
-0.07882677763700485,
0.1283472180366516,
-0.15301746129989624,
0.6183714866638184,
-0.21120339632034302,
-0.19929198920726776,
-0.5091244578361511,
-0.25274133682250977,
0.6111540198326111,
-0.053424037992954254,
0.1178597435... | |
{$result = "_DEC_"}
default {$result ="_No_Result_"}
}
return [string]$result;
}
``` | [
-0.20666909217834473,
-0.11864098906517029,
0.2299056351184845,
-0.2970986068248749,
0.1359694004058838,
-0.07206841558218002,
0.22031335532665253,
-0.13048870861530304,
-0.23647798597812653,
-0.1221928596496582,
-0.5134196877479553,
0.6393854022026062,
-0.1611141711473465,
0.2688342034816... | |
I neeed to create multiple versions of my project using configuration just like we do with `#define`, `#if`, `#endif`.
The down side of using these preprocessor directives is that I need to define symbols in almost every file of the project but I want to handle this thing by my build configurations.
I am not even sure if Build Configurations will help me to do this.
What I want is if I create a configuration with name "Development" and other with name "QA", my code would look like:
```
if #Development or if $QA
```
Kindly guide me towards achieving this.
Configuration Manager exist for this reason.
* Go | [
0.49925994873046875,
0.21585670113563538,
-0.30076277256011963,
-0.021352434530854225,
0.04314003139734268,
0.24507248401641846,
0.2960018217563629,
0.17370310425758362,
0.019776856526732445,
-0.989488959312439,
0.21046173572540283,
0.5578092932701111,
-0.13518644869327545,
0.2192758172750... | |
to the Configuration Manager and create a New Configuration
copying from the predefined DEBUG configuration
* Name the configuration DEVELOPMENT and apply to all projects
* Select as Active Configuration the DEVELOPMENT configuration (should already be the
active one)
* Go to the properties page of each project requiring `#if DEVELOPMENT`
conditional compile and insert the DEVELOPMENT symbol in first textbox of the BUILD tab
Now each of your projects can use the #if DEVELOPMENT preprocessor directive
If you need this also for RELEASE repeat the above steps but copy from predefined RELEASE configuration and give a different NAME
Now switching from a configuration with or without the DEVELOPMENT | [
0.5171358585357666,
0.002213318133726716,
0.17269940674304962,
-0.08783623576164246,
0.09193920344114304,
-0.2150193750858307,
0.21749117970466614,
0.013672014698386192,
0.04448890686035156,
-0.8966449499130249,
-0.34540775418281555,
0.593578577041626,
-0.27917397022247314,
0.0983414873480... | |
symbol defined could be done directly from the Solution Configurations combo Tool present in the Standard Toolbar of Visual Studio without editing each project.
You can also view MSDN article [How to: Create and Edit Configurations](http://msdn.microsoft.com/en-us/library/kwybya3w.aspx) | [
0.234969824552536,
-0.39633113145828247,
0.11982489377260208,
0.3042287826538086,
-0.11041044443845749,
0.25296059250831604,
0.2328595072031021,
-0.4559207260608673,
-0.14747090637683868,
-0.785847544670105,
0.11896763741970062,
0.11879754066467285,
-0.11952712386846542,
-0.099079877138137... | |
In Visual Studio I use `.load sos` in the Immediate Window to load sos.dll. What is this '.load'? Is there some description for it?
In the Immediate Window I Can:
Evaluate an expression (`? varA`), execute program command (`varA=1`) or execute VS commad (`>cmd`). Where is .load at this scheme? Can it be used on some other place (Command Window Macro)?
Is is a command for the unmanaged debugger. You'll need Project + Properties, Debug tab, "Enable unmanaged code debugging" option turned on and start debugging your program. After loading an extension with .load, you can get help for it by typing !help. | [
0.25798505544662476,
-0.23957492411136627,
0.2732173204421997,
-0.13031934201717377,
-0.18525899946689606,
-0.26936113834381104,
0.22161702811717987,
-0.23779398202896118,
-0.15272098779678345,
-0.8247294425964355,
-0.30466216802597046,
0.8134937286376953,
-0.2573322653770447,
-0.281970679... | |
Debugger extension commands start with . or !
You can get more info about debugger extensions from the debugger.chm help file that's included with the Debugging Tools for Windows package. It is no longer a separate download these days but included with the Windows SDK. Find it back in c:\program files (x86)\debugging tools for windows (x86) directory. | [
0.34255897998809814,
0.06893187761306763,
0.06856370717287064,
0.029572205618023872,
-0.0447235107421875,
0.006272089201956987,
0.3313819169998169,
0.06357347965240479,
-0.5187616944313049,
-0.4982247054576874,
-0.34313222765922546,
0.4462180733680725,
-0.2229623794555664,
0.35060527920722... | |
I need to *`export/update schema without loosing existing data`*. I found that there are two `Red Gate` tools which you are probably have heard about:
* `SQL Compare`;
* `SQL Data Compare`;
Which one of them could help me to solve migration?
You need [SQL Data Compare](http://www.red-gate.com/products/sql-development/sql-data-compare/), because SQL Compare is only synchronizes the schema not the data. | [
0.15061302483081818,
0.1151747778058052,
0.35799750685691833,
0.05937404930591583,
-0.02132253907620907,
0.12121547013521194,
-0.08950193226337433,
-0.1082528829574585,
-0.27409088611602783,
-0.6516123414039612,
0.028510503470897675,
0.44774359464645386,
-0.12024936825037003,
0.31171354651... | |
I have wix installer and it copies some files to some directories. Each file is declared as single component, with some path - if directory does not exist, installer will create it and place file there.
What I want to do: if directory already exists, installer should not copy any files there (even if file does not exists, it should not be copied to already existing directory).
But it's impossible to set "Never overwrite" to directory, so how can I prevent copy new files to already existing directory? Is there any condition (something like "is directory exist") that I can use | [
0.7090297341346741,
0.18660517036914825,
0.3133138418197632,
-0.010398674756288528,
0.1765759438276291,
-0.45822006464004517,
0.34761008620262146,
-0.04273770749568939,
0.00015080136654432863,
-0.85541832447052,
0.08623760938644409,
0.492191344499588,
-0.2929616868495941,
0.451349020004272... | |
here?
> Is there any condition (something like "is directory exist") that I can use here?
Yes, you can use a Condition element like this:
```
<Directory Id="FooFolder" Name="Foo">
<Component Id="SomeId">
<File Source="..." />
<Condition>Not FOO_FOLDER_ALREADY_EXISTS</Condition>
</Component>
</Directory>
```
The kind of things that you can use as a condition are explained in the [Conditional Statement Syntax](http://msdn.microsoft.com/en-us/library/windows/desktop/aa368012%28v=vs.85%29.aspx) documentation of windows installer.
In this case, I believe you can set the `FOO_FOLDER_ALREADY_EXISTS` property with a [DirectorySearch](http://wix.sourceforge.net/manual-wix3/wix_xsd_directorysearch.htm) like this:
```
<Property Id="FOO_FOLDER_ALREADY_EXISTS">
<DirectorySearch Id="FooFolderSearch" Path="[FooFolder]" />
</Property>
```
**edit**: apparently the directory | [
0.39591091871261597,
0.19828394055366516,
0.4536670744419098,
-0.13034990429878235,
0.3675869107246399,
-0.24030758440494537,
0.1186986044049263,
-0.012983569875359535,
-0.19457337260246277,
-0.5833415389060974,
-0.03933308273553848,
0.5193748474121094,
-0.025245852768421173,
0.25683578848... | |
search above doesn't work because the `[FooFolder]` property is only resolved during the `CostFinalize` action (see [documentation](http://msdn.microsoft.com/en-us/library/windows/desktop/aa372403%28v=vs.85%29.aspx)). But the directory search already happens before that during the `AppSearch` action.
I am unsure how to work around that. It would probably involve setting the FOO\_FOLDER\_ALREADY\_EXISTS property after `CostFinalize` with a custom action instead of a windows installer directory search. | [
-0.06529784202575684,
0.22797001898288727,
0.7695103287696838,
-0.23727385699748993,
0.23678793013095856,
-0.3237830102443695,
0.24719567596912384,
-0.2715974450111389,
-0.26018890738487244,
-0.6770291328430176,
-0.23015035688877106,
0.7636889815330505,
-0.3421749770641327,
0.0347269698977... | |
I am trying to implement the timer in code, All the example that I found are using `while(1)` or `for(;;)` but when I tried with using `scanf` my program terminates. Is it getting any value on `stdin` because if I use `scanf` two times then timer is called two time before exiting from program.
Here is my sample code:
```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <netinet/in.h>
#include <signal.h>
#include <time.h>
#include <linux/socket.h>
#include <time.h>
#define SIGTIMER (SIGRTMAX)
#define SIG SIGUSR1
static timer_t tid;
static timer_t tid2;
void SignalHandler(int, siginfo_t*, void* );
timer_t SetTimer(int, int);
int main(int argc, char *argv[]) {
int t; | [
0.22037965059280396,
-0.2155376821756363,
0.48826587200164795,
-0.40050122141838074,
-0.09994015097618103,
0.21282970905303955,
0.3216385245323181,
-0.47645875811576843,
-0.22267374396324158,
-0.7462879419326782,
-0.08902596682310104,
0.282720148563385,
-0.46983569860458374,
0.197054743766... | |
printf("SIGRTMAX %d\n", SIGRTMAX);
printf("SIGRTMIN %d\n", SIGRTMIN);
struct sigaction sigact;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_SIGINFO;
sigact.sa_sigaction = SignalHandler;
// set up sigaction to catch signal
if (sigaction(SIGTIMER, &sigact, NULL) == -1) {
perror("sigaction failed");
exit( EXIT_FAILURE );
}
// Establish a handler to catch CTRL+c and use it for exiting.
sigaction(SIGINT, | [
-0.5190303921699524,
-0.47782567143440247,
0.4662836790084839,
-0.4698159992694855,
0.0023891273885965347,
0.5137863159179688,
0.5219706892967224,
-0.3265990912914276,
-0.0327736921608448,
-0.36298036575317383,
-0.3871786892414093,
0.19314251840114594,
-0.5546883940696716,
0.04463854804635... | |
&sigact, NULL);
tid=SetTimer(SIGTIMER, 1000);
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = SignalHandler;
// set up sigaction to catch signal
if (sigaction(SIG, &sa, NULL) == -1) {
perror("sa failed");
exit( EXIT_FAILURE );
}
// Establish a handler to catch CTRL+c and use it for exiting.
sigaction(SIGINT, &sa, NULL);
tid2=SetTimer(SIG, 1000); | [
-0.2898569405078888,
-0.45235055685043335,
0.5615178942680359,
-0.3405078053474426,
-0.014340829104185104,
0.5467195510864258,
0.5789415836334229,
-0.4740772545337677,
-0.015853671357035637,
-0.24689127504825592,
-0.3520100712776184,
0.0782347247004509,
-0.4960469901561737,
0.1474014222621... | |
// for(;;); or while(1) Working properly
scanf("%d", &t); /// Program terminates
return 0;
}
void SignalHandler(int signo, siginfo_t* info, void* context)
{
if (signo == SIGTIMER) {
printf("Command Caller has ticked\n");
}else if (signo == SIG) {
printf("Data Caller has ticked\n");
} else if (signo == SIGINT) {
timer_delete(tid);
perror("Crtl+c cached!");
exit(1); | [
0.18724189698696136,
-0.18457773327827454,
0.49962136149406433,
-0.5526251792907715,
0.2033507376909256,
0.34874817728996277,
0.3953065276145935,
-0.36832407116889954,
-0.12821604311466217,
-0.42452967166900635,
-0.33381524682044983,
0.46975505352020264,
-0.24534665048122406,
0.21254202723... | |
// exit if CRTL/C is issued
}
}
timer_t SetTimer(int signo, int sec)
{
static struct sigevent sigev;
static timer_t tid;
static struct itimerspec itval;
static struct itimerspec oitval;
// Create the POSIX timer to generate signo
sigev.sigev_notify = SIGEV_SIGNAL;
sigev.sigev_signo = signo;
sigev.sigev_value.sival_ptr = &tid;
if (timer_create(CLOCK_REALTIME, &sigev, &tid) == 0)
{
itval.it_value.tv_sec = sec / 1000; | [
-0.03411881625652313,
-0.42035654187202454,
0.9169015288352966,
-0.3076306879520416,
0.217695415019989,
0.23405715823173523,
0.23305639624595642,
-0.27087318897247314,
-0.207919642329216,
-0.47775721549987793,
-0.5001365542411804,
0.3981051445007324,
-0.27972865104675293,
0.118637084960937... | |
itval.it_value.tv_nsec = (long)(sec % 1000) * (1000000L);
itval.it_interval.tv_sec = itval.it_value.tv_sec;
itval.it_interval.tv_nsec = itval.it_value.tv_nsec;
if (timer_settime(tid, 0, &itval, &oitval) != 0)
{
perror("time_settime error!");
}
}
else
{
perror("timer_create error!"); | [
-0.12416385114192963,
-0.609805703163147,
0.8770332932472229,
-0.33226603269577026,
0.019029702991247177,
0.3730096220970154,
0.5670396685600281,
-0.17230184376239777,
-0.19045619666576385,
-0.4478120803833008,
-0.24324975907802582,
0.4748789966106415,
-0.17624959349632263,
0.2806266248226... | |
return NULL;
}
return tid;
}
```
So, How can I resolve this problem ?
Any help would be Appreciated.
Thanks, Yuvi
Signal interrupts scanf. If you add `perror('scanf')` after scanf output will be:
```
SIGRTMAX 64
SIGRTMIN 34
Command Caller has ticked
Data Caller has ticked
scanf: Interrupted system call
```
If you replace `scanf` with:
```
do {
errno = 0;
scanf("%d", &t);
} while(errno == EINTR);
```
scanf will be retried when it fail with `Interrupted system call`. | [
-0.09786727279424667,
-0.16248108446598053,
0.46681129932403564,
-0.286032497882843,
-0.04329432174563408,
0.16197465360164642,
0.4460063576698303,
-0.2614576518535614,
-0.130126953125,
-0.4540053606033325,
-0.05727006494998932,
0.7360330820083618,
-0.31554827094078064,
0.22722157835960388... | |
Were are facing a big problem with string length control in SQL Server 2008.
A brief recap of our system:
* import data in a persistent staging area from `*.txt` file (semicolon as separator), using bulk insert in SQL Server environment;
* in PSA table all columns are `varchar(MAX)`;
* cleaning operations using insert statement based on a select with multiple where conditions.
The problem we deal with is on a single column type and length, in fact in data warehouse level it has to be numeric and its lengths must not exceed 13 digits.
The select is the following:
```
select cast(LTRIM(RTRIM(data_giacenza)) as numeric), | [
0.23778390884399414,
-0.15316663682460785,
0.6922497153282166,
-0.29130563139915466,
-0.3568825423717499,
0.21448473632335663,
0.3187238574028015,
-0.5630810856819153,
-0.15556120872497559,
-0.36245155334472656,
-0.09930290281772614,
0.2879810631275177,
-0.3287077844142914,
0.1761652976274... | |
LTRIM(RTRIM(codice_socio)),
LTRIM(RTRIM(codice_gln)),
LTRIM(RTRIM(tipo_gln)),
LTRIM(RTRIM(codice_articolo_socio)), | [
0.03605698421597481,
-0.12585502862930298,
0.7815437316894531,
-0.14924943447113037,
0.020474467426538467,
0.3430093824863434,
-0.3186022639274597,
-0.6230624318122864,
-0.5915994048118591,
-0.6415624022483826,
-0.4072476625442505,
0.9122083783149719,
-0.18993248045444489,
-0.2678508162498... | |
LTRIM(RTRIM(codice_ean_prodotto)),
LTRIM(RTRIM(codice_ecat_prodotto)),
LTRIM(RTRIM(famiglia)),
LTRIM(RTRIM(marca)), | [
0.03441789746284485,
-0.33359289169311523,
1.0051621198654175,
-0.31199929118156433,
0.21091528236865997,
0.3331930637359619,
-0.32940661907196045,
-0.2674318253993988,
-0.46775582432746887,
-0.4514681100845337,
-0.4898594915866852,
0.7970197796821594,
-0.3039933741092682,
-0.2442984282970... | |
LTRIM(RTRIM(classificazione_liv_1)),
LTRIM(RTRIM(classificazione_liv_2)),
LTRIM(RTRIM(classificazione_liv_3)),
LTRIM(RTRIM(classificazione_liv_4)), | [
-0.24704505503177643,
0.02529485896229744,
0.8466711044311523,
-0.2861337661743164,
0.028157653287053108,
0.2207156866788864,
0.20369383692741394,
-0.5870938897132874,
-0.5843790173530579,
-0.6912044286727905,
-0.6915718913078308,
0.9792605042457581,
-0.24357342720031738,
-0.00455479230731... | |
LTRIM(RTRIM(modello)),
LTRIM(RTRIM(descrizione_articolo)),
cast(LTRIM(RTRIM(giacenza)) as numeric),
cast(LTRIM(RTRIM(acquistato)) as numeric), 'X' | [
0.14560745656490326,
-0.2183697521686554,
0.7831532955169678,
0.07022517919540405,
0.14027144014835358,
0.48801788687705994,
-0.24506208300590515,
-0.5962975025177002,
-0.3071568012237549,
-0.4908446669578552,
-0.4194220006465912,
0.5546262860298157,
-0.22214233875274658,
0.097216859459877... | |
FROM psa_stock a
where EXISTS
(
SELECT 0 | [
-0.08165859431028366,
-0.0637953132390976,
-0.24320650100708008,
-0.24702347815036774,
0.33063259720802307,
0.0009664581157267094,
-0.13785360753536224,
-0.053019650280475616,
0.041099950671195984,
-0.35234034061431885,
-0.2195112109184265,
0.235539048910141,
-0.3345591723918915,
0.0738923... | |
FROM(
SELECT
data_giacenza | [
-0.07218378782272339,
-0.40803757309913635,
0.17858317494392395,
-0.05090603604912758,
0.5395816564559937,
-0.14815452694892883,
-0.2817870080471039,
-0.08370405435562134,
-0.4984707832336426,
-0.43404877185821533,
-0.32656583189964294,
0.30694580078125,
-0.32082289457321167,
0.11766567081... | |
,codice_socio
,codice_gln | [
-0.02983158640563488,
-0.025523677468299866,
0.08975528180599213,
-0.045729685574769974,
-0.06654208153486252,
0.3456610143184662,
-0.27491217851638794,
0.289968878030777,
-0.49034157395362854,
-0.6068508625030518,
-0.11565351486206055,
0.5885751247406006,
-0.3120321035385132,
0.2318729162... | |
,codice_articolo_socio
FROM psa_stock
where | [
-0.0924658253788948,
-0.040050238370895386,
0.0877918004989624,
0.3203858733177185,
0.15490977466106415,
0.39985838532447815,
-0.4103964567184448,
-0.13482899963855743,
-0.20245027542114258,
-0.5882089734077454,
-0.06274785101413727,
0.5729396343231201,
0.062381088733673096,
-0.22960487008... | |
LEN(LTRIM(RTRIM(data_giacenza))) = 8 and LEN(LTRIM(RTRIM(codice_socio))) = 3
and LEN(LTRIM(RTRIM(codice_gln))) = 13 and LEN(LTRIM(RTRIM(tipo_gln))) = 3
and LEN(LTRIM(RTRIM(codice_articolo_socio))) <= 15
and (LEN(LTRIM(RTRIM(codice_ean_prodotto))) <= 13 or LEN(ISNULL(codice_ean_prodotto, '')) = 0) | [
-0.07772495597600937,
-0.35891592502593994,
0.8040050268173218,
-0.17828688025474548,
0.1489734649658203,
0.5406365990638733,
-0.18980246782302856,
-0.7288112044334412,
-0.670966625213623,
-0.3377683758735657,
-0.40575525164604187,
1.020482063293457,
-0.13581201434135437,
-0.56584483385086... | |
and (LEN(LTRIM(RTRIM(codice_ecat_prodotto))) = 9 or LEN(ISNULL(codice_ecat_prodotto, '')) = 0)
and LEN(LTRIM(RTRIM(famiglia))) = 2
and (LEN(LTRIM(RTRIM(marca))) <= 20 or LEN(ISNULL(marca, '')) = 0)
and (LEN(LTRIM(RTRIM(modello))) <= 30 or LEN(ISNULL(modello, '')) = 0) | [
-0.12891124188899994,
-0.6836400628089905,
1.054258108139038,
-0.3015981912612915,
0.3283753991127014,
0.5578765273094177,
-0.23228512704372406,
-0.7761085629463196,
-0.6377322673797607,
-0.3011034429073334,
-0.4540310204029083,
0.9627377390861511,
-0.07288333773612976,
-0.3045977652072906... | |
and (LEN(LTRIM(RTRIM(descrizione_articolo))) <= 50 or LEN(ISNULL(descrizione_articolo, '')) = 0)
and LEN(LTRIM(RTRIM(giacenza))) <= 5
and LEN(LTRIM(RTRIM(acquistato))) <= 5
and (LEN(LTRIM(RTRIM(classificazione_liv_1))) <= 15 or LEN(ISNULL(classificazione_liv_1, '')) = 0) | [
-0.1401890218257904,
-0.41024497151374817,
0.7492692470550537,
-0.26442280411720276,
0.33160948753356934,
0.49669602513313293,
-0.26713889837265015,
-0.796840250492096,
-0.5826700329780579,
-0.4195035398006439,
-0.46500927209854126,
0.932945191860199,
0.10646235942840576,
-0.21610870957374... | |
and (LEN(LTRIM(RTRIM(classificazione_liv_2))) <= 15 or LEN(ISNULL(classificazione_liv_2, '')) = 0)
and (LEN(LTRIM(RTRIM(classificazione_liv_3))) <= 15 or LEN(ISNULL(classificazione_liv_3, '')) = 0)
and (LEN(LTRIM(RTRIM(classificazione_liv_4))) <= 15 or LEN(ISNULL(classificazione_liv_4, '')) = 0)
and ISNUMERIC(ltrim(rtrim(REPLACE(data_giacenza, ' ', '')))) = 1 | [
-0.32728227972984314,
-0.371399849653244,
0.7057532668113708,
-0.17678868770599365,
0.17487765848636627,
0.4844128489494324,
-0.1677359640598297,
-0.5706183314323425,
-0.5543261170387268,
-0.44670620560646057,
-0.5821262001991272,
1.034938097000122,
0.06262422353029251,
-0.3092062175273895... | |
and ISNUMERIC(ltrim(rtrim(REPLACE(codice_gln, ' ', '')))) = 1
and ISNUMERIC(LTRIM(RTRIM(REPLACE(giacenza, ' ', '')))) = 1 and charindex(',', giacenza) = 0
and ISNUMERIC(LTRIM(RTRIM(REPLACE(acquistato, ' ', '')))) = 1
and ISNUMERIC(ltrim(rtrim(REPLACE(codice_ean_prodotto, ' ', '')))) = 1 | [
-0.7604213953018188,
-0.12971580028533936,
0.7491544485092163,
-0.48797133564949036,
-0.015491785481572151,
0.6054785847663879,
0.26877084374427795,
-0.5380244851112366,
-0.014115297235548496,
-0.19317826628684998,
-0.5231999754905701,
0.9196038842201233,
-0.1608741730451584,
-0.3686401546... | |
and ISNUMERIC(ltrim(rtrim(REPLACE(codice_ecat_prodotto, ' ', '')))) = 1
and codice_socio in (select codice_socio from ana_socio)
and tipo_gln in (select tipo from ana_gln)
and codice_gln in (select codice_gln from dw_key_gln) | [
-0.3916126489639282,
-0.5955109000205994,
0.8032220602035522,
-0.35607191920280457,
0.10990438610315323,
0.3667445480823517,
-0.05456134304404259,
-0.6750673055648804,
-0.12669913470745087,
-0.4322001338005066,
-0.19053997099399567,
0.7386005520820618,
-0.10319811850786209,
-0.578579246997... | |
group by
data_giacenza
,codice_socio
,codice_gln
,codice_articolo_socio | [
-0.14585000276565552,
-0.04357414320111275,
0.2607617676258087,
0.032951146364212036,
-0.16213953495025635,
0.34470680356025696,
-0.1840132474899292,
-0.038079749792814255,
-0.6793525815010071,
-0.6261484622955322,
-0.20426765084266663,
-0.03500272333621979,
-0.3159434497356415,
0.02673467... | |
having COUNT (*) = 1
) b
where
a.data_giacenza = b.data_giacenza and
a.codice_articolo_socio = b.codice_articolo_socio and
a.codice_socio | [
0.06110038235783577,
-0.2669461965560913,
0.6858491897583008,
0.03440997377038002,
-0.06138527765870094,
0.26966989040374756,
-0.16601286828517914,
-0.5640804171562195,
-0.2832627594470978,
-0.5265142917633057,
-0.07594309002161026,
0.3381863832473755,
-0.4644950330257416,
-0.2015148252248... | |
= b.codice_socio and
a.codice_gln = b.codice_gln)
```
The critical field is `codice_ean_prodotto`.
In fact, it allows to consider also values as `SEAGAT7636490026751,NE20000003039,NE20000002168` which are not numeric and, the first, overlap maximum dimensions.
As result, the insert statement gives back
> String o binary data would be truncated
error and fails the insertion.
Thanks in advance! I look forward your help!!!
Enrico
Signal interrupts scanf. If you add `perror('scanf')` after scanf output will be:
```
SIGRTMAX 64
SIGRTMIN 34
Command Caller has ticked
Data Caller has ticked
scanf: Interrupted system call
```
If you replace `scanf` with:
```
do { | [
-0.26885807514190674,
-0.0022470334079116583,
0.751137912273407,
-0.2501057982444763,
-0.042211178690195084,
0.4195338189601898,
0.21398970484733582,
-0.658566415309906,
-0.21599680185317993,
-0.462209016084671,
-0.09303362667560577,
0.8814612627029419,
-0.24958042800426483,
0.059378936886... | |
errno = 0;
scanf("%d", &t);
} while(errno == EINTR);
```
scanf will be retried when it fail with `Interrupted system call`. | [
-0.19442981481552124,
-0.331164687871933,
0.42790931463241577,
-0.42406654357910156,
0.2127375453710556,
-0.006730338092893362,
0.43641453981399536,
-0.20520246028900146,
0.07665648311376572,
-0.2674066126346588,
-0.46481895446777344,
0.7582069039344788,
-0.3058786988258362,
-0.00045713403... | |
There is one function called test(), I want to call this function in every 30 seconds, Please find my implemented code snippet.
```
void init_sigaction(void) {
struct sigaction act;
act.sa_handler = test; //test()
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGPROF, &act, NULL);
}
void init_time(void) {
struct itimerval val;
val.it_value.tv_sec = 30; //Timer 30 Seconds
val.it_value.tv_usec = 0;
val.it_interval = val.it_value;
setitimer(ITIMER_PROF, &val, NULL);
}
int main()
{
/*Set the handler for the signal | [
0.19580091536045074,
-0.729577362537384,
0.8291688561439514,
-0.11246252804994583,
-0.001298754126764834,
0.13375580310821533,
0.7460319399833679,
-0.3425711691379547,
-0.10300716012716293,
-0.5681300759315491,
-0.2624635100364685,
0.5441607236862183,
-0.42842531204223633,
0.14861944317817... | |
SIG to HANDLER */
signal(SIGINT, signal_handler);
init_sigaction();
init_time();
Some_other_function();
}
```
Now I am using some other function, and I want to pause sigaction timer until other function's execution. how can I implemented interrupt for pause?
Thanks,
From the [manual page](http://linux.die.net/man/2/setitimer) of `setitimer`:
> A timer which is set to zero (it\_value is zero or the timer expires and it\_interval is zero) stops.
Call `setitimer` with zero times, and with a valid `old_value` argument to store the current values of the timer, so you can start it again later.
**Edit:**
How about something like this:
```
struct itimerval old_timer;
void | [
0.08146125823259354,
-0.45100757479667664,
0.5375269055366516,
-0.3263813555240631,
0.08039182424545288,
-0.08117629587650299,
0.09798931330442429,
-0.22975805401802063,
-0.1091504618525505,
-0.5312319397926331,
-0.23516692221164703,
0.606110155582428,
-0.5302901864051819,
-0.0875398740172... | |
pause_timer()
{
struct itimerval zero_timer = { 0 };
setitimer(ITIMER_PROF, &zero_time, &old_timer);
}
void resume_timer()
{
setitimer(ITIMER_PROF, &old_timer, NULL);
}
```
**Note** The code above is untested, and coded only by reading the manual page. | [
0.22207482159137726,
-0.14585106074810028,
0.6575588583946228,
-0.4751749038696289,
0.5916658043861389,
0.1554623246192932,
0.20369143784046173,
-0.06762565672397614,
-0.041630834341049194,
-0.22681169211864471,
-0.3408527076244354,
0.7499245405197144,
-0.2066679298877716,
-0.0749878063797... | |
I have code like:
```
void Foo(int& a, string& b, vector<int>& c) {
... // 30 lines of code are same as another function
... // 10 lines of code to parse and assign value to vector<int>& c
}
void Foo(int& a, string& b, map<string, int>& d) {
... // 30 lines of code are same as another function
... // 10 lines of code to parse and assign value to map<string, int>& d
}
```
Is there any way to avoid repeat that 30 lines of code? Should I use function overloading in this case?
**EDIT:**
What if the code is not easy to separate out? Like:
```
void Foo(int& a, string& b, vector<int>& | [
0.31878939270973206,
0.10821497440338135,
0.35112375020980835,
-0.041323285549879074,
-0.05582570284605026,
0.33015090227127075,
0.23839901387691498,
-0.3003377914428711,
-0.0645403191447258,
-0.9075193405151367,
0.025978490710258484,
0.38436219096183777,
-0.33733054995536804,
0.2125808000... | |
c) {
for() {
if(m) ... // 30 lines of 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 'vector<int>& c' code
else if(q) ... // 10 lines of 'vector<int>& c' code
}
}
void Foo(int& a, string& b, map<string, int>& d) {
for() {
if(m) ... // 30 lines of | [
0.05410000681877136,
0.08888011425733566,
0.4736698865890503,
-0.18459638953208923,
0.37615638971328735,
0.5578396320343018,
-0.054870713502168655,
-0.5621394515037537,
-0.25304800271987915,
-0.27069470286369324,
-0.3692871630191803,
0.7646562457084656,
-0.4747864007949829,
-0.073703527450... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.