text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
If I want to read or write a file I *could* use stream.BeginRead and stream.EndRead, but that requires callbacks and a LOT of ugly, complicated code using the asynchronous programming model.
Why would I want to use these asynchronous IO methods (that use the .NET threadpool behind the scenes) than write the same code ... | [
0.49738258123397827,
0.1164470985531807,
0.2061549425125122,
0.14669431746006012,
-0.11349178105592728,
-0.05491751804947853,
0.36594828963279724,
-0.16769926249980927,
-0.35931187868118286,
-0.6772343516349792,
0.01434566080570221,
0.5926222205162048,
-0.1467491090297699,
-0.0293458867818... | |
But where does the 'BeginRead' and 'Endread' execute? The threadpool? Is reusing a thread which has already been allocated the only benefit?
First of all, you should also look into the [Event-based APM](http://msdn.microsoft.com/en-us/library/wewwczdw.aspx).
To answer your question, you're probably thinking about usin... | [
0.05897443741559982,
-0.1827591508626938,
0.21910366415977478,
0.1934313029050827,
-0.06882884353399277,
-0.2496757209300995,
0.0459245964884758,
-0.005606073420494795,
-0.4803359806537628,
-0.6519221663475037,
-0.17256276309490204,
0.3061566948890686,
-0.2987065613269806,
0.19546821713447... | |
I have two following Fasta file:
file1.fasta
```
>0
GAATAGATGTTTCAAATGTACCAATTTCTTTCGATT
>1
GTTAAGTTATATCAAACTAAATATACATACTATAAA
>2
GGGGCTGTGGATAAAGATAATTCCGGGTTCGAATAC
```
file2.qual
```
>0
40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40
40 40 40 40 40 40 40 40 15 40 40
>1
40 40 40 40 4... | [
-0.07938268780708313,
0.3805396258831024,
0.43429073691368103,
0.21947696805000305,
-0.3995768129825592,
0.23351259529590607,
0.4508867859840393,
0.007321160286664963,
-0.005166942719370127,
-0.49798569083213806,
-0.19264988601207733,
0.5422772765159607,
-0.2400866597890854,
-0.03894688561... | |
29 10 19 18 40 19 15 5
```
Note the line break in "qual" file for each fasta header - marked with ">".
Number of file header ('>') is the same for both files. Number of numerical qualities = sequence length.
What I want to do is to append this two files yielding:
```
GAATAGATGTTTCAAATGTACCAATTTCTTTCGATT 40 40 40 4... | [
0.2031884789466858,
0.49702081084251404,
0.38895803689956665,
0.10136488080024719,
-0.29124218225479126,
0.1277034431695938,
0.724718451499939,
-0.16251489520072937,
-0.07903268188238144,
-0.3664950430393219,
-0.25996431708335876,
0.7168618440628052,
-0.2617020606994629,
-0.095181778073310... | |
40 40 40 40 40 40 40 40 40 20 40 40 40 40 40 40 40 40 40 40 40 40 40 40
GGGGCTGTGGATAAAGATAATTCCGGGTTCGAATAC 40 40 40 40 7 40 40 5 40 40 40 40 40 40 40 40 37 13 31 20 15 40 10 11 4 40 8 3 29 10 19 18 40 19 15 5
```
But somehow my code below fail to do it correctly? Especially the second line of each entry in 'qual' ... | [
0.3563149571418762,
0.5569843053817749,
0.569574236869812,
0.06605998426675797,
-0.2591651380062103,
0.01582484319806099,
0.8585244417190552,
-0.08659814298152924,
0.013115174137055874,
-0.22525562345981598,
-0.3934897780418396,
0.46036967635154724,
-0.11661697924137115,
0.1103637367486953... | |
my $fastafile = $ARGV[0] || "reads/2039F.2.fasta";
my $base = basename( $fastafile, ".fasta" );
my $qualfile = "reads/" . $base . ".qual";
print "$qualfile\n";
open SEQ, '<', $fastafile or die $!; #Seq
open PRB, '<', $qualfile or die $!; #quality
while (my $seq = <SEQ>) {
my $qual = <PRB>;
chomp($seq... | [
-0.309404581785202,
-0.08600469678640366,
0.6197770237922668,
-0.18260596692562103,
0.30924052000045776,
0.3056609630584717,
0.2812865972518921,
0.01420407835394144,
-0.044271647930145264,
-0.5840171575546265,
-0.591182291507721,
0.4424545466899872,
-0.17661456763744354,
-0.086903288960456... | |
print "$seq\t$qual\n";
}
}
```
What's the correct way to do it?
You're missing the 2nd (and every subsequent) line of the quality scores and would also miss additional sequence lines. For this and code re-use purposes, the way to handle FASTA sequences is as whole entries/records:
```
local $/ = "\n>";
w... | [
-0.3173670172691345,
-0.18724988400936127,
0.43688341975212097,
0.08414807170629501,
0.32574036717414856,
0.09874439239501953,
0.14124201238155365,
-0.12130293250083923,
-0.11353474855422974,
-0.5519312620162964,
-0.5877808332443237,
0.28553029894828796,
-0.16597841680049896,
-0.2872792482... | |
/g;
print "$seq\t$qual\n";
}
```
You could also easily capture the FASTA header in the first replace. | [
-0.06017845496535301,
-0.2749142050743103,
0.006797189358621836,
-0.277400940656662,
0.1691381335258484,
-0.2962192893028259,
-0.017327815294265747,
0.1791383922100067,
-0.0215587317943573,
-0.6999056339263916,
-0.46374526619911194,
0.6509680151939392,
-0.5302670001983643,
-0.2074266523122... | |
How do I apply an svn:ignore glob recursively while doing an import?
I'm not sure what you mean by "applying *svn:ignore* recursively while importing".
If you want to exclude a set of files from being imported you can set the *global-ignores* property in `~/.subversion/config` before importing. There's no command line... | [
0.42756572365760803,
0.2738889455795288,
0.5714727640151978,
-0.32439008355140686,
-0.15642693638801575,
-0.1750776320695877,
0.3893530070781708,
-0.2534027695655823,
-0.443102091550827,
-0.362617164850235,
-0.25757449865341187,
0.8000943660736084,
-0.5852790474891663,
0.10569997876882553,... | |
big fan of *svn import* (the *svn del* part is not common for me and I like to review the file list before committing).
Otherwise, if what you want is to set the *svn:ignore* property of every directory in the hierarchy before importing you must use the second method and do a *svn propset* (instead of *svn del*) befor... | [
0.3324286937713623,
-0.27924901247024536,
0.3410888612270355,
-0.13954870402812958,
-0.10641814768314362,
-0.4024334251880646,
0.06516559422016144,
0.4549446702003479,
-0.644432783126831,
-0.2446448802947998,
-0.291721910238266,
0.7968130111694336,
-0.40254834294319153,
0.09200987964868546... | |
Whenever a single page report is exported to excel, sheet in excel is named by the report name.
If a report has multiple pages, the sheets are named as sheet1, sheet2,....
Is there any way to specify sheet names in SSRS 2005 ?
solution:
Found this after some googleing:
[Changing the Sheet names in SQL Server RS Excel... | [
-0.09628721326589584,
0.02629258669912815,
0.3371484577655792,
0.05519716814160347,
-0.39493146538734436,
-0.14234310388565063,
0.1189970150589943,
-0.33699822425842285,
-0.42976948618888855,
-0.4147120416164398,
-0.10174728184938431,
0.14624136686325073,
-0.46058475971221924,
0.0153708625... | |
(or however you want it sorted).
[](https://i.stack.imgur.com/0RsVX.png)
* 'Zeilengruppe' means 'Target group'
* 'Gruppeneigenschaften' means 'Group properties'
2. Set the page break in the group properties
[. That's exactly what happened to USB subsystem. <http://www.linux-magazine.com/online/news/linux_2_6_25_without_closed_source_usb_dri... | [
0.2702876329421997,
0.0023358094040304422,
0.5820266604423523,
0.12635399401187897,
0.08482915163040161,
-0.332154244184494,
-0.29666823148727417,
-0.00935934204608202,
-0.33837229013442993,
-0.5455707311630249,
-0.17421089112758636,
0.7281739711761475,
-0.2721443772315979,
0.2392356246709... | |
I have searched the Web for this, but with no luck. Any idea?
Thanks.
As described [here](http://lists.apple.com/archives/webobjects-dev/2007/Dec/msg00042.html), you can set emacs key binding to work in component editor in Eclipse
Go to `Preferences -> General -> Keys`.
* Change Scheme to Emacs if you haven't done s... | [
0.09522152692079544,
0.14280445873737335,
0.759774923324585,
0.017509078606963158,
-0.14109322428703308,
-0.01236828975379467,
0.038510512560606,
-0.3350635766983032,
-0.12194369733333588,
-0.6621281504631042,
-0.2413141280412674,
0.8320898413658142,
-0.32849395275115967,
-0.08044694364070... | |
Components`".
* Repeat for all the key bindings you care about.
So if, in emacs, selection is done by setting the mark (`Control-Space`) at the start of the region, then moving the point to to the end of the region, you could associate the appropriate shortcut to:
```
Text Editing > Select Text Start
Text Editing > S... | [
-0.12131372839212418,
0.05803423374891281,
0.5207940340042114,
0.11012037843465805,
0.18527589738368988,
0.03805200755596161,
0.09949375689029694,
-0.27506229281425476,
-0.03036355786025524,
-0.6526191830635071,
-0.3407132923603058,
0.20563100278377533,
-0.18712139129638672,
0.297302931547... | |
Which Java SOAP XML object serialization library would you recommend for **Java object exchange** with other platforms / languages (.NET, Delphi)?
Communication scenarios could look like this:
* Java object writer -> SOAP XML text -> .NET or Delphi object reader
* .NET or Delphi object writer -> SOAP XML text -> Java... | [
0.3354596197605133,
0.014402049593627453,
0.09915739297866821,
0.028503315523266792,
-0.4310935139656067,
-0.054660823196172714,
0.004067396745085716,
-0.08943921327590942,
-0.05734940245747566,
-0.6973855495452881,
0.25116443634033203,
0.509729266166687,
-0.3751738965511322,
-0.2268552929... | |
- (<https://jaxb.dev.java.net/>), **JAXMe**, and **JiBX** - Binding XML to Java Code(<http://jibx.sourceforge.net/>). But they do not generate SOAP serialized XML by default.
A possible solution would be a web service library which is able to run without a HTTP server, and offers a simple file interface for the SOAP X... | [
0.39787471294403076,
0.09835885465145111,
0.33450883626937866,
0.030581915751099586,
-0.6789826154708862,
-0.03700544685125351,
0.04789698123931885,
-0.42107734084129333,
0.1825069934129715,
-0.6374604105949402,
0.12247917056083679,
0.3496715724468231,
-0.3996102511882782,
0.05683455243706... | |
maxoccurs > 1. JAX-WS itself is reasonably well documented and provides a reasonably good API. The method and parameter annotations can get a bit out of hand in some cases - XML hell in annotation form. It usually isn't so bad.
One of the nice aspects of the JAX-WS stack is project Metro, which Sun co-developed with M... | [
0.12841100990772247,
-0.2689363658428192,
0.40825220942497253,
0.31247469782829285,
0.02007944881916046,
-0.07133013755083084,
0.043806158006191254,
-0.19963335990905762,
-0.2619755268096924,
-0.4785352051258087,
-0.0850926861166954,
0.3165934085845947,
-0.14497485756874084,
-0.43608081340... | |
Is is possible to open a text file and read the contents while another application is updating the file, in such a way that it does not cause a lock conflict?
I need to monitor a log file from one application which is updated by another application each time an event occurs.
I do check if the file is in use before I... | [
0.3843488097190857,
-0.1367218941450119,
0.14800134301185608,
0.21349360048770905,
-0.002486793091520667,
-0.16684509813785553,
0.250328004360199,
-0.16813935339450836,
-0.4948667585849762,
-0.5598412156105042,
-0.1383945494890213,
0.5251912474632263,
-0.20534007251262665,
-0.1629684120416... | |
the api how to open it (if this was given 0, it can't be accessed from other applications IIRC).
otherwise there should be no problem with reading from that file.
if im not mistaken, to check if that file is being opened read only u can call
something like
```
CreateFile(pchar(fName), GENERIC_READ or GENERIC_WRITE,... | [
0.4081037938594818,
-0.08339624851942062,
0.5377503037452698,
0.12672877311706543,
-0.014284501783549786,
-0.36348459124565125,
0.17130734026432037,
0.08714842051267624,
-0.08843743056058884,
-0.6737809777259827,
-0.13170650601387024,
0.5373085737228394,
-0.231344535946846,
0.1711435317993... | |
I'm using jquery for modal dialogs. I want to open model dialog from one page and to send some additional query string to modal dialog page. something like this:
```
<asp:HyperLink ID="hypClientSearch" runat="server" NavigateUrl="~/SomePage.aspx?KeepThis=true&additionalQS='<%= txtBox.Text %>'&TB_iframe=true&height=65... | [
-0.08542640507221222,
0.0026862318627536297,
0.7977004051208496,
-0.10353633761405945,
-0.15339724719524384,
-0.14087440073490143,
0.5040118098258972,
-0.16741891205310822,
-0.25862738490104675,
-0.8866450786590576,
-0.03617052361369133,
0.6900832056999207,
-0.41816723346710205,
0.10320790... | |
get the value from within the iFrame using:
```
var textBoxValue = $(textBoxSelector, window.parent.document).val();
```
Also if you need to send it to the server at the iFrame request try editing the href attribite of the link on click:
```
$('#hypClientSearch').click( function() {
var textBoxContent = $(textBoxS... | [
-0.12167761474847794,
-0.0427146777510643,
0.6387526392936707,
-0.2757241725921631,
0.2394000142812729,
-0.0008590673096477985,
0.40135836601257324,
-0.12324681878089905,
0.053614068776369095,
-0.7222778797149658,
-0.41318613290786743,
0.7866504192352295,
-0.35769811272621155,
0.0095865949... | |
pthread\_create returns the value 251 without creating the thread. Does anyone know what the problem is? Please help. The machine is a HP-UX.
I'm new to multi-threading.
```
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *print_message_function( void *ptr );
main()
{
pth... | [
0.20351967215538025,
0.04655417799949646,
0.6519106030464172,
-0.23441457748413086,
0.08469723910093307,
0.26849043369293213,
0.4977925419807434,
-0.23020964860916138,
-0.11886638402938843,
-0.7134205102920532,
-0.1018977165222168,
0.36807486414909363,
-0.6229803562164307,
0.50517529249191... | |
/* Create independent threads each of which will
* execute function */
iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1);
iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2);
/* Wait till threads are complete before
... | [
0.4222404360771179,
-0.2310318797826767,
0.4835357964038849,
-0.05012987181544304,
-0.03752196952700615,
0.24445870518684387,
0.5494880080223083,
-0.4320564866065979,
-0.24342094361782074,
-0.3816980719566345,
0.16638220846652985,
0.4777524471282959,
-0.49556875228881836,
0.243394032120704... | |
* exit which will terminate */
/* the process and all threads before the
* threads have completed. */
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
printf("Thread 1 returns: %d\n",iret1);
printf("Thread 2 returns: %d\n",iret2);
exit(0);
} | [
-0.037979673594236374,
-0.07587750256061554,
0.6098158955574036,
-0.32565343379974365,
0.4559589624404907,
0.24555604159832,
0.687698483467102,
-0.1293542981147766,
-0.06591518968343735,
-0.40376678109169006,
-0.4536815881729126,
0.20833100378513336,
-0.2991603910923004,
0.5918031930923462... | |
void *print_message_function( void *ptr )
{
char *message;
message = (char *) ptr;
printf("%s \n", message);
}
```
Edit : On HP-UX11. pthread\_create is failing with error 251: Function is not available.
Check whether -lc comes before -lpthread in your link order.
If this is the case, th... | [
-0.061209697276353836,
0.10536976158618927,
0.6013772487640381,
-0.06590008735656738,
0.26365938782691956,
0.09230665117502213,
0.4888402819633484,
-0.1541280299425125,
-0.26147395372390747,
-0.45169946551322937,
-0.12120473384857178,
0.7609288096427917,
-0.49629393219947815,
0.22252051532... | |
give you a more detailled message :
```
printf("%s\n", strerror(errno));
```
Moreover, when using pthread, you should check for the return value of almost every call to pthread\* (see the [man](http://www.manpagez.com/man/3/pthread_create/) of every function to check for possible error returned)
For pthread\_create... | [
-0.13374577462673187,
0.27242234349250793,
0.3162085711956024,
-0.13086244463920593,
0.09001751244068146,
0.06006811931729317,
0.7152096629142761,
-0.3730248808860779,
-0.33154934644699097,
-0.6634222865104675,
-0.2443450540304184,
0.6303527355194092,
-0.346527636051178,
0.2977155148983001... | |
I have a table with primary key in my MS SQL Server 2005 table. I would like to disable it. Now i get error:
Violation of PRIMARY KEY constraint 'PK\_Name'. Cannot insert duplicate key in object 'dbo.Table'.
I would like this error not to occur and to work with PRIMARY KEY like with normal column without constraint a... | [
-0.5442569255828857,
0.08739735931158066,
0.34080466628074646,
0.06141859292984009,
-0.07441332191228867,
-0.06345724314451218,
0.48391252756118774,
-0.11462444067001343,
-0.39737749099731445,
-0.422476589679718,
-0.05998852103948593,
0.578149676322937,
-0.6231165528297424,
0.2343064993619... | |
when I have duplicate values in primary key column. But at the end of my query I have all values unique.
I do not know much about this constraint because i'm not a designer of this table. I have it's name, but I don't now if it's clustered and so on (what is config of this column).
Relational tables without primary k... | [
-0.08170370757579803,
0.2074156403541565,
0.21107983589172363,
0.21924607455730438,
-0.09154248237609863,
-0.03464038670063019,
0.06302817165851593,
0.15346957743167877,
-0.5703142285346985,
-0.5122550129890442,
0.03088800050318241,
0.15988638997077942,
-0.3417222797870636,
0.5739239454269... | |
primary key constraint, but I would consider doing that without replacing it with one of the other candidate keys is a red flag that should be investigated. | [
-0.05746731534600258,
-0.20392411947250366,
0.43276578187942505,
0.2488727569580078,
0.22344885766506195,
-0.20284949243068695,
-0.005667786579579115,
-0.13959097862243652,
-0.12106675654649734,
-0.393787145614624,
-0.17675745487213135,
0.3660777509212494,
-0.2621072828769684,
0.2293448001... | |
I have a user control which has a textbox on it, now this usercontrol is on another user control which I am using on aspx page how can I get value of the textbox on the first user control.
Write a property in your usercontrol to expose its contents, e.g.,
```
public string TextBoxValue
{
get { return txtControl1.T... | [
0.1617831587791443,
-0.019505631178617477,
0.3035908341407776,
0.04024607315659523,
-0.09461474418640137,
-0.24142968654632568,
0.3222030699253082,
-0.11273656040430069,
-0.014715665951371193,
-0.6839563846588135,
-0.01827339455485344,
0.6738302111625671,
-0.2199994921684265,
0.16248603165... | |
I have the two entity classes, User and MyCharacter. User has a list of MyCharacters and each MyCharacter has a reference back to the User (owner). What I'd like to accomplish is, that I use the same join table for both relations, meaning, that the owner relation found in MyCharacter would automatically use the same jo... | [
0.40795424580574036,
0.35882648825645447,
0.2586170732975006,
0.03691340982913971,
-0.007568036206066608,
0.11659341305494308,
0.21372032165527344,
-0.22065550088882446,
0.30038437247276306,
-0.7527428865432739,
0.10586818307638168,
0.5215263366699219,
0.024947458878159523,
0.3672107458114... | |
User user = new User();
MyCharacter character = new MyCharacter();
List<MyCharacter> chars = new ArrayList<MyCharacter>();
chars.add(character);
user.setCharacters(chars);
facade.store(user);
assertNotNull(character.getId());
character = facade.find(MyCharacter.class, character.getId());
... | [
-0.1662597507238388,
0.10760393738746643,
0.6550671458244324,
-0.3698318600654602,
0.12616781890392303,
0.2844789922237396,
0.3939449191093445,
-0.5056742429733276,
-0.14856769144535065,
-0.8277870416641235,
-0.15882420539855957,
0.612405002117157,
-0.3819017708301544,
0.3351939916610718,
... | |
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<MyCharacter> getCharacters() {
return characters;
}
public void setCharacters(List<MyCharacter> characters) {
this.characters = characters;
}
}
@Entity
public clas... | [
0.20536425709724426,
-0.32323551177978516,
0.2718554735183716,
0.09259823709726334,
0.2027919888496399,
0.23356695473194122,
0.11316777765750885,
-0.21275709569454193,
0.06336856633424759,
-0.6151925325393677,
-0.22462865710258484,
0.5597214102745056,
-0.040833860635757446,
0.1968602985143... | |
Long id;
@ManyToOne
@JoinTable(name = "myuser_mycharacter", joinColumns = @JoinColumn(name = "characters_id"), inverseJoinColumns = { @JoinColumn(name = "user_id") })
protected User owner;
public MyCharacter() {
}
public Long getId() {
return id;
}
public void setId(Long id)... | [
0.04094306752085686,
-0.296399861574173,
0.5710034370422363,
-0.2210380733013153,
0.28081077337265015,
-0.042685262858867645,
0.21696719527244568,
-0.19976243376731873,
0.07568822056055069,
-0.4520377814769745,
-0.37785500288009644,
0.6187491416931152,
-0.3378574550151825,
0.37101241946220... | |
}
public void setOwner(User owner) {
this.owner = owner;
}
}
```
That's how we join two entities with jpa in our project:
```
@Entity
@Table(name = "Period")
public class Period implements Serializable {
private List<Delay> delays = new ArrayList<Delay>();
@OneToMany(mappedBy... | [
0.2811998426914215,
-0.5620483756065369,
0.1046794131398201,
0.09089568257331848,
0.11067758500576019,
0.05877746641635895,
0.06315745413303375,
-0.2565707862377167,
-0.5264028310775757,
-0.2830478549003601,
-0.20495156943798065,
0.24257586896419525,
-0.09145977348089218,
0.637760102748870... | |
}
}
@Entity
@Table(name = "Delay")
public class Delay implements Serializable {
private Period period;
@ManyToOne
@JoinColumn(name = "PERIODID")
public Period getPeriod() {
return period;
}
}
``` | [
0.25605204701423645,
-0.5900614857673645,
0.306029349565506,
-0.21469610929489136,
0.4047304689884186,
0.13834233582019806,
0.14202432334423065,
-0.09928536415100098,
-0.5112093687057495,
-0.11237256228923798,
-0.21475157141685486,
0.3120540380477905,
-0.07799886167049408,
0.56573045253753... | |
How do i blink the text in console using C#?
Person-b was on the right track, but their code needs some changes:
```
static void Main()
{
string txt = "Hello, world!";
while (true)
{
WriteBlinkingText(txt, 500, true);
WriteBlinkingText(txt, 500, false);
}... | [
0.062038030475378036,
0.02462664619088173,
0.7356440424919128,
-0.2820277512073517,
0.28120800852775574,
0.07530184835195541,
0.4609839618206024,
0.00581701286137104,
0.14379379153251648,
-0.6811118721961975,
-0.2907717823982239,
0.8490041494369507,
-0.15350918471813202,
-0.098580747842788... | |
private static void WriteBlinkingText(string text, int delay, bool visible)
{
if (visible)
Console.Write(text);
else
for (int i = 0; i < text.Length; i++)
Console.Write(" ");
Console.CursorLeft -= text.Length;
System.Threading.Thread.Sleep(dela... | [
-0.013077698647975922,
-0.06914789974689484,
0.6231621503829956,
-0.5250786542892456,
0.31255996227264404,
0.05212056264281273,
0.3453992009162903,
-0.21889370679855347,
-0.12827354669570923,
-0.4228510558605194,
-0.41521817445755005,
0.6741848587989807,
-0.47023168206214905,
0.38935324549... | |
}
```
**EDIT**: Refactored the code a little | [
0.22256310284137726,
0.2547781765460968,
0.0010111909359693527,
0.01487177237868309,
0.1527918130159378,
-0.14147323369979858,
0.3011695146560669,
0.013991177082061768,
-0.0048587205819785595,
-0.40609869360923767,
0.26693063974380493,
0.5070576071739197,
-0.19565977156162262,
-0.026217358... | |
I have an MVC app and I want on the top of the master page to
have a series of random images from the folder.
To do this I have to write code but not where to write the code??
It has to be done in one place.
I will probably just set the images at the beginning of the session
so they are cached by the browser and imp... | [
0.4544663429260254,
0.08432567119598389,
0.3620646595954895,
0.12189817428588867,
-0.009960678406059742,
-0.2731417715549469,
0.3752957582473755,
-0.006556310690939426,
-0.45038920640945435,
-0.6055946946144104,
0.03611455112695694,
0.45422178506851196,
-0.24804842472076416,
0.112556941807... | |
of the image file paths you will need for each subsequent request. `System.Web.Caching` is perfect for this because you can create a `CacheDependency` object directly on your image directory -- if a file gets changed or added, your cache is automatically invalidated. It is then recreated the next time it is requested.
... | [
0.5692211389541626,
-0.14200469851493835,
0.20504535734653473,
0.31091007590293884,
-0.08819913119077682,
-0.23781539499759674,
0.29807859659194946,
0.08874335139989853,
-0.5177435278892517,
-0.937171220779419,
0.2933049499988556,
0.46420231461524963,
-0.4965452253818512,
0.194174230098724... | |
Model**
This operation should be part of your model in MVC. You change it to go along with your other data fetching classes as you see fit.
```
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Caching;
public class RandomImage
{
public static ... | [
-0.02623971365392208,
-0.6180678606033325,
0.7263533473014832,
0.1273389458656311,
0.13024172186851501,
0.15145857632160187,
0.11322380602359772,
-0.36913424730300903,
-0.32482343912124634,
-0.7987895011901855,
-0.06189528852701187,
0.5452623963356018,
-0.406790554523468,
0.411734461784362... | |
var images = cache[folder + "_images"] as List<string>;
// cache string array if it does not exist
if (images == null)
{
var di = new DirectoryInfo(absoluteFolderPath);
images = (from fi in di.GetFiles() | [
0.3354934751987457,
-0.6281816363334656,
0.898170530796051,
-0.1812242716550827,
0.36385634541511536,
0.16079114377498627,
0.24507558345794678,
-0.19333244860172272,
-0.08402036130428314,
-0.7356964349746704,
-0.11646118015050888,
0.8136121034622192,
-0.4880535304546356,
0.0133053539320826... | |
where fi.Extension.ToLower() == ".jpg" || fi.Extension.ToLower() == ".gif"
select string.Format("{0}{1}", virtualFolderPath, fi.Name))
.ToList();
// create cach dependency on image randomFolderName
cache.Insert(folder | [
0.21469280123710632,
-0.43843433260917664,
0.6098219752311707,
0.045397378504276276,
0.444536954164505,
0.07142733037471771,
-0.2199421525001526,
-0.37262487411499023,
-0.082563616335392,
-0.5706659555435181,
-0.12100126594305038,
0.6778627634048462,
-0.27422404289245605,
0.157359987497329... | |
+ "_images", images, new CacheDependency(absoluteFolderPath));
}
Random random = new Random();
var imageSet = new HashSet<string>();
if (count > images.Count())
{
throw new ArgumentOutOfRangeException("count");
}
while (imageSet.Count() < count)
... | [
0.05148429423570633,
-0.44187527894973755,
0.359048068523407,
-0.2170482724905014,
-0.03583746403455734,
0.2855052649974823,
0.07659261673688889,
-0.49597325921058655,
-0.20318183302879333,
-0.5684739351272583,
-0.026268765330314636,
0.6077234148979187,
-0.41284725069999695,
0.121149569749... | |
//using an hashset will ensure a random set with unique values.
imageSet.Add(images[random.Next(count)]);
}
return imageSet.ToArray();
}
}
```
**The Controller**
Access the method in your controller something like....
```
string[] images = Models.RandomImage.GetImages("myPictures", ... | [
0.12980033457279205,
-0.4171660244464874,
0.6093274354934692,
0.4196000397205353,
0.3044472634792328,
-0.04302264004945755,
-0.019720377400517464,
-0.11672160029411316,
-0.414478063583374,
-0.8177697062492371,
0.11721378564834595,
0.36343735456466675,
-0.3857493996620178,
0.243115603923797... | |
I'm trying to change how section numbering is displayed in a Latex document I'm working on. What I want to do is this:
**Section Title**
(i) Subsection title in normal weight
(a) Lorem ipsum (no subsubsection title being used)...
I've come up with the following, but it's not right in terms of indent... | [
0.20248712599277496,
0.08357901126146317,
0.6299135088920593,
0.13586963713169098,
-0.06847991049289703,
-0.32739269733428955,
-0.10263068228960037,
-0.02932497300207615,
-0.28224679827690125,
-0.435881644487381,
-0.060462526977062225,
0.2646731436252594,
0.1767749935388565,
0.224147289991... | |
This code works correctly to make a web service call:
```
int numberOfGuests = Convert.ToInt32(search.Guest);
var list = new List<Guest>();
Guest adult = new Guest();
adult.Id = 1;
adult.Title = "Mr";
adult.Firstname = "Test";
adult.Surname = "Test";
list.Add(adult);
Guest adult2 = new Guest();
adult2.Id = 2;
adult2.T... | [
0.2326497733592987,
0.14899511635303497,
0.3588412404060364,
-0.12687300145626068,
0.36008745431900024,
-0.0032732945401221514,
0.4658602774143219,
-0.7707359790802002,
-0.29729098081588745,
-0.36578094959259033,
-0.49561992287635803,
0.4772968292236328,
-0.4758264422416687,
0.061633016914... | |
var adult = new Guest();
adult.Id = i;
adult.Title = "Mr";
adult.Firstname = "Test";
adult.Surname = "Test";
list.Add(adult)
}
```
This runs the code within the loop once from 1 to `numberOfGuests`, setting the variable `i` to the current value. | [
0.061389923095703125,
0.2032400369644165,
0.30390506982803345,
-0.27692824602127075,
0.3027327358722687,
0.05077026039361954,
0.47690853476524353,
-0.5309282541275024,
-0.03111160174012184,
-0.3341129720211029,
-0.40421444177627563,
0.5231875777244568,
-0.1801195591688156,
0.37710800766944... | |
I want to read each line from a text file and store them in an ArrayList (each line being one entry in the ArrayList).
So far I understand that a BufferedInputStream writes to the buffer and only does another read once the buffer is empty which minimises or at least reduces the amount of operating system operations.
... | [
0.24121160805225372,
-0.0029681960586458445,
0.27020230889320374,
0.09223426133394241,
0.039743829518556595,
0.10711773484945297,
0.08409689366817474,
-0.027432840317487717,
0.08353939652442932,
-0.764275074005127,
0.1604672223329544,
0.5565226078033447,
-0.4203549921512604,
-0.02931126765... | |
wrapped in an `InputStreamReader` and then wrapped in a `BufferedReader` - then call `readLine` on the `BufferedReader`.
`DataInputStream` is good for reading primitives, length-prefixed strings etc. | [
0.08975520730018616,
-0.47701629996299744,
0.3394182622432709,
0.2816029191017151,
-0.014719203114509583,
-0.16570962965488434,
-0.18546852469444275,
0.1694357991218567,
0.12126433104276657,
-0.5002086758613586,
-0.1589013636112213,
0.29791587591171265,
-0.14975188672542572,
-0.08290890604... | |
I need a simple php library which can be used to easily pass rules and field names to, and then validation could be easily performed. There should also be an easy way to retrieve the errors.
Any suggestions?
I wrote a simple class of my own, combining some regexes i collected over the years with PHP's sanatize and fil... | [
0.4134393632411957,
0.31938740611076355,
-0.08149044960737228,
-0.11043190211057663,
-0.36961668729782104,
0.048016417771577835,
0.13284340500831604,
-0.4787895083427429,
-0.05798012390732765,
-0.6321897506713867,
0.2706215977668762,
0.612068235874176,
-0.283978670835495,
-0.38643807172775... | |
@author SchizoDuckie
* @copyright SchizoDuckie 2009
* @version 1.0
* @access public
*/
class FormValidator
{
public static $regexes = Array(
'date' => "^[0-9]{4}[-/][0-9]{1,2}[-/][0-9]{1,2}\$",
'amount' => "^[-]?[0-9]+\$",
'number' => "^[-]?[0-9,]+\$",
'alfanum' =... | [
-0.3211778402328491,
-0.06727474927902222,
0.6871272921562195,
0.21281400322914124,
-0.049949854612350464,
-0.2956341803073883,
0.2887907326221466,
0.0552426241338253,
0.0031530135311186314,
-0.25246861577033997,
0.038006458431482315,
0.17260068655014038,
-0.2241915613412857,
0.43028953671... | |
'words' => "^[A-Za-z]+[A-Za-z \\s]*\$",
'phone' => "^[0-9]{10,11}\$",
'zipcode' => "^[1-9][0-9]{3}[a-zA-Z]{2}\$",
'plate' => "^([0-9a-zA-Z]{2}[-]){2}[0-9a-zA-Z]{2}\$",
'price' => "^[0-9.,]*(([.,][-])|([.,][0-9]{2}))?\$",
'2digitopt' => "^\d+(\,\d{2})?\$",
... | [
0.12254554033279419,
0.12081610411405563,
0.5633129477500916,
0.058492548763751984,
0.06320871412754059,
0.5183200240135193,
0.45988231897354126,
-0.191710963845253,
0.2840648293495178,
-0.5318565964698792,
-0.658771276473999,
0.3181149661540985,
-0.20394466817378998,
0.19178716838359833,
... | |
'anything' => "^[\d\D]{1,}\$"
);
private $validations, $sanatations, $mandatories, $errors, $corrects, $fields;
public function __construct($validations=array(), $mandatories = array(), $sanatations = array())
{
$this->validations = $validations;
$this->sanatations = $sanatations;
... | [
0.07089440524578094,
-0.09002278745174408,
-0.038047999143600464,
-0.08161702007055283,
0.03818843886256218,
-0.12160979956388474,
0.6526325941085815,
-0.3087891638278961,
-0.14470919966697693,
-0.26210328936576843,
-0.7126786708831787,
0.5454269051551819,
-0.21176104247570038,
-0.07514855... | |
an array of items (if needed) and returns true or false
*
*/
public function validate($items)
{
$this->fields = $items;
$havefailures = false;
foreach($items as $key=>$val)
{
if((strlen($val) == 0 || array_search($key, $this->validations) === false) && array... | [
0.04177270829677582,
-0.14101342856884003,
0.31725385785102844,
-0.13001884520053864,
0.028624745085835457,
0.20774714648723602,
0.36399656534194946,
-0.5070323944091797,
-0.20175553858280182,
-0.3672832250595093,
-0.5457260608673096,
0.5683926343917847,
-0.3241221010684967,
0.251468330621... | |
{
$this->corrects[] = $key;
continue;
}
$result = self::validateItem($val, $this->validations[$key]);
if($result === false) {
$havefailures = true; | [
0.3550560474395752,
0.05806579813361168,
0.714714527130127,
-0.45268309116363525,
0.41842183470726013,
-0.1659843623638153,
0.7390213012695312,
-0.5202295184135437,
0.28102847933769226,
-0.1860489845275879,
-0.5305305123329163,
0.7187635898590088,
-0.18048754334449768,
0.06774313002824783,... | |
$this->addError($key, $this->validations[$key]);
}
else
{
$this->corrects[] = $key;
}
}
return(!$havefailures); | [
0.2548588514328003,
0.030848000198602676,
0.5419623255729675,
-0.3794439435005188,
0.3582361042499542,
-0.3080519437789917,
0.5678951144218445,
-0.4406391978263855,
0.32672953605651855,
-0.39777418971061707,
-0.5598531365394592,
0.8485132455825806,
-0.3318609595298767,
0.141866073012352,
... | |
}
/**
*
* Adds unvalidated class to thos elements that are not validated. Removes them from classes that are.
*/
public function getScript() {
if(!empty($this->errors))
{
$errors = array();
foreach($this->errors as $key=>$val) { $errors[] = "'INPUT[name={... | [
-0.18546777963638306,
-0.1586189717054367,
0.25387823581695557,
-0.06186744570732117,
0.14054366946220398,
0.09624113142490387,
0.558708667755127,
-0.14341451227664948,
0.07942967861890793,
-0.5987868309020996,
-0.32154929637908936,
0.597191333770752,
-0.4101506769657135,
0.060422021895647... | |
$output = '$$('.implode(',', $errors).').addClass("unvalidated");';
$output .= "alert('there are errors in the form');"; // or your nice validation here
}
if(!empty($this->corrects))
{
$corrects = array();
foreach($this->corrects as $key) { $corrects[] = "'IN... | [
-0.049330729991197586,
-0.024365020915865898,
0.45316851139068604,
-0.26470157504081726,
0.3127526640892029,
0.06117818504571915,
0.6511023044586182,
-0.1938803493976593,
-0.088650643825531,
-0.341116726398468,
-0.38085001707077026,
0.6795321106910706,
-0.1882798820734024,
0.09691294282674... | |
$output .= '$$('.implode(',', $corrects).').removeClass("unvalidated");';
}
$output = "<script type='text/javascript'>{$output} </script>";
return($output);
}
/**
*
* Sanatizes an array of items according to the $this->sanatations
* sanatations will be standard of type... | [
0.10918862372636795,
-0.15392890572547913,
-0.0892440527677536,
-0.2990959584712982,
-0.283050537109375,
0.07315025478601456,
0.4753524661064148,
-0.4611336886882782,
-0.0817171186208725,
-0.5236824154853821,
-0.35243913531303406,
0.2816615402698517,
-0.4422364830970764,
0.1592660397291183... | |
* $sanatations = array('fieldname', 'otherfieldname'=>'float');
*/
public function sanatize($items)
{
foreach($items as $key=>$val)
{
if(array_search($key, $this->sanatations) === false && !array_key_exists($key, $this->sanatations)) continue;
$items[$key] = self::sa... | [
-0.023421429097652435,
-0.3041013181209564,
0.18085823953151703,
-0.36461687088012695,
-0.09526694566011429,
0.4114152193069458,
0.689099907875061,
-0.5335387587547302,
-0.1606055647134781,
-0.5605003237724304,
-0.43959856033325195,
0.4541988968849182,
-0.3427537977695465,
0.26943641901016... | |
*
* Adds an error to the errors array.
*/
private function addError($field, $type='string')
{
$this->errors[$field] = $type;
}
/**
*
* Sanatize a single var according to $type.
* Allows for static calling to allow simple sanatization
*/
public static function ... | [
0.09829787164926529,
-0.20884905755519867,
-0.2643167972564697,
-0.22366061806678772,
-0.2952030599117279,
0.339863121509552,
0.7258970141410828,
-0.37775400280952454,
-0.0865464061498642,
-0.6625336408615112,
0.023692963644862175,
0.4216192364692688,
-0.44850918650627136,
0.23041014373302... | |
$flags = NULL;
switch($type)
{
case 'url':
$filter = FILTER_SANITIZE_URL;
break;
case 'int':
$filter = FILTER_SANITIZE_NUMBER_INT; | [
-0.04674263671040535,
-0.43501371145248413,
0.13173872232437134,
-0.23176778852939606,
0.2419743835926056,
-0.09519721567630768,
0.30738064646720886,
-0.27810415625572205,
-0.1813620626926422,
-0.516511857509613,
-0.46234846115112305,
0.3153440058231354,
-0.642876386642456,
0.2660445272922... | |
break;
case 'float':
$filter = FILTER_SANITIZE_NUMBER_FLOAT;
$flags = FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND;
break;
case 'email':
$var = | [
0.017762819305062294,
-0.21195577085018158,
0.4165731370449066,
-0.15769147872924805,
0.25738176703453064,
0.003645744174718857,
0.27420663833618164,
-0.2803412079811096,
-0.1537526696920395,
-0.4332787096500397,
-0.1856020838022232,
0.3942375183105469,
-0.37746304273605347,
0.035463776439... | |
substr($var, 0, 254);
$filter = FILTER_SANITIZE_EMAIL;
break;
case 'string':
default:
$filter = FILTER_SANITIZE_STRING;
$flags = FILTER_FLAG_NO_ENCODE_QUOTES; | [
-0.07183006405830383,
-0.3622899353504181,
0.31183624267578125,
-0.33422625064849854,
0.22465583682060242,
-0.021778425201773643,
0.2888149619102478,
-0.20269379019737244,
-0.13759352266788483,
-0.44328683614730835,
-0.5445921421051025,
0.30148667097091675,
-0.8345589637756348,
0.002354005... | |
break;
}
$output = filter_var($var, $filter, $flags);
return($output);
}
/**
*
* Validates a single var according to $type.
* Allows for static calling to allow simple validation.
*
*/
public static function validateItem($var, $type) | [
0.12195003777742386,
-0.20740219950675964,
0.3078179955482483,
-0.1810639202594757,
0.018538109958171844,
-0.08610230684280396,
0.5218839049339294,
-0.43183043599128723,
-0.4032772481441498,
-0.05574146285653114,
-0.4151325821876526,
0.18178896605968475,
-0.5674130916595459,
0.141293555498... | |
{
if(array_key_exists($type, self::$regexes))
{
$returnval = filter_var($var, FILTER_VALIDATE_REGEXP, array("options"=> array("regexp"=>'!'.self::$regexes[$type].'!i'))) !== false;
return($returnval);
}
$filter = false;
switch($type)
{
... | [
-0.13614551723003387,
-0.349351704120636,
0.4136439263820648,
-0.3905197083950043,
0.29478707909584045,
0.00398144731298089,
0.28603053092956543,
-0.21256814897060394,
0.05484124645590782,
-0.7275128364562988,
-0.24701809883117676,
0.719445526599884,
-0.6339200139045715,
-0.077104650437831... | |
$var = substr($var, 0, 254);
$filter = FILTER_VALIDATE_EMAIL;
break;
case 'int':
$filter = FILTER_VALIDATE_INT;
break; | [
-0.12838320434093475,
-0.3373502790927887,
0.3054439425468445,
-0.3579122722148895,
-0.020622821524739265,
0.10548537969589233,
0.40228500962257385,
-0.1827307790517807,
-0.2039920687675476,
-0.4763340353965759,
-0.41560813784599304,
0.21116335690021515,
-0.8621812462806702,
0.036180399358... | |
case 'boolean':
$filter = FILTER_VALIDATE_BOOLEAN;
break;
case 'ip':
$filter = FILTER_VALIDATE_IP;
break;
case 'url': | [
-0.4729222059249878,
-0.2886406183242798,
0.1959802508354187,
0.07110906392335892,
0.006560721434652805,
-0.14114373922348022,
-0.06346560269594193,
0.06477838009595871,
-0.1585851013660431,
-0.37981414794921875,
-0.4523862600326538,
0.16801023483276367,
-0.5673782229423523,
0.142132937908... | |
$filter = FILTER_VALIDATE_URL;
break;
}
return ($filter === false) ? false : filter_var($var, $filter) !== false ? true : false;
}
}
```
Now this requires mootools for some of the javascript you see here, but you can easily change that to your favorite javascript framework. All... | [
0.2211914211511612,
-0.22799822688102722,
0.16279788315296173,
-0.2357177734375,
0.13771967589855194,
-0.32264596223831177,
0.44853800535202026,
-0.4906276762485504,
-0.1707492470741272,
-0.7325394153594971,
-0.19568371772766113,
0.6039800047874451,
-0.7676729559898376,
-0.1349189728498459... | |
CSS class to it.
Usage is as simple as i always ever wanted:
Example:
```
$validations = array(
'name' => 'anything',
'email' => 'email',
'alias' => 'anything',
'pwd'=>'anything',
'gsm' => 'phone',
'birthdate' => 'date');
$required = array('name', 'email', 'alias', 'pwd');
$sanatize = array('... | [
0.03187058866024017,
0.13313527405261993,
0.5514353513717651,
-0.3298679292201996,
-0.16115091741085052,
0.01333346776664257,
0.14918389916419983,
-0.4824507236480713,
-0.21119728684425354,
-0.7101966738700867,
-0.2560177743434906,
0.07173684984445572,
-0.3004452586174011,
0.03314854204654... | |
= new FormValidator()->sanatize('<b>blah</b>', 'string');
```
The coolest thing about this class is that you can send your form with an ajax or iframe target and execute the resulting script. No need to refresh the page or re-send the same form data back to the browser :) Also, if the script needs changing, there's n... | [
0.3864510655403137,
-0.38284242153167725,
0.3842863440513611,
0.121857188642025,
-0.464437335729599,
-0.6305688619613647,
0.2699999213218689,
0.04868198558688164,
0.05220101773738861,
-1.163031816482544,
0.0758715569972992,
0.4778342545032501,
-0.3513544797897339,
-0.07115873694419861,
-... | |
I will soon work on a project about a mobile application. This application will work on a PDT with Windows Mobile and we will use Visual Studio and .NET to develop it.
This application will intensively use Wifi and need to consume as little power as possible. I found on the internet a lot of stuff concerning embedded ... | [
0.6657480001449585,
0.32074159383773804,
0.25189998745918274,
0.22324758768081665,
0.3084326982498169,
-0.2079104334115982,
-0.10100457817316055,
-0.10329872369766235,
-0.04956703633069992,
-0.9110710024833679,
-0.10414790362119675,
0.6517694592475891,
-0.030041811987757683,
-0.02541858330... | |
handles as soon as possible or use few I/Os).
I would like to know if you are aware of some leads concerning the architecture or the design of such application.
I also saw advice about the use of event driven architecture: is it so useful concerning power saving? And is it usable with the Compact Framework?
Edit
--... | [
0.32117611169815063,
0.1537097692489624,
0.2972513735294342,
0.414939284324646,
-0.03880807384848595,
-0.0031508475076407194,
0.08960100263357162,
-0.05176573991775513,
-0.2671325206756592,
-0.6124595403671265,
-0.06117815524339676,
0.5108773708343506,
0.21530120074748993,
-0.1710415035486... | |
that minimize the battery consumption.
What about at a middle level of abstraction (during the design phase)? Is there some methodology for low-power software design (design patterns, etc)?
Links:
<http://msdn.microsoft.com/en-us/library/aa455167.aspx>
<http://www.eventhelix.com/RealTimeMantra/Basics/>
Perhaps you... | [
0.22567617893218994,
-0.061196014285087585,
0.14431284368038177,
0.029618987813591957,
0.28786417841911316,
-0.16023431718349457,
-0.012047816999256611,
-0.16057835519313812,
-0.19674526154994965,
-0.34129831194877625,
-0.22389565408229828,
0.8733182549476624,
0.12784942984580994,
-0.36768... | |
standard stuff. Keep off the Wifi if you can, as well as other devices. Use cacheing if you have the memory available (but measure what's happening so the cache doesn't become a liability). Never, ever do an idle loop, but use Thread.Sleep() or better, try to make everything event-driven, with short processing bursts. ... | [
0.660641610622406,
-0.13539312779903412,
0.03989912196993828,
0.3192332088947296,
0.3285926282405853,
-0.6094194650650024,
0.4915332496166229,
0.12239106744527817,
-0.37905827164649963,
-0.6685930490493774,
-0.005257051438093185,
0.9774792194366455,
-0.29779890179634094,
-0.434610307216644... | |
information does it need to receive or send? Who are the users, and where do they move? Are there any heavy calculations involved? How much user interface do you need to present? Have you targeted specific hardware yet (specific CPU and WLAN interfaces will have different power consumption behaviours). | [
0.20068813860416412,
-0.3438095152378082,
0.2927897274494171,
0.4713490903377533,
0.008359268307685852,
-0.10971536487340927,
-0.13304249942302704,
-0.06910253316164017,
-0.09471430629491806,
-0.7047946453094482,
-0.07735142111778259,
0.3829474151134491,
0.052785031497478485,
0.03405225649... | |
I must be slow or something today, I cannot find this menu option. I attached a screenshot of my IDE's Debug menu:
[](https://i.stack.imgur.com/RMKxy.jpg)
Any ideas?
Right mouse click on the menu and select customize from the drop down. Click Commands, then select the Debug ... | [
0.2518393099308014,
-0.018897056579589844,
0.1635509431362152,
0.1401292383670807,
0.1242460310459137,
0.041897229850292206,
0.3143722116947174,
-0.0007905875099822879,
-0.17562423646450043,
-0.5068073272705078,
-0.18672779202461243,
0.6455307006835938,
-0.13376860320568085,
0.121980912983... | |
After reading a question on [the difference between pointers and references](https://stackoverflow.com/questions/57483/difference-between-pointer-variable-and-reference-variable-in-c), I decided that I'd like to use references instead of pointers for my class fields. However it seems that this is not possible, because ... | [
0.036869198083877563,
0.32604891061782837,
0.17440015077590942,
-0.05268854275345802,
-0.021276185289025307,
0.08002244681119919,
0.31694313883781433,
-0.07251371443271637,
-0.14899924397468567,
-0.18263809382915497,
-0.22974327206611633,
0.359043687582016,
-0.5268824696540833,
0.339428931... | |
and \*bar3 is happy as larry because pointers can be declared uninitialized (by the way, is it best practice to set this to NULL?).
```
class Foo
{
public:
Bar bar1;
Bar &bar2;
Bar *bar3;
}
```
It looks like I have to use pointers in this scenario, is this true? Also, what's the best way of using the var... | [
-0.042967382818460464,
0.3463810086250305,
0.29176750779151917,
-0.18846645951271057,
0.007122047711163759,
-0.16826021671295166,
0.3278696835041046,
0.08049528300762177,
-0.2512909173965454,
-0.302665650844574,
-0.13965530693531036,
0.7567832469940186,
-0.3703072965145111,
0.0268653705716... | |
receive the following error?
```
../src/textures/VTexture.cpp: In constructor ‘vimrid::textures::VTexture::VTexture()’:
../src/textures/VTexture.cpp:19: error: uninitialized reference member ‘vimrid::textures::VTexture::image’
```
Here's the real code:
```
// VTexture.h
class VTexture
{
public:
VTexture(vimrid:... | [
-0.06269706785678864,
0.21707531809806824,
0.5298607349395752,
0.001391422701999545,
-0.07604724168777466,
0.10859206318855286,
0.4799525737762451,
-0.38687312602996826,
-0.26136431097984314,
-0.5467697381973267,
-0.2891494929790497,
0.9555751085281372,
-0.47293752431869507,
0.105418287217... | |
used with a std::vector which requires there to be a default constructor. So it looks like I must use a default constructor, and therefore must use a pointer. Shame... or is it? :)
**Answer to Question 1:**
> However it seems that this is not possible, because they [references] cannot be declared uninitialized (right?... | [
-0.11897511780261993,
0.09237582981586456,
0.36651185154914856,
-0.31977206468582153,
-0.15410083532333374,
0.11424507200717926,
0.27323418855667114,
-0.15789060294628143,
-0.11604391783475876,
-0.5605884790420532,
-0.11442482471466064,
0.589659571647644,
-0.5641729235649109,
0.16870631277... | |
Foo(Bar &rBar) : bar2(rBar), bar3(NULL)
{
}
Bar bar1;
Bar &bar2;
Bar *bar3;
}
```
---
**Answer to Question 3:**
> In the particular scenario I'm working
> on right now, I don't want to use
> normal variables (what's the correct
> term for them by the way?)
There is no correct name for them,... | [
0.1690623164176941,
0.5235990285873413,
0.3692840337753296,
-0.3402983546257019,
-0.1531260758638382,
0.1316232532262802,
0.3910520672798157,
-0.3714652955532074,
-0.14579682052135468,
-0.1822134405374527,
-0.20181424915790558,
0.47160616517066956,
-0.7250056266784668,
0.19905626773834229,... | |
way via the initailizer list.
```
class Foo
{
public:
Foo() : x(0), y(4)
{
}
int x, y;
};
```
---
**Answer to Question 4:**
> pointers can be declared uninitialized
> (by the way, is it best practice to
> set this to NULL?).
They can be declared uninitialized yes. It is better to initialize them to ... | [
-0.1400836706161499,
-0.04329470545053482,
0.22919590771198273,
-0.020289786159992218,
0.1399596929550171,
0.009513627737760544,
0.3883877992630005,
-0.13565325736999512,
-0.17452766001224518,
-0.5249878168106079,
-0.318901389837265,
0.5399999022483826,
-0.3542291224002838,
-0.163662627339... | |
of using the
> variable?
You can use either pointers or references, but references cannot be re-assigned and references cannot be NULL. A pointer is just like any other variable, like an int, but it holds a memory address. An array is an aliased name for another variable.
A pointer has its own memory address, where... | [
0.23617959022521973,
-0.23043784499168396,
0.23639200627803802,
0.21141895651817322,
-0.17605990171432495,
-0.17911940813064575,
0.05608319491147995,
-0.0917670950293541,
-0.006100194528698921,
-0.46070414781570435,
-0.18268688023090363,
0.4113231897354126,
-0.6018005013465881,
0.210047066... | |
access the value at the address it holds, you have to `dereference` the pointer. You do this by putting a \* before it.
```
int x=0;
int *p = &x;//p holds the address of x
int &r(x);//r is a reference to x
//From this point *p == r == x
*p = 3;//change x to 3
r = 4;//change x to 4
//Up until now
int y=0;
p = &y;//p n... | [
-0.2658332884311676,
0.1275578886270523,
0.33765316009521484,
0.026020154356956482,
0.09827561676502228,
0.022965356707572937,
0.18164187669754028,
-0.29520872235298157,
-0.1336526721715927,
-0.5203166007995605,
-0.3269912600517273,
0.3761650323867798,
-0.20834232866764069,
0.1576391309499... | |
your memory. None of the examples I gave above allocated on the heap. Here is an example where the use of smart pointers would have helped.
```
void createANewFooAndCallOneOfItsMethods(Bar &bar)
{
Foo *p = new Foo(bar);
p->f();
//The memory for p is never freed here, but if you would have used a smart po... | [
0.12568923830986023,
0.14877301454544067,
0.25264662504196167,
0.005063225980848074,
0.18259233236312866,
-0.02846555784344673,
0.3725762665271759,
-0.10848934948444366,
-0.24114005267620087,
-0.6921452283859253,
-0.1151423305273056,
0.6628367304801941,
-0.10939355939626694,
-0.04307943582... | |
I receive the
> following error?
The problem is that you didn't specify an initializer list. See my answer to question 2 above. Everything after the colon :
```
class VTexture
{
public:
VTexture(vimrid::imaging::ImageMatrix &rImage)
: image(rImage)
{
}
private:
vimrid::imaging::ImageMatrix &im... | [
0.010887096635997295,
-0.11643718183040619,
0.7179775238037109,
0.08525577187538147,
-0.06171192228794098,
-0.011498082429170609,
0.3379244804382324,
-0.19194848835468292,
-0.1063203364610672,
-0.6634384989738464,
-0.11708949506282806,
0.9515214562416077,
-0.328551322221756,
0.123737424612... | |
I'm developing an extension to MATLAB's PsychToolbox that allows for better control of the mouse during psychophysical experiments (specifically, preventing the screen boundaries from limiting drag operations... it should feel like you can move the mouse "infinitely" in all directions). Since MATLAB doesn't support the... | [
-0.04698372259736061,
-0.2586677372455597,
0.5105864405632019,
-0.0041591450572013855,
0.22646580636501312,
-0.023226942867040634,
0.005655553191900253,
-0.08469939231872559,
-0.61463463306427,
-0.48284992575645447,
0.19946683943271637,
0.5599965453147888,
-0.16471253335475922,
0.121659748... | |
screen boundaries), however there is one slight problem. When moving the mouse programatically (using either CGWarpMouseCursorPosition or CGDisplayMoveCursorToPoint), no events are generated. Therefore, CGGetLastMouseDelta doesn't seem to be aware that the mouse has moved at all. In other words, if I move the mouse 50 ... | [
-0.14142094552516937,
-0.22909857332706451,
0.6450667381286621,
-0.24008317291736603,
-0.0015958442818373442,
0.013663845136761665,
0.03872913494706154,
-0.1552457958459854,
-0.4002445340156555,
-0.7719480991363525,
-0.012428662739694118,
0.3607674837112427,
-0.18641114234924316,
0.0232743... | |
int nrhs, const mxArray *prhs[]) {
CGEventRef event;
CGPoint offset;
CGPoint currentLocation;
CGPoint newLocation;
if (nrhs != 2)
mexErrMsgTxt("The global x and y coordinates (and only those) must be supplied.");
event = CGEventCreate(NULL);
currentLocation = CGEventGetLocation(eve... | [
-0.20236797630786896,
-0.3646155893802643,
1.1015403270721436,
-0.06529844552278519,
0.33945637941360474,
0.23623594641685486,
0.17832329869270325,
-0.4895288348197937,
-0.2905045449733734,
-0.30487534403800964,
-0.41303005814552307,
0.5249834656715393,
-0.3279613256454468,
0.1286786645650... | |
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
}
```
This happily moves the mouse, but doesn't seem to change the behavior of CGGetLastMouseDelta at all. Does anybody know the exact specifications regarding what is returned by CGGetLastMouseDelta (and when?). Apple's documentation on on this stuff (the Qua... | [
-0.19362226128578186,
-0.03164749592542648,
0.7877209186553955,
0.078360915184021,
0.3275120258331299,
-0.3600350320339203,
0.31318581104278564,
0.13527029752731323,
-0.2810366749763489,
-0.5525562763214111,
-0.016017792746424675,
0.7547873854637146,
-0.07293888926506042,
0.056504555046558... | |
Is there a virtualizing WrapPanel available? Commercial or free ones.
I have seen some blogs (dan's included) but it does not seem to work well in my application, especially when i have child items of varying sizes.
Also even with same size those free ones do not work well.
Are there any commercial ones available in... | [
0.5797576904296875,
-0.29758748412132263,
-0.22211270034313202,
0.3043798804283142,
-0.06966129690408707,
0.10429525375366211,
0.0021578301675617695,
0.6642849445343018,
-0.44351670145988464,
-0.7147210836410522,
0.10988840460777283,
0.37749233841896057,
-0.17399640381336212,
0.12119854241... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.