text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
final submit input should be inside the form.
```
<form>
<div id="first_button">
<button type='button' id="your_button" class="btn span6 large">
Submit
</button>
</div>
<div id="real_form">
CONTENT OF RE-CAPTCHA
<button type='submit'>Real Submit</button>
</div>
</form>
<script>
$(docu... | [
-0.025522522628307343,
-0.0935700386762619,
0.7888087034225464,
-0.03932410851120949,
-0.025013001635670662,
0.20939475297927856,
0.17071393132209778,
-0.7417662143707275,
0.16584740579128265,
-0.7229429483413696,
-0.593126118183136,
0.37620505690574646,
-0.10677140951156616,
-0.1318273693... | |
I want my C# (winforms) application to be multilingual. My idea is:
* I will have my translations in some text file(s), each "sentence" or phrase will have it's unique ID (integer)
* at the start-up of the app I will iterate through all controls on all forms I have in my app (I suppose this should be done in each form... | [
0.17775540053844452,
0.14672578871250153,
0.5423629879951477,
-0.04144662618637085,
-0.16861861944198608,
0.22010844945907593,
0.37884047627449036,
-0.029392164200544357,
-0.05063588544726372,
-0.6827103495597839,
-0.37515318393707275,
0.6200113892555237,
-0.4746970236301422,
-0.2522858381... | |
through this ID will locate translated phrase in (other) text file
* then I will overwrite that *'Text'* property of the control with translated phrase
This enables me to have separate text file with phrases for each and every language (easy to maintain individual translation in the future - only 1 txt file)
1. I wou... | [
0.38578855991363525,
0.17961956560611725,
0.47677120566368103,
0.3218076229095459,
-0.25206485390663147,
-0.20596656203269958,
0.41186094284057617,
-0.04613741487264633,
0.2678588628768921,
-0.7170431613922119,
0.030910270288586617,
0.563453733921051,
-0.18278703093528748,
0.01383794378489... | |
finding a phrase in XML would be in C# faster than going line-by-line in plain text file and searching for given phrase/string...?
3. **EDIT** - I want users (community) to be able to translate my app for them into their native language without my interaction (it means Microsoft's resources are out of the game)
Thank ... | [
0.30294933915138245,
0.2204335331916809,
0.4902651906013489,
0.2240843027830124,
-0.11192616820335388,
-0.0744665265083313,
0.48449209332466125,
0.2514451742172241,
0.039580050855875015,
-0.7354033589363098,
-0.28352609276771545,
0.21188242733478546,
-0.1206880584359169,
0.0322742387652397... | |
use only the line numbers, but it would need advanced text editor (Notepad shows no line numbers) and if somebody accidentaly hits shortcut for "Delete line" and doesn't notice that, whole app would go crazy :)
`//sample of my translation text file for one language
0001:Text of my first button
0002:Text of my fi... | [
-0.07949002087116241,
0.055995699018239975,
0.6082647442817688,
0.0458553172647953,
-0.4632438123226166,
0.0589757114648819,
0.6010401248931885,
0.058352526277303696,
0.021512210369110107,
-0.6753111481666565,
-0.39551037549972534,
0.677727460861206,
-0.34702566266059875,
-0.21317569911479... | |
question on how to do it best with a *text file*, it is pretty straight forward: You just make sure that your unique identifier (`int` probably) are in order (validate before using the file). Then to search quickly, you use the technique of the halves.
You look for number X, so you go to the file's middle line. If id... | [
0.44752970337867737,
0.02092324011027813,
0.004797809757292271,
0.22164003551006317,
-0.06000610813498497,
-0.24598021805286407,
0.15639591217041016,
-0.015813805162906647,
0.11363142728805542,
-0.6820300221443176,
0.10925396531820297,
0.5066078901290894,
0.08043867349624634,
0.13589164614... | |
need translation: External file items, information contained in a database, etc. | [
0.032475490123033524,
0.28601112961769104,
0.1616329699754715,
0.251223087310791,
0.38778579235076904,
-0.18702922761440277,
0.020336175337433815,
-0.07842034101486206,
-0.18809105455875397,
-0.665585458278656,
-0.8547689318656921,
0.571430504322052,
-0.12351232022047043,
0.019613496959209... | |
Could anybody explain, why next code isn't compiling?
I'm creating a partially-specialized Map and Map.Entry for it:
```
public class Trie<T> implements Map<String, T> {
private class TrieEntry<S> implements Map.Entry<String, S> {
// stupid implementation here
}
// uninterested code here
}
```
... | [
0.08436949551105499,
0.16372491419315338,
0.123491071164608,
0.2476804107427597,
0.08334655314683914,
-0.17183975875377655,
0.3027937114238739,
-0.17534370720386505,
-0.03639690950512886,
-0.6632896661758423,
-0.061555441468954086,
0.7515078783035278,
-0.27679502964019775,
0.02582880668342... | |
be unrolled to `Map.Entry<String, T>` and it accords to expression in definition.
Where am I wrong?
You are right that a `TrieEntry<T>` is a `Map.Entry<String, T>`. A `HashSet<TrieEntry<T>>` is also a `Set<TrieEntry<T>>`, but it is **not** a `Set<Map.Entry<String, T>>`.
If it were you could do this:
```
Set<TrieEntr... | [
-0.0024559814482927322,
-0.2652013599872589,
0.20930162072181702,
0.21953098475933075,
0.16724812984466553,
-0.3023958206176758,
0.25886526703834534,
-0.4261390268802643,
-0.06990233063697815,
-0.6999478936195374,
0.044167473912239075,
0.5759385824203491,
-0.3661549985408783,
0.15805430710... | |
problem. I actually believe, that this is **not solveable** in this way because of the current definition of the method entrySet(). It *should* return `? extends Map.Entry<String, T>`, but it *does* return `Map.Entry<String, T>`.
There is actually a [bug report](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=62313... | [
-0.14176350831985474,
-0.3182522654533386,
0.5160375833511353,
0.2302158772945404,
0.3990068733692169,
-0.11366277188062668,
0.27545854449272156,
-0.1902681440114975,
-0.4798937141895294,
-0.7206601500511169,
-0.1255687177181244,
0.6522946953773499,
-0.30634167790412903,
0.3482992053031921... | |
ideal, and there may be better solutions, but this is all what I currently can tell you. | [
0.4120647609233856,
0.12482010573148727,
0.13302204012870789,
0.2765960097312927,
0.4779539704322815,
-0.0004228004836477339,
0.20599226653575897,
-0.0017795043531805277,
0.0242314450442791,
-0.5548290610313416,
-0.04602242633700371,
0.5072780847549438,
-0.24060921370983124,
0.158092722296... | |
I have 2 forms. in form 1, I have a treeview. in one method, I get list of nodes that checked.
```
private void CreateListOfCheckedNodes()
{
TreeNodeCollection nodes = TreeData.Nodes;
Int32 EffectedNodes = GetCheckedNodesCount(nodes);
if (EffectedNodes > 0)
{ | [
-0.01933795027434826,
-0.24757590889930725,
0.4462420642375946,
-0.26037120819091797,
-0.10153234004974365,
-0.09772511571645737,
0.31844431161880493,
-0.38668695092201233,
-0.02844863012433052,
-0.676387369632721,
-0.053259145468473434,
0.2543807029724121,
-0.20083531737327576,
0.25361451... | |
;//my code
}
}
public int GetCheckedNodesCount(TreeNodeCollection nodes)
{
int CheckedNodesCount = 0;
for (int i = 0; i < nodes.Count; i++)
{ | [
-0.16811972856521606,
-0.3698558807373047,
0.3607273995876312,
0.017447471618652344,
0.37172582745552063,
0.03639594838023186,
0.5237100124359131,
-0.1551097333431244,
-0.25275835394859314,
-0.48125922679901123,
-0.28675225377082825,
0.14767925441265106,
-0.16919195652008057,
0.02120091952... | |
TreeNode node = nodes[i];
if (node.Checked)
{
TreeFieldSet Item = new TreeFieldSet { TreeId = Int32.Parse(node.Tag.ToString()), Title = node.Text };
MyProject.Tree.TreeCheckedNodes.TreeList.Add(Item); | [
-0.5758193135261536,
-0.3294179141521454,
0.36604365706443787,
-0.16711926460266113,
0.18156443536281586,
-0.03540278971195221,
0.4668677747249603,
-0.101935476064682,
-0.17652158439159393,
-0.5060276389122009,
-0.49545371532440186,
0.2668825387954712,
-0.2700182795524597,
0.21885168552398... | |
CheckedNodesCount++;
}
if (node.Nodes.Count > 0)
CheckedNodesCount += GetCheckedNodesCount(node.Nodes);
}
return CheckedNodesCount; | [
-0.04668217897415161,
-0.5269672870635986,
0.353733628988266,
0.07470100373029709,
0.40951162576675415,
-0.284603089094162,
0.4054521322250366,
-0.10061563551425934,
-0.14777539670467377,
-0.6125756502151489,
-0.06416165083646774,
0.3471215069293976,
-0.2831757962703705,
-0.021308969706296... | |
}
```
How can I calling method `CreateListOfCheckedNodes` in Form 2 without new of Form1 ?
With this calling :
```
Tree.TreeSubjects Ts = new Tree.TreeSubjects();
Ts.CreateListOfCheckedNodes();//if CreateListOfCheckedNodes public
```
I get error !
Please Help !
Move the code into a new class that can be accessed ... | [
-0.1450846791267395,
-0.1553870141506195,
0.2514554560184479,
-0.1373729407787323,
0.011885312385857105,
-0.34991002082824707,
0.48789647221565247,
-0.2190719097852707,
-0.3477112054824829,
-0.49798959493637085,
-0.26138317584991455,
0.6194921135902405,
-0.5045062899589539,
0.2757410407066... | |
an [extension method](http://msdn.microsoft.com/en-us/library/bb383977.aspx) of the TreeNodeCollection class, but this should be done with caution as it may surprise your colleagues. | [
-0.1300765573978424,
-0.33263450860977173,
0.09946348518133163,
0.03732068091630936,
0.19396327435970306,
-0.4026877284049988,
0.2735995948314667,
0.0408247672021389,
-0.5218806862831116,
-0.2724703550338745,
-0.4999060034751892,
0.09011615812778473,
-0.2561066746711731,
-0.009581069462001... | |
I have a sources of existing portlet. I changed it a bit to fix some errors and now I need to deploy fixed sources to liferay. I build war file using artifact option and deploy this war file as usual. But I still can't add my portlet on the page because I do not see it in the list. What am I doing wrong?
I use Idea 11... | [
0.5805525183677673,
0.24795156717300415,
0.23640750348567963,
0.3488408029079437,
0.05479459837079048,
0.1494453400373459,
0.07063126564025879,
-0.08310134708881378,
-0.3402058780193329,
-0.8319117426872253,
0.4231884479522705,
0.9212801456451416,
-0.2622276544570923,
0.3440723717212677,
... | |
when building artifact, and do not use Ant.
---
logs:
```
09:37:09,430 INFO [PortletAutoDeployListener:71] Copying portlets for D:\odesk_work\liferay\liferay-portal-6.0.6\deploy\Comply-Activities-portlet-6.0.5.2.war
Expanding: D:\odesk_work\liferay\liferay-portal-6.0.6\deploy\Comply-Activities-portlet-6.0.5.2.war... | [
-0.18349124491214752,
0.297700971364975,
0.47633835673332214,
0.1752070039510727,
-0.011918292380869389,
0.48272448778152466,
0.40621381998062134,
-0.6838879585266113,
-0.5460073947906494,
-0.9084649682044983,
-0.24627475440502167,
0.6680070757865906,
-0.3087906539440155,
0.498960286378860... | |
[PortletHotDeployListener:220] Registering portlets for Comply-Activities-portlet
09:13:37,976 INFO [PortletHotDeployListener:369] 1 portlet for Comply-Activities-portlet is available for use
```
---
UPD: Maybe someone will provide me with instruction how to build \*.war properly? I think it will be enough.
Make su... | [
0.2556254267692566,
0.3141617476940155,
0.727324903011322,
0.043585143983364105,
0.07192540168762207,
0.0046719033271074295,
0.5116857290267944,
-0.6677129864692688,
-0.5436353087425232,
-0.631008505821228,
-0.09498214721679688,
0.8298923969268799,
-0.3073583245277405,
-0.08814497292041779... | |
missing it when it creates war.
If not, put it in there manually and see if that works.
**edit**
Ok. Now having more information it looks like you're including `servlet-api` in your war. That jar (and classes inside it) are provided by portal (or, more specifically by the servlet container). The same goes for `portl... | [
0.2677154242992401,
0.023758770897984505,
0.04471428319811821,
-0.06770211458206177,
-0.007751239463686943,
-0.026575887575745583,
0.07723744213581085,
-0.002543747192248702,
-0.516434907913208,
-0.5463427901268005,
-0.14342787861824036,
0.5072812438011169,
-0.2958832383155823,
0.173064067... | |
my model store image described with file name (as String) and data (as byte array). I use Hibernate and here's my model:
```
@Entity
public class Image {
private Long id;
private String name;
private byte[] data;
@Id
@GeneratedValue
@Column(name = "IMAGE_ID")
public Long getId() {
... | [
0.2320980280637741,
-0.27490806579589844,
0.4445728361606598,
-0.00793664064258337,
-0.05229301378130913,
0.10484772175550461,
0.11391296237707138,
-0.2242526262998581,
0.05516427382826805,
-0.8027578592300415,
0.05267476290464401,
0.7543702721595764,
-0.42129987478256226,
0.22146782279014... | |
@Column(nullable = false, length = 100)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Lob
@Column(nullable = false)
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.d... | [
0.052970994263887405,
-0.22954097390174866,
0.5839863419532776,
-0.35700523853302,
0.17406302690505981,
0.2156609147787094,
0.14357425272464752,
-0.25201743841171265,
0.02777273952960968,
-0.25310999155044556,
-0.256120502948761,
0.4748373031616211,
-0.4635196626186371,
0.04478574544191360... | |
}
}
```
But I want to display my stored image, on web site like:
```
<img src="${image.data}" alt="car_image"/>
```
How could I do that?
Should I write controller that serve requests for images?
Any code examples?
---
UPDATE
```
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedV... | [
0.25988250970840454,
-0.04454581066966057,
0.46512216329574585,
-0.0773186981678009,
-0.16617661714553833,
-0.027666671201586723,
0.27744728326797485,
-0.32146602869033813,
-0.4107808470726013,
-0.683957576751709,
0.02201223187148571,
0.49225038290023804,
-0.3587929606437683,
0.19028212130... | |
somehow via normal URL. In Spring MVC create a controller that returns an image (raw data) under particular URL:
```
@RequestMapping(value = "/imageController/{imageId}")
@ResponseBody
public byte[] helloWorld(@PathVariable long imageId) {
Image image = //obtain Image instance by id somehow from DAO/Hibernate
ret... | [
0.0009424719610251486,
-0.38216930627822876,
1.075932502746582,
0.18539391458034515,
-0.316311240196228,
-0.10403258353471756,
0.20115813612937927,
-0.17801201343536377,
-0.19586007297039032,
-0.8027264475822449,
0.09499634057283401,
0.533254086971283,
-0.12306150048971176,
0.3048230409622... | |
I did not find any reference to user related commands for the jenkins-cli tool.
I need this to automate deployment.
Any comeback?
Maybe you don't want to use Jenkins' internal user database at all. There are a host of "Authentication and User Management" plugins.
If you like MySQL, there is a MySQL authenticator (it... | [
0.06898530572652817,
-0.09379266202449799,
0.20840218663215637,
0.22175200283527374,
0.04920187592506409,
0.009474671445786953,
0.13703446090221405,
0.032019827514886856,
-0.10641022771596909,
-0.8160409331321716,
0.04244881123304367,
0.7745052576065063,
-0.13848261535167694,
-0.0645079761... | |
"adduser" script that writes to it, and write an auth script that reads the file and determines whether to authenticate the user.
You can also hook up to an LDAP server, Active Directory, Atlassian Crowd, Unix user accounts (pw\_auth), or whatever authentication your application server uses (if it's running off of a T... | [
0.12806446850299835,
-0.12117370218038559,
0.38914957642555237,
0.1311216652393341,
0.2018691897392273,
-0.10670610517263412,
-0.020433038473129272,
-0.002467553364112973,
-0.04658619314432144,
-0.8732050061225891,
-0.17147280275821686,
0.5722979307174683,
-0.5290423631668091,
-0.075050890... | |
I am writing a C# binding for an unmanaged C dll.
The dll provides 5 hooks to return several data:
```
typedef void (*t_libpd_printhook)(const char *recv);
```
and exports a field like:
```
EXTERN t_libpd_printhook libpd_printhook;
```
now i was using [Interop Assistant](http://clrinterop.codeplex.com/releases/... | [
0.32566702365875244,
0.21885813772678375,
0.5333489775657654,
0.07771936058998108,
-0.04253985360264778,
-0.2124573290348053,
0.1430158168077469,
-0.6596401333808899,
-0.14287050068378448,
-0.5199223160743713,
-0.14763793349266052,
0.47299307584762573,
-0.4541260004043579,
0.14990729093551... | |
IntPtr LoadLibrary(string lpFileName);
[DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true,
SetLastError=true)]
static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool FreeLibrary(IntPtr hModule);
.....
IntPtr lib = Loa... | [
-0.2266269028186798,
-0.14729304611682892,
0.6712489128112793,
-0.09375378489494324,
-0.05981555953621864,
-0.1545543521642685,
0.38315197825431824,
-0.32446447014808655,
-0.07128968089818954,
-0.504845142364502,
-0.5165717005729675,
0.8908665776252747,
-0.524228572845459,
0.04909832775592... | |
another question for all of you-
So i am trying to get a program called Pysomap to work (its basically ISOMAP but for python[http://web.vscht.cz/spiwokv/pysomap/]), i follow the directions best as i can, building it on Ubuntu, Windows, and Fedora (prebuilt libraries), but cant seem to get it to work. On windows (which... | [
0.517510712146759,
0.17496663331985474,
0.3580760657787323,
0.15751825273036957,
0.03938116505742073,
0.060312461107969284,
0.04544064402580261,
0.033088039606809616,
-0.402835875749588,
-0.7240356802940369,
-0.3314466178417206,
0.4071888327598572,
-0.40242400765419006,
-0.3259438574314117... | |
url ="http://web.vscht.cz/spiwokv/pysomap/",
description="A library for isometric feature mapping.",
license='Unknown',
author="Vojtech Spiwok",
py_modules=["floyd", "pysomap"],
ext_modules=[Extension('_floyd', ["floyd_wrap.c", "floyd.c"])]
)
```
Build the `_floyd` extension (assum... | [
-0.2988393008708954,
-0.13208097219467163,
0.911461353302002,
0.019425170496106148,
-0.10764399915933609,
-0.09292006492614746,
0.2822268605232239,
-0.4854310154914856,
-0.4085029661655426,
-0.47143983840942383,
-0.48211830854415894,
0.4598657190799713,
-0.17759181559085846,
-0.08303945511... | |
s
Multidimensionally scalling ............ 7.11 s
--------------------------------------------------
Total procedure ........................ 12.79 s
``` | [
-0.2869466543197632,
0.1538088172674179,
0.6206414103507996,
0.037906017154455185,
-0.1413733959197998,
0.25187328457832336,
0.48588991165161133,
-0.49484533071517944,
-0.5858515501022339,
-0.4023537337779999,
-0.4036028981208801,
0.48188674449920654,
-0.2887839078903198,
0.196910247206687... | |
I have a very small program:
```
public static void main(String[] args) {
Queue<String> queue = new LinkedList<String>();
queue.add("one");
queue.add("two");
queue.add("tree");
printQueue(queue);
customizeQueue(queue);
printQueue(queue);
}
private static void customizeQueue(Queue<String> queue) {
queue.add("fo... | [
-0.007539540994912386,
-0.09802130609750748,
0.38749024271965027,
-0.3176617920398712,
0.036282170563936234,
0.21846435964107513,
0.18813522160053253,
-0.13820074498653412,
-0.2549947500228882,
-0.8854056596755981,
-0.04366462305188179,
0.4149864912033081,
-0.538250207901001,
0.24042007327... | |
are passing is not the object, but the reference to the object. This means that a copy of your whole queue is not created when you pass the reference, instead only a copy of the reference is created. The newly created reference still belongs to the same object and therefore when you do a `queue.add()` , elements are ad... | [
0.24870671331882477,
-0.16947142779827118,
0.6575961112976074,
-0.05656040832400322,
-0.15210051834583282,
-0.040475115180015564,
0.2903423011302948,
-0.1335848867893219,
-0.09508161246776581,
-0.520126461982727,
-0.08169396966695786,
0.12883581221103668,
-0.9014205932617188,
0.37543115019... | |
I would like to take the **words** of a sentence, if that word has in each end, the forward slash character `/`
For example, a string should contain spaces so may have to pull a string from something like:
*Example:*
```
"Hello /World/" --> "World"
```
Would I have to use regular expressions for this, if so, coul... | [
-0.12371912598609924,
-0.018491409718990326,
0.34659796953201294,
0.048617713153362274,
0.010611061006784439,
0.2567431628704071,
0.1830308586359024,
-0.2754576802253723,
-0.0578366219997406,
-0.5779898762702942,
-0.14388535916805267,
0.4846979081630707,
-0.2321448028087616,
-0.03347354382... | |
I use the following code to open an URL in browser:
```
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
startActivity(intent);
```
But if the page behind the url was already opened in browser, running the above code doesn't refresh the page. How could I force page refreshing?
to my knowledg... | [
0.2881218492984772,
0.235939621925354,
0.8764115571975708,
-0.3718189597129822,
-0.03632313758134842,
-0.10426834970712662,
0.4379168152809143,
-0.131853848695755,
-0.10364460945129395,
-0.6970522403717041,
-0.15025274455547333,
0.7205363512039185,
-0.00007552803435828537,
0.13135179877281... | |
so my main goal with this query is to select all departments and employees under a manager named Mario Souza.
```
SELECT d.deptname,e.name FROM employee e JOIN department d ON e.dept = d.deptnum WHERE idmanager IN(
SELECT id FROM employee WHERE name = 'Mario Souza'
) AND manager IN(
SELECT id FROM employee WHERE name... | [
-0.03952282294631004,
0.37556371092796326,
0.4509572684764862,
0.31798750162124634,
-0.07012268155813217,
0.39945659041404724,
-0.18054242432117462,
-0.35871437191963196,
-0.20630063116550446,
-0.6480181813240051,
0.10668926686048508,
0.3021099865436554,
-0.3545665740966797,
0.308844178915... | |
WHERE manager.name = 'Mario Souza'
AND manager.id = e.idmanager
AND manager.id = d.manager
)
``` | [
-0.06629406660795212,
0.3118270933628082,
0.16447941958904266,
0.13833549618721008,
0.30305561423301697,
-0.1278352588415146,
-0.1469915509223938,
-0.219684436917305,
-0.17373260855674744,
-0.28031960129737854,
-0.042838599532842636,
0.4010152220726013,
-0.16910767555236816,
0.185939475893... | |
I am trying to use the [svgo package](https://github.com/ajstarks/svgo) to plot points on an svg file and display that using the web browser. From looking at the `net/http` documetation, I don't know how I could pass arguments into my `svgWeb` function.
The example below compiles and displays a triangle and a line in ... | [
0.24339556694030762,
0.048252835869789124,
0.5055032968521118,
0.14709453284740448,
-0.23626752197742462,
-0.039683759212493896,
0.0065048071555793285,
-0.06118007004261017,
-0.1548641324043274,
-0.7964398860931396,
-0.03130786120891571,
0.26303741335868835,
-0.22050994634628296,
0.0679151... | |
http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "image/svg+xml")
xpts := []int{1, 200, 5}
ypts := []int{200, 400, 300}
s := svg.New(w)
s.Start(500, 500)
s.Line(5, 10, 400, 400, "stroke:black")
s.Polyline(xpts, ypts, "stroke:black")
s.End()
}
//// Main Program f... | [
0.1637222021818161,
-0.49895617365837097,
0.9450633525848389,
-0.029686804860830307,
-0.061319075524806976,
0.5409157276153564,
0.1985088437795639,
-0.423150897026062,
-0.2463918924331665,
-0.6891052722930908,
-0.3921521008014679,
0.2491322010755539,
-0.31835687160491943,
0.144868671894073... | |
xpts = append(ypts, i+5)
}
http.Handle("/economy", http.HandlerFunc(svgWeb))
err := http.ListenAndServe(":2003", nil)
if err != nil {
log.Fatal("ListenAndServe:", err)
}
}
```
If your arguments are meant to be supplied by the client, then they should be passed to your handler via the `http... | [
0.12537667155265808,
0.22067293524742126,
0.8215621709823608,
-0.09634646028280258,
-0.2879301905632019,
-0.014793331734836102,
0.36999982595443726,
-0.44601643085479736,
-0.0898962989449501,
-0.38352376222610474,
-0.45795032382011414,
0.9668509364128113,
-0.28691014647483826,
-0.087939411... | |
one way would be to structure your handler into a struct and use member attributes.
The struct may look like this:
```go
type SvgManager struct {
Xpts, Ypts []int
}
func (m *SvgManager) SvgWeb(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "image/svg+xml")
s := svg.New(w)
... | [
-0.13005535304546356,
-0.2782858610153198,
0.7114222049713135,
-0.15399950742721558,
-0.23995229601860046,
0.022329343482851982,
0.2319064438343048,
-0.5851666331291199,
-0.26088014245033264,
-0.5529667139053345,
-0.4313415288925171,
0.48011651635169983,
-0.3475732207298279,
-0.13510935008... | |
this assignment to make the SO display shorter in width.
// Could have put it directly in the http.Handle()
handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
manager.SvgWeb(w, req)
})
http.Handle("/economy", handler)
```
Now you have an SvgManager instance that could contain other han... | [
-0.014477484859526157,
-0.3057115077972412,
0.3398604691028595,
-0.2449413537979126,
-0.25687670707702637,
0.09824930131435394,
0.1537875384092331,
-0.48260506987571716,
-0.33825743198394775,
-0.6199381947517395,
-0.07444514334201813,
0.15261992812156677,
-0.530639111995697,
0.127959996461... | |
As opposed to virtual member functions, I need a solution where a function implemented at each level class derivation can be registered for later call by the base class. ( Not just the most derived implementation)
To do this, I was thinking on providing a mechanism for derived classes to register their function with t... | [
0.1373872458934784,
-0.14770540595054626,
-0.02895319275557995,
0.10382585972547531,
-0.20799168944358826,
-0.11163313686847687,
0.23763278126716614,
-0.05319652706384659,
0.07236460596323013,
-0.40442153811454773,
0.15006302297115326,
0.6005460023880005,
-0.09366269409656525,
0.2389206737... | |
I need to use static member functions, `void *`, and `static_cast`?**
```
class Base
{
protected:
typedef void (Base::*PrepFn)( int n );
void registerPrepFn( PrepFn fn ) {};
}
class Derived : public Base
{
Derived() {
registerPrepFn( &Derived::derivedPrepFn );
};
void derivedPrepFn( int n... | [
-0.11541301757097244,
-0.017178336158394814,
0.4221411645412445,
-0.07625401020050049,
-0.03667103499174118,
0.014063121750950813,
0.37245213985443115,
-0.6650755405426025,
0.1804347187280655,
-0.5625872015953064,
-0.1805131882429123,
0.6783510446548462,
-0.17324429750442505,
-0.0403618030... | |
then casting will do:
```
class Derived : public Base
{
Derived() {
registerPrepFn( static_cast<PrepFn>(&Derived::derivedPrepFn) );
};
void derivedPrepFn( int n ) {};
}
```
Call it normally with a `Base* p` (**provided it actually points to a Derived**): `(p->*registered)(0)`
See <http://ideon... | [
0.39538389444351196,
-0.10077342391014099,
0.4146442711353302,
-0.15933667123317719,
-0.2633688151836395,
0.1684599667787552,
-0.09894926100969315,
-0.6067050695419312,
0.10994774103164673,
-0.35877078771591187,
-0.01041746512055397,
0.1853867471218109,
0.04182474687695503,
0.2092753797769... | |
I have the following array:
```
var arry = [{title='Test'}, {title='Test2'}, {title='Test3'}];
```
I want to add a new property to each of the objects in the array. What is the fastest way of doing this?
Given no further information: hands down and String manipulation.
Before every occurrence of `}`you insert `foo=... | [
0.7793028950691223,
0.3012407720088959,
0.3197583556175232,
-0.16568751633167267,
-0.13627547025680542,
-0.07100783288478851,
0.41689980030059814,
-0.5314155220985413,
0.10891614109277725,
-0.31605666875839233,
0.044694069772958755,
0.689719021320343,
-0.30577602982521057,
0.10561989247798... | |
with double qoutes.
Anyway I recommend you to get a JSONParser and start working with objects then you have a more robust solution e.g. Matthew posted it.
And here's the example of valid JSON
```
[
{
"title": "Test"
},
{
"title2": "Test2"
},
{
"title3": "Test3"
}
]
``... | [
0.20628374814987183,
0.0027421440463513136,
-0.045832309871912,
0.15496131777763367,
-0.27817681431770325,
-0.03811211138963699,
0.5126873254776001,
-0.18595768511295319,
-0.08312197029590607,
-0.6653476357460022,
-0.2437310814857483,
0.4573046565055847,
-0.17920300364494324,
-0.2954489588... | |
My program has a tableview, I want to show selected items from the tableview in a textview
I have following code **which shows only the last item of the NSMutablearray** in textview:
I guess problem is the **for loop** but couldnt figure it out.
stands is NSMutablearray, selectItems is NSMutablearray, selected items... | [
-0.05197134613990784,
-0.08213227242231369,
0.6259241104125977,
-0.14002977311611176,
-0.127911776304245,
0.07447728514671326,
0.23089396953582764,
-0.4272104501724243,
-0.15862387418746948,
-0.8099685907363892,
0.08122996240854263,
0.27922919392585754,
-0.2064526379108429,
0.1316240876913... | |
= %@", yourVar);
}
[self.mytableView reloadData];
}
```
I try the following but it crashes:
```
[selectItems addObject:[stands objectAtIndex:indexPath.row]];
int length = [selectItems count];
for(int i=0;i<=length;i++){
selectedItems.text= [selectItems objectAtIndex:i];
}
```
how can I... | [
-0.13957414031028748,
0.0015867747133597732,
0.9753341674804688,
-0.26622769236564636,
-0.08682089298963547,
0.021915210410952568,
0.5097862482070923,
-0.6148514747619629,
0.14180108904838562,
-0.7634013295173645,
-0.06577730178833008,
0.7564365863800049,
-0.31164780259132385,
0.1708226948... | |
NSLog (@"Your Array elements are = %@", yourVar);
[exString appendFormat:@"\n%@",yourVar];
}
selectedItems.text=exString;
[self.mytableView reloadData];
}
```
What about something like this? It takes each object, puts a newline in it, then adds it to exString to form one long chain of the object... | [
-0.1125955656170845,
-0.4202296733856201,
0.3472873866558075,
-0.29767468571662903,
-0.06794929504394531,
-0.07022961974143982,
0.3516272306442261,
-0.12048358470201492,
-0.31079378724098206,
-0.5976235270500183,
-0.014158014208078384,
0.22206254303455353,
-0.34244978427886963,
0.130864441... | |
I want to create an macro for trimming my string.
I use this code below for trimming:
```
[[NSString stringWithString:string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]
```
But if I create macro as below I get an error: **expected expression**
```
#define TRIM_STRING(string)... | [
0.05091243237257004,
0.1627316027879715,
0.3585657477378845,
-0.3268670439720154,
0.295487642288208,
0.04483351483941078,
0.154407799243927,
-0.2985658049583435,
-0.08839412033557892,
-0.6010737419128418,
0.1948353797197342,
0.8666975498199463,
-0.530227541923523,
-0.14976750314235687,
0... | |
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
```
Or, even better, create a category on NSString for this:
```
@interface NSString (additions)
- (NSString *)stringByTrimmingWhitespace;
@end
@implementation NSString (additions)
- (NSString *)stringByTrimmingWhitespace
{
return [self stringByTrimmingCh... | [
-0.07334725558757782,
0.11182992905378342,
0.3371637463569641,
-0.285625159740448,
-0.19400055706501007,
-0.16318506002426147,
0.29560935497283936,
-0.45880863070487976,
-0.39402127265930176,
-0.5014214515686035,
-0.086591936647892,
0.8476162552833557,
-0.43364161252975464,
-0.009953466244... | |
I have this form that spawns a new thread and starts listening and waiting for UDP packets in a loop. What I need is to keep the UI updated with the number of bytes received.
For that, I have setup an event which I'll raise as soon as a packet is received and pass the number of bytes received as an argument. Since I'm... | [
0.20299643278121948,
-0.23361164331436157,
0.43344539403915405,
-0.260768324136734,
-0.02391946315765381,
-0.24338623881340027,
0.2880209982395172,
-0.22214797139167786,
-0.2010307013988495,
-0.6845927238464355,
0.10808094590902328,
0.6279268860816956,
-0.33439067006111145,
0.4328852891921... | |
{
totalReceivedBytes += receivedBytes;
Label.Text = totalReceivedBytes.ToString("##,0");
}));
}
}
```
But this is still **running on the same thread as the packet reception loop** and it will not return to that loop - and wait for another packet - until this `EVENTHANDLER_UpdateTra... | [
0.11706766486167908,
-0.17686255276203156,
0.7017272114753723,
-0.22828829288482666,
-0.050881046801805496,
-0.16860979795455933,
0.3633984327316284,
-0.1721777766942978,
-0.19992908835411072,
-0.6042713522911072,
-0.05086813122034073,
0.649989128112793,
-0.3266565203666687,
0.374280214309... | |
line off (or comment it), the packet reception will be much faster.
How can I possibly solve this issue? I think more threads is the key, but I'm not sure how to properly implement them in this situation... I'm using Windows Forms with .NET 2.0.
**EDIT:**
On my previous testing, the above seem to be true and it may ... | [
0.4124044179916382,
-0.2787482440471649,
0.8074215650558472,
-0.14132073521614075,
-0.04532717540860176,
-0.1130201444029808,
0.5432643294334412,
0.12378828972578049,
-0.1838548332452774,
-0.6634706854820251,
0.14819589257240295,
0.4575677216053009,
-0.5821598172187805,
0.37882864475250244... | |
event, the packet reception is much faster.
I tested receiving some file which took in average about ~1.5sec without calling `Invoke()` at all on the event handler. When I did call `Invoke()` in the event handler, even without updating any control in the UI or doing any operation (in other words, the anonymous method ... | [
-0.1648470014333725,
-0.48776841163635254,
0.2351258099079132,
0.19532491266727448,
-0.5531923174858093,
-0.17873746156692505,
0.41922858357429504,
-0.26471298933029175,
-0.34247133135795593,
-0.9619779586791992,
-0.07519446313381195,
0.6163135170936584,
-0.049492597579956055,
-0.169005990... | |
1000 times every second! The monitor probably doesn't refresh more than 100 times per second, and nobody is going to be able to read it if it updates more than 10 times per second.
A better way to approach this problem is to put the `totalReceivedBytes += receivedBytes;` in the thread that handles the I/O and put a ti... | [
0.32400932908058167,
-0.3481347858905792,
0.707342267036438,
0.1223740205168724,
0.13546058535575867,
0.02644958347082138,
0.38157427310943604,
-0.008282882161438465,
-0.4560789465904236,
-0.8493308424949646,
0.10517411679029465,
0.4544713497161865,
-0.21569545567035675,
0.1817828267812729... | |
If you using Facebook graph API, you can see all public information of someone if that person set those information public, only few things you need to do: open a browser, log-in to Facebook and know that person user ID#, for example, Mark Zuckerberg - facebook founder have user ID# 4, so go to:
<https://graph.facebook... | [
0.5685058832168579,
0.10351391136646271,
0.37374594807624817,
0.21292263269424438,
0.03095746599137783,
-0.054920364171266556,
0.31652525067329407,
0.1599118560552597,
-0.6064552068710327,
-0.5389688014984131,
0.0715801939368248,
-0.09903068095445633,
-0.05050067603588104,
0.31163644790649... | |
link you can see more information such as person favorites and education ...
\_https://graph.facebook.com/4?access\_token=**XXX** with **XXX** is a unique code, it changes every time you log-in to Facebook ( see more in <http://developers.facebook.com/docs/reference/api/>)
My goal is using basic java url to go to thes... | [
0.04190093278884888,
0.19484056532382965,
0.6103610992431641,
0.1351870447397232,
-0.20540307462215424,
0.054010871797800064,
0.25723573565483093,
-0.011147895827889442,
-0.3402450680732727,
-0.9709605574607849,
0.32960614562034607,
0.1970125436782837,
-0.03280157223343849,
0.3316541314125... | |
is there anyway to get a permanent access token or extend it for longer time, remember I only using a small java program, nothing to do with Facebook app or anything else. Thanks in advanced!
Unfortunately you can't get a permanent access token but instead you can catch the error when the access token is expired and re... | [
0.2782263457775116,
-0.07778965681791306,
0.2004859447479248,
0.5391307473182678,
0.0967104509472847,
-0.24775274097919464,
0.3497897684574127,
0.2893470525741577,
-0.4086771011352539,
-0.3429989516735077,
0.24769900739192963,
0.2633855640888214,
0.047938745468854904,
-0.3434811532497406,
... | |
I have been always using
```
a != null
```
to check that `a` is not a null reference. But now I've met another way used:
```
a.ne(null)
```
what way is better and how are they different?
Like @Jack said `x ne null` is equal to `!(x eq null)`. The difference between `x != null` and `x ne null` is that `!=` checks ... | [
0.2619461119174957,
0.14161080121994019,
-0.04896455630660057,
-0.1738441288471222,
-0.2817554771900177,
0.1074921190738678,
0.33330202102661133,
-0.5930808186531067,
-0.19530481100082397,
-0.5418750643730164,
0.12962836027145386,
0.5703548789024353,
-0.18186992406845093,
0.308511912822723... | |
There's a simple CSS 3 hack to append ` ` to a div's contents, to prevent it from height-collapsing regardless of whether it contains text or not. I just can't find it again.
Where is it?
`<div></div> <!-- nothing in it = will collapse -->`
`<div> </div> <!-- still nothing in it but with appended it... | [
-0.21960920095443726,
0.2790219485759735,
0.554262638092041,
-0.03990986570715904,
0.13509522378444672,
-0.033348601311445236,
0.5369479656219482,
0.004198565613478422,
-0.09454024583101273,
-0.530217170715332,
-0.424737811088562,
0.36565011739730835,
-0.032115232199430466,
0.1739131063222... | |
is to use the Unicode representation as a escaped sequence:
```
#someId:after {
content: '\0000a0';
}
``` | [
-0.3915461599826813,
-0.06814533472061157,
0.10085388273000717,
-0.037574172019958496,
0.1518583446741104,
-0.12187681347131729,
0.2191765457391739,
0.24326515197753906,
-0.12184508144855499,
-0.32221439480781555,
-0.4423699378967285,
0.2583147883415222,
-0.2756631672382355,
-0.09867075830... | |
I'm very new to NHibernate, and I'm running into a problem while saving a list of child objects.
**NOTE**
```
<class name="Note" table="NOTE">
<id name="NoteID" column="NOTE_ID">
<generator class="identity" />
</id>
...
<list name="Sections" table="NOTE_SECTIONS" ca... | [
-0.18143197894096375,
-0.02273704670369625,
0.2587350010871887,
-0.2105037122964859,
-0.3004245162010193,
-0.004045392386615276,
0.30519020557403564,
-0.20076367259025574,
0.02043016627430916,
-0.6278676986694336,
0.2277432531118393,
0.04819265753030777,
-0.04457593336701393,
0.08711496740... | |
<index column="SORT_ORDER"/>
<one-to-many class="Section"/>
</list>
</class>
```
**NOTE SECTION**
```
<class name="Section" table="NOTE_SECTIONS">
<id name="SectionID" column="Section_ID">
<generator class="identity" />
</id>
<property name="NoteID" column="NOTE_ID"/>
... | [
-0.18743807077407837,
0.15164731442928314,
0.4390031099319458,
-0.10702624171972275,
0.131871297955513,
-0.05610005185008049,
-0.1333591789007187,
-0.37660539150238037,
-0.18706567585468292,
-0.8808088302612305,
-0.3000180125236511,
0.07473286986351013,
0.012475199066102505,
-0.01992982253... | |
appears to be going through the proper steps, but then I get the following error:
> NHibernate.Exceptions.GenericADOException: could not delete collection: [Domain.Note.Sections#1][SQL: UPDATE NOTE\_SECTIONS SET NOTE\_ID = null, SORT\_ORDER = null WHERE NOTE\_ID = @p0] ---> System.Data.SqlClient.SqlException: Cannot i... | [
-0.1493469774723053,
-0.04626688361167908,
0.4322658181190491,
0.05964432284235954,
-0.08858398348093033,
0.014241251163184643,
0.4350055754184723,
-0.35496124625205994,
-0.1986548751592636,
-0.6222361922264099,
0.11398172378540039,
0.33640769124031067,
-0.04570900648832321,
0.241887882351... | |
collection mapping if you wish to save child objects in this manner.
```
<list name="Sections" table="NOTE_SECTIONS" inverse="true" cascade="all" lazy="false">
<key column="NOTE_ID"/>
<index column="SORT_ORDER"/>
<one-to-many class="Section"/>
</list>
```
[Inverse Attribute in NHib... | [
-0.35962989926338196,
-0.33819112181663513,
0.12425485253334045,
0.3292579650878906,
-0.3907999098300934,
0.2993183434009552,
-0.022649267688393593,
-0.47615912556648254,
-0.49921679496765137,
-0.4337591528892517,
-0.1281949132680893,
0.10915477573871613,
-0.07978381961584091,
-0.030748577... | |
I want my users' search results to include some idea of how many matches there were for a given search query.
However, after a bit of research and observation of my users' search logs, I've noticed a direct correlation between logged query speed and the number of total results and have determined that this is because ... | [
0.534812331199646,
0.13829858601093292,
0.13749469816684723,
0.14900235831737518,
-0.1074986383318901,
0.12613503634929657,
0.31202828884124756,
-0.05053491145372391,
-0.14443811774253845,
-0.39147037267684937,
0.301705002784729,
0.6487668752670288,
-0.05190785229206085,
0.3129922747611999... | |
results are available, but I can't see if there's any good way to calculate this without noticeably affecting performance. I don't really want to just dump a seemingly-bottomless result set in front of the user without providing them any rough idea of how many results their search matched.
Any suggestions?
With boolea... | [
-0.17048099637031555,
0.08676327764987946,
0.35301393270492554,
0.2842597961425781,
-0.04571850597858429,
0.01753421686589718,
0.06854484975337982,
-0.16568224132061005,
-0.1458342969417572,
-0.51862633228302,
-0.16347560286521912,
0.43627214431762695,
0.11894276738166809,
-0.0631080567836... | |
basically making an assumption of independence.
You can use the `rewrite` method to rewrite any query to a boolean query.
There isn't really a better way of doing this, but I've found that this assumption isn't too bad in practice. If you have a very small number of docs it might give bad answers though.
EDIT: as j... | [
-0.09377290308475494,
-0.10671602189540863,
0.17109012603759766,
0.029340261593461037,
0.11144579946994781,
-0.03228132054209709,
0.1478707641363144,
-0.10439720749855042,
-0.31762629747390747,
-0.19059063494205475,
-0.1408882886171341,
0.6890907287597656,
-0.23694704473018646,
0.018784249... | |
= 1 - (1 - P(A))(1 - P(B))
= 1 - (1 - P(A) - P(B) + P(A)P(B))
= P(A) + P(B) - P(A)P(B)
``` | [
-0.22024975717067719,
0.39735904335975647,
0.31518152356147766,
-0.38411426544189453,
0.03847788646817207,
0.15447644889354706,
0.15596476197242737,
-0.5991144776344299,
-0.16237469017505646,
-0.04728741943836212,
-0.6319906711578369,
0.5917485952377319,
-0.5311970710754395,
0.095755167305... | |
i'm developing a driving school test app and I need some help.
I have xml file like this:
```
<!-- language: lang-xml -->
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layo... | [
0.28745222091674805,
0.14439254999160767,
0.5851693153381348,
0.060340091586112976,
-0.15004870295524597,
0.2998386323451996,
-0.07501759380102158,
-0.16474923491477966,
0.42769524455070496,
-0.5330084562301636,
0.09568461030721664,
0.6488584876060486,
0.11723259836435318,
-0.1138515621423... | |
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/e1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enun" | [
-0.28275489807128906,
-0.3552548587322235,
0.32384899258613586,
-0.5011693239212036,
-0.022068476304411888,
0.39160242676734924,
0.03313957899808884,
-0.13702073693275452,
-0.21754272282123566,
-1.0557421445846558,
-0.4335288107395172,
0.8017385601997375,
-0.15817567706108093,
-0.192296311... | |
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radio0"
android:layo... | [
-0.11170341819524765,
0.1530599743127823,
0.5629249811172485,
-0.36576345562934875,
0.04675399139523506,
-0.15096311271190643,
0.404385507106781,
-0.47599413990974426,
-0.1118985190987587,
-0.50058513879776,
-0.4430095851421356,
0.804936945438385,
-0.25345537066459656,
-0.08601580560207367... | |
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content" | [
0.0986068844795227,
0.05529710277915001,
0.5207458734512329,
-0.31439557671546936,
0.1222057119011879,
-0.13614118099212646,
0.2946379780769348,
-0.5010427832603455,
-0.22652652859687805,
-0.43201252818107605,
-0.31895774602890015,
0.8547635674476624,
-0.3036547303199768,
-0.17482776939868... | |
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" /> | [
0.024413932114839554,
0.10237158089876175,
0.4549936056137085,
-0.45181915163993835,
0.10615431517362595,
0.014449678361415863,
0.1899520456790924,
-0.46038052439689636,
-0.3345712721347809,
-0.4380500912666321,
-0.360859215259552,
0.7931685447692871,
-0.3436698019504547,
-0.09279411286115... | |
</RadioGroup>
<ImageView
android:id="@+id/i2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/e2"
android:layout_width="wrap_content" | [
0.16578848659992218,
0.2098870575428009,
0.549454391002655,
-0.288362979888916,
-0.14067314565181732,
-0.29210662841796875,
0.5315253138542175,
-0.4159327447414398,
-0.11574345827102661,
-0.4452410042285919,
-0.3566662073135376,
0.855848491191864,
-0.18020141124725342,
-0.23675207793712616... | |
android:layout_height="wrap_content"
android:text="Enun"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/radioGroup2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<... | [
-0.035759445279836655,
0.029466917738318443,
0.5630560517311096,
-0.305387943983078,
0.05199240893125534,
-0.07078015059232712,
0.33096039295196533,
-0.41370293498039246,
-0.24530129134655,
-0.4862399995326996,
-0.3232065439224243,
0.9234209656715393,
-0.274691641330719,
0.0031632483005523... | |
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1" | [
0.0006486562779173255,
0.10947190225124359,
0.5752250552177429,
-0.2768010199069977,
0.1345786154270172,
-0.11411342024803162,
0.2336926907300949,
-0.6038607954978943,
-0.1087140142917633,
-0.5010761618614197,
-0.2907320261001587,
0.8038249611854553,
-0.5370426774024963,
-0.066925734281539... | |
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content" | [
-0.011128241196274757,
0.10309141874313354,
0.4478697180747986,
-0.4123491644859314,
0.07901062071323395,
-0.057711128145456314,
0.26978886127471924,
-0.44289055466651917,
-0.3353162109851837,
-0.47937604784965515,
-0.43712833523750305,
0.7852790355682373,
-0.27687597274780273,
-0.15977492... | |
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
```
... x 30 times and a button that will correct the test and show if you passed or not. You pass the test when you fail 3 questions or less.
Questions are stored this way:
Id\_question Id\_topic Id\_test Quest... | [
-0.1227298304438591,
0.24956847727298737,
0.5556694269180298,
0.009333156049251556,
0.14433583617210388,
0.18217210471630096,
0.4001264274120331,
-0.6247544288635254,
0.03897885978221893,
-0.6665896773338318,
-0.2209479957818985,
0.3967089354991913,
-0.05576033517718315,
-0.241616636514663... | |
3
* Image is the name of the related image, extracted from resources folder.
I use a database to populate every field in the xml. Images and questions are extracted from database this way:
```
<!-- language: lang-java -->
Cursor c = adbh.query(bundle.getString("test"));
//"test"-->"SELECT question, image FRO... | [
0.15206657350063324,
0.04435614123940468,
0.6897372603416443,
-0.039005134254693985,
-0.18871912360191345,
0.14733494818210602,
-0.2108692228794098,
-0.6625821590423584,
-0.01143495924770832,
-0.6247256398200989,
-0.1747189164161682,
0.4036758542060852,
-0.21871669590473175,
-0.02178625576... | |
String path = c.getString(index);
String nimage = "i"+i;
int idImage = getResources().getIdentifier(nimage, "id", this.getPackageName());
ImageView image = (ImageView) findViewById(idImage);
int idDrawable = getResources().getIdentifier(ruta, "drawable", t... | [
0.005502460058778524,
-0.599323034286499,
0.19311074912548065,
-0.02988964505493641,
0.07815464586019516,
0.173365980386734,
0.32804346084594727,
-0.5655260682106018,
-0.04531612619757652,
-0.6448622941970825,
-0.29457852244377136,
0.5863961577415466,
-0.3963218927383423,
-0.03757212683558... | |
image.setImageResource(idDrawable);
String nenun = "e"+i;
String enun = c.getString(anotherIndex);
int idEnun = getResources().getIdentifier(nenun, "id", this.getPackageName());
TextView txtenun = (TextView) findViewById(idEnun);
txtenun.s... | [
0.08943160623311996,
-0.6504847407341003,
0.44605135917663574,
-0.04601717367768288,
0.03820066526532173,
0.154527947306633,
0.2576426565647125,
-0.37860721349716187,
-0.07162584364414215,
-0.7953963875770569,
-0.5276473760604858,
0.8322734236717224,
-0.5799106359481812,
-0.202023208141326... | |
i++;
} while (c.moveToNext());
```
How can I populate radiobuttons? The query would be "SELECT AnswerA, AnswerB, AnswerC from table WHERE id\_test = 1"
And my last question is how can I correct the test. I think on storing radiobutton pressed (I don't know exactly how) in an array and then compare with c... | [
0.05178544670343399,
0.04196846857666969,
0.6970173120498657,
-0.14838948845863342,
0.036683134734630585,
0.1251811981201172,
0.13566990196704865,
-0.5668965578079224,
0.20205821096897125,
-0.3665038049221039,
-0.23378916084766388,
0.6315155625343323,
-0.30281171202659607,
0.16067329049110... | |
3 1 3 2...
Array of correct answers:
3 2 1 2 2 3 2 3 2 2 2...
```
<!-- language: lang-java -->
for (int i=0; i<30; i++)
if (a[i] == b[i])
numberOfRightAnswers++;
```
Thank you :)
> How can I populate radiobuttons? The query would be "SELECT AnswerA,
> AnswerB, AnswerC from table WHERE id\_test = 1"
Wi... | [
0.2052878737449646,
0.033489055931568146,
1.022152304649353,
0.021482590585947037,
-0.14549165964126587,
-0.18027770519256592,
0.32619941234588623,
-0.7621261477470398,
0.25944405794143677,
-0.2676624059677124,
-0.4628044366836548,
0.8456036448478699,
-0.41206955909729004,
0.20716232061386... | |
//"test"-->"SELECT question, AnswerA, AnswerB, AnswerC, image FROM table WHERE id_test = 1"
```
Then in that `while` loop assign the text to the `RadioButton`s like you did for `TextView txtenun`.
> And my last question is how can I correct the test. I think on storing
> radiobutton pressed (I don't know exactly h... | [
0.4233796000480652,
0.28533682227134705,
0.2942226529121399,
0.07208798080682755,
-0.1618257462978363,
-0.14950031042099,
0.39931702613830566,
-0.31136012077331543,
0.2736949324607849,
-0.5254181027412415,
0.060406506061553955,
0.9481133818626404,
-0.22879453003406525,
-0.207139253616333,
... | |
should modify your layout and your current approach. Making the user scroll your 30 question layout might not be such a good idea, also you're loading many resources although the user will not actually see them until it gets to that particular question(I don't know the size of your image, if they are small this probabl... | [
0.4882459342479706,
-0.23841577768325806,
0.2651134133338928,
0.3964618444442749,
0.02271365374326706,
-0.047093573957681656,
0.19602183997631073,
-0.062441352754831314,
-0.29379814863204956,
-0.7727972269058228,
0.33930057287216187,
0.7764610648155212,
0.07956818491220474,
-0.082877792418... | |
the `getIdentifier` method calls, this method is slower then the `findViewById` and should be avoided. Bellow is a layout:
```
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
... | [
-0.07843431830406189,
-0.24576106667518616,
0.6602829694747925,
-0.2352018654346466,
-0.03973464295268059,
0.058379944413900375,
0.1112566590309143,
-0.6554333567619324,
-0.09015937149524689,
-0.3269682824611664,
-0.17069830000400543,
0.401579350233078,
-0.03457197546958923,
-0.08079162240... | |
android:layout_height="wrap_content" />
<TextView
android:id="@+id/questionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enun"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Radi... | [
-0.2470851093530655,
0.09452783316373825,
0.3842221200466156,
-0.2769549489021301,
0.029492877423763275,
0.05214540660381317,
0.3846554160118103,
-0.30979546904563904,
-0.1691334843635559,
-0.8206520080566406,
-0.393596887588501,
0.9614919424057007,
-0.26745399832725525,
-0.095184169709682... | |
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" | [
0.01844852790236473,
0.228206068277359,
0.5138565301895142,
-0.3802626132965088,
0.15643271803855896,
-0.13725051283836365,
0.49609649181365967,
-0.5876715183258057,
-0.028101759031414986,
-0.49985840916633606,
-0.2694386839866638,
0.994797945022583,
-0.06965107470750809,
-0.27629494667053... | |
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" /> | [
0.1540926694869995,
0.04900289326906204,
0.5075774788856506,
-0.31846484541893005,
0.020653456449508667,
-0.0546964593231678,
0.12605993449687958,
-0.4865138828754425,
-0.22371405363082886,
-0.35633379220962524,
-0.27496111392974854,
0.743953287601471,
-0.5040966868400574,
-0.0554508641362... | |
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<LinearLayout
android:layout_width="fill_parent" | [
0.017367994412779808,
0.016155347228050232,
0.636038601398468,
-0.40553906559944153,
0.012250431813299656,
-0.15686136484146118,
0.09074638783931732,
-0.4064632058143616,
-0.04937363043427467,
-0.15246041119098663,
-0.12921646237373352,
0.5409002900123596,
-0.2736642360687256,
0.1249030604... | |
android:layout_height="wrap_content"
android:weightSum="3" >
<Button
android:id="@+id/previousQuestion"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" | [
-0.2746143937110901,
-0.3418251574039459,
0.5656119585037231,
-0.5305662751197815,
0.15774595737457275,
0.5132989287376404,
-0.24729034304618835,
-0.6049360036849976,
-0.21552777290344238,
-0.685556948184967,
-0.28017956018447876,
0.3635207414627075,
-0.1852816939353943,
-0.256593763828277... | |
android:text="previous" />
<Button
android:id="@+id/validateTest"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" | [
-0.3296169340610504,
-0.1940920203924179,
0.46041905879974365,
-0.2789522111415863,
0.14214016497135162,
0.5160260200500488,
-0.188286691904068,
-0.5713856816291809,
-0.19552265107631683,
-0.7667287588119507,
-0.2098076045513153,
0.20240062475204468,
-0.1283702254295349,
-0.193852156400680... | |
android:text="validate" />
<Button
android:id="@+id/nextQuestion"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" | [
-0.39971891045570374,
-0.33568739891052246,
0.49996453523635864,
-0.3288145661354065,
0.22056463360786438,
0.4450560510158539,
-0.25168222188949585,
-0.5598598718643188,
-0.26433494687080383,
-0.8154686689376831,
-0.2458483725786209,
0.2431386113166809,
-0.1123347282409668,
-0.258104145526... | |
android:text="next" />
</LinearLayout>
</LinearLayout>
</ScrollView>
```
You'll make a query for all the question in that test(including all the data) and start with a static field `int counter = 0`. When the app is started you'll move the cursor to the counter value(which is 0 at the start):
```
c.move... | [
0.040585707873106,
-0.02815902791917324,
0.7720848917961121,
-0.12936952710151672,
0.18318331241607666,
0.5205396413803101,
0.13315507769584656,
-0.644932210445404,
0.10167212039232254,
-0.8302929401397705,
-0.45910412073135376,
0.8173002600669861,
-0.5795407295227051,
-0.3699100613594055,... | |
cursor
```
When the user presses the `nextQuestion` `Button` you'll increment the `counter` value(you should do some checks so you don't go overboard the 30 questions), move the cursor to the `counter` position again and then populate the layout like above. When the user presses previousQuestion you decrement `counte... | [
-0.04784797504544258,
0.14231456816196442,
0.8689813017845154,
0.07538331300020218,
-0.1005241870880127,
-0.2857794761657715,
0.027290059253573418,
-0.5989408493041992,
-0.07691729068756104,
-0.4217928349971771,
-0.0898437649011612,
0.9964961409568787,
-0.35518789291381836,
-0.022214317694... | |
the correct answers for the test from the database and see if the user it's a good driver.
Also you could(probably) optimize your database.
**Edit:**
```
private ArrayList<Integer> responses = new ArrayList<Integer>(); // this will hold the number of the correct answer. Note that this will work if the user answers q... | [
0.19796817004680634,
-0.10409702360630035,
0.49529170989990234,
-0.014443758875131607,
-0.08052564412355423,
-0.29436060786247253,
0.7522029876708984,
-0.9276525974273682,
0.014339513145387173,
-0.4823050796985626,
-0.030517661944031715,
1.0667377710342407,
-0.3774864077568054,
0.030816532... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.